aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_import_issues.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_import_issues.py')
-rw-r--r--tests/test_import_issues.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/test_import_issues.py b/tests/test_import_issues.py
new file mode 100644
index 0000000..d6b2dbc
--- /dev/null
+++ b/tests/test_import_issues.py
@@ -0,0 +1,52 @@
+import os.path
+import textwrap
+import unittest
+
+from import_issues import MAX_SIZE_COMMENT, split_long_str
+
+
+class TestStringSplitting(unittest.TestCase):
+ maxDiff = None
+
+ def setUp(self):
+ __cur_dir = os.path.abspath(os.path.dirname(__file__))
+ with open(os.path.join(__cur_dir, "209_description.txt")) as inf:
+ self.long_str = inf.read()
+
+ def test_one_line(self):
+ in_str = "Testing string."
+ split_str = split_long_str(in_str, 100)
+ self.assertIsInstance(split_str, list)
+ self.assertEqual(len(split_str), 1)
+ self.assertEqual(in_str, "".join(split_str))
+
+ def test_short_str(self):
+ in_str = textwrap.dedent(
+ """\
+ Reader, I married him.
+ A quiet wedding we had: he and I, the parson and clerk, were alone present.
+ When we got back from church, I went into the kitchen of the manor-house, where Mary was cooking the dinner and John cleaning the knives, and I said—
+
+ “Mary, I have been married to Mr. Rochester this morning.”
+
+ The housekeeper and her husband were both of that decent phlegmatic order of people, to whom one may at any time safely communicate a remarkable piece of news without incurring the danger of having one’s ears pierced by some shrill ejaculation, and subsequently stunned by a torrent of wordy wonderment.
+ Mary did look up, and she did stare at me: the ladle with which she was basting a pair of chickens roasting at the fire, did for some three minutes hang suspended in air; and for the same space of time John’s knives also had rest from the polishing process: but Mary, bending again over the roast, said only—
+
+ “Have you, Miss? Well, for sure!”
+
+ """
+ )
+ split_str = split_long_str(in_str, 100)
+ self.assertIsInstance(split_str, list)
+ self.assertEqual(len(split_str), 6)
+ self.assertEqual(in_str, "".join(split_str))
+
+ def test_long_str(self):
+ split_str = split_long_str(self.long_str, MAX_SIZE_COMMENT)
+ self.assertIsInstance(split_str, list)
+ self.assertEqual(len(split_str), 4)
+ self.assertEqual(self.long_str, "".join(split_str))
+
+
+if __name__ == "__main__":
+ unittest.main()