Skip to content

Commit 8d548e7

Browse files
committed
Merge pull request pytest-dev#603 from Code0x58/issue-596-markinfo-deprecation
Fixes pytest-dev#596.
2 parents a3c62ef + d9a9e9a commit 8d548e7

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ _build
1111
/.coverage
1212
/htmlcov/
1313
.cache
14+
.pytest_cache/
1415
.Python
1516
.eggs
1617
*.egg

docs/changelog.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
Changelog
22
=========
33

4-
unreleased
5-
----------
4+
3.3.0 (unreleased)
5+
------------------
66

77
* Fix test for classmethod with Django TestCases (#597, #598).
8+
* Fix RemovedInPytest4Warning: MarkInfo objects are deprecated (#596, #603)
89

910
3.2.1
1011
-----

pytest_django/plugin.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -382,10 +382,10 @@ def _django_db_marker(request):
382382
This will dynamically request the ``db`` or ``transactional_db``
383383
fixtures as required by the django_db marker.
384384
"""
385-
marker = request.keywords.get('django_db', None)
385+
marker = request.node.get_closest_marker('django_db')
386386
if marker:
387-
validate_django_db(marker)
388-
if marker.transaction:
387+
transaction = validate_django_db(marker)
388+
if transaction:
389389
getfixturevalue(request, 'transactional_db')
390390
else:
391391
getfixturevalue(request, 'db')
@@ -451,7 +451,7 @@ def mailoutbox(monkeypatch, _dj_autoclear_mailbox):
451451
@pytest.fixture(autouse=True, scope='function')
452452
def _django_set_urlconf(request):
453453
"""Apply the @pytest.mark.urls marker, internal to pytest-django."""
454-
marker = request.keywords.get('urls', None)
454+
marker = request.node.get_closest_marker('urls')
455455
if marker:
456456
skip_if_no_django()
457457
import django.conf
@@ -461,9 +461,9 @@ def _django_set_urlconf(request):
461461
# Removed in Django 2.0
462462
from django.core.urlresolvers import clear_url_caches, set_urlconf
463463

464-
validate_urls(marker)
464+
urls = validate_urls(marker)
465465
original_urlconf = django.conf.settings.ROOT_URLCONF
466-
django.conf.settings.ROOT_URLCONF = marker.urls
466+
django.conf.settings.ROOT_URLCONF = urls
467467
clear_url_caches()
468468
set_urlconf(None)
469469

@@ -660,8 +660,8 @@ def validate_django_db(marker):
660660
the marker which will have the correct value.
661661
"""
662662
def apifun(transaction=False):
663-
marker.transaction = transaction
664-
apifun(*marker.args, **marker.kwargs)
663+
return transaction
664+
return apifun(*marker.args, **marker.kwargs)
665665

666666

667667
def validate_urls(marker):
@@ -671,5 +671,5 @@ def validate_urls(marker):
671671
marker which will have the correct value.
672672
"""
673673
def apifun(urls):
674-
marker.urls = urls
675-
apifun(*marker.args, **marker.kwargs)
674+
return urls
675+
return apifun(*marker.args, **marker.kwargs)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def read(fname):
3030
long_description=read('README.rst'),
3131
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
3232
setup_requires=['setuptools_scm>=1.11.1'],
33-
install_requires=['pytest>=2.9'],
33+
install_requires=['pytest>=3.6'],
3434
classifiers=['Development Status :: 5 - Production/Stable',
3535
'Framework :: Django',
3636
'Framework :: Django :: 1.8',

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ envlist =
88

99
[testenv]
1010
deps =
11-
pytest>=3.0,<3.6
11+
pytest>=3.6
1212
django-configurations==2.0
1313
pytest-xdist==1.15
1414
{env:_PYTESTDJANGO_TOX_EXTRA_DEPS:}

0 commit comments

Comments
 (0)