Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 459ef06

Browse files
committed
Xml generation test was not detecting failure
Code was returning an exception instead of throwing it leading to an non detected failure in the test. Signed-off-by: Kevin Rocard <[email protected]>
1 parent bf24860 commit 459ef06

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

test/xml-generator/test.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,16 @@ def check(self, reference=None, expectedErrors=0):
7373

7474
if not reference:
7575
# The caller only wants to check the number of errors
76-
return True
76+
return
7777

7878
# The generation has succeeded as expected - let's compare with the reference.
79-
unified = difflib.unified_diff(reference,
80-
actual,
81-
fromfile="reference.xml",
82-
tofile="-",
83-
lineterm="")
84-
diffs = list(unified)
85-
if diffs:
86-
for d in diffs:
87-
print(d)
88-
return AssertionError("The result and the reference don't match.")
89-
return True
79+
if reference != actual:
80+
unified = difflib.unified_diff(reference,
81+
actual,
82+
fromfile="reference.xml",
83+
tofile="-",
84+
lineterm="")
85+
raise AssertionError("The result and the reference don't match:" + "\n".join(unified))
9086

9187

9288
basedir = os.path.dirname(sys.argv[0])
@@ -106,14 +102,14 @@ class TestCase(unittest.TestCase):
106102

107103
def test_nominal(self):
108104
tester = Tester(self.nominal_pfconfig, self.nominal_vector)
109-
self.assertTrue(tester.check(self.nominal_reference))
105+
tester.check(self.nominal_reference)
110106

111107
def test_nonfatalError(self):
112108
vector = copy.copy(self.nominal_vector)
113109
vector.edds.append(os.path.join(vector_dir, "duplicate.pfw"))
114110

115111
tester = Tester(self.nominal_pfconfig, vector)
116-
self.assertTrue(tester.check(self.nominal_reference, expectedErrors=1))
112+
tester.check(self.nominal_reference, expectedErrors=1)
117113

118114
if __name__ == "__main__":
119115
unittest.main()

0 commit comments

Comments
 (0)