diff options
| author | historia <historiavg@proton.me> | 2026-08-24 02:59:26 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-24 02:59:26 -0400 |
| commit | f00249db9d1ea051d29aa1bcca869fc4b88e83eb (patch) | |
| tree | a75f076fac1b63e0b4bf2eb8f54affbcc681a891 /tests/test_cleaning.py | |
| parent | 9dd4f9595be3b1d76a3a07dc3eca90cfaf8a3f97 (diff) | |
| download | tts-audiobook-generator-f00249db9d1ea051d29aa1bcca869fc4b88e83eb.tar.gz | |
refactor: add app directory, dir structure change
Diffstat (limited to 'tests/test_cleaning.py')
| -rw-r--r-- | tests/test_cleaning.py | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/tests/test_cleaning.py b/tests/test_cleaning.py deleted file mode 100644 index 41f4ed7..0000000 --- a/tests/test_cleaning.py +++ /dev/null @@ -1,54 +0,0 @@ -"""Tests for text and HTML cleaning.""" - -import unittest - -from converter.extractors import clean_html, clean_text - - -class CleanTextTests(unittest.TestCase): - def test_empty_input(self): - self.assertEqual(clean_text(""), "") - self.assertEqual(clean_text(None), "") - - def test_collapses_whitespace(self): - self.assertEqual(clean_text("a\n\n b \t c"), "a b c") - - def test_preserves_inline_numbers(self): - self.assertEqual(clean_text("He was 42 years old."), "He was 42 years old.") - - def test_preserves_grouped_and_decimal_numbers(self): - self.assertEqual( - clean_text("Over 1,000 pages and 3.5 stars."), - "Over 1,000 pages and 3.5 stars.", - ) - - def test_removes_standalone_page_numbers(self): - self.assertEqual( - clean_text("End of page.\n7\nNext page text."), - "End of page. Next page text.", - ) - - def test_page_number_removal_leaves_single_spacing(self): - result = clean_text("Chapter one\n\n12\n\nChapter two") - self.assertEqual(result, "Chapter one Chapter two") - self.assertNotIn(" ", result) - - -class CleanHtmlTests(unittest.TestCase): - def test_strips_tags(self): - self.assertEqual(clean_html("<p>Hello <b>world</b></p>"), "Hello world") - - def test_removes_script_and_style(self): - html = "<style>.x{color:red}</style><p>Text</p><script>var a=1;</script>" - self.assertEqual(clean_html(html), "Text") - - def test_unescapes_entities(self): - self.assertEqual(clean_html("Tom & Jerry"), "Tom & Jerry") - - def test_empty(self): - self.assertEqual(clean_html(""), "") - self.assertEqual(clean_html(None), "") - - -if __name__ == "__main__": - unittest.main() |
