← Back to team overview

sts-sponsors team mailing list archive

[Merge] ~ack/maas:split-pytest-tests into maas:master

 

Alberto Donato has proposed merging ~ack/maas:split-pytest-tests into maas:master.

Commit message:
move pytest tests to a tree parallel to code

Requested reviews:
  MAAS Maintainers (maas-maintainers)

For more details, see:
https://code.launchpad.net/~ack/maas/+git/maas/+merge/441583
-- 
Your team MAAS Maintainers is requested to review the proposed merge of ~ack/maas:split-pytest-tests into maas:master.
diff --git a/pyproject.toml b/pyproject.toml
index d6de9a2..6e5f7a6 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -46,19 +46,7 @@ filterwarnings = "error::BytesWarning"
 testpaths = [
   "src/apiclient",
   "src/maascli",
-  "src/maastesting",
   "src/maasperf",
-  # [[[cog
-  # import cog
-  # from pathlib import Path
-  # for path in sorted(Path("src").glob("**/pytest_tests")):
-  #    cog.outl(f'"{path}",')
-  # ]]]
-  "src/maasserver/djangosettings/pytest_tests",
-  "src/maasserver/management/commands/pytest_tests",
-  "src/maasserver/models/pytest_tests",
-  "src/maasserver/pytest_tests",
-  "src/metadataserver/builtin_scripts/pytest_tests",
-  "src/provisioningserver/utils/pytest_tests",
-  # [[[end]]]
+  "src/maastesting",
+  "src/tests",
 ]
diff --git a/setup.cfg b/setup.cfg
index a92ecaf..46796d5 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -27,14 +27,15 @@ package_dir =
 
 [options.packages.find]
 where = src
+include =
+   apiclient*
+   maascli*
+   maasserver*
+   metadataserver*
+   provisioningserver*
 exclude =
     *.testing
     *.tests
-    *.pytest_tests
-    maastesting
-    maastesting.*
-    maasperf
-    maasperf.*
 
 [options.entry_points]
 console_scripts =
diff --git a/src/maastesting/pytest.dirs b/src/maastesting/pytest.dirs
deleted file mode 100644
index 2c155af..0000000
--- a/src/maastesting/pytest.dirs
+++ /dev/null
@@ -1,13 +0,0 @@
-# [[[cog
-# import cog
-# from pathlib import Path
-# for path in sorted(Path("src").glob("**/pytest_tests")):
-#    cog.outl(str(path))
-# ]]]
-src/maasserver/djangosettings/pytest_tests
-src/maasserver/management/commands/pytest_tests
-src/maasserver/models/pytest_tests
-src/maasserver/pytest_tests
-src/metadataserver/builtin_scripts/pytest_tests
-src/provisioningserver/utils/pytest_tests
-# [[[end]]]
diff --git a/src/maastesting/scripts.py b/src/maastesting/scripts.py
index ef48b5a..dc4f7ff 100644
--- a/src/maastesting/scripts.py
+++ b/src/maastesting/scripts.py
@@ -50,8 +50,6 @@ def run_region():
         "--select-dir=src/metadataserver",
         "--cover-package=maas,maasserver,metadataserver",
         "--cover-branches",
-        # exclude pytest tests
-        "--exclude-dir-file=src/maastesting/pytest.dirs",
         # Reduce the logging level to INFO here as
         # DebuggingLoggerMiddleware logs the content of all the
         # requests at DEBUG level: we don't want this in the
@@ -94,8 +92,6 @@ def run_region_legacy():
         "--select-dir=src/metadataserver",
         "--cover-package=maas,maasserver,metadataserver",
         "--cover-branches",
-        # exclude pytest tests
-        "--exclude-dir-file=src/maastesting/pytest.dirs",
         # Reduce the logging level to INFO here as DebuggingLoggerMiddleware
         # logs the content of all the requests at DEBUG level: we don't want
         # this in the tests as it's too verbose.
