From bf213ae31ba9bf8c76cf85e28e7c46dba7ceccfe Mon Sep 17 00:00:00 2001 From: Paolo Tormene Date: Mon, 27 Jan 2025 15:58:49 +0100 Subject: [PATCH] Revert the addition of pytest-django --- .github/workflows/engine_pr_test.yml | 12 ++++++--- .github/workflows/macos_intel_install.yml | 6 +++-- .github/workflows/macos_m1_install.yml | 5 ++-- .github/workflows/windows_test.yml | 6 +++-- conftest.py | 30 ----------------------- openquake/server/settings.py | 2 +- pytest.ini | 1 - requirements-py310-linux64.txt | 1 - requirements-py310-macos_arm64.txt | 1 - requirements-py310-macos_x86_64.txt | 1 - requirements-py310-win64.txt | 1 - requirements-py311-linux64.txt | 1 - requirements-py311-macos_arm64.txt | 1 - requirements-py311-macos_x86_64.txt | 1 - requirements-py311-win64.txt | 1 - requirements-py312-linux64.txt | 1 - requirements-py312-macos_arm64.txt | 1 - requirements-py312-macos_x86_64.txt | 1 - requirements-py312-win64.txt | 1 - 19 files changed, 20 insertions(+), 54 deletions(-) delete mode 100644 conftest.py diff --git a/.github/workflows/engine_pr_test.yml b/.github/workflows/engine_pr_test.yml index c2169a1c47d4..3f5a91068221 100644 --- a/.github/workflows/engine_pr_test.yml +++ b/.github/workflows/engine_pr_test.yml @@ -110,7 +110,8 @@ jobs: sleep 5 # wait for 5 seconds before check again done pytest -xs --doctest-modules --disable-warnings --color=yes openquake/commands openquake/engine - pytest -v openquake/server/tests/test_public_mode.py + # -v 2 also logs the test names + ./openquake/server/manage.py test -v 2 tests.test_public_mode server_read_only_mode: runs-on: ${{ matrix.os }} @@ -139,7 +140,8 @@ jobs: run: | source ~/openquake/bin/activate oq engine --upgrade-db - pytest -v openquake/server/tests/test_read_only_mode.py + # -v 2 also logs the test names + ./openquake/server/manage.py test -v 2 tests.test_read_only_mode server_aelo_mode: runs-on: ${{ matrix.os }} @@ -172,7 +174,8 @@ jobs: ./openquake/server/manage.py migrate ./openquake/server/manage.py loaddata openquake/server/fixtures/0001_cookie_consent_required_plus_hide_cookie_bar.json ./openquake/server/manage.py collectstatic --noinput - pytest -v openquake/server/tests/test_aelo_mode.py + # -v 2 also logs the test names + ./openquake/server/manage.py test -v 2 tests.test_aelo_mode server_aristotle_mode: runs-on: ${{ matrix.os }} @@ -212,4 +215,5 @@ jobs: oq engine --upgrade-db ./openquake/server/manage.py migrate touch ~/webui-access.log - pytest -v openquake/server/tests/test_aristotle_mode.py + # -v 2 also logs the test names + ./openquake/server/manage.py test -v 2 tests.test_aristotle_mode diff --git a/.github/workflows/macos_intel_install.yml b/.github/workflows/macos_intel_install.yml index e9e73c801066..29a5670038e3 100644 --- a/.github/workflows/macos_intel_install.yml +++ b/.github/workflows/macos_intel_install.yml @@ -93,14 +93,16 @@ jobs: run: | source ~/openquake/bin/activate cd ~/work/oq-engine/oq-engine - OQ_APPLICATION_MODE=PUBLIC pytest -v openquake/server/tests/test_public_mode.py + # -v 2 also logs the test names + OQ_APPLICATION_MODE=PUBLIC ./openquake/server/manage.py test -v 2 tests.test_public_mode - name: Run tests for the engine server in read-only mode to test installation if: always() run: | source ~/openquake/bin/activate cd ~/work/oq-engine/oq-engine - OQ_APPLICATION_MODE=READ_ONLY pytest -v openquake/server/tests/test_read_only_mode.py + # -v 2 also logs the test names + OQ_APPLICATION_MODE=READ_ONLY ./openquake/server/manage.py test -v 2 tests.test_read_only_mode # NOTE: we shouldn't need to install the engine in AELO mode on mac # - name: Run tests for the engine server in aelo mode to test installation diff --git a/.github/workflows/macos_m1_install.yml b/.github/workflows/macos_m1_install.yml index e37726737f3e..18e539fe44b6 100644 --- a/.github/workflows/macos_m1_install.yml +++ b/.github/workflows/macos_m1_install.yml @@ -109,14 +109,15 @@ jobs: run: | source ~/openquake/bin/activate cd /Users/runner/runner-isolation/actions-runner/_work/oq-engine/oq-engine/ - OQ_APPLICATION_MODE=PUBLIC pytest -v openquake/server/tests/test_public_mode.py + # -v 2 also logs the test names + OQ_APPLICATION_MODE=PUBLIC ./openquake/server/manage.py test -v 2 tests.test_public_mode - name: Run tests for the engine server in read-only mode to test installation if: always() run: | source ~/openquake/bin/activate cd /Users/runner/runner-isolation/actions-runner/_work/oq-engine/oq-engine/ - OQ_APPLICATION_MODE=READ_ONLY pytest -v openquake/server/tests/test_read_only_mode.py + OQ_APPLICATION_MODE=READ_ONLY ./openquake/server/manage.py test -v 2 tests.test_read_only_mode # NB: the demos are tested on linux; there is no reason a demo should # not run on macos, so we can avoid running them diff --git a/.github/workflows/windows_test.yml b/.github/workflows/windows_test.yml index d1906cb96f51..784e233bcd6b 100644 --- a/.github/workflows/windows_test.yml +++ b/.github/workflows/windows_test.yml @@ -122,7 +122,8 @@ jobs: sleep 10 cd D:\a\oq-engine\oq-engine $Env:OQ_APPLICATION_MODE='PUBLIC' - pytest -v openquake\server\tests\test_public_mode.py + # -v 2 also logs the test names + python .\openquake\server\manage.py test -v 2 tests.test_public_mode - name: Run tests for the engine server in read-only mode to test installation if: always() && env.to_run == 0 @@ -133,7 +134,8 @@ jobs: sleep 10 cd D:\a\oq-engine\oq-engine $Env:OQ_APPLICATION_MODE='READ_ONLY' - pytest -v openquake\server\tests\test_read_only_mode.py + # -v 2 also logs the test names + python .\openquake\server\manage.py test -v 2 tests.test_read_only_mode - name: Run all demos if: env.to_run == 0 diff --git a/conftest.py b/conftest.py deleted file mode 100644 index 4c95eb9a93f0..000000000000 --- a/conftest.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: tabstop=4 shiftwidth=4 softtabstop=4 -# -# Copyright (C) 2025, GEM Foundation -# -# OpenQuake is free software: you can redistribute it and/or modify it -# under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# OpenQuake is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with OpenQuake. If not, see . - -import pytest -from django.core import mail - - -@pytest.fixture(scope="function", autouse=True) -def _dj_autoclear_mailbox(): - """ - Override the `_dj_autoclear_mailbox` test fixture in `pytest_django` - to clear the outbox only if it exists. - """ - if hasattr(mail, 'outbox'): - del mail.outbox[:] diff --git a/openquake/server/settings.py b/openquake/server/settings.py index df47a15de42a..11aafeea7f1d 100644 --- a/openquake/server/settings.py +++ b/openquake/server/settings.py @@ -35,7 +35,7 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' WEBUI_USER = 'openquake' -TEST = 'test' in sys.argv or any('pytest' in arg for arg in sys.argv) +TEST = 'test' in sys.argv INSTALLED_APPS = ('openquake.server.db',) diff --git a/pytest.ini b/pytest.ini index 11455d4fd9b5..91efdb53ac55 100644 --- a/pytest.ini +++ b/pytest.ini @@ -2,4 +2,3 @@ markers = slow: a slow test addopts = --tb short -DJANGO_SETTINGS_MODULE = openquake.server.settings diff --git a/requirements-py310-linux64.txt b/requirements-py310-linux64.txt index e1be1fc2b3c8..6be02787ad2a 100644 --- a/requirements-py310-linux64.txt +++ b/requirements-py310-linux64.txt @@ -76,4 +76,3 @@ https://wheelhouse.openquake.org/v3/py/zipp-3.17.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pluggy-1.5.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pytest-8.3.3-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/django_appconf-1.0.6-py3-none-any.whl -https://wheelhouse.openquake.org/v3/py/pytest_django-4.9.0-py3-none-any.whl diff --git a/requirements-py310-macos_arm64.txt b/requirements-py310-macos_arm64.txt index 51e5868767e1..b85ef2626021 100644 --- a/requirements-py310-macos_arm64.txt +++ b/requirements-py310-macos_arm64.txt @@ -72,4 +72,3 @@ https://wheelhouse.openquake.org/v3/py/zipp-3.17.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pluggy-1.5.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pytest-8.3.3-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/django_appconf-1.0.6-py3-none-any.whl -https://wheelhouse.openquake.org/v3/py/pytest_django-4.9.0-py3-none-any.whl diff --git a/requirements-py310-macos_x86_64.txt b/requirements-py310-macos_x86_64.txt index 36797dce885e..f39d27d1fef5 100644 --- a/requirements-py310-macos_x86_64.txt +++ b/requirements-py310-macos_x86_64.txt @@ -72,4 +72,3 @@ https://wheelhouse.openquake.org/v3/py/zipp-3.17.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pluggy-1.5.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pytest-8.3.3-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/django_appconf-1.0.6-py3-none-any.whl -https://wheelhouse.openquake.org/v3/py/pytest_django-4.9.0-py3-none-any.whl diff --git a/requirements-py310-win64.txt b/requirements-py310-win64.txt index d073c9b1f19b..07ee2a5f27f1 100644 --- a/requirements-py310-win64.txt +++ b/requirements-py310-win64.txt @@ -71,4 +71,3 @@ https://wheelhouse.openquake.org/v3/py/zipp-3.17.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pluggy-1.5.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pytest-8.3.3-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/django_appconf-1.0.6-py3-none-any.whl -https://wheelhouse.openquake.org/v3/py/pytest_django-4.9.0-py3-none-any.whl diff --git a/requirements-py311-linux64.txt b/requirements-py311-linux64.txt index 9230bbe70240..df7c418675fe 100644 --- a/requirements-py311-linux64.txt +++ b/requirements-py311-linux64.txt @@ -76,4 +76,3 @@ https://wheelhouse.openquake.org/v3/py/zipp-3.17.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pluggy-1.5.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pytest-8.3.3-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/django_appconf-1.0.6-py3-none-any.whl -https://wheelhouse.openquake.org/v3/py/pytest_django-4.9.0-py3-none-any.whl diff --git a/requirements-py311-macos_arm64.txt b/requirements-py311-macos_arm64.txt index 70433a4cd782..dc68b81538fe 100644 --- a/requirements-py311-macos_arm64.txt +++ b/requirements-py311-macos_arm64.txt @@ -72,4 +72,3 @@ https://wheelhouse.openquake.org/v3/py/zipp-3.17.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pluggy-1.5.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pytest-8.3.3-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/django_appconf-1.0.6-py3-none-any.whl -https://wheelhouse.openquake.org/v3/py/pytest_django-4.9.0-py3-none-any.whl diff --git a/requirements-py311-macos_x86_64.txt b/requirements-py311-macos_x86_64.txt index bf34ebd07d47..876b4d019bf6 100644 --- a/requirements-py311-macos_x86_64.txt +++ b/requirements-py311-macos_x86_64.txt @@ -72,4 +72,3 @@ https://wheelhouse.openquake.org/v3/py/zipp-3.17.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pluggy-1.5.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pytest-8.3.3-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/django_appconf-1.0.6-py3-none-any.whl -https://wheelhouse.openquake.org/v3/py/pytest_django-4.9.0-py3-none-any.whl diff --git a/requirements-py311-win64.txt b/requirements-py311-win64.txt index 0da9e2c9f46d..952d55518a18 100644 --- a/requirements-py311-win64.txt +++ b/requirements-py311-win64.txt @@ -72,4 +72,3 @@ https://wheelhouse.openquake.org/v3/py/zipp-3.17.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pluggy-1.5.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pytest-8.3.3-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/django_appconf-1.0.6-py3-none-any.whl -https://wheelhouse.openquake.org/v3/py/pytest_django-4.9.0-py3-none-any.whl diff --git a/requirements-py312-linux64.txt b/requirements-py312-linux64.txt index 6cdf48eb0b9f..62ba153bc2f0 100644 --- a/requirements-py312-linux64.txt +++ b/requirements-py312-linux64.txt @@ -76,4 +76,3 @@ https://wheelhouse.openquake.org/v3/py/zipp-3.17.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pluggy-1.5.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pytest-8.3.3-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/django_appconf-1.0.6-py3-none-any.whl -https://wheelhouse.openquake.org/v3/py/pytest_django-4.9.0-py3-none-any.whl diff --git a/requirements-py312-macos_arm64.txt b/requirements-py312-macos_arm64.txt index cd24ef15df80..7aae7fbebe3c 100644 --- a/requirements-py312-macos_arm64.txt +++ b/requirements-py312-macos_arm64.txt @@ -72,4 +72,3 @@ https://wheelhouse.openquake.org/v3/py/zipp-3.17.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pluggy-1.5.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pytest-8.3.3-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/django_appconf-1.0.6-py3-none-any.whl -https://wheelhouse.openquake.org/v3/py/pytest_django-4.9.0-py3-none-any.whl diff --git a/requirements-py312-macos_x86_64.txt b/requirements-py312-macos_x86_64.txt index 87a96e3aa504..210a169fbd9b 100644 --- a/requirements-py312-macos_x86_64.txt +++ b/requirements-py312-macos_x86_64.txt @@ -72,4 +72,3 @@ https://wheelhouse.openquake.org/v3/py/zipp-3.17.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pluggy-1.5.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pytest-8.3.3-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/django_appconf-1.0.6-py3-none-any.whl -https://wheelhouse.openquake.org/v3/py/pytest_django-4.9.0-py3-none-any.whl diff --git a/requirements-py312-win64.txt b/requirements-py312-win64.txt index 183961318321..1463487f9ec3 100644 --- a/requirements-py312-win64.txt +++ b/requirements-py312-win64.txt @@ -72,4 +72,3 @@ https://wheelhouse.openquake.org/v3/py/zipp-3.17.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pluggy-1.5.0-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/pytest-8.3.3-py3-none-any.whl https://wheelhouse.openquake.org/v3/py/django_appconf-1.0.6-py3-none-any.whl -https://wheelhouse.openquake.org/v3/py/pytest_django-4.9.0-py3-none-any.whl