Where do the Python unit tests go? -


if you're writing library, or app, unit test files go?

it's nice separate test files main app code, it's awkward put them "tests" subdirectory inside of app root directory, because makes harder import modules you'll testing.

is there best practice here?

for file module.py, unit test should called test_module.py, following pythonic naming conventions.

there several commonly accepted places put test_module.py:

  1. in same directory module.py.
  2. in ../tests/test_module.py (at same level code directory).
  3. in tests/test_module.py (one level under code directory).

i prefer #1 simplicity of finding tests , importing them. whatever build system you're using can configured run files starting test_. actually, default unittest pattern used test discovery test*.py.


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -