Hacker News new | past | comments | ask | show | jobs | submit login

...so that it helps me write the function, but "hard-wires" a particular order?

Use 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))).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: