Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#596 MarkInfo deprecation #603

Merged
merged 2 commits into from
May 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was missing, so added it in a separate commit.

.Python
.eggs
*.egg
20 changes: 10 additions & 10 deletions pytest_django/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two places like this bump the requirements to pytest >= 3.6 - I think it would be easy enough to have code branch for pytest < 3.6 to maintain existing compatibility if that feels like a blocker to this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I think requiring pytest 3.6 is fine.

marker = request.node.get_closest_marker('django_db')
if marker:
validate_django_db(marker)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% happy with the naming, but I didn't think of anything better.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What naming do you mean?
marker here, or transaction below?
As for transaction it could be named transactional mabye?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking validate_django_db(…) as it gets a value, and may happen to blow up, but it feels more ok to me now

if marker.transaction:
transaction = validate_django_db(marker)
if transaction:
getfixturevalue(request, 'transactional_db')
else:
getfixturevalue(request, 'db')
Expand Down Expand Up @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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):
Expand All @@ -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)
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