diff --git a/test/ganeti.utils.text_unittest.py b/test/ganeti.utils.text_unittest.py index f80ecb36b122234c8bee275ed7fa8aefc3118a65..e1181821fe48929ff1fde8b3ddbf923c6c3e48b9 100755 --- a/test/ganeti.utils.text_unittest.py +++ b/test/ganeti.utils.text_unittest.py @@ -593,5 +593,41 @@ class TestTruncate(unittest.TestCase): self.assertRaises(AssertionError, utils.Truncate, "", i) +class TestFilterEmptyLinesAndComments(unittest.TestCase): + @staticmethod + def _Test(text): + return list(utils.FilterEmptyLinesAndComments(text)) + + def testEmpty(self): + self.assertEqual(self._Test(""), []) + self.assertEqual(self._Test("\n"), []) + self.assertEqual(self._Test("\n" * 100), []) + self.assertEqual(self._Test("\n \n\t \n"), []) + + def test(self): + text = """ + This + is + # with comments + a + test + # in + # + saying + ...#... + # multiple places + Hello World! + """ + self.assertEqual(self._Test(text), [ + "This", + "is", + "a", + "test", + "saying", + "...#...", + "Hello World!", + ]) + + if __name__ == "__main__": testutils.GanetiTestProgram()