From 4902bbb7dca5f366fd5fac346cd322258014da32 Mon Sep 17 00:00:00 2001 From: Oliver Bristow Date: Tue, 29 May 2018 12:17:41 +0100 Subject: [PATCH 1/2] Add .pytest_cache to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f6c9e664e..c5872bc1f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ _build /.coverage /htmlcov/ .cache +.pytest_cache/ .Python .eggs *.egg From d9a9e9a8866d3966ad44f89b6244aec70580afb1 Mon Sep 17 00:00:00 2001 From: Oliver Bristow Date: Tue, 29 May 2018 12:18:57 +0100 Subject: [PATCH 2/2] Issue 596: update to use node.get_closest_marker --- pytest_django/plugin.py | 20 ++++++++++---------- setup.py | 2 +- tox.ini | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pytest_django/plugin.py b/pytest_django/plugin.py index 1585c6983..7ec766146 100644 --- a/pytest_django/plugin.py +++ b/pytest_django/plugin.py @@ -378,10 +378,10 @@ def _django_db_marker(request): This will dynamically request the ``db`` or ``transactional_db`` fixtures as required by the django_db marker. """ - marker = request.keywords.get('django_db', None) + marker = request.node.get_closest_marker('django_db') if marker: - validate_django_db(marker) - if marker.transaction: + transaction = validate_django_db(marker) + if transaction: getfixturevalue(request, 'transactional_db') else: getfixturevalue(request, 'db') @@ -447,7 +447,7 @@ def mailoutbox(monkeypatch, _dj_autoclear_mailbox): @pytest.fixture(autouse=True, scope='function') def _django_set_urlconf(request): """Apply the @pytest.mark.urls marker, internal to pytest-django.""" - marker = request.keywords.get('urls', None) + marker = request.node.get_closest_marker('urls') if marker: skip_if_no_django() import django.conf @@ -457,9 +457,9 @@ def _django_set_urlconf(request): # Removed in Django 2.0 from django.core.urlresolvers import clear_url_caches, set_urlconf - validate_urls(marker) + urls = validate_urls(marker) original_urlconf = django.conf.settings.ROOT_URLCONF - django.conf.settings.ROOT_URLCONF = marker.urls + django.conf.settings.ROOT_URLCONF = urls clear_url_caches() set_urlconf(None) @@ -656,8 +656,8 @@ def validate_django_db(marker): the marker which will have the correct value. """ def apifun(transaction=False): - marker.transaction = transaction - apifun(*marker.args, **marker.kwargs) + return transaction + return apifun(*marker.args, **marker.kwargs) def validate_urls(marker): @@ -667,5 +667,5 @@ def validate_urls(marker): marker which will have the correct value. """ def apifun(urls): - marker.urls = urls - apifun(*marker.args, **marker.kwargs) + return urls + return apifun(*marker.args, **marker.kwargs) diff --git a/setup.py b/setup.py index e25d5e4ef..55b5a95e9 100755 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ def read(fname): long_description=read('README.rst'), python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*', setup_requires=['setuptools_scm>=1.11.1'], - install_requires=['pytest>=2.9'], + install_requires=['pytest>=3.6'], classifiers=['Development Status :: 5 - Production/Stable', 'Framework :: Django', 'Framework :: Django :: 1.8', diff --git a/tox.ini b/tox.ini index c3abb09c8..02242df27 100644 --- a/tox.ini +++ b/tox.ini @@ -8,7 +8,7 @@ envlist = [testenv] deps = - pytest>=3.0,<3.6 + pytest>=3.6 django-configurations==2.0 pytest-xdist==1.15 {env:_PYTESTDJANGO_TOX_EXTRA_DEPS:}