python - for loop in unittest -



python - for loop in unittest -

is there way tell python unittest execute assertion in method , show cases fails, instead of stop @ first failed.

class mytestcase(testcase): def test_a(self): open('testcase.txt') ifile: iline in ifile: self.assertequal(iline, 'it test!')

python 3.4 introduced subtest context manager. code like

class mytestcase(testcase): def test_a(self): open('testcase.txt') ifile: iline in ifile: self.subtest(line=iline): self.assertequal(iline, 'it test!')

the ugly way accomplish without subtest create self.assert* calls within try block, print errors caught, , raise assertionerror explicitly after loop if @ to the lowest degree 1 test failed.

python unit-testing python-unittest

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -