From bb854384bd218f49239931ed8c4c40cc91fe866e Mon Sep 17 00:00:00 2001 From: asechrest Date: Mon, 5 May 2014 01:59:51 -0400 Subject: [PATCH] Add unittest of utils.crop --- src/tests/test_utils_utils.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/tests/test_utils_utils.py b/src/tests/test_utils_utils.py index 48a9e2c58d..86aaf7271f 100644 --- a/src/tests/test_utils_utils.py +++ b/src/tests/test_utils_utils.py @@ -10,8 +10,15 @@ class TestIsIter(unittest.TestCase): class TestCrop(unittest.TestCase): def test_crop(self): - # self.assertEqual(expected, crop(text, width, suffix)) - assert True # TODO: implement your test here + # No text, return no text + self.assertEqual("", utils.crop("", width=10, suffix="[...]")) + # Input length equal to max width, no crop + self.assertEqual("0123456789", utils.crop("0123456789", width=10, suffix="[...]")) + # Input length greater than max width, crop (suffix included in width) + self.assertEqual("0123[...]", utils.crop("0123456789", width=9, suffix="[...]")) + # Input length less than desired width, no crop + self.assertEqual("0123", utils.crop("0123", width=9, suffix="[...]")) + self.assertEqual("[..", utils.crop("0123", width=3, suffix="[...]")) class TestDedent(unittest.TestCase): def test_dedent(self):