Skip to content

Commit

Permalink
Merge pull request #603 from Code0x58/issue-596-markinfo-deprecation
Browse files Browse the repository at this point in the history
Fixes #596.
  • Loading branch information
blueyed committed May 30, 2018
2 parents a3c62ef + d9a9e9a commit 8d548e7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ _build
/.coverage
/htmlcov/
.cache
.pytest_cache/
.Python
.eggs
*.egg
5 changes: 3 additions & 2 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Changelog
=========

unreleased
----------
3.3.0 (unreleased)
------------------

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

3.2.1
-----
Expand Down
20 changes: 10 additions & 10 deletions pytest_django/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,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')
Expand Down Expand Up @@ -451,7 +451,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
Expand All @@ -461,9 +461,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)

Expand Down Expand Up @@ -660,8 +660,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):
Expand All @@ -671,5 +671,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)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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:}
Expand Down

0 comments on commit 8d548e7

Please sign in to comment.