From 5c0515e9c672a4fed034bc3923ee7953cd87c860 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Mon, 29 Aug 2022 15:14:34 +0100 Subject: [PATCH] tests: Prevent invocation in root dir, point to `src/` Because the code itself only runs properly from inside the `src/` directory, you cannot run `pytest` from the root directory and have the tests work. So, set things up such that running `pytest` in the root directory will only run the one test, and have that test point out the user error. --- pytest.ini | 3 +++ tests/test_run_pytest_in_src_dir_not_here.py | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 pytest.ini create mode 100644 tests/test_run_pytest_in_src_dir_not_here.py diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..93c70a3 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +norecursedirs = src +testpaths = tests/ diff --git a/tests/test_run_pytest_in_src_dir_not_here.py b/tests/test_run_pytest_in_src_dir_not_here.py new file mode 100644 index 0000000..7311eb3 --- /dev/null +++ b/tests/test_run_pytest_in_src_dir_not_here.py @@ -0,0 +1,3 @@ +"""Inform the invoker they ran `pytest` in the wrong place.""" +print('You must run `pytest` from inside the `src/` directory') +assert False