Skip to content

Commit 705ae1b

Browse files
authored
Merge branch 'main' into dev/remote-PT023
2 parents 55c3113 + cdef84f commit 705ae1b

7 files changed

Lines changed: 49 additions & 54 deletions

File tree

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
- name: Install dependencies
5151
run: |
5252
python -m pip install --upgrade pip
53-
pip install tox==4.11.1
53+
pip install tox==4.26.0
5454
5555
- name: Run tox
5656
run: tox -e ${{ matrix.name }}

Makefile

Lines changed: 0 additions & 13 deletions
This file was deleted.

pyproject.toml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ classifiers = [
4040
dependencies = [
4141
"pytest>=7.0.0",
4242
]
43-
[project.optional-dependencies]
43+
[dependency-groups]
4444
docs = [
4545
"sphinx",
4646
"sphinx_rtd_theme",
@@ -49,6 +49,23 @@ testing = [
4949
"Django",
5050
"django-configurations>=2.0",
5151
]
52+
coverage = [
53+
"coverage[toml]",
54+
"coverage-enable-subprocess",
55+
]
56+
postgres = [
57+
"psycopg[binary]",
58+
]
59+
mysql = [
60+
"mysqlclient==2.1.0",
61+
]
62+
xdist = [
63+
"pytest-xdist",
64+
]
65+
linting = [
66+
"ruff==0.9.5",
67+
"mypy==1.15.0",
68+
]
5269
[project.urls]
5370
Documentation = "https://pytest-django.readthedocs.io/"
5471
Repository = "https://github.com/pytest-dev/pytest-django"
@@ -137,7 +154,6 @@ extend-select = [
137154
ignore = [
138155
"PLR0913", # Too many arguments in function definition
139156
"PLR2004", # Magic value used in comparison, consider replacing 3 with a constant variable
140-
"PT001", # Use `@pytest.fixture()` over `@pytest.fixture`
141157
]
142158

143159
[tool.ruff.lint.isort]

pytest_django/fixtures.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def django_db_setup(
201201
)
202202

203203

204-
@pytest.fixture()
204+
@pytest.fixture
205205
def _django_db_helper(
206206
request: pytest.FixtureRequest,
207207
django_db_setup: None,
@@ -365,7 +365,7 @@ def _set_suffix_to_test_databases(suffix: str) -> None:
365365
# ############### User visible fixtures ################
366366

367367

368-
@pytest.fixture()
368+
@pytest.fixture
369369
def db(_django_db_helper: None) -> None:
370370
"""Require a django test database.
371371
@@ -382,7 +382,7 @@ def db(_django_db_helper: None) -> None:
382382
# The `_django_db_helper` fixture checks if `db` is requested.
383383

384384

385-
@pytest.fixture()
385+
@pytest.fixture
386386
def transactional_db(_django_db_helper: None) -> None:
387387
"""Require a django test database with transaction support.
388388
@@ -398,7 +398,7 @@ def transactional_db(_django_db_helper: None) -> None:
398398
# The `_django_db_helper` fixture checks if `transactional_db` is requested.
399399

400400

401-
@pytest.fixture()
401+
@pytest.fixture
402402
def django_db_reset_sequences(
403403
_django_db_helper: None,
404404
transactional_db: None,
@@ -414,7 +414,7 @@ def django_db_reset_sequences(
414414
# is requested.
415415

416416

417-
@pytest.fixture()
417+
@pytest.fixture
418418
def django_db_serialized_rollback(
419419
_django_db_helper: None,
420420
db: None,
@@ -435,7 +435,7 @@ def django_db_serialized_rollback(
435435
# is requested.
436436

437437

438-
@pytest.fixture()
438+
@pytest.fixture
439439
def client() -> django.test.Client:
440440
"""A Django test client instance."""
441441
skip_if_no_django()
@@ -445,7 +445,7 @@ def client() -> django.test.Client:
445445
return Client()
446446

447447

448-
@pytest.fixture()
448+
@pytest.fixture
449449
def async_client() -> django.test.AsyncClient:
450450
"""A Django test async client instance."""
451451
skip_if_no_django()
@@ -455,22 +455,22 @@ def async_client() -> django.test.AsyncClient:
455455
return AsyncClient()
456456

457457

458-
@pytest.fixture()
458+
@pytest.fixture
459459
def django_user_model(db: None):
460460
"""The class of Django's user model."""
461461
from django.contrib.auth import get_user_model
462462

463463
return get_user_model()
464464

465465

466-
@pytest.fixture()
466+
@pytest.fixture
467467
def django_username_field(django_user_model) -> str:
468468
"""The fieldname for the username used with Django's user model."""
469469
field: str = django_user_model.USERNAME_FIELD
470470
return field
471471

472472

473-
@pytest.fixture()
473+
@pytest.fixture
474474
def admin_user(
475475
db: None,
476476
django_user_model,
@@ -501,7 +501,7 @@ def admin_user(
501501
return user
502502

503503

504-
@pytest.fixture()
504+
@pytest.fixture
505505
def admin_client(
506506
db: None,
507507
admin_user,
@@ -514,7 +514,7 @@ def admin_client(
514514
return client
515515

516516

517-
@pytest.fixture()
517+
@pytest.fixture
518518
def rf() -> django.test.RequestFactory:
519519
"""RequestFactory instance"""
520520
skip_if_no_django()
@@ -524,7 +524,7 @@ def rf() -> django.test.RequestFactory:
524524
return RequestFactory()
525525

526526

527-
@pytest.fixture()
527+
@pytest.fixture
528528
def async_rf() -> django.test.AsyncRequestFactory:
529529
"""AsyncRequestFactory instance"""
530530
skip_if_no_django()
@@ -569,7 +569,7 @@ def finalize(self) -> None:
569569
del self._to_restore[:]
570570

571571

572-
@pytest.fixture()
572+
@pytest.fixture
573573
def settings():
574574
"""A Django settings object which restores changes after the testrun"""
575575
skip_if_no_django()
@@ -702,13 +702,13 @@ def _assert_num_queries(
702702
pytest.fail(msg)
703703

704704

705-
@pytest.fixture()
705+
@pytest.fixture
706706
def django_assert_num_queries(pytestconfig: pytest.Config) -> DjangoAssertNumQueries:
707707
"""Allows to check for an expected number of DB queries."""
708708
return partial(_assert_num_queries, pytestconfig)
709709

710710

711-
@pytest.fixture()
711+
@pytest.fixture
712712
def django_assert_max_num_queries(pytestconfig: pytest.Config) -> DjangoAssertNumQueries:
713713
"""Allows to check for an expected maximum number of DB queries."""
714714
return partial(_assert_num_queries, pytestconfig, exact=False)
@@ -726,7 +726,7 @@ def __call__(
726726
pass # pragma: no cover
727727

728728

729-
@pytest.fixture()
729+
@pytest.fixture
730730
def django_capture_on_commit_callbacks() -> DjangoCaptureOnCommitCallbacks:
731731
"""Captures transaction.on_commit() callbacks for the given database connection."""
732732
from django.test import TestCase

pytest_django/plugin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ def _dj_autoclear_mailbox() -> None:
605605
mail.outbox.clear()
606606

607607

608-
@pytest.fixture()
608+
@pytest.fixture
609609
def mailoutbox(
610610
django_mail_patch_dns: None,
611611
_dj_autoclear_mailbox: None,
@@ -620,7 +620,7 @@ def mailoutbox(
620620
return []
621621

622622

623-
@pytest.fixture()
623+
@pytest.fixture
624624
def django_mail_patch_dns(
625625
monkeypatch: pytest.MonkeyPatch,
626626
django_mail_dnsname: str,
@@ -631,7 +631,7 @@ def django_mail_patch_dns(
631631
monkeypatch.setattr(mail.message, "DNS_NAME", django_mail_dnsname)
632632

633633

634-
@pytest.fixture()
634+
@pytest.fixture
635635
def django_mail_dnsname() -> str:
636636
"""Return server dns name for using in email messages."""
637637
return "fake-tests.example.com"

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def pytester(pytester: pytest.Pytester, monkeypatch: pytest.MonkeyPatch) -> pyte
4646
return pytester
4747

4848

49-
@pytest.fixture()
49+
@pytest.fixture
5050
def django_pytester(
5151
request: pytest.FixtureRequest,
5252
pytester: pytest.Pytester,

tox.ini

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,19 @@ envlist =
88
linting
99

1010
[testenv]
11-
extras = testing
11+
dependency_groups =
12+
testing
13+
coverage: coverage
14+
mysql: mysql
15+
postgres: postgres
16+
xdist: xdist
1217
deps =
1318
djmain: https://github.com/django/django/archive/main.tar.gz
1419
dj52: Django>=5.2a1,<6.0
1520
dj51: Django>=5.1,<5.2
1621
dj50: Django>=5.0,<5.1
1722
dj42: Django>=4.2,<4.3
18-
19-
mysql: mysqlclient==2.1.0
20-
21-
postgres: psycopg[binary]
22-
coverage: coverage[toml]
23-
coverage: coverage-enable-subprocess
24-
2523
pytestmin: pytest>=7.0,<7.1
26-
xdist: pytest-xdist>=1.15
2724

2825
setenv =
2926
mysql: DJANGO_SETTINGS_MODULE=pytest_django_test.settings_mysql
@@ -46,26 +43,21 @@ commands =
4643
coverage: coverage xml
4744

4845
[testenv:linting]
49-
extras =
50-
deps =
51-
ruff==0.9.5
52-
mypy==1.15.0
46+
dependency_groups = linting
5347
commands =
5448
ruff check --diff {posargs:pytest_django pytest_django_test tests}
5549
ruff format --quiet --diff {posargs:pytest_django pytest_django_test tests}
5650
mypy {posargs:pytest_django pytest_django_test tests}
5751

5852
[testenv:doc8]
59-
extras =
6053
basepython = python3
6154
skip_install = true
55+
dependency_groups = docs
6256
deps =
63-
sphinx
6457
doc8
6558
commands =
6659
doc8 docs/
6760

6861
[testenv:docs]
69-
deps =
70-
extras = docs
62+
dependency_groups = docs
7163
commands = sphinx-build -n -W -b html -d docs/_build/doctrees docs docs/_build/html

0 commit comments

Comments
 (0)