Skip to content

Commit 218be96

Browse files
michael-kblueyed
authored andcommitted
Drop support for Django 1.7 (#524)
* Remove BaseDatabaseWrapper from compat
1 parent 1609780 commit 218be96

12 files changed

+16
-40
lines changed

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ matrix:
4141
env: TOXENV=py27-pytest3-dj19-postgres
4242
- python: 2.7
4343
env: TOXENV=py27-pytest3-dj18-postgres
44-
- python: 2.7
45-
env: TOXENV=py27-pytest3-dj17-postgres
4644
- python: 2.7
4745
env: TOXENV=py27-checkqa
4846

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pytest-django allows you to test your Django project/applications with the
2222
<https://pytest-django.readthedocs.io/en/latest/contributing.html>`_
2323
* Version compatibility:
2424

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

docs/contributing.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ writing), running them all will take a long time. All valid configurations can
137137
be found in `tox.ini`. To test against a few of them, invoke tox with the `-e`
138138
flag::
139139

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

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

145145

146146
Measuring test coverage

docs/helpers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ when trying to access the database.
8585
If you run pytest using the ``--fail-on-template-vars`` option,
8686
tests will fail should your templates contain any invalid variables.
8787
This marker will disable this feature by setting ``settings.TEMPLATE_STRING_IF_INVALID=None``
88-
or the ``string_if_invalid`` template option in Django>=1.7
88+
or the ``string_if_invalid`` template option
8989

9090
Example usage::
9191

docs/managing_python_path.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ add this directly to your project's requirements.txt file like this::
7171

7272
# requirements.txt
7373
-e .
74-
django>=1.7
74+
django>=1.11
7575
pytest-django
7676

7777

pytest_django/compat.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# This file cannot be imported from until Django sets up
2-
32
try:
43
# Django 1.11
54
from django.test.utils import setup_databases, teardown_databases # noqa
@@ -11,9 +10,3 @@ def teardown_databases(db_cfg, verbosity):
1110
(_DiscoverRunner(verbosity=verbosity,
1211
interactive=False)
1312
.teardown_databases(db_cfg))
14-
15-
try:
16-
from django.db.backends.base.base import BaseDatabaseWrapper # noqa
17-
except ImportError:
18-
# Django 1.7.
19-
from django.db.backends import BaseDatabaseWrapper # noqa

pytest_django/fixtures.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from .django_compat import is_django_unittest
1414
from .pytest_compat import getfixturevalue
1515

16-
from .lazy_django import get_django_version, skip_if_no_django
16+
from .lazy_django import skip_if_no_django
1717

1818
__all__ = ['django_db_setup', 'db', 'transactional_db', 'admin_user',
1919
'django_user_model', 'django_username_field',
@@ -83,14 +83,7 @@ def django_db_setup(
8383
_disable_native_migrations()
8484

8585
if django_db_keepdb:
86-
if get_django_version() >= (1, 8):
87-
setup_databases_args['keepdb'] = True
88-
else:
89-
# Django 1.7 compatibility
90-
from .db_reuse import monkey_patch_creation_for_db_reuse
91-
92-
with django_db_blocker.unblock():
93-
monkey_patch_creation_for_db_reuse()
86+
setup_databases_args['keepdb'] = True
9487

9588
with django_db_blocker.unblock():
9689
db_cfg = setup_databases(

pytest_django/plugin.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
from .fixtures import transactional_db # noqa
3535
from .pytest_compat import getfixturevalue
3636

37-
from .lazy_django import (django_settings_is_configured,
38-
get_django_version, skip_if_no_django)
37+
from .lazy_django import django_settings_is_configured, skip_if_no_django
3938

4039

4140
SETTINGS_MODULE_ENV = 'DJANGO_SETTINGS_MODULE'
@@ -63,10 +62,10 @@ def pytest_addoption(parser):
6362
help='Set DJANGO_CONFIGURATION.')
6463
group._addoption('--nomigrations', '--no-migrations',
6564
action='store_true', dest='nomigrations', default=False,
66-
help='Disable Django 1.7+ migrations on test setup')
65+
help='Disable Django migrations on test setup')
6766
group._addoption('--migrations',
6867
action='store_false', dest='nomigrations', default=False,
69-
help='Enable Django 1.7+ migrations on test setup')
68+
help='Enable Django migrations on test setup')
7069
parser.addini(CONFIGURATION_ENV,
7170
'django-configurations class to use by pytest-django.')
7271
group._addoption('--liveserver', default=None,
@@ -540,7 +539,7 @@ def __mod__(self, var):
540539
django_settings_is_configured()):
541540
from django.conf import settings as dj_settings
542541

