Skip to content

Commit eed4981

Browse files
TheBukyTheBuky
authored andcommitted
Fix test for Travis environements
1 parent 27f461f commit eed4981

File tree

7 files changed

+14
-34
lines changed

7 files changed

+14
-34
lines changed

HISTORY.rst

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,9 @@ History
1414
* Remove of old imports form 'django.utils.six' and these fixes (1.7.0).
1515
* Remove tests of uncovered versions of Python and Django.
1616
* Replace tests for Pypy by Pypy3.
17-
* Explicitly specify when files are read / writ in binary mode.
18-
* Deal with universal newlines of Python 3 for tests. When opening a file
19-
as binary mode '\r\n' is used as linebreak instead of '\n'. Open file in
20-
text mode for tests to let OS correctly interpret line breaks and remove
21-
'smart_bytes' not anymore used.
22-
* Add method to simulate file reading for tests to correctly interpret
23-
line breaks from given string.
24-
* Upgrade documentation version to 2.0.
17+
* Explicitly specify when files are read / write in binary mode.
18+
* Set opening files for tests to deal with universal newlines.
19+
* Upgrade documentation version to 2.0 to follow the project version.
2520

2621
1.7.0
2722
=====

pipeline/collector.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from django.contrib.staticfiles import finders
77
from django.contrib.staticfiles.storage import staticfiles_storage
88

9-
109
from pipeline.finders import PipelineFinder
1110

1211

pipeline/compressors/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ def reconstruct(match):
137137
# content needs to be unicode to avoid explosions with non-ascii chars
138138
content = re.sub(URL_DETECTOR, reconstruct, content)
139139
stylesheets.append(content)
140-
return '\r\n'.join(stylesheets)
140+
return '\n'.join(stylesheets)
141141

142142
def concatenate(self, paths):
143143
"""Concatenate together a list of files"""
144144
# Note how a semicolon is added between the two files to make sure that
145-
# their behavior is not changed. '(expression1)\n\r(expression2)' calls
145+
# their behavior is not changed. '(expression1)\n(expression2)' calls
146146
# `expression1` with `expression2` as an argument! Superfluos semicolons
147147
# are valid in JavaScript and will be removed by the minifier.
148-
return "\r\n;".join([self.read_text(path) for path in paths])
148+
return "\n;".join([self.read_text(path) for path in paths])
149149

150150
def construct_asset_path(self, asset_path, css_path, output_filename, variant=None):
151151
"""Return a rewritten asset URL for a stylesheet"""

pipeline/compressors/yui.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import unicode_literals
2-
31
from pipeline.conf import settings
42
from pipeline.compressors import SubProcessCompressor
53

pipeline/jinja2/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import unicode_literals
2-
31
from jinja2 import nodes, TemplateSyntaxError
42
from jinja2.ext import Extension
53

tests/tests/test_compressor.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ def setUp(self):
3131
self.compressor = Compressor()
3232
default_collector.collect()
3333

34-
@staticmethod
35-
def emulate_file_reading(text):
36-
with io.StringIO(text, newline='\r\n') as f:
37-
data = f.read()
38-
return data
39-
4034
def test_js_compressor_class(self):
4135
self.assertEqual(self.compressor.js_compressor, YuglifyCompressor)
4236

@@ -49,15 +43,15 @@ def test_concatenate_and_rewrite(self):
4943
_('pipeline/css/second.css')
5044
], 'css/screen.css')
5145
expected = """.concat {\n display: none;\n}\n\n.concatenate {\n display: block;\n}\n"""
52-
self.assertEqual(self.emulate_file_reading(expected), css)
46+
self.assertEqual(expected, css)
5347

5448
def test_concatenate(self):
5549
js = self.compressor.concatenate([
5650
_('pipeline/js/first.js'),
5751
_('pipeline/js/second.js')
5852
])
5953
expected = """(function() {\n window.concat = function() {\n console.log(arguments);\n }\n}()) // No semicolon\n\n;(function() {\n window.cat = function() {\n console.log("hello world");\n }\n}());\n"""
60-
self.assertEqual(self.emulate_file_reading(expected), js)
54+
self.assertEqual(expected, js)
6155