@@ -122,8 +118,6 @@ def run_rack():
         "--select-dir=src/provisioningserver",
         "--cover-package=provisioningserver",
         "--cover-branches",
-        # exclude pytest tests
-        "--exclude-dir-file=src/maastesting/pytest.dirs",
     ]
     inject_test_options(options)
     update_environ()
diff --git a/src/maasserver/djangosettings/pytest_tests/__init__.py b/src/tests/__init__.py
similarity index 100%
rename from src/maasserver/djangosettings/pytest_tests/__init__.py
rename to src/tests/__init__.py
diff --git a/src/conftest.py b/src/tests/conftest.py
similarity index 84%
rename from src/conftest.py
rename to src/tests/conftest.py
index 4743647..1fc9ea9 100644
--- a/src/conftest.py
+++ b/src/tests/conftest.py
@@ -5,7 +5,12 @@ from pathlib import Path
 
 import pytest
 
-from provisioningserver.utils.env import MAAS_ID, MAAS_UUID, MAAS_SHARED_SECRET, MAAS_SECRET
+from provisioningserver.utils.env import (
+    MAAS_ID,
+    MAAS_SECRET,
+    MAAS_SHARED_SECRET,
+    MAAS_UUID,
+)
 
 
 @pytest.fixture(autouse=True)
diff --git a/src/maasserver/management/commands/pytest_tests/__init__.py b/src/tests/maasserver/__init__.py
similarity index 100%
rename from src/maasserver/management/commands/pytest_tests/__init__.py
rename to src/tests/maasserver/__init__.py
diff --git a/src/maasserver/conftest.py b/src/tests/maasserver/conftest.py
similarity index 100%
rename from src/maasserver/conftest.py
rename to src/tests/maasserver/conftest.py
diff --git a/src/maasserver/pytest_tests/__init__.py b/src/tests/maasserver/djangosettings/__init__.py
similarity index 100%
rename from src/maasserver/pytest_tests/__init__.py
rename to src/tests/maasserver/djangosettings/__init__.py
diff --git a/src/maasserver/djangosettings/pytest_tests/test_settings.py b/src/tests/maasserver/djangosettings/test_settings.py
similarity index 100%
rename from src/maasserver/djangosettings/pytest_tests/test_settings.py
rename to src/tests/maasserver/djangosettings/test_settings.py
diff --git a/src/metadataserver/builtin_scripts/pytest_tests/__init__.py b/src/tests/maasserver/management/commands/__init__.py
similarity index 100%
rename from src/metadataserver/builtin_scripts/pytest_tests/__init__.py
rename to src/tests/maasserver/management/commands/__init__.py
diff --git a/src/maasserver/management/commands/pytest_tests/test_config_vault.py b/src/tests/maasserver/management/commands/test_config_vault.py
similarity index 100%
rename from src/maasserver/management/commands/pytest_tests/test_config_vault.py
rename to src/tests/maasserver/management/commands/test_config_vault.py
diff --git a/src/maasserver/models/pytest_tests/test_node.py b/src/tests/maasserver/models/test_node.py
similarity index 100%
rename from src/maasserver/models/pytest_tests/test_node.py
rename to src/tests/maasserver/models/test_node.py
diff --git a/src/maasserver/pytest_tests/test_certificates.py b/src/tests/maasserver/test_certificates.py
similarity index 100%
rename from src/maasserver/pytest_tests/test_certificates.py
rename to src/tests/maasserver/test_certificates.py
diff --git a/src/maasserver/pytest_tests/test_fields.py b/src/tests/maasserver/test_fields.py
similarity index 100%
rename from src/maasserver/pytest_tests/test_fields.py
rename to src/tests/maasserver/test_fields.py
diff --git a/src/maasserver/pytest_tests/test_secrets.py b/src/tests/maasserver/test_secrets.py
similarity index 100%
rename from src/maasserver/pytest_tests/test_secrets.py
rename to src/tests/maasserver/test_secrets.py
diff --git a/src/maasserver/pytest_tests/test_sessiontimeout.py b/src/tests/maasserver/test_sessiontimeout.py
similarity index 100%
rename from src/maasserver/pytest_tests/test_sessiontimeout.py
rename to src/tests/maasserver/test_sessiontimeout.py
diff --git a/src/maasserver/pytest_tests/test_vault.py b/src/tests/maasserver/test_vault.py
similarity index 100%
rename from src/maasserver/pytest_tests/test_vault.py
rename to src/tests/maasserver/test_vault.py
diff --git a/src/provisioningserver/utils/pytest_tests/__init__.py b/src/tests/metadataserver/builtin_scripts/__init__.py
similarity index 100%
rename from src/provisioningserver/utils/pytest_tests/__init__.py
rename to src/tests/metadataserver/builtin_scripts/__init__.py
diff --git a/src/metadataserver/builtin_scripts/pytest_tests/test_hooks.py b/src/tests/metadataserver/builtin_scripts/test_hooks.py
similarity index 100%
rename from src/metadataserver/builtin_scripts/pytest_tests/test_hooks.py
rename to src/tests/metadataserver/builtin_scripts/test_hooks.py
diff --git a/src/tests/provisioningserver/utils/__init__.py b/src/tests/provisioningserver/utils/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/tests/provisioningserver/utils/__init__.py
diff --git a/src/provisioningserver/utils/pytest_tests/test_arch.py b/src/tests/provisioningserver/utils/test_arch.py
similarity index 100%
rename from src/provisioningserver/utils/pytest_tests/test_arch.py
rename to src/tests/provisioningserver/utils/test_arch.py
diff --git a/src/provisioningserver/utils/pytest_tests/test_env.py b/src/tests/provisioningserver/utils/test_env.py
similarity index 100%
rename from src/provisioningserver/utils/pytest_tests/test_env.py
rename to src/tests/provisioningserver/utils/test_env.py
diff --git a/tox.ini b/tox.ini
index b89e81d..8083ad6 100644
--- a/tox.ini
+++ b/tox.ini
@@ -14,7 +14,6 @@ commands =
     setup-cfg-fmt setup.cfg
     isort {[files]lint}
     black -q {[files]lint}
