@@ -31,12 +31,6 @@ def setUp(self):
31
31
self .compressor = Compressor ()
32
32
default_collector .collect ()
33
33
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
-
40
34
def test_js_compressor_class (self ):
41
35
self .assertEqual (self .compressor .js_compressor , YuglifyCompressor )
42
36
@@ -49,15 +43,15 @@ def test_concatenate_and_rewrite(self):
49
43
_ ('pipeline/css/second.css' )
50
44
], 'css/screen.css' )
51
45
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 )
53
47
54
48
def test_concatenate (self ):
55
49
js = self .compressor .concatenate ([
56
50
_ ('pipeline/js/first.js' ),
57
51
_ ('pipeline/js/second.js' )
58
52
])
59
53
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 )
61
55
62
56
@patch .object (base64 , 'b64encode' )
63
57
def test_encoded_content (self , mock ):
@@ -142,7 +136,7 @@ def test_url_rewrite(self):
142
136
output = self .compressor .concatenate_and_rewrite ([
143
137
_ ('pipeline/css/urls.css' ),
144
138
], 'css/screen.css' )
145
- expected = """.embedded-url-svg {
139
+ self . assertEqual ( """.embedded-url-svg {
146
140
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");
147
141
}
148
142
@font-face {
@@ -172,21 +166,19 @@ def test_url_rewrite(self):
172
166
background-image: url(#image-gradient);
173
167
}
174
168
@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 )
177
170
178
171
def test_url_rewrite_data_uri (self ):
179
172
output = self .compressor .concatenate_and_rewrite ([
180
173
_ ('pipeline/css/nested/nested.css' ),
181
174
], 'pipeline/screen.css' )
182
- expected = """.data-url {
175
+ self . assertEqual ( """.data-url {
183
176
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);
184
177
}
185
178
.data-url-quoted {
186
179
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');
187
180
}
188
- """
189
- self .assertEqual (self .emulate_file_reading (expected ), output )
181
+ """ , output )
190
182
191
183
@skipIf (sys .platform .startswith ("win" ), "requires posix platform" )
192
184
def test_compressor_subprocess_unicode (self ):
0 commit comments