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 can warn the test using assert method and not fail?
I was trying to see if I could use  assertWarns but the  help says that
  “The test passes if warning is triggered and fails if it isn’t “.

    I don’t want to fail on warning but just continue which next checks


You can, but you're just going to complicate your life. A "test" is a thing that passes (all) or fails (any). If you need it to keep going after a failure, what you have are two tests. There's nothing wrong with having a whole mess of test functions. If there's a lot of common code there you'd have to replicate, that's what setUp() is for. If there are several different flavors of common code you need, you can create a base TestCase subclass and then derive further subclasses from that.

Do the things the way the tools want to do them. Unit testing is enough of a pain without trying to drive nails with the butt of a screwdriver.

--
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to