Where to keep Python unit tests?

I prefer to keep them in a seperate directory, usually called either "unittests" or just "tests". I then play games in the Makefile to have to automatically handle this directory, if it exists.

It's a little bit of a pain to set up, but I personally prefer not to have the unit tests cluttering up the functional code. This way they are "close" enough to be obvious, but not in your face all the time.


I always place my unit tests in a subdirectory to the related code called test.

For example: /libs/authentication, the tests would be placed in /libs/authentication/tests


The usual project layout is to have a separate directory with tests, with the tests also subdivided by what they are testing.