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
Post a Comment