|
14 | 14 |
|
15 | 15 | # TODO: Tests in this fire are very bad. Stop using Mocks in this module. |
16 | 16 |
|
17 | | -from os import path, remove |
| 17 | +import os |
18 | 18 | from pathlib import Path |
19 | 19 | from shutil import rmtree |
20 | 20 | from tempfile import mkdtemp |
@@ -171,9 +171,9 @@ def test_playlist_update(self): |
171 | 171 | spl = SmartPlaylistPlugin() |
172 | 172 |
|
173 | 173 | i = Mock(path=b"/tagada.mp3") |
174 | | - i.evaluate_template.side_effect = lambda pl, _: pl.replace( |
175 | | - b"$title", b"ta:ga:da" |
176 | | - ).decode() |
| 174 | + i.evaluate_template.side_effect = lambda pl, *_: os.fsdecode( |
| 175 | + pl |
| 176 | + ).replace("$title", "ta:ga:da") |
177 | 177 |
|
178 | 178 | lib = Mock() |
179 | 179 | lib.replacements = CHAR_REPLACE |
@@ -212,10 +212,9 @@ def test_playlist_update_output_extm3u(self): |
212 | 212 | type(i).title = PropertyMock(return_value="fake title") |
213 | 213 | type(i).length = PropertyMock(return_value=300.123) |
214 | 214 | type(i).path = PropertyMock(return_value=b"/tagada.mp3") |
215 | | - i.evaluate_template.side_effect = lambda pl, _: pl.replace( |
216 | | - b"$title", |
217 | | - b"ta:ga:da", |
218 | | - ).decode() |
| 215 | + i.evaluate_template.side_effect = lambda pl, *_: os.fsdecode( |
| 216 | + pl |
| 217 | + ).replace("$title", "ta:ga:da") |
219 | 218 |
|
220 | 219 | lib = Mock() |
221 | 220 | lib.replacements = CHAR_REPLACE |
@@ -262,10 +261,9 @@ def test_playlist_update_output_extm3u_fields(self): |
262 | 261 | type(i).path = PropertyMock(return_value=b"/tagada.mp3") |
263 | 262 | a = {"id": 456, "genres": ["Rock", "Pop"]} |
264 | 263 | i.__getitem__.side_effect = a.__getitem__ |
265 | | - i.evaluate_template.side_effect = lambda pl, _: pl.replace( |
266 | | - b"$title", |
267 | | - b"ta:ga:da", |
268 | | - ).decode() |
| 264 | + i.evaluate_template.side_effect = lambda pl, *_: os.fsdecode( |
| 265 | + pl |
| 266 | + ).replace("$title", "ta:ga:da") |
269 | 267 |
|
270 | 268 | lib = Mock() |
271 | 269 | lib.replacements = CHAR_REPLACE |
@@ -308,9 +306,9 @@ def test_playlist_update_uri_format(self): |
308 | 306 | i = MagicMock() |
309 | 307 | type(i).id = PropertyMock(return_value=3) |
310 | 308 | type(i).path = PropertyMock(return_value=b"/tagada.mp3") |
311 | | - i.evaluate_template.side_effect = lambda pl, _: pl.replace( |
312 | | - b"$title", b"ta:ga:da" |
313 | | - ).decode() |
| 309 | + i.evaluate_template.side_effect = lambda pl, *_: os.fsdecode( |
| 310 | + pl |
| 311 | + ).replace("$title", "ta:ga:da") |
314 | 312 |
|
315 | 313 | lib = Mock() |
316 | 314 | lib.replacements = CHAR_REPLACE |
@@ -471,10 +469,9 @@ def test_playlist_update_dest_regen(self): |
471 | 469 | ) |
472 | 470 | # Set a path which would be equal to the one returned by `item.destination`. |
473 | 471 | type(i).destination = PropertyMock(return_value=lambda: b"/tagada.mp3") |
474 | | - i.evaluate_template.side_effect = lambda pl, _: pl.replace( |
475 | | - b"$title", |
476 | | - b"ta:ga:da", |
477 | | - ).decode() |
| 472 | + i.evaluate_template.side_effect = lambda pl, *_: os.fsdecode( |
| 473 | + pl |
| 474 | + ).replace("$title", "ta:ga:da") |
478 | 475 |
|
479 | 476 | lib = Mock() |
480 | 477 | lib.replacements = CHAR_REPLACE |
|
0 commit comments