543-
if get_django_version() >= (1, 8) and dj_settings.TEMPLATES:
542+
if dj_settings.TEMPLATES:
544543
dj_settings.TEMPLATES[0]['OPTIONS']['string_if_invalid'] = (
545544
InvalidVarException())
546545
else:
@@ -556,7 +555,7 @@ def _template_string_if_invalid_marker(request):
556555
if marker and django_settings_is_configured():
557556
from django.conf import settings as dj_settings
558557

559-
if get_django_version() >= (1, 8) and dj_settings.TEMPLATES:
558+
if dj_settings.TEMPLATES:
560559
dj_settings.TEMPLATES[0]['OPTIONS']['string_if_invalid'].fail = False
561560
else:
562561
dj_settings.TEMPLATE_STRING_IF_INVALID.fail = False
@@ -601,7 +600,7 @@ def __init__(self):
601600

602601
@property
603602
def _dj_db_wrapper(self):
604-
from .compat import BaseDatabaseWrapper
603+
from django.db.backends.base.base import BaseDatabaseWrapper
605604

606605
# The first time the _dj_db_wrapper is accessed, we will save a
607606
# reference to the real implementation.

tests/test_db_setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def test_inner():
223223

224224

225225
class TestNativeMigrations(object):
226-
""" Tests for Django 1.7 Migrations """
226+
""" Tests for Django Migrations """
227227

228228
def test_no_migrations(self, django_testdir):
229229
django_testdir.create_test_module('''

tests/test_environment.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,6 @@ def test_more_verbose_with_vv_and_reusedb(self, testdir):
225225
not in result.stdout.str())
226226

227227

228-
@pytest.mark.skipif(
229-
get_django_version() < (1, 8),
230-
reason='Django 1.7 requires settings.SITE_ID to be set, so this test is invalid'
231-
)
232228
@pytest.mark.django_db
233229
@pytest.mark.parametrize('site_name', ['site1', 'site2'])
234230
def test_clear_site_cache(site_name, rf, monkeypatch):

tests/test_fixtures.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,6 @@ def test_a(self, live_server, settings):
310310
result.stdout.fnmatch_lines(['*test_a*PASSED*'])
311311
assert result.ret == 0
312312

313-
@pytest.mark.skipif(get_django_version() < (1, 7),
314-
reason="Django >= 1.7 required")
315313
def test_serve_static_dj17_without_staticfiles_app(self, live_server,
316314
settings):
317315
"""

tox.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ envlist =
44
- py34-pytest3-dj{20,111,110}-postgres
55
- py33-pytest3-dj18-postgres
66
- py27-pytest3-dj{111,110}-{mysql_innodb,mysql_myisam,postgres}
7-
- py27-pytest3-dj{111,110,19,18,17}-postgres
7+
- py27-pytest3-dj{111,110,19,18}-postgres
88
- py{36,py27}-checkqa
99

1010
[testenv]
@@ -21,7 +21,6 @@ deps =
2121
dj110: Django>=1.10,<1.11
2222
dj19: Django>=1.9,<1.10
2323
dj18: Django>=1.8,<1.9
24-
dj17: Django>=1.7,<1.8
2524

2625
mysql_myisam: mysql-python==1.2.5
2726
mysql_innodb: mysql-python==1.2.5

0 commit comments

Comments
 (0)