From 221d3f1c4064e265f55f08c30f1f4f724b7282ef Mon Sep 17 00:00:00 2001 From: Leon Wright Date: Fri, 20 Sep 2024 09:17:48 +0800 Subject: [PATCH] tests: Convert to Autodiscovery This allows the test cases to use the autodiscovery mechanisms of unittest and pytest. Instead of requiring a bunch of manual configuration --- .vscode/settings.json | 6 ++---- netkan/Dockerfile | 1 + netkan/pyproject.toml | 1 - netkan/tests/__init__.py | 14 -------------- .../{auto_freezer.py => test_auto_freezer.py} | 0 netkan/tests/{cli.py => test_cli.py} | 0 .../{csharp_compat.py => test_csharp_compat.py} | 0 netkan/tests/{indexer.py => test_indexer.py} | 0 netkan/tests/{metadata.py => test_metadata.py} | 0 netkan/tests/{mirrorer.py => test_mirrorer.py} | 0 netkan/tests/{repos.py => test_repos.py} | 0 netkan/tests/{scheduler.py => test_scheduler.py} | 0 ...{spacedock_adder.py => test_spacedock_adder.py} | 0 netkan/tests/{status.py => test_status.py} | 0 netkan/tests/{utils.py => test_utils.py} | 0 netkan/tests/{webhooks.py => test_webhooks.py} | 0 pytest.ini | 4 ---- 17 files changed, 3 insertions(+), 23 deletions(-) rename netkan/tests/{auto_freezer.py => test_auto_freezer.py} (100%) rename netkan/tests/{cli.py => test_cli.py} (100%) rename netkan/tests/{csharp_compat.py => test_csharp_compat.py} (100%) rename netkan/tests/{indexer.py => test_indexer.py} (100%) rename netkan/tests/{metadata.py => test_metadata.py} (100%) rename netkan/tests/{mirrorer.py => test_mirrorer.py} (100%) rename netkan/tests/{repos.py => test_repos.py} (100%) rename netkan/tests/{scheduler.py => test_scheduler.py} (100%) rename netkan/tests/{spacedock_adder.py => test_spacedock_adder.py} (100%) rename netkan/tests/{status.py => test_status.py} (100%) rename netkan/tests/{utils.py => test_utils.py} (100%) rename netkan/tests/{webhooks.py => test_webhooks.py} (100%) delete mode 100644 pytest.ini diff --git a/.vscode/settings.json b/.vscode/settings.json index ea49c5af..ff8d9055 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,15 +1,13 @@ { - "python.pythonPath": "/usr/bin/python3", - "python.formatting.provider": "autopep8", + "python.defaultInterpreterPath": "/usr/bin/python", + "python.testing.cwd": "netkan/", "editor.formatOnSave": true, "files.exclude": { "**/__pycache__": true }, "python.testing.pytestEnabled": true, - "python.testing.nosetestsEnabled": false, "python.testing.unittestEnabled": false, "files.trimTrailingWhitespace": true, "files.insertFinalNewline": true, "files.trimFinalNewlines": true, - "mypy.configFile": "netkan/mypy.ini" } diff --git a/netkan/Dockerfile b/netkan/Dockerfile index e1dadc4b..f3301c4b 100644 --- a/netkan/Dockerfile +++ b/netkan/Dockerfile @@ -44,6 +44,7 @@ RUN /home/netkan/.local/bin/pytest -v FROM production AS dev USER root +RUN apt-get install nodejs -y && apt-get clean ADD . /netkan RUN chown -R netkan:netkan /netkan COPY run_dev.sh /usr/local/bin/ diff --git a/netkan/pyproject.toml b/netkan/pyproject.toml index 2ad5024e..2e8f6dd8 100644 --- a/netkan/pyproject.toml +++ b/netkan/pyproject.toml @@ -73,7 +73,6 @@ omit = ["tests/*"] exclude_lines = ["if TYPE_CHECKING:", " pass"] [tool.pytest.ini_options] -python_files = "tests/__init__.py" addopts = "-p no:cacheprovider --mypy --pylint" filterwarnings = ["ignore", "default:::netkan.*", "default:::tests.*"] diff --git a/netkan/tests/__init__.py b/netkan/tests/__init__.py index ff276367..e69de29b 100644 --- a/netkan/tests/__init__.py +++ b/netkan/tests/__init__.py @@ -1,14 +0,0 @@ -# flake8: noqa - -from .cli import * -from .indexer import * -from .metadata import * -from .mirrorer import * -from .repos import * -from .scheduler import * -from .utils import * -from .csharp_compat import * -from .auto_freezer import * -from .spacedock_adder import * -from .status import * -from .webhooks import * diff --git a/netkan/tests/auto_freezer.py b/netkan/tests/test_auto_freezer.py similarity index 100% rename from netkan/tests/auto_freezer.py rename to netkan/tests/test_auto_freezer.py diff --git a/netkan/tests/cli.py b/netkan/tests/test_cli.py similarity index 100% rename from netkan/tests/cli.py rename to netkan/tests/test_cli.py diff --git a/netkan/tests/csharp_compat.py b/netkan/tests/test_csharp_compat.py similarity index 100% rename from netkan/tests/csharp_compat.py rename to netkan/tests/test_csharp_compat.py diff --git a/netkan/tests/indexer.py b/netkan/tests/test_indexer.py similarity index 100% rename from netkan/tests/indexer.py rename to netkan/tests/test_indexer.py diff --git a/netkan/tests/metadata.py b/netkan/tests/test_metadata.py similarity index 100% rename from netkan/tests/metadata.py rename to netkan/tests/test_metadata.py diff --git a/netkan/tests/mirrorer.py b/netkan/tests/test_mirrorer.py similarity index 100% rename from netkan/tests/mirrorer.py rename to netkan/tests/test_mirrorer.py diff --git a/netkan/tests/repos.py b/netkan/tests/test_repos.py similarity index 100% rename from netkan/tests/repos.py rename to netkan/tests/test_repos.py diff --git a/netkan/tests/scheduler.py b/netkan/tests/test_scheduler.py similarity index 100% rename from netkan/tests/scheduler.py rename to netkan/tests/test_scheduler.py diff --git a/netkan/tests/spacedock_adder.py b/netkan/tests/test_spacedock_adder.py similarity index 100% rename from netkan/tests/spacedock_adder.py rename to netkan/tests/test_spacedock_adder.py diff --git a/netkan/tests/status.py b/netkan/tests/test_status.py similarity index 100% rename from netkan/tests/status.py rename to netkan/tests/test_status.py diff --git a/netkan/tests/utils.py b/netkan/tests/test_utils.py similarity index 100% rename from netkan/tests/utils.py rename to netkan/tests/test_utils.py diff --git a/netkan/tests/webhooks.py b/netkan/tests/test_webhooks.py similarity index 100% rename from netkan/tests/webhooks.py rename to netkan/tests/test_webhooks.py diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 68d9a7cb..00000000 --- a/pytest.ini +++ /dev/null @@ -1,4 +0,0 @@ -[pytest] -testpaths = netkan -python_files = tests/__init__.py -addopts = -p no:cacheprovider -v