From 3a80d77997451d3299dc33f23f4d2e875eb3c5f8 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sun, 21 Mar 2021 11:17:59 +0000 Subject: [PATCH] Contributing.md: We use `pytest` and a particular file layout for tests. --- Contributing.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Contributing.md b/Contributing.md index 80374301..15c1981c 100644 --- a/Contributing.md +++ b/Contributing.md @@ -157,10 +157,20 @@ Note that if your PR does not cleanly (or mostly cleanly) pass a linting scan, y ### Unit testing -Where possible please write unit tests for your PRs, especially in the case of bug fixes, having regression tests help -ensure that we don't accidentally re-introduce a bug down the line. +Where possible please write unit tests for your PRs, especially in the case of +bug fixes, having regression tests help ensure that we don't accidentally +re-introduce a bug down the line. -We use the python stdlib library `unittest` for unit testing. +We use the `pytest` for unit testing. + +The files for a test should go in a sub-directory of `tests/` names after the +(main) file that contains the code they are testing. e.g. for journal_lock.py +the tests are in `tests/journal_lock.py/test_journal_lock.py`. The `test_` +prefix on `test_journal_lock.py` is necessary in order for `pytest` to +recognise the file as containing tests to be run. +The sub-directory avoids having a mess of files in `tests`, particularly when +there might be supporting files, e.g. `tests/config.py/_old_config.py` or files +containing test data. ---