Skip to content

Commit decffd3

Browse files
author
Asif Saif Uddin
authored
Merge pull request #693 from jazzband/dj22
Django 2.2
2 parents 3cd2f93 + 05380c1 commit decffd3

File tree

13 files changed

+101
-170
lines changed

13 files changed

+101
-170
lines changed

.travis.yml

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,23 @@
11
language: python
2-
sudo: false
2+
sudo: True
3+
dist: xenial
34
matrix:
45
include:
5-
- env: TOXENV=py27-django16
6-
python: "2.7"
7-
- env: TOXENV=pypy-django16
8-
python: "pypy"
9-
- env: TOXENV=py34-django16
10-
python: "3.4"
11-
- env: TOXENV=py27-django17
12-
python: "2.7"
13-
- env: TOXENV=pypy-django17
14-
python: "pypy"
15-
- env: TOXENV=py34-django17
16-
python: "3.4"
17-
- env: TOXENV=py27-django18
18-
python: "2.7"
19-
- env: TOXENV=pypy-django18
20-
python: "pypy"
21-
- env: TOXENV=py34-django18
22-
python: "3.4"
23-
- env: TOXENV=py27-django19
24-
python: "2.7"
25-
- env: TOXENV=pypy-django19
26-
python: "pypy"
27-
- env: TOXENV=py34-django19
28-
python: "3.4"
29-
- env: TOXENV=py35-django19
30-
python: "3.5"
31-
- env: TOXENV=py27-django110
32-
python: "2.7"
33-
- env: TOXENV=pypy-django110
34-
python: "pypy"
35-
- env: TOXENV=py34-django110
36-
python: "3.4"
37-
- env: TOXENV=py35-django110
38-
python: "3.5"
396
- env: TOXENV=py27-django111
407
python: "2.7"
418
- env: TOXENV=pypy-django111
429
python: "pypy"
43-
- env: TOXENV=py34-django111
44-
python: "3.4"
4510
- env: TOXENV=py35-django111
4611
python: "3.5"
4712
- env: TOXENV=py36-django111
4813
python: "3.6"
49-
- env: TOXENV=py34-django20
50-
python: "3.4"
51-
- env: TOXENV=py35-django20
52-
python: "3.5"
5314
- env: TOXENV=py36-django20
5415
python: "3.6"
55-
- env: TOXENV=py37-django20
16+
- env: TOXENV=py35-django22
17+
python: "3.5"
18+
- env: TOXENV=py36-django22
19+
python: "3.6"
20+
- env: TOXENV=py37-django22
5621
python: "3.7-dev"
5722
- env: TOXENV=py35-django-master
5823
python: "3.5"
@@ -63,10 +28,6 @@ matrix:
6328
- env: TOXENV=docs
6429
python: "2.7"
6530
allow_failures:
66-
- env: TOXENV=py34-django20
67-
- env: TOXENV=py35-django20
68-
- env: TOXENV=py36-django20
69-
- env: TOXENV=py37-django20
7031
- env: TOXENV=py35-django-master
7132
- env: TOXENV=py36-django-master
7233
- env: TOXENV=py37-django-master

CONTRIBUTING.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,26 @@ Contribute
1717

