From 24d47d3de5995dbf93ed04653f60203d3682dfe2 Mon Sep 17 00:00:00 2001 From: Martin Mader Date: Fri, 2 Feb 2024 11:11:32 +0100 Subject: [PATCH] fix running pytest in github and locally with pytest 8.0.0 --- .github/workflows/check-datasources.yml | 4 ++-- .github/workflows/python-app.yml | 2 +- README.md | 6 +++--- pyproject.toml | 14 +++++++++----- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/check-datasources.yml b/.github/workflows/check-datasources.yml index 6cbf5b8..ae0ba42 100644 --- a/.github/workflows/check-datasources.yml +++ b/.github/workflows/check-datasources.yml @@ -28,8 +28,8 @@ jobs: - name: "[DE/BNA] Data retrieval check" run: | - pytest tests/integration/test_int_de_bna.py + python -m pytest tests/integration/test_int_de_bna.py - name: "[FR] Data retrieval check" run: | - pytest tests/integration/test_int_fr_france.py + python -m pytest tests/integration/test_int_fr_france.py diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 8c34028..675bfc2 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -45,4 +45,4 @@ jobs: - name: Run tests run: | pip install -r test/requirements.txt - pytest -m "not check_datasource" + python -m pytest -m "not check_datasource" diff --git a/README.md b/README.md index 83cf3cc..44158f3 100644 --- a/README.md +++ b/README.md @@ -193,14 +193,14 @@ Before you run the tests you need to install test dependencies by pip install -r test/requirements.txt ``` -You can run all tests under `/test` by running the following command: +You can run all tests by running the following command: ```bash # to run all tests, use: -pytest +python -m pytest # ... or the following to run only the unit tests, i.e. not the integration tests (which run a bit longer): -pytest -m 'not integration_test' -W ignore::DeprecationWarning +python -m pytest -m 'not integration_test' ``` #### Testdata import / Integration test for the merger diff --git a/pyproject.toml b/pyproject.toml index 2d058bf..0242358 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,16 +15,20 @@ requires = [ build-backend = "setuptools.build_meta" [tool.pytest.ini_options] - -# Set logging for code under test -addopts = "--verbose --capture=no --log-cli-level=DEBUG --log-cli-format='%(asctime)s %(levelname)s %(message)s' --log-cli-date-format='%Y-%m-%d %H:%M:%S' -W ignore::DeprecationWarning" - +addopts = [ + "--import-mode=importlib", + "--capture=no", + "--log-level=WARN", + "--log-cli-level=DEBUG", + "--log-cli-format='%(asctime)s %(levelname)s %(message)s'", + "--log-cli-date-format='%Y-%m-%d %H:%M:%S'", + "-W ignore::DeprecationWarning" +] # Limit search for tests to following folders testpaths = [ "test", # TODO: move content to tests/unit/ folder "tests", ] - # Declare custom markers markers = [ "integration_test: marks tests as integration tests (deselect with '-m \"not integration_test\"')",