[CentralOH] Most "Pythonic" way to accomplish this?
Max
kedlav at gmail.com
Tue Feb 5 13:07:31 EST 2019
Generally speaking, it's strongly discouraged to structure tests in this
way where you have conditional logic baked into the test. Instead, you'd
want to setup individual tests covering scenarios.
Base State: Motor running
Test 1:
1.) Call function
2.) mock return of temperature below 'too hot'
3.) assert that the correct behavior has occurred.
Test 2:
1.) Call function
2.) mock return of temperature below 'too hot'
3.) assert that the isCoolingValveOpen function was called
Test 3:
Unit tests to cover isCoolingValveOpen does what it is supposed to do.
On Tue, Feb 5, 2019 at 12:14 PM Joshua Kramer <joskra42.list at gmail.com>
wrote:
> Thanks Zak! I should clarify that with this particular question, I am
> not writing tests for code. For failures, Pytest gives a lot of
> information about the code, which would not apply in my case. For
> example, I might want to run some hardware tests. The runTest method
> in myTest1 object might run a function called "isMotorTooHot()", and
> if that returns true, then the next test in the list would run
> "isCoolingValveOpen()", etc. So perhaps we should think of these as
> "tasks" instead of "tests".
> _______________________________________________
> CentralOH mailing list
> CentralOH at python.org
> https://mail.python.org/mailman/listinfo/centraloh
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/centraloh/attachments/20190205/d3bb5601/attachment.html>
More information about the CentralOH
mailing list