6256
@patch.object(base64, 'b64encode')
6357
def test_encoded_content(self, mock):
@@ -142,7 +136,7 @@ def test_url_rewrite(self):
142136
output = self.compressor.concatenate_and_rewrite([
143137
_('pipeline/css/urls.css'),
144138
], 'css/screen.css')
145-
expected = """.embedded-url-svg {
139+
self.assertEqual(""".embedded-url-svg {
146140
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(255, 255, 255, 0.5)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8h24M4 16h24M4 24h24'/%3E% 3C/svg%3E");
147141
}
148142
@font-face {
@@ -172,21 +166,19 @@ def test_url_rewrite(self):
172166
background-image: url(#image-gradient);
173167
}
174168
@font-face{src:url(../pipeline/fonts/pipeline.eot);src:url(../pipeline/fonts/pipeline.eot?#iefix) format('embedded-opentype'),url(../pipeline/fonts/pipeline.woff) format('woff'),url(../pipeline/fonts/pipeline.ttf) format('truetype');}
175-
"""
176-
self.assertEqual(self.emulate_file_reading(expected), output)
169+
""", output)
177170

178171
def test_url_rewrite_data_uri(self):
179172
output = self.compressor.concatenate_and_rewrite([
180173
_('pipeline/css/nested/nested.css'),
181174
], 'pipeline/screen.css')
182-
expected = """.data-url {
175+
self.assertEqual(""".data-url {
183176
background-image: url(data:image/svg+xml;charset=US-ASCII,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22iso-8859-1%22%3F%3E%3C!DOCTYPE%20svg%20PUBLIC%20%22-%2F%2FW3C%2F%2FDTD%20SVG%201.1%2F%2FEN%22%20%22http%3A%2F%2Fwww.w3.org%2FGraphics%2FSVG%2F1.1%2FDTD%2Fsvg11.dtd%22%3E%3Csvg%20version%3D%221.1%22%20id%3D%22Layer_1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20x%3D%220px%22%20y%3D%220px%22%20%20width%3D%2212px%22%20height%3D%2214px%22%20viewBox%3D%220%200%2012%2014%22%20style%3D%22enable-background%3Anew%200%200%2012%2014%3B%22%20xml%3Aspace%3D%22preserve%22%3E%3Cpath%20d%3D%22M11%2C6V5c0-2.762-2.239-5-5-5S1%2C2.238%2C1%2C5v1H0v8h12V6H11z%20M6.5%2C9.847V12h-1V9.847C5.207%2C9.673%2C5%2C9.366%2C5%2C9%20c0-0.553%2C0.448-1%2C1-1s1%2C0.447%2C1%2C1C7%2C9.366%2C6.793%2C9.673%2C6.5%2C9.847z%20M9%2C6H3V5c0-1.657%2C1.343-3%2C3-3s3%2C1.343%2C3%2C3V6z%22%2F%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3C%2Fsvg%3E);
184177
}
185178
.data-url-quoted {
186179
background-image: url('data:image/svg+xml;charset=US-ASCII,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22iso-8859-1%22%3F%3E%3C!DOCTYPE%20svg%20PUBLIC%20%22-%2F%2FW3C%2F%2FDTD%20SVG%201.1%2F%2FEN%22%20%22http%3A%2F%2Fwww.w3.org%2FGraphics%2FSVG%2F1.1%2FDTD%2Fsvg11.dtd%22%3E%3Csvg%20version%3D%221.1%22%20id%3D%22Layer_1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20x%3D%220px%22%20y%3D%220px%22%20%20width%3D%2212px%22%20height%3D%2214px%22%20viewBox%3D%220%200%2012%2014%22%20style%3D%22enable-background%3Anew%200%200%2012%2014%3B%22%20xml%3Aspace%3D%22preserve%22%3E%3Cpath%20d%3D%22M11%2C6V5c0-2.762-2.239-5-5-5S1%2C2.238%2C1%2C5v1H0v8h12V6H11z%20M6.5%2C9.847V12h-1V9.847C5.207%2C9.673%2C5%2C9.366%2C5%2C9%20c0-0.553%2C0.448-1%2C1-1s1%2C0.447%2C1%2C1C7%2C9.366%2C6.793%2C9.673%2C6.5%2C9.847z%20M9%2C6H3V5c0-1.657%2C1.343-3%2C3-3s3%2C1.343%2C3%2C3V6z%22%2F%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3Cg%3E%3C%2Fg%3E%3C%2Fsvg%3E');
187180
}
188-
"""
189-
self.assertEqual(self.emulate_file_reading(expected), output)
181+
""", output)
190182

191183
@skipIf(sys.platform.startswith("win"), "requires posix platform")
192184
def test_compressor_subprocess_unicode(self):

tests/tests/test_middleware.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
try:
2-
from mock import patch
3-
except ImportError:
4-
from unittest.mock import patch # noqa
1+
2+
from unittest.mock import patch
53

64
from django.core.exceptions import MiddlewareNotUsed
75
from django.test import TestCase

0 commit comments

Comments
 (0)