Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to keep Python unit tests? [duplicate]

Possible Duplicate:
Where do the Python unit tests go?

Are unit tests kept in the same file as the code, a separate file in the same directory, or in an entirely different directory?

like image 825
MKaras Avatar asked May 19 '09 12:05

MKaras


People also ask

Where should the unit tests reside in the repository?

The developers should write unit tests alongside the source code and execute them in pipelines. Separating the repositories keeps more clean environment.


2 Answers

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

like image 154
alexn Avatar answered Sep 19 '22 19:09

alexn


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.

like image 21
Chris Arguin Avatar answered Sep 20 '22 19:09

Chris Arguin