| 38 | |
| 39 | |
| 40 | class CollapseWhitespaceTests(unittest.TestCase): |
| 41 | def test_empty_string_returns_empty(self): |
| 42 | self.assertEqual(collapse_whitespace(""), "") |
| 43 | |
| 44 | def test_runs_of_spaces_collapsed(self): |
| 45 | self.assertEqual(collapse_whitespace("hello world"), "hello world") |
| 46 | |
| 47 | def test_tabs_treated_as_spaces(self): |
| 48 | self.assertEqual(collapse_whitespace("a\t\t\tb"), "a b") |
| 49 | |
| 50 | def test_paragraph_breaks_preserved(self): |
| 51 | text = "para one\n\npara two" |
| 52 | self.assertEqual(collapse_whitespace(text), "para one\n\npara two") |
| 53 | |
| 54 | def test_more_than_two_newlines_collapsed_to_two(self): |
| 55 | text = "a\n\n\n\nb" |
| 56 | self.assertEqual(collapse_whitespace(text), "a\n\nb") |
| 57 | |
| 58 | def test_trailing_whitespace_per_line_stripped(self): |
| 59 | text = "line one \nline two\t\t" |
| 60 | self.assertEqual(collapse_whitespace(text), "line one\nline two") |
| 61 | |
| 62 | def test_leading_and_trailing_blank_lines_stripped(self): |
| 63 | self.assertEqual(collapse_whitespace("\n\n hi \n\n"), "hi") |
| 64 | |
| 65 | |
| 66 | class DedupeLinesTests(unittest.TestCase): |
nothing calls this directly
no outgoing calls
no test coverage detected