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

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -