From 171c469f55c181e3385d96e48766223811345c34 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: May 08 2020 23:28:47 +0000 Subject: test_result.py: pylint fixups Signed-off-by: Adam Williamson --- diff --git a/tests/test_result.py b/tests/test_result.py index 61678c7..c43418e 100644 --- a/tests/test_result.py +++ b/tests/test_result.py @@ -20,14 +20,17 @@ # Author: Adam Williamson # these are all kinda inappropriate for pytest patterns -# pylint: disable=no-init, protected-access, no-self-use, unused-argument +# pylint: disable=no-init, protected-access, no-self-use, unused-argument, too-many-arguments + +"""Tests for result.py.""" import wikitcms.result as rs class TestResults: """Tests for find_results().""" - def _check_result(self, res, status=None, user=None, bugs=None, comment="", bot=False, transferred=False, comment_bugs=None): + def _check_result(self, res, status=None, user=None, bugs=None, comment="", bot=False, + transferred=False, comment_bugs=None): if bugs is None: bugs = [] if comment_bugs is None: @@ -55,12 +58,13 @@ class TestResults: {{result |fail | rené|372312 |9345671}} """ results = rs.find_results(restext) - assert len(results) is 9 + assert len(results) == 9 self._check_result(results[0]) self._check_result(results[1], status="pass") self._check_result(results[2], status="fail", user="adamwill") self._check_result(results[3], status="warn", user="adamwill", bugs=['345234']) - self._check_result(results[4], status="pass", user="kparal", bugs=['6789032'], comment="Some comment.") + self._check_result(results[4], status="pass", user="kparal", bugs=['6789032'], + comment="Some comment.") self._check_result(results[5], status="fail", bugs=['3456780']) self._check_result(results[6], status="pass", user="previous RC3 run", transferred=True) self._check_result(results[7], status="pass", user="coconut", bot=True) @@ -77,12 +81,17 @@ class TestResults: {{testresult/warn|jlaska}} NEEDS REVIEW - https://fedorahosted.org/pipermail/autoqa-results/2009-November/001966.html """ results = rs.find_results(restext) - assert len(results) is 5 + assert len(results) == 5 self._check_result(results[0]) self._check_result(results[1], status="pass", user="jlaska") self._check_result(results[2], status="fail", user="jkeating", bugs=['517926']) - self._check_result(results[3], status="fail", user="jlaska", bugs=['533420'], comment="- broken dep: gnome-python2-gdl-2.25.3-12.fc12.i686 requires libgdl-1.so.2") - self._check_result(results[4], status="warn", user="jlaska", comment="NEEDS REVIEW - https://fedorahosted.org/pipermail/autoqa-results/2009-November/001966.html") + res3comm = ("- broken dep: gnome-python2-gdl-2.25.3-12.fc12.i686 requires " + "libgdl-1.so.2") + self._check_result(results[3], status="fail", user="jlaska", bugs=['533420'], + comment=res3comm) + res4comm = ("NEEDS REVIEW - https://fedorahosted.org/pipermail/autoqa-results/" + "2009-November/001966.html") + self._check_result(results[4], status="warn", user="jlaska", comment=res4comm) def test_find_results_exclusions(self): @@ -94,10 +103,10 @@ class TestResults: {{result|pass|previous RC2 run}} {{result|pass|coconut|bot=true}} """ - assert len(rs.find_results(restext)) is 3 - assert len(rs.find_results(restext, transferred=False)) is 2 - assert len(rs.find_results(restext, bot=False)) is 2 - assert len(rs.find_results(restext, transferred=False, bot=False)) is 1 + assert len(rs.find_results(restext)) == 3 + assert len(rs.find_results(restext, transferred=False)) == 2 + assert len(rs.find_results(restext, bot=False)) == 2 + assert len(rs.find_results(restext, transferred=False, bot=False)) == 1 def test_find_results_statuses(self): @@ -173,7 +182,7 @@ The explanation of test case priority is available at [[QA:Fedora_12_Install_Tes | Tier3 """ results = rs.find_results(f12text) - assert len(results) is 9 + assert len(results) == 9 for res in results[3:6]: self._check_result(res, status="pass", user="kparal") for res in results[6:8]: @@ -198,11 +207,13 @@ The explanation of test case priority is available at [[QA:Fedora_12_Install_Tes |- """ results = rs.find_results(f16text) - assert len(results) is 6 - self._check_result(results[0], status="pass", user="rmarko", comment="{{bz|744463}} Final blocker?\n", comment_bugs=set(['744463'])) - for res in (results[1],results[2],results[4]): + assert len(results) == 6 + self._check_result(results[0], status="pass", user="rmarko", + comment="{{bz|744463}} Final blocker?\n", + comment_bugs=set(['744463'])) + for res in (results[1], results[2], results[4]): self._check_result(res, status="pass", user="rmarko") - for res in (results[3],results[5]): + for res in (results[3], results[5]): self._check_result(res, status="pass", user="robatino") # from Test_Results:Fedora_23_Final_RC3_Installation @@ -230,8 +241,8 @@ The explanation of test case priority is available at [[QA:Fedora_12_Install_Tes """ results = rs.find_results(f23text) resexc = rs.find_results(f23text, bot=False) - assert len(results) is 11 - assert len(resexc) is 5 + assert len(results) == 11 + assert len(resexc) == 5 for res in (results[0], results[2], results[5], results[7], results[9], results[10]): self._check_result(res, status="pass", user="coconut", bot=True) for res in (results[3], results[8]): @@ -241,6 +252,7 @@ The explanation of test case priority is available at [[QA:Fedora_12_Install_Tes self._check_result(results[4], status="pass", user="roshi") def test_find_results_by_row(self): + """Tests for find_results_by_row.""" # extracts from Test_Day:2011-02-23_Radeon # example results (should be filtered), various username styles # one result with a username included added to make coverage @@ -342,7 +354,8 @@ The explanation of test case priority is available at [[QA:Fedora_12_Install_Tes assert results[35].user == "foobar" - def _check_resultrow(self, row, testcase, milestone, columns, results, section='', secid=0, name=None): + def _check_resultrow(self, row, testcase, milestone, columns, results, section='', secid=0, + name=None): assert row.testcase == testcase assert row.milestone == milestone assert row.columns == columns @@ -386,11 +399,14 @@ The explanation of test case priority is available at [[QA:Fedora_12_Install_Tes |} """ rows = rs.find_resultrows(text) - assert len(rows) is 3 + assert len(rows) == 3 cols = ["Milestone", "Test Case", "x86 BIOS", "x86 UEFI", "ARM"] - self._check_resultrow(rows[0], "QA:Testcase_Install_to_Previous_KVM", "Beta", cols, {'x86 BIOS': 2, 'x86 UEFI': 1, 'ARM': 1}) - self._check_resultrow(rows[1], "QA:Testcase_Install_to_Current_KVM", "Beta", cols, {'x86 BIOS': 1, 'x86 UEFI': 1, 'ARM': 1}) - self._check_resultrow(rows[2], "QA:Testcase_Boot_Methods_Xen_Para_Virt", "Final", cols, {'x86 BIOS': 1, 'x86 UEFI': 1, 'ARM': 1}) + self._check_resultrow(rows[0], "QA:Testcase_Install_to_Previous_KVM", "Beta", cols, + {'x86 BIOS': 2, 'x86 UEFI': 1, 'ARM': 1}) + self._check_resultrow(rows[1], "QA:Testcase_Install_to_Current_KVM", "Beta", cols, + {'x86 BIOS': 1, 'x86 UEFI': 1, 'ARM': 1}) + self._check_resultrow(rows[2], "QA:Testcase_Boot_Methods_Xen_Para_Virt", "Final", cols, + {'x86 BIOS': 1, 'x86 UEFI': 1, 'ARM': 1}) def test_find_resultrows_names(self): @@ -420,7 +436,7 @@ The explanation of test case priority is available at [[QA:Fedora_12_Install_Tes |- """ rows = rs.find_resultrows(text) - assert len(rows) is 3 + assert len(rows) == 3 cols = ["Milestone", "Image", "i386", "x86_64", "UEFI"] self._check_resultrow(rows[0], "QA:Testcase_Boot_default_install", "Alpha", cols, {'i386': 1, 'x86_64': 2, 'UEFI': 3}, name="Workstation live") @@ -446,7 +462,7 @@ The explanation of test case priority is available at [[QA:Fedora_12_Install_Tes |} """ rows = rs.find_resultrows(text) - assert len(rows) is 1 + assert len(rows) == 1 self._check_resultrow(rows[0], "QA:Testcase_base_startup", "Alpha", ["Milestone", "Test Case", "Local", "EC2", "Openstack"], {'Local': 2, 'EC2': 1, 'Openstack': 2}) @@ -491,7 +507,7 @@ The explanation of test case priority is available at [[QA:Fedora_12_Install_Tes |} """ rows = rs.find_resultrows(text) - assert len(rows) is 2 + assert len(rows) == 2 def test_find_resultrows_column_titles_no_separator(self): @@ -512,7 +528,8 @@ The explanation of test case priority is available at [[QA:Fedora_12_Install_Tes |- """ rows = rs.find_resultrows(text) - assert rows[0].columns == ['Priority', 'Test Area', 'Test Case', 'i386', 'ppc', 'x86_64', 'References'] + assert rows[0].columns == ['Priority', 'Test Area', 'Test Case', 'i386', 'ppc', 'x86_64', + 'References'] def test_find_resultrows_column_titles_sanitize(self): @@ -532,7 +549,8 @@ The explanation of test case priority is available at [[QA:Fedora_12_Install_Tes |- """ rows = rs.find_resultrows(text) - assert rows[0].columns == ['Priority', 'Test Area', 'Test Case', 'i386', 'ppc', 'x86_64', 'References'] + assert rows[0].columns == ['Priority', 'Test Area', 'Test Case', 'i386', 'ppc', 'x86_64', + 'References'] def test_result_string_template(self): @@ -550,12 +568,12 @@ The explanation of test case priority is available at [[QA:Fedora_12_Install_Tes assert str(res) == "Result: Fail from adamwill" assert res.result_template == "{{result|fail|adamwill}}" - # FIXME: use rené when py3 is merged - res = rs.Result(status="warn", user="rene", bugs=['435678', '1340987']) - assert str(res) == "Result: Warn from rene, bugs: 435678, 1340987" - assert res.result_template == "{{result|warn|rene|435678|1340987}}" + res = rs.Result(status="warn", user="rené", bugs=['435678', '1340987']) + assert str(res) == "Result: Warn from rené, bugs: 435678, 1340987" + assert res.result_template == "{{result|warn|rené|435678|1340987}}" - res = rs.Result(status="pass", user="kparal", comment="some comment some reference") + res = rs.Result(status="pass", user="kparal", + comment="some comment some reference") assert str(res) == "Result: Pass from kparal, comment: some comment some reference" assert res.result_template == "{{result|pass|kparal}}some comment some reference"