1818
Otherwise, if you simply wants to suggest a feature or report a bug, create an issue :
1919
https://github.com/jazzband/django-pipeline/issues
20+
21+
22+
Running tests
23+
=============
24+
25+
We use tox to run the test suite on different versions locally (and travis-ci
26+
to automate the check for PRs).
27+
28+
To tun the test suite locally, please make sure your python environment has
29+
tox and django installed::
30+
31+
python3.7 -m pip install tox
32+
33+
Since we use a number of node.js tools, one should first install the node
34+
depencies. We reccomend using [nvm](https://github.com/nvm-sh/nvm#installation-and-update) , tl;dr::
35+
36+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
37+
nvm install node
38+
nvm use node
39+
40+
And then simply execute tox to run the whole test matrix::
41+
42+
tox

docs/installation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Installation
2929

3030

3131
.. note::
32-
You need to use ``Django>=1.7`` to be able to use this version of pipeline.
32+
You need to use ``Django>=1.11`` to be able to use this version of pipeline.
3333

3434
.. _GitHub: http://github.com/jazzband/django-pipeline
3535
.. _PyPI: http://pypi.python.org/pypi/django-pipeline

pipeline/conf.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66
import shlex
77

88
from django.conf import settings as _settings
9-
try:
10-
from django.core.signals import setting_changed
11-
except ImportError:
12-
# Django < 1.8
13-
from django.test.signals import setting_changed
9+
from django.core.signals import setting_changed
1410
from django.dispatch import receiver
1511
from django.utils.six import string_types
1612

pipeline/middleware.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66

77
from pipeline.conf import settings
88

9-
try:
10-
# Support for Django 1.10 new MIDDLEWARE setting
11-
from django.utils.deprecation import MiddlewareMixin
12-
except ImportError: # Django < 1.10
13-
MiddlewareMixin = object
9+
from django.utils.deprecation import MiddlewareMixin
1410

1511

1612
class MinifyHTMLMiddleware(MiddlewareMixin):

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ coveralls
22
flake8
33
tox
44
wheel
5+
django

setup.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,18 @@
2424
'Development Status :: 5 - Production/Stable',
2525
'Environment :: Web Environment',
2626
'Framework :: Django',
27-
'Framework :: Django :: 1.6',
28-
'Framework :: Django :: 1.7',
29-
'Framework :: Django :: 1.8',
30-
'Framework :: Django :: 1.9',
31-
'Framework :: Django :: 1.10',
3227
'Framework :: Django :: 1.11',
28+
'Framework :: Django :: 2.0',
29+
'Framework :: Django :: 2.2',
3330
'Intended Audience :: Developers',
3431
'License :: OSI Approved :: MIT License',
3532
'Operating System :: OS Independent',
3633
'Programming Language :: Python',
3734
'Programming Language :: Python :: 2.7',
3835
'Programming Language :: Python :: 3',
39-
'Programming Language :: Python :: 3.4',
4036
'Programming Language :: Python :: 3.5',
4137
'Programming Language :: Python :: 3.6',
38+
'Programming Language :: Python :: 3.7',
4239
'Programming Language :: Python :: Implementation :: PyPy',
4340
'Topic :: Utilities',
4441
'Topic :: Software Development :: Libraries :: Python Modules',

tests/settings.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def local_path(path):
1919

2020
INSTALLED_APPS = [
2121
'django.contrib.contenttypes',
22+
'django.contrib.messages',
2223
'django.contrib.sites',
2324
'django.contrib.sessions',
2425
'django.contrib.staticfiles',
@@ -28,17 +29,16 @@ def local_path(path):
2829
'tests.tests'
2930
]
3031

31-
MIDDLEWARE_CLASSES = (
32-
'django.contrib.sessions.middleware.SessionMiddleware',
33-
'django.contrib.auth.middleware.AuthenticationMiddleware'
34-
)
3532

3633
ROOT_URLCONF = 'tests.urls'
3734

38-
MIDDLEWARE_CLASSES = (
35+
MIDDLEWARE = [
36+
'django.contrib.sessions.middleware.SessionMiddleware',
37+
'django.contrib.auth.middleware.AuthenticationMiddleware',
38+
'django.contrib.messages.middleware.MessageMiddleware',
3939
'django.middleware.common.CommonMiddleware',
40-
'django.middleware.csrf.CsrfViewMiddleware'
41-
)
40+
'django.middleware.csrf.CsrfViewMiddleware',
41+
]
4242

4343
MEDIA_URL = '/media/'
4444

@@ -172,6 +172,7 @@ def node_exe_path(command):
172172
'OPTIONS': {
173173
'context_processors': [
174174
'django.contrib.auth.context_processors.auth',
175+
'django.contrib.messages.context_processors.messages',
175176
]
176177
}
177178
},

tests/tests/test_forms.py

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from django.forms import Media
44
from django.test import TestCase
5-
from django.utils import six
65

