3 ms·
...so that it helps me write the function, but "hard-wires" a particular order? Use assertItemsEqual. http://docs.python.org/library/unittest.html#unittest.Te
by yummyfajitas 14y ago
...so that it helps me write the function, but "hard-wires" a particular order?
Use assertItemsEqual.
http://docs.python.org/library/unittest.html#unittest.TestCase.assertItemsEqual http://docs.python.org/library/unittest.html#unittest.TestCa...
The way I do it:
In the doctest, I include a few toy examples, stuff I can verify by hand, and which helps the user understand what I'm doing.
In the unit tests, I try to do things in the style of Haskell's Quickcheck (the greatest testing library out there). Generate some random values and test properties (e.g., len(permute(x)) == factorial(len(x))).