Re: Best way to assert unit test cases with many conditions

2017-07-19 Thread Rob Gaddi
On 07/19/2017 03:26 AM, Ganesh Pal wrote: Yes. Just assert each thing as it needs asserting. Asserting each sub test will fail the entire test, I want the to pass the test if any the sub test passes. If the sub test fail try all cases and fail for the last one. Example : def

Re: Best way to assert unit test cases with many conditions

2017-07-19 Thread Terry Reedy
On 7/19/2017 8:24 AM, Peter Otten wrote: Ganesh Pal wrote: (1) I would want my subtest to have a *Condition* based on which it that would pass my entire test if any of the sub-test passed. If I understand correctly, you want assertTrue(subtest1 or subtest2 or subtest3 or subtest4 ...)

Re: Best way to assert unit test cases with many conditions

2017-07-19 Thread Peter Otten
Ganesh Pal wrote: > On Tue, Jul 18, 2017 at 11:02 PM, Dan Strohl wrote: > >> >> Like this: >> >> Def test_this(self): >> For i in range(10): >> with self.subTest('test number %s) % i): >> self.assertTrue(I <= 5) >> >> With the subTest() method, if

Re: Best way to assert unit test cases with many conditions

2017-07-19 Thread Ganesh Pal
> > Yes. Just assert each thing as it needs asserting. > > Asserting each sub test will fail the entire test, I want the to pass the test if any the sub test passes. If the sub test fail try all cases and fail for the last one. Example : def test_this(self): if Sub_test_1():

Re: Best way to assert unit test cases with many conditions

2017-07-19 Thread Ganesh Pal
On Tue, Jul 18, 2017 at 11:02 PM, Dan Strohl wrote: > > Like this: > > Def test_this(self): > For i in range(10): > with self.subTest('test number %s) % i): > self.assertTrue(I <= 5) > > With the subTest() method, if anything within that subTest fails, it

RE: Best way to assert unit test cases with many conditions

2017-07-18 Thread Dan Strohl via Python-list
Ganesh; I'm not 100% sure what you are trying to do.. so let me throw out a few things I do and see if that helps... If you are trying to run a bunch of similar tests on something, changing only (or mostly) in the parameters passed, you can use self.subTest(). Like this: Def test_this(self):

Re: Best way to assert unit test cases with many conditions

2017-07-18 Thread Rob Gaddi
On 07/18/2017 09:56 AM, Ganesh Pal wrote: (1) should I add several asserts per test case, or just warn with the error and fail at the end . In the line 33 – 35 / 37-38 ( sorry this is a dirty pusedo-code) . Yes. Just assert each thing as it needs asserting. (2) Is there a way we