-    cog -r --verbosity=1 {[files]cog}
     - pyproject-fmt pyproject.toml
     - tox-ini-fmt tox.ini
 
@@ -25,7 +24,6 @@ commands =
     isort --check-only --diff {[files]lint}
     black --check {[files]lint}
     flake8 {[files]lint}
-    cog --check --verbosity=1 {[files]cog}
     pyproject-fmt --check pyproject.toml
 
 [testenv:oapi]
@@ -47,21 +45,18 @@ lint =
     src/metadataserver \
     src/provisioningserver \
     src/provisioningserver/refresh/50-maas-01-commissioning \
+    src/tests/ \
     utilities/bin2python.py \
     utilities/check-imports \
     utilities/check-oapi \
     utilities/import-db-dump \
     utilities/python_standard_libs.py \
     utilities/snap-bind-mounts
-cog =
-    src/maastesting/pytest.dirs \
-    pyproject.toml
 
 [deps]
 lint =
     black == 23.1.0
     click == 8.1.3
-    cogapp == 3.3.0
     flake8 == 6.0.0
     flake8-pyproject == 1.2.3
     isort == 5.12.0
diff --git a/utilities/check-imports b/utilities/check-imports
index 70f75a5..6badb2f 100755
--- a/utilities/check-imports
+++ b/utilities/check-imports
@@ -326,7 +326,6 @@ Tests = files(
     "src/**/test_*.py",
     "src/**/testing/**/*.py",
     "src/**/testing.py",
-    "src/**/conftest.py",
 )
 
 

Follow ups