76
from pipeline.forms import PipelineFormMedia
87
from ..utils import pipeline_settings
@@ -76,21 +75,23 @@ class MyMedia(PipelineFormMedia):
7675
'print': ['/static/print.min.css'],
7776
})
7877
self.assertEqual(MyMedia.css, media._css)
79-
self.assertEqual(
80-
list(media.render_css()),
81-
[
82-
'<link href="%s" type="text/css" media="all" '
83-
'rel="stylesheet" />' % path
84-
for path in (
85-
'/static/extra1.css',
86-
'/static/extra2.css',
87-
'/static/styles1.min.css',
88-
'/static/styles2.min.css',
89-
)
90-
] + [
91-
'<link href="/static/print.min.css" type="text/css" '
92-
'media="print" rel="stylesheet" />'
93-
])
78+
expected_regex = [
79+
r'<link href="%s" type="text/css" media="all" '
80+
'rel="stylesheet"( /)?>' % path
81+
for path in (
82+
'/static/extra1.css',
83+
'/static/extra2.css',
84+
'/static/styles1.min.css',
85+
'/static/styles2.min.css',
86+
)
87+
] + [
88+
r'<link href="/static/print.min.css" type="text/css" '
89+
'media="print" rel="stylesheet"( /)?>'
90+
]
91+
for rendered_node, expected_node in zip(
92+
media.render_css(), expected_regex
93+
):
94+
self.assertRegex(rendered_node, expected_node)
9495

9596
@pipeline_settings(PIPELINE_ENABLED=False)
9697
def test_css_packages_with_pipeline_disabled(self):
@@ -120,22 +121,25 @@ class MyMedia(PipelineFormMedia):
120121
'print': ['pipeline/css/urls.css'],
121122
})
122123
self.assertEqual(MyMedia.css, media._css)
123-
self.assertEqual(
124-
list(media.render_css()),
125-
[
126-
'<link href="%s" type="text/css" media="all" '
127-
'rel="stylesheet" />' % path
128-
for path in (
129-
'/static/extra1.css',
130-
'/static/extra2.css',
131-
'/static/pipeline/css/first.css',
132-
'/static/pipeline/css/second.css',
133-
'/static/pipeline/css/unicode.css',
134-
)
135-
] + [
136-
'<link href="/static/pipeline/css/urls.css" type="text/css" '
137-
'media="print" rel="stylesheet" />'
138-
])
124+
125+
expected_regex = [
126+
'<link href="%s" type="text/css" media="all" '
127+
'rel="stylesheet"( /)?>' % path
128+
for path in (
129+
'/static/extra1.css',
130+
'/static/extra2.css',
131+
'/static/pipeline/css/first.css',
132+
'/static/pipeline/css/second.css',
133+
'/static/pipeline/css/unicode.css',
134+
)
135+
] + [
136+
'<link href="/static/pipeline/css/urls.css" type="text/css" '
137+
'media="print" rel="stylesheet"( /)?>'
138+
]
139+
for rendered_node, expected_node in zip(
140+
media.render_css(), expected_regex
141+
):
142+
self.assertRegex(rendered_node, expected_node)
139143

140144
@pipeline_settings(PIPELINE_ENABLED=True)
141145
def test_js_packages_with_pipeline_enabled(self):

tests/tests/test_middleware.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import unicode_literals
33

4+
try:
5+
from mock import patch
6+
except ImportError:
7+
from unittest.mock import patch # noqa
8+
9+
from django.core.exceptions import MiddlewareNotUsed
410
from django.test import TestCase
511
from django.http import HttpRequest, HttpResponse
612

@@ -34,3 +40,9 @@ def test_middleware_text(self):
3440
response = MinifyHTMLMiddleware().process_response(self.req, self.resp)
3541
self.assertIn('text/plain', response['Content-Type'])
3642
self.assertIn(self.whitespace, response.content)
43+
44+
@patch('pipeline.middleware.settings.PIPELINE_ENABLED', False)
45+
def test_middleware_not_used(self):
46+
self.resp['Content-Type'] = 'text/plain; charset=UTF-8'
47+
48+
self.assertRaises(MiddlewareNotUsed, MinifyHTMLMiddleware)

0 commit comments

Comments
 (0)