From d1e190f29f209423df2c7b74e62cf586ee7e3395 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Sun, 9 Apr 2023 14:25:32 +0200 Subject: [PATCH] Tests: Use assertEqual over assertTrue --- lib/tests/htmlizer_test.py | 52 +++++++++++++++++++------------------- tests/lazyblorg_test.py | 12 ++++----- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/lib/tests/htmlizer_test.py b/lib/tests/htmlizer_test.py index 12f953f..9396880 100644 --- a/lib/tests/htmlizer_test.py +++ b/lib/tests/htmlizer_test.py @@ -89,7 +89,7 @@ def test_sanitize_and_htmlize_blog_content(self): htmlized_entry_test = htmlizer.sanitize_and_htmlize_blog_content(entry) self.assertTrue( htmlized_entry_test['content'] == htmlized_content_expected) - self.assertTrue(htmlized_entry_test['htmlteaser'] == [ + self.assertEqual(htmlized_entry_test['htmlteaser'], [ '

First paragraph

']) self.assertTrue( 'htmlteaser-equals-content' in list(htmlized_entry_test.keys())) @@ -109,7 +109,7 @@ def test_sanitize_and_htmlize_blog_content(self): self.assertTrue( htmlized_entry_test['content'] == htmlized_content_expected) - self.assertTrue(htmlized_entry_test['htmlteaser'] == [ + self.assertEqual(htmlized_entry_test['htmlteaser'], [ '

First paragraph

']) self.assertTrue( 'htmlteaser-equals-content' in list(htmlized_entry_test.keys())) @@ -421,9 +421,9 @@ def testgenerate_entry_list_by_newest_timestamp(self): entrylist = htmlizer.generate_entry_list_by_newest_timestamp() - self.assertTrue(entrylist[0]['id'] == 'c_entry_from_2011') - self.assertTrue(entrylist[1]['id'] == 'a_entry_from_2008') - self.assertTrue(entrylist[2]['id'] == 'b_entry_from_2007') + self.assertEqual(entrylist[0]['id'], 'c_entry_from_2011') + self.assertEqual(entrylist[1]['id'], 'a_entry_from_2008') + self.assertEqual(entrylist[2]['id'], 'b_entry_from_2007') def test_generate_tag_page_with_more_than_one_word_in_title(self): @@ -569,16 +569,16 @@ def test_simple_formatting(self): autotag_language, ignore_missing_ids) - self.assertTrue(htmlizer.htmlize_simple_text_formatting("*This* is *bold face* and *bold face style*. With *end*") == + self.assertEqual(htmlizer.htmlize_simple_text_formatting("*This* is *bold face* and *bold face style*. With *end*"), "This is bold face and bold face style. With end") - self.assertTrue(htmlizer.htmlize_simple_text_formatting("~This~ is ~code~ and ~code style~. With ~end~") == + self.assertEqual(htmlizer.htmlize_simple_text_formatting("~This~ is ~code~ and ~code style~. With ~end~"), "This is code and code style. With end") - self.assertTrue(htmlizer.htmlize_simple_text_formatting("=This= is =verbatim= and =verbatim style=. With =end=") == + self.assertEqual(htmlizer.htmlize_simple_text_formatting("=This= is =verbatim= and =verbatim style=. With =end="), "This is verbatim and verbatim style. With end") - self.assertTrue(htmlizer.htmlize_simple_text_formatting("+This+ is +strike through+ and +strike through style+. With +end+") == + self.assertEqual(htmlizer.htmlize_simple_text_formatting("+This+ is +strike through+ and +strike through style+. With +end+"), "This is strike through and strike through style. With end") # real-world examples: @@ -600,7 +600,7 @@ def test_simple_formatting(self): "*mit Umlaut Öäß und Anfang und Ende*") == "mit Umlaut Öäß und Anfang und Ende") # testing teletype at begin and end of line with german umlauts: - self.assertTrue(htmlizer.htmlize_simple_text_formatting("Das ist ~mit Umlaut Öäß und so weiter~.") == + self.assertEqual(htmlizer.htmlize_simple_text_formatting("Das ist ~mit Umlaut Öäß und so weiter~."), "Das ist mit Umlaut Öäß und so weiter.") self.assertTrue(htmlizer.htmlize_simple_text_formatting( "Das ist ~mit Umlaut Öäß und Ende~") == "Das ist mit Umlaut Öäß und Ende") @@ -705,9 +705,9 @@ def test_sanitize_internal_links(self): "no link here to find") == "no link here to find") # simple links: - self.assertTrue(htmlizer.sanitize_internal_links("[[id:2014-03-02-my-persistent]]") == + self.assertEqual(htmlizer.sanitize_internal_links("[[id:2014-03-02-my-persistent]]"), "2014-03-02-my-persistent") - self.assertTrue(htmlizer.sanitize_internal_links("[[id:2014-03-02-my-temporal]]") == + self.assertEqual(htmlizer.sanitize_internal_links("[[id:2014-03-02-my-temporal]]"), "2014-03-02-my-temporal") self.assertTrue( htmlizer.sanitize_internal_links( @@ -718,17 +718,17 @@ def test_sanitize_internal_links(self): keep_orgmode_format=True) == "[[" + config.BASE_URL + "/tags/testtag][my-tag]]") # links with description: - self.assertTrue(htmlizer.sanitize_internal_links("[[id:2014-03-02-my-persistent][my description text]]") == + self.assertEqual(htmlizer.sanitize_internal_links("[[id:2014-03-02-my-persistent][my description text]]"), "my description text") - self.assertTrue(htmlizer.sanitize_internal_links("[[id:2014-03-02-my-temporal][another description text]]") == + self.assertEqual(htmlizer.sanitize_internal_links("[[id:2014-03-02-my-temporal][another description text]]"), "another description text") - self.assertTrue(htmlizer.sanitize_internal_links("[[id:my-tag][tag link description text]]") == + self.assertEqual(htmlizer.sanitize_internal_links("[[id:my-tag][tag link description text]]"), "tag link description text") self.assertTrue( htmlizer.sanitize_internal_links( "[[id:2014-03-02-my-persistent][my description text]]") == "my description text") - self.assertTrue(htmlizer.sanitize_internal_links("[[id:2014-03-02-my-temporal][another description text]]") == + self.assertEqual(htmlizer.sanitize_internal_links("[[id:2014-03-02-my-temporal][another description text]]"), "another description text") self.assertTrue( htmlizer.sanitize_internal_links( @@ -737,21 +737,21 @@ def test_sanitize_internal_links(self): self.assertTrue( htmlizer.sanitize_internal_links( "[[id:2014-03-02-my-persistent][my description text]]") == "my description text") - self.assertTrue(htmlizer.sanitize_internal_links("[[id:2014-03-02-my-temporal][another description text]]") == + self.assertEqual(htmlizer.sanitize_internal_links("[[id:2014-03-02-my-temporal][another description text]]"), "another description text") - self.assertTrue(htmlizer.sanitize_internal_links("[[id:my-tag][tag link description text]]") == + self.assertEqual(htmlizer.sanitize_internal_links("[[id:my-tag][tag link description text]]"), "tag link description text") self.assertTrue( htmlizer.sanitize_internal_links( "like [[id:my-tag][text]] used") == "like text used") - self.assertTrue(htmlizer.sanitize_internal_links("like [[id:my-tag][this]] and [[id:my-tag][that]] used") == + self.assertEqual(htmlizer.sanitize_internal_links("like [[id:my-tag][this]] and [[id:my-tag][that]] used"), "like this and that used") self.assertTrue(htmlizer.sanitize_internal_links("like [[id:my-tag][this]] and [[id:my-tag][that]] used", keep_orgmode_format=True) == "like [[" + config.BASE_URL + "/tags/testtag][this]] and [[" + config.BASE_URL + "/tags/testtag][that]] used") # links with description and formatting: - self.assertTrue(htmlizer.sanitize_internal_links("[[id:2014-03-02-my-persistent][my *description* text]]") == + self.assertEqual(htmlizer.sanitize_internal_links("[[id:2014-03-02-my-persistent][my *description* text]]"), "my *description* text") self.assertTrue( htmlizer.htmlize_simple_text_formatting( @@ -779,7 +779,7 @@ def test_sanitize_internal_links(self): if expectedoutput != value: print("expectedoutput: [" + expectedoutput + "]") print("value : [" + value + "]") - self.assertTrue(expectedoutput == value) + self.assertEqual(expectedoutput, value) # internal and external links in one line: myinput = "foo http://karl-voit.at [[id:2014-03-02-my-persistent][my *description* text]], " + \ @@ -794,7 +794,7 @@ def test_sanitize_internal_links(self): if expectedoutput != value: print("expectedoutput: [" + expectedoutput + "]") print("value : [" + value + "]") - self.assertTrue(expectedoutput == value) + self.assertEqual(expectedoutput, value) def test_sanitize_external_links(self): @@ -828,10 +828,10 @@ def test_sanitize_external_links(self): self.assertTrue(htmlizer.sanitize_external_links( "xy[[https://foo][bar]]z") == "xybarz") - self.assertTrue(htmlizer.sanitize_external_links("xy[[http://foo][bar]]z[[http://first][second]]end") == + self.assertEqual(htmlizer.sanitize_external_links("xy[[http://foo][bar]]z[[http://first][second]]end"), "xybarzsecondend") - self.assertTrue(htmlizer.sanitize_external_links("xy[[http://foo][bar]][[http://first][second]]end") == + self.assertEqual(htmlizer.sanitize_external_links("xy[[http://foo][bar]][[http://first][second]]end"), "xybarsecondend") self.assertTrue(htmlizer.sanitize_external_links("This is an [[http://www.example.com][example " + @@ -843,10 +843,10 @@ def test_sanitize_external_links(self): # URL links of style http(s)://example.org - self.assertTrue(htmlizer.sanitize_external_links("foo http://example.org bar") == + self.assertEqual(htmlizer.sanitize_external_links("foo http://example.org bar"), "foo http://example.org bar") - self.assertTrue(htmlizer.sanitize_external_links("foo https://example.org bar") == + self.assertEqual(htmlizer.sanitize_external_links("foo https://example.org bar"), "foo https://example.org bar") # combining both URL styles: diff --git a/tests/lazyblorg_test.py b/tests/lazyblorg_test.py index afc28cb..0f1de27 100644 --- a/tests/lazyblorg_test.py +++ b/tests/lazyblorg_test.py @@ -95,8 +95,8 @@ def test_determine_changes(self): marked_for_feed_sorted = sorted(marked_for_feed) # increment_version_sorted = sorted(increment_version) - self.assertTrue(increment_version == []) - self.assertTrue(generate_sorted == marked_for_feed_sorted) + self.assertEqual(increment_version, []) + self.assertEqual(generate_sorted, marked_for_feed_sorted) self.assertTrue( generate_sorted == [ 'case4', @@ -146,8 +146,8 @@ def test_determine_changes(self): marked_for_feed_sorted = sorted(marked_for_feed) increment_version_sorted = sorted(increment_version) - self.assertTrue(increment_version_sorted == ['case8']) - self.assertTrue(marked_for_feed_sorted == ['case1', 'case8']) + self.assertEqual(increment_version_sorted, ['case8']) + self.assertEqual(marked_for_feed_sorted, ['case1', 'case8']) self.assertTrue( generate_sorted == [ 'case1', @@ -247,8 +247,8 @@ def test_determine_changes(self): #old# generate_sorted = sorted(generate) #old# marked_for_feed_sorted = sorted(marked_for_feed) #old# -#old# self.assertTrue(increment_version == []) -#old# self.assertTrue(generate_sorted == marked_for_feed_sorted) +#old# self.assertEqual(increment_version, []) +#old# self.assertEqual(generate_sorted, marked_for_feed_sorted) #old# #old# blog_data, stats_parsed_org_lines = mylazyblorg._parse_orgmode_file( #old# org_testfile)