diff --git a/docs/dev.rst b/docs/dev.rst index a72f4739..f3314f5c 100644 --- a/docs/dev.rst +++ b/docs/dev.rst @@ -214,7 +214,7 @@ production, see documentation_. - app@...$ pytest tests/unittest/test_crashstorage.py + app@...$ pytest tests/test_crashstorage.py We're using pytest_ for a test harness and test discovery. @@ -423,7 +423,7 @@ For example: - app@...$ pytest tests/unittest/test_crashstorage.py + app@...$ pytest tests/test_crashstorage.py We're using pytest_ for a test harness and test discovery. diff --git a/pyproject.toml b/pyproject.toml index f78e4da0..a382060e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ docstring-quotes = "double" [tool.pytest.ini_options] addopts = "-rsxX --tb=native --showlocals -m 'not gcp'" norecursedirs = [".git", "docs", "bin"] -testpaths = "tests/unittest/" +testpaths = "tests/" markers = [ "aws: tests that require aws backends to be configured in the environment. this is the default.", diff --git a/tests/README.rst b/tests/README.rst index 4c38517b..d3fa8208 100644 --- a/tests/README.rst +++ b/tests/README.rst @@ -1,29 +1,25 @@ -============ -Tests README -============ +====== +README +====== -In this directory are all the tests for Antenna. Each subdirectory holds a -different test system. Consult the README in the subdirectory for details -on setting up and running those tests. +These test the Antenna code. We use the pytest test runner. +Contents of this directory:: -Subdirectories -============== + data/ -- holds test data + conftest.py -- holds pytest fixtures + test_*.py -- a test file -**tests/data/** - Data to make it easier to test a local instance. +Run these tests from the repository root using:: -**tests/unittest/** + make test - These are written in Python, use pytest as the test runner and are run - during normal development to unit test the code in Antenna. - Run these with:: +To run a single test or group of tests or with different options, do:: - $ make test + make testshell - Run with more options with:: - $ make testshell - app@xxx:/app$ pytest +This gives you a bash shell in the docker container where you can more easily +do test runs and debugging. diff --git a/tests/unittest/conftest.py b/tests/conftest.py similarity index 99% rename from tests/unittest/conftest.py rename to tests/conftest.py index 8217ae3a..1412af72 100644 --- a/tests/unittest/conftest.py +++ b/tests/conftest.py @@ -24,7 +24,7 @@ # Add repository root so we can import antenna and testlib. -REPO_ROOT = Path(__file__).parent.parent.parent +REPO_ROOT = Path(__file__).parent.parent.resolve() sys.path.insert(0, str(REPO_ROOT)) from antenna.app import get_app, setup_logging # noqa diff --git a/tests/unittest/test_app.py b/tests/test_app.py similarity index 100% rename from tests/unittest/test_app.py rename to tests/test_app.py diff --git a/tests/unittest/test_bin.py b/tests/test_bin.py similarity index 90% rename from tests/unittest/test_bin.py rename to tests/test_bin.py index fa41e8b5..6d7d1c3e 100644 --- a/tests/unittest/test_bin.py +++ b/tests/test_bin.py @@ -7,7 +7,9 @@ from click.testing import CliRunner -sys.path.insert(0, str(Path(__file__).resolve().parent.parent.parent / "bin")) +# Add bin/ directory so we can import scripts +REPO_ROOT = Path(__file__).parent.parent.resolve() +sys.path.insert(0, str(REPO_ROOT / "bin")) class TestPubSubCli: diff --git a/tests/unittest/test_breakpad_resource.py b/tests/test_breakpad_resource.py similarity index 100% rename from tests/unittest/test_breakpad_resource.py rename to tests/test_breakpad_resource.py diff --git a/tests/unittest/test_crashmover.py b/tests/test_crashmover.py similarity index 100% rename from tests/unittest/test_crashmover.py rename to tests/test_crashmover.py diff --git a/tests/unittest/test_fs_crashstorage.py b/tests/test_fs_crashstorage.py similarity index 100% rename from tests/unittest/test_fs_crashstorage.py rename to tests/test_fs_crashstorage.py diff --git a/tests/unittest/test_gcs_crashstorage.py b/tests/test_gcs_crashstorage.py similarity index 100% rename from tests/unittest/test_gcs_crashstorage.py rename to tests/test_gcs_crashstorage.py diff --git a/tests/unittest/test_health_resource.py b/tests/test_health_resource.py similarity index 100% rename from tests/unittest/test_health_resource.py rename to tests/test_health_resource.py diff --git a/tests/unittest/test_libdockerflow.py b/tests/test_libdockerflow.py similarity index 100% rename from tests/unittest/test_libdockerflow.py rename to tests/test_libdockerflow.py diff --git a/tests/unittest/test_mini_poster.py b/tests/test_mini_poster.py similarity index 100% rename from tests/unittest/test_mini_poster.py rename to tests/test_mini_poster.py diff --git a/tests/unittest/test_noopcrashpublish.py b/tests/test_noopcrashpublish.py similarity index 100% rename from tests/unittest/test_noopcrashpublish.py rename to tests/test_noopcrashpublish.py diff --git a/tests/unittest/test_noopcrashstorage.py b/tests/test_noopcrashstorage.py similarity index 100% rename from tests/unittest/test_noopcrashstorage.py rename to tests/test_noopcrashstorage.py diff --git a/tests/unittest/test_pubsub_crashpublish.py b/tests/test_pubsub_crashpublish.py similarity index 100% rename from tests/unittest/test_pubsub_crashpublish.py rename to tests/test_pubsub_crashpublish.py diff --git a/tests/unittest/test_s3_crashstorage.py b/tests/test_s3_crashstorage.py similarity index 100% rename from tests/unittest/test_s3_crashstorage.py rename to tests/test_s3_crashstorage.py diff --git a/tests/unittest/test_sentry.py b/tests/test_sentry.py similarity index 100% rename from tests/unittest/test_sentry.py rename to tests/test_sentry.py diff --git a/tests/unittest/test_sqs_crashpublish.py b/tests/test_sqs_crashpublish.py similarity index 100% rename from tests/unittest/test_sqs_crashpublish.py rename to tests/test_sqs_crashpublish.py diff --git a/tests/unittest/test_throttler.py b/tests/test_throttler.py similarity index 100% rename from tests/unittest/test_throttler.py rename to tests/test_throttler.py diff --git a/tests/unittest/test_util.py b/tests/test_util.py similarity index 100% rename from tests/unittest/test_util.py rename to tests/test_util.py diff --git a/tests/unittest/README.rst b/tests/unittest/README.rst deleted file mode 100644 index 7b511b21..00000000 --- a/tests/unittest/README.rst +++ /dev/null @@ -1,24 +0,0 @@ -=============== -Unittest README -=============== - -These test the Antenna code. We use the pytest test runner. - -Contents of this directory:: - - conftest.py -- holds pytest fixtures - test_*.py -- a test file - - -Run these tests from the repository root using:: - - make test - - -To run a single test or group of tests or with different options, do:: - - make shell - - -This gives you a bash shell in the docker container where you can more easily -do test runs and debugging.