Skip to content

Commit d9a9e9a

Browse files
committed
Issue 596: update to use node.get_closest_marker
1 parent 4902bbb commit d9a9e9a

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

pytest_django/plugin.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,10 @@ def _django_db_marker(request):
378378
This will dynamically request the ``db`` or ``transactional_db``
379379
fixtures as required by the django_db marker.
380380
"""
381-
marker = request.keywords.get('django_db', None)
381+
marker = request.node.get_closest_marker('django_db')
382382
if marker:
383-
validate_django_db(marker)
384-
if marker.transaction:
383+
transaction = validate_django_db(marker)
384+
if transaction:
385385
getfixturevalue(request, 'transactional_db')
386386
else:
387387
getfixturevalue(request, 'db')
@@ -447,7 +447,7 @@ def mailoutbox(monkeypatch, _dj_autoclear_mailbox):
447447
@pytest.fixture(autouse=True, scope='function')
448448
def _django_set_urlconf(request):
449449
"""Apply the @pytest.mark.urls marker, internal to pytest-django."""
450-
marker = request.keywords.get('urls', None)
450+
marker = request.node.get_closest_marker('urls')
451451
if marker:
452452
skip_if_no_django()
453453
import django.conf
@@ -457,9 +457,9 @@ def _django_set_urlconf(request):
457457
# Removed in Django 2.0
458458
from django.core.urlresolvers import clear_url_caches, set_urlconf
459459

460-
validate_urls(marker)
460+
urls = validate_urls(marker)
461461
original_urlconf = django.conf.settings.ROOT_URLCONF
462-
django.conf.settings.ROOT_URLCONF = marker.urls
462+
django.conf.settings.ROOT_URLCONF = urls
463463
clear_url_caches()
464464
set_urlconf(None)
465465

@@ -656,8 +656,8 @@ def validate_django_db(marker):
656656
the marker which will have the correct value.
657657
"""
658658
def apifun(transaction=False):
659-
marker.transaction = transaction
660-
apifun(*marker.args, **marker.kwargs)
659+
return transaction
660+
return apifun(*marker.args, **marker.kwargs)
661661

662662

663663
def validate_urls(marker):
@@ -667,5 +667,5 @@ def validate_urls(marker):
667667
marker which will have the correct value.
668668
"""
669669
def apifun(urls):
670-
marker.urls = urls
671-
apifun(*marker.args, **marker.kwargs)
670+
return urls
671+
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)