diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5c9238e..83e6bad 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,7 +27,7 @@ jobs: docker compose up -d --wait python-api php-api - run: docker container ls && docker image ls - run: docker exec python-api python -m pip freeze - - run: docker exec python-api python -m pytest -xv -m "php" + - run: docker exec python-api python -m pytest -xv -m "php_api" python: runs-on: ubuntu-latest steps: @@ -38,4 +38,4 @@ jobs: - run: docker compose up -d --wait database python-api - run: docker container ls && docker image ls - run: docker exec python-api python -m pip freeze - - run: docker exec python-api python -m pytest -xv -m "not php" + - run: docker exec python-api python -m pytest -xv -m "not php_api" diff --git a/pyproject.toml b/pyproject.toml index 7ba4969..b5400cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,10 +61,12 @@ pythonpath = [ "src" ] markers = [ - "php: tests that compare directly to an old PHP endpoint.", "slow: test or sets of tests which take more than a few seconds to run.", # While the `mut`ation marker below is not strictly necessary as every change is # executed within transaction that is rolled back, it can halt other unit tests which # whose queries may depend on the execution or rollback of the transaction. "mut: executes a mutation on the database (in a transaction which is rolled back)", ] +filterwarnings = [ + 'ignore:A private pytest class or function was used.:DeprecationWarning:tests.conftest:119', +] diff --git a/tests/conftest.py b/tests/conftest.py index 47f0f39..1e52ba8 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,8 +4,11 @@ from pathlib import Path from typing import Any, Iterator, NamedTuple +import _pytest.mark import httpx import pytest +from _pytest.config import Config +from _pytest.nodes import Item from database.setup import expdb_database, user_database from fastapi.testclient import TestClient from main import create_api @@ -108,3 +111,9 @@ def persisted_flow(flow: Flow, expdb_test: Connection) -> Iterator[Flow]: parameters={"flow_id": flow.id}, ) expdb_test.commit() + + +def pytest_collection_modifyitems(config: Config, items: list[Item]) -> None: # noqa: ARG001 + for test_item in items: + for fixture in test_item.fixturenames: # type: ignore[attr-defined] + test_item.own_markers.append(_pytest.mark.Mark(fixture, (), {})) diff --git a/tests/routers/openml/datasets_list_datasets_test.py b/tests/routers/openml/datasets_list_datasets_test.py index c05e9f2..1ed61d6 100644 --- a/tests/routers/openml/datasets_list_datasets_test.py +++ b/tests/routers/openml/datasets_list_datasets_test.py @@ -222,7 +222,6 @@ def test_list_data_quality(quality: str, range_: str, count: int, py_api: TestCl assert len(response.json()) == count -@pytest.mark.php() @pytest.mark.slow() @hypothesis.settings( max_examples=5000, diff --git a/tests/routers/openml/migration/datasets_migration_test.py b/tests/routers/openml/migration/datasets_migration_test.py index 0eea9f3..0d62fc0 100644 --- a/tests/routers/openml/migration/datasets_migration_test.py +++ b/tests/routers/openml/migration/datasets_migration_test.py @@ -9,7 +9,6 @@ from tests.conftest import ApiKey -@pytest.mark.php() @pytest.mark.parametrize( "dataset_id", range(1, 132), @@ -136,7 +135,6 @@ def test_private_dataset_admin_access(py_api: TestClient) -> None: # test against cached response -@pytest.mark.php() @pytest.mark.parametrize( "dataset_id", list(range(1, 10)) + [101], @@ -188,7 +186,6 @@ def test_dataset_tag_response_is_identical( assert original == new -@pytest.mark.php() @pytest.mark.parametrize( "data_id", list(range(1, 130)), diff --git a/tests/routers/openml/migration/evaluations_migration_test.py b/tests/routers/openml/migration/evaluations_migration_test.py index bb03154..a2a77c1 100644 --- a/tests/routers/openml/migration/evaluations_migration_test.py +++ b/tests/routers/openml/migration/evaluations_migration_test.py @@ -1,11 +1,9 @@ from typing import Any import httpx -import pytest from starlette.testclient import TestClient -@pytest.mark.php() def test_evaluationmeasure_list(py_api: TestClient, php_api: httpx.Client) -> None: new = py_api.get("/evaluationmeasure/list") original = php_api.get("/evaluationmeasure/list") @@ -13,7 +11,6 @@ def test_evaluationmeasure_list(py_api: TestClient, php_api: httpx.Client) -> No assert new.json() == original.json()["evaluation_measures"]["measures"]["measure"] -@pytest.mark.php() def test_estimation_procedure_list(py_api: TestClient, php_api: httpx.Client) -> None: new = py_api.get("/estimationprocedure/list") original = php_api.get("/estimationprocedure/list") diff --git a/tests/routers/openml/migration/flows_migration_test.py b/tests/routers/openml/migration/flows_migration_test.py index 70f80d8..90f4f21 100644 --- a/tests/routers/openml/migration/flows_migration_test.py +++ b/tests/routers/openml/migration/flows_migration_test.py @@ -14,7 +14,6 @@ @pytest.mark.mut() -@pytest.mark.php() def test_flow_exists_not( py_api: TestClient, php_api: TestClient, @@ -32,7 +31,6 @@ def test_flow_exists_not( @pytest.mark.mut() -@pytest.mark.php() def test_flow_exists( persisted_flow: Flow, py_api: TestClient, @@ -49,7 +47,6 @@ def test_flow_exists( assert py_response.json() == {"flow_id": persisted_flow.id} -@pytest.mark.php() @pytest.mark.parametrize( "flow_id", range(1, 16), diff --git a/tests/routers/openml/migration/studies_migration_test.py b/tests/routers/openml/migration/studies_migration_test.py index b5834d0..daf4c6c 100644 --- a/tests/routers/openml/migration/studies_migration_test.py +++ b/tests/routers/openml/migration/studies_migration_test.py @@ -1,11 +1,9 @@ import deepdiff import httpx -import pytest from core.conversions import nested_num_to_str, nested_remove_nones from starlette.testclient import TestClient -@pytest.mark.php() def test_get_study_equal(py_api: TestClient, php_api: httpx.Client) -> None: new = py_api.get("/studies/1") old = php_api.get("/study/1") diff --git a/tests/routers/openml/migration/tasks_migration_test.py b/tests/routers/openml/migration/tasks_migration_test.py index e5a02a9..120012c 100644 --- a/tests/routers/openml/migration/tasks_migration_test.py +++ b/tests/routers/openml/migration/tasks_migration_test.py @@ -9,7 +9,6 @@ from starlette.testclient import TestClient -@pytest.mark.php() @pytest.mark.parametrize( "task_id", range(1, 1306), diff --git a/tests/routers/openml/qualities_test.py b/tests/routers/openml/qualities_test.py index 377ec57..4d04a38 100644 --- a/tests/routers/openml/qualities_test.py +++ b/tests/routers/openml/qualities_test.py @@ -28,7 +28,6 @@ def _remove_quality_from_database(quality_name: str, expdb_test: Connection) -> ) -@pytest.mark.php() def test_list_qualities_identical(py_api: TestClient, php_api: httpx.Client) -> None: original = php_api.get("/data/qualities/list") new = py_api.get("/datasets/qualities/list") @@ -279,7 +278,6 @@ def test_get_quality(py_api: TestClient) -> None: assert not difference -@pytest.mark.php() @pytest.mark.parametrize( "data_id", list(set(range(1, 132)) - {55, 56, 59, 116, 130}), @@ -299,7 +297,6 @@ def test_get_quality_identical(data_id: int, py_api: TestClient, php_api: httpx. assert python_response.json() == expected -@pytest.mark.php() @pytest.mark.parametrize( "data_id", [55, 56, 59, 116, 130, 132], diff --git a/tests/routers/openml/task_type_test.py b/tests/routers/openml/task_type_test.py index c518271..64d2cbf 100644 --- a/tests/routers/openml/task_type_test.py +++ b/tests/routers/openml/task_type_test.py @@ -6,7 +6,6 @@ from starlette.testclient import TestClient -@pytest.mark.php() def test_list_task_type(py_api: TestClient, php_api: httpx.Client) -> None: response = py_api.get("/tasktype/list") original = php_api.get("/tasktype/list") @@ -14,7 +13,6 @@ def test_list_task_type(py_api: TestClient, php_api: httpx.Client) -> None: assert response.json() == original.json() -@pytest.mark.php() @pytest.mark.parametrize( "ttype_id", list(range(1, 12)),