Skip to content

Drop support for Django 1.7 #524

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

Merged
merged 2 commits into from
Oct 25, 2017
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
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ matrix:
env: TOXENV=py27-pytest3-dj19-postgres
- python: 2.7
env: TOXENV=py27-pytest3-dj18-postgres
- python: 2.7
env: TOXENV=py27-pytest3-dj17-postgres
- python: 2.7
env: TOXENV=py27-checkqa

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pytest-django allows you to test your Django project/applications with the
<https://pytest-django.readthedocs.io/en/latest/contributing.html>`_
* Version compatibility:

* Django: 1.7-1.11 and latest master branch (compatible at the time of each release)
* Django: 1.8-1.11 and latest master branch (compatible at the time of each release)
* Python: CPython 2.7,3.3-3.6 or PyPy 2,3
* pytest: >2.9.x

Expand Down
6 changes: 3 additions & 3 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ writing), running them all will take a long time. All valid configurations can
be found in `tox.ini`. To test against a few of them, invoke tox with the `-e`
flag::

$ tox -e python3.3-1.7-postgres,python2.7-1.9-sqlite
$ tox -e python3.6-1.11-postgres,python2.7-1.11-mysql_innodb

This will run the tests on Python 3.3/Django 1.7/PostgeSQL and Python
2.7/Django 1.9/SQLite.
This will run the tests on Python 3.6/Django 1.11/PostgeSQL and Python
2.7/Django 1.11/MySQL.


Measuring test coverage
Expand Down
2 changes: 1 addition & 1 deletion docs/helpers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ when trying to access the database.
If you run pytest using the ``--fail-on-template-vars`` option,
tests will fail should your templates contain any invalid variables.
This marker will disable this feature by setting ``settings.TEMPLATE_STRING_IF_INVALID=None``
or the ``string_if_invalid`` template option in Django>=1.7
or the ``string_if_invalid`` template option

Example usage::

Expand Down
2 changes: 1 addition & 1 deletion docs/managing_python_path.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ add this directly to your project's requirements.txt file like this::

# requirements.txt
-e .
django>=1.7
django>=1.11
pytest-django


Expand Down
7 changes: 0 additions & 7 deletions pytest_django/compat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# This file cannot be imported from until Django sets up

try:
# Django 1.11
from django.test.utils import setup_databases, teardown_databases # noqa
Expand All @@ -11,9 +10,3 @@ def teardown_databases(db_cfg, verbosity):
(_DiscoverRunner(verbosity=verbosity,
interactive=False)
.teardown_databases(db_cfg))

try:
from django.db.backends.base.base import BaseDatabaseWrapper # noqa
except ImportError:
# Django 1.7.
from django.db.backends import BaseDatabaseWrapper # noqa
11 changes: 2 additions & 9 deletions pytest_django/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from .django_compat import is_django_unittest
from .pytest_compat import getfixturevalue

from .lazy_django import get_django_version, skip_if_no_django
from .lazy_django import skip_if_no_django

__all__ = ['django_db_setup', 'db', 'transactional_db', 'admin_user',
'django_user_model', 'django_username_field',
Expand Down Expand Up @@ -83,14 +83,7 @@ def django_db_setup(
_disable_native_migrations()

if django_db_keepdb:
if get_django_version() >= (1, 8):
setup_databases_args['keepdb'] = True
else:
# Django 1.7 compatibility
from .db_reuse import monkey_patch_creation_for_db_reuse

with django_db_blocker.unblock():
monkey_patch_creation_for_db_reuse()
setup_databases_args['keepdb'] = True

with django_db_blocker.unblock():
db_cfg = setup_databases(
Expand Down
13 changes: 6 additions & 7 deletions pytest_django/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
from .fixtures import transactional_db # noqa
from .pytest_compat import getfixturevalue

from .lazy_django import (django_settings_is_configured,
get_django_version, skip_if_no_django)
from .lazy_django import django_settings_is_configured, skip_if_no_django


SETTINGS_MODULE_ENV = 'DJANGO_SETTINGS_MODULE'
Expand Down Expand Up @@ -63,10 +62,10 @@ def pytest_addoption(parser):
help='Set DJANGO_CONFIGURATION.')
group._addoption('--nomigrations', '--no-migrations',
action='store_true', dest='nomigrations', default=False,
help='Disable Django 1.7+ migrations on test setup')
help='Disable Django migrations on test setup')
group._addoption('--migrations',
action='store_false', dest='nomigrations', default=False,
help='Enable Django 1.7+ migrations on test setup')
help='Enable Django migrations on test setup')
parser.addini(CONFIGURATION_ENV,
'django-configurations class to use by pytest-django.')
group._addoption('--liveserver', default=None,
Expand Down Expand Up @@ -540,7 +539,7 @@ def __mod__(self, var):
django_settings_is_configured()):
from django.conf import settings as dj_settings

if get_django_version() >= (1, 8) and dj_settings.TEMPLATES:
if dj_settings.TEMPLATES:
dj_settings.TEMPLATES[0]['OPTIONS']['string_if_invalid'] = (
InvalidVarException())
else:
Expand All @@ -556,7 +555,7 @@ def _template_string_if_invalid_marker(request):
if marker and django_settings_is_configured():
from django.conf import settings as dj_settings

if get_django_version() >= (1, 8) and dj_settings.TEMPLATES:
if dj_settings.TEMPLATES:
dj_settings.TEMPLATES[0]['OPTIONS']['string_if_invalid'].fail = False
else:
dj_settings.TEMPLATE_STRING_IF_INVALID.fail = False
Expand Down Expand Up @@ -601,7 +600,7 @@ def __init__(self):

@property
def _dj_db_wrapper(self):
from .compat import BaseDatabaseWrapper
from django.db.backends.base.base import BaseDatabaseWrapper

# The first time the _dj_db_wrapper is accessed, we will save a
# reference to the real implementation.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_db_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def test_inner():


class TestNativeMigrations(object):
""" Tests for Django 1.7 Migrations """
""" Tests for Django Migrations """

def test_no_migrations(self, django_testdir):
django_testdir.create_test_module('''
Expand Down
4 changes: 0 additions & 4 deletions tests/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,6 @@ def test_more_verbose_with_vv_and_reusedb(self, testdir):
not in result.stdout.str())


@pytest.mark.skipif(
get_django_version() < (1, 8),
reason='Django 1.7 requires settings.SITE_ID to be set, so this test is invalid'
)
@pytest.mark.django_db
@pytest.mark.parametrize('site_name', ['site1', 'site2'])
def test_clear_site_cache(site_name, rf, monkeypatch):
Expand Down
2 changes: 0 additions & 2 deletions tests/test_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,6 @@ def test_a(self, live_server, settings):
result.stdout.fnmatch_lines(['*test_a*PASSED*'])
assert result.ret == 0

@pytest.mark.skipif(get_django_version() < (1, 7),
reason="Django >= 1.7 required")
def test_serve_static_dj17_without_staticfiles_app(self, live_server,
settings):
"""
Expand Down
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ envlist =
- py34-pytest3-dj{20,111,110}-postgres
- py33-pytest3-dj18-postgres
- py27-pytest3-dj{111,110}-{mysql_innodb,mysql_myisam,postgres}
- py27-pytest3-dj{111,110,19,18,17}-postgres
- py27-pytest3-dj{111,110,19,18}-postgres
- py{36,py27}-checkqa

[testenv]
Expand All @@ -21,7 +21,6 @@ deps =
dj110: Django>=1.10,<1.11
dj19: Django>=1.9,<1.10
dj18: Django>=1.8,<1.9
dj17: Django>=1.7,<1.8

mysql_myisam: mysql-python==1.2.5
mysql_innodb: mysql-python==1.2.5
Expand Down