diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 9d521d1d..523f2bec 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,7 +10,7 @@ permissions: {} jobs: package: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 timeout-minutes: 10 steps: @@ -24,7 +24,7 @@ jobs: deploy: if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') && github.repository == 'pytest-dev/pytest-django' needs: [package] - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 environment: deploy timeout-minutes: 15 permissions: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fe8e6b43..cc1da1c4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ permissions: {} jobs: test: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 continue-on-error: ${{ matrix.allow_failure }} timeout-minutes: 15 permissions: @@ -64,11 +64,11 @@ jobs: matrix: include: - name: linting,docs - python: '3.12' + python: '3.13' allow_failure: false - - name: py312-dj51-postgres-xdist-coverage - python: '3.12' + - name: py313-dj51-postgres-xdist-coverage + python: '3.13' allow_failure: false - name: py312-dj42-postgres-xdist-coverage @@ -103,8 +103,8 @@ jobs: python: '3.9' allow_failure: false - - name: py312-djmain-sqlite-coverage - python: '3.12' + - name: py313-djmain-sqlite-coverage + python: '3.13' allow_failure: true - name: py312-dj51-sqlite-xdist-coverage @@ -139,7 +139,7 @@ jobs: needs: - test - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Decide whether the needed jobs succeeded or failed diff --git a/docs/changelog.rst b/docs/changelog.rst index 617132b7..990ec51c 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,6 +1,20 @@ Changelog ========= +v4.10.0 (Not released yet) +-------------------------- + +Compatibility +^^^^^^^^^^^^^ + +* Added official support for Python 3.13. + +Bugfixes +^^^^^^^^ + +* Fixed lock/unlock of db breaks if pytest is executed twice in the same process. + + v4.9.0 (2024-09-02) ------------------- diff --git a/pyproject.toml b/pyproject.toml index 9f922dc4..914e96cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,6 +33,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Testing", @@ -138,7 +139,6 @@ ignore = [ "PLR0913", # Too many arguments in function definition "PLR2004", # Magic value used in comparison, consider replacing 3 with a constant variable "PT001", # Use `@pytest.fixture()` over `@pytest.fixture` - "PT004", # Fixture `fixture_with_db` does not return anything, add leading underscore "PT023", # Use `@pytest.mark.django_db()` over `@pytest.mark.django_db` ] diff --git a/pytest_django/__init__.py b/pytest_django/__init__.py index 4e551d5b..e4bb08f5 100644 --- a/pytest_django/__init__.py +++ b/pytest_django/__init__.py @@ -10,8 +10,8 @@ __all__ = [ - "__version__", "DjangoAssertNumQueries", "DjangoCaptureOnCommitCallbacks", "DjangoDbBlocker", + "__version__", ] diff --git a/pytest_django/fixtures.py b/pytest_django/fixtures.py index 8c4cad94..1daab118 100644 --- a/pytest_django/fixtures.py +++ b/pytest_django/fixtures.py @@ -41,25 +41,25 @@ __all__ = [ - "django_db_setup", + "_live_server_helper", + "admin_client", + "admin_user", + "async_client", + "async_rf", + "client", "db", - "transactional_db", + "django_assert_max_num_queries", + "django_assert_num_queries", + "django_capture_on_commit_callbacks", "django_db_reset_sequences", "django_db_serialized_rollback", - "admin_user", + "django_db_setup", "django_user_model", "django_username_field", - "client", - "async_client", - "admin_client", + "live_server", "rf", - "async_rf", "settings", - "live_server", - "_live_server_helper", - "django_assert_num_queries", - "django_assert_max_num_queries", - "django_capture_on_commit_callbacks", + "transactional_db", ] diff --git a/pytest_django/plugin.py b/pytest_django/plugin.py index 285f1733..08d961a6 100644 --- a/pytest_django/plugin.py +++ b/pytest_django/plugin.py @@ -129,13 +129,13 @@ def pytest_addoption(parser: pytest.Parser) -> None: parser.addini( "django_find_project", - "Automatically find and add a Django project to the " "Python path.", + "Automatically find and add a Django project to the Python path.", type="bool", default=True, ) parser.addini( "django_debug_mode", - "How to set the Django DEBUG setting (default `False`). " "Use `keep` to not override.", + "How to set the Django DEBUG setting (default `False`). Use `keep` to not override.", default="False", ) group.addoption( diff --git a/setup.py b/setup.py deleted file mode 100644 index 7f1a1763..00000000 --- a/setup.py +++ /dev/null @@ -1,4 +0,0 @@ -from setuptools import setup - -if __name__ == "__main__": - setup() diff --git a/tests/test_fixtures.py b/tests/test_fixtures.py index ed7fcba2..dd695136 100644 --- a/tests/test_fixtures.py +++ b/tests/test_fixtures.py @@ -104,7 +104,7 @@ def test_django_assert_num_queries_db( with django_assert_num_queries(2) as captured: Item.objects.create(name="quux") assert excinfo.value.args == ( - "Expected to perform 2 queries but 1 was done " "(add -v option to show queries)", + "Expected to perform 2 queries but 1 was done (add -v option to show queries)", ) assert len(captured.captured_queries) == 1 @@ -556,11 +556,10 @@ def test_specified_port_django_111(self, django_pytester: DjangoPytester) -> Non sock.close() django_pytester.create_test_module( + f""" + def test_with_live_server(live_server): + assert live_server.port == {port} """ - def test_with_live_server(live_server): - assert live_server.port == %d - """ - % port ) django_pytester.runpytest_subprocess(f"--liveserver=localhost:{port}") diff --git a/tests/test_manage_py_scan.py b/tests/test_manage_py_scan.py index 053c5c2a..76ec8ad7 100644 --- a/tests/test_manage_py_scan.py +++ b/tests/test_manage_py_scan.py @@ -123,7 +123,7 @@ def test_django_project_scan_disabled_invalid_settings( assert result.ret != 0 result.stderr.fnmatch_lines(["*ImportError*DOES_NOT_EXIST*"]) - result.stderr.fnmatch_lines(["*pytest-django did not search for " "Django projects*"]) + result.stderr.fnmatch_lines(["*pytest-django did not search for Django projects*"]) @pytest.mark.django_project(project_root="django_project_root", create_manage_py=True) diff --git a/tox.ini b/tox.ini index c72b1f42..d9ce1c6d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,6 @@ [tox] envlist = + py313-dj{main,51}-postgres py312-dj{main,51,50,42}-postgres py311-dj{main,51,50,42}-postgres py310-dj{main,51,50,42}-postgres @@ -49,8 +50,8 @@ commands = [testenv:linting] extras = deps = - ruff==0.6.3 - mypy==1.11.2 + ruff==0.9.5 + mypy==1.15.0 commands = ruff check {posargs:pytest_django pytest_django_test tests} ruff format --quiet --diff {posargs:pytest_django pytest_django_test tests}