commit 6e3768be317a2aaa642cdee5f694c0d2395e955a
from: Aleksey Ryndin
date: Thu Sep 05 10:34:21 2024 UTC
Using unittest
commit - 11eb9ffae8b7af8e9474e4d3e3149de0246e5017
commit + 6e3768be317a2aaa642cdee5f694c0d2395e955a
blob - 1421ebd352620245cec8ef55ee9c7bc465266d83
blob + 82b65b146819d13416f37b7f0be522f51fceaeda
--- tests.py
+++ tests.py
@@ -1,15 +1,25 @@
+from unittest import TestCase, main
from lonk import HtmlToGmi
-def test_html2gmi_header():
- html = """\
-Header 1
-Paragraph 1
-Header 1.1
-Paragraph 1.1
-"""
- gmi = HtmlToGmi().feed(html)
- assert gmi == """\
+class TestHtmlToGmi(TestCase):
+ def test_in_text_tag(self):
+ html = "bold text
"
+ self.assertEqual(HtmlToGmi().feed(html), "bold text\n")
+
+
+ def test_img_emu(self):
+ html = "aa bb
"
+ self.assertEqual(HtmlToGmi().feed(html), "aa :blobcatgooglyshrug: bb\n")
+
+ def test_html2gmi_header(self):
+ html = """\
+ Header 1
+ Paragraph 1
+ Header 1.1
+ Paragraph 1.1
+ """
+ self.assertEqual(HtmlToGmi().feed(html), """\
# Header 1
Paragraph 1
@@ -17,20 +27,19 @@ Paragraph 1
## Header 1.1
Paragraph 1.1
-""", gmi
+""")
-def test_html2gmi_pre():
- html = """\
+ def test_html2gmi_pre(self):
+ html = """\
def fib(n):
if n == 1 or n == 2:
return 1
return fib(n - 1) + fib(n - 1)
-"""
- gmi = HtmlToGmi().feed(html)
- assert gmi == """\
+ """
+ self.assertEqual(HtmlToGmi().feed(html), """\
```
def fib(n):
@@ -39,20 +48,19 @@ def fib(n):
return fib(n - 1) + fib(n - 1)
```
-""", gmi
+""")
-def test_html2gmi_description_list():
- html = """\
-
- - Coffee
- - Black hot drink
- - Milk
- - White cold drink
-
-"""
- gmi = HtmlToGmi().feed(html)
- assert gmi == """\
+ def test_html2gmi_description_list(self):
+ html = """
+
+ - Coffee
+ - Black hot drink
+ - Milk
+ - White cold drink
+
+ """
+ self.assertEqual(HtmlToGmi().feed(html), """\
* Coffee
Black hot drink
@@ -60,16 +68,8 @@ Black hot drink
* Milk
White cold drink
-""", gmi
+""")
if __name__ == '__main__':
- TESTS = (
- test_html2gmi_header,
- test_html2gmi_pre,
- test_html2gmi_description_list,
- )
- for func in TESTS:
- print(f"{func.__name__} ... ", end="")
- func()
- print("PASSED")
+ main()