Browse Source

refactor empty_id3_* test fixtures

Fabian Peter Hammerle 4 years ago
parent
commit
64eee4fa7f
3 changed files with 19 additions and 20 deletions
  1. 13 0
      tests/conftest.py
  2. 2 12
      tests/tag_interface/test_id3.py
  3. 4 8
      tests/test_track.py

+ 13 - 0
tests/conftest.py

@@ -1,8 +1,21 @@
 import os
+import shutil
 
 import pytest
 
+# pylint: disable=redefined-outer-name
+
 
 @pytest.fixture
 def tracks_dir_path():
     return os.path.join(os.path.dirname(__file__), 'tracks')
+
+
+@pytest.fixture
+def empty_id3_path(tmpdir, tracks_dir_path):
+    path = tmpdir.join('empty.mp3').strpath
+    shutil.copyfile(
+        src=os.path.join(tracks_dir_path, 'id3v2.4-empty.mp3'),
+        dst=path,
+    )
+    return path

+ 2 - 12
tests/tag_interface/test_id3.py

@@ -1,5 +1,4 @@
 import os
-import shutil
 
 import mutagen
 import pytest
@@ -7,16 +6,6 @@ import pytest
 from symuid._tag_interface import ID3
 
 
-@pytest.fixture
-def empty_id3_iface(tmpdir, tracks_dir_path):
-    path = tmpdir.join('empty.mp3').strpath
-    shutil.copyfile(
-        src=os.path.join(tracks_dir_path, 'id3v2.4-empty.mp3'),
-        dst=path,
-    )
-    return ID3(mutagen.File(path))
-
-
 @pytest.mark.parametrize('track_name', ['id3v2.4-empty.mp3'])
 def test_get_track_path(tracks_dir_path, track_name):
     track_path = os.path.join(tracks_dir_path, track_name)
@@ -44,7 +33,8 @@ def test_get_comment(tracks_dir_path, track_name, expected_comment):
     assert expected_comment == iface.get_comment()
 
 
-def test_set_comment(empty_id3_iface):
+def test_set_comment(empty_id3_path):
+    empty_id3_iface = ID3(mutagen.File(empty_id3_path))
     assert empty_id3_iface.get_comment() is None
     empty_id3_iface.set_comment('latin')
     assert empty_id3_iface.get_comment() == 'latin'

+ 4 - 8
tests/test_track.py

@@ -1,12 +1,13 @@
 import datetime as dt
 import os
-import shutil
 
 import mutagen
 import pytest
 
 import symuid
 
+# pylint: disable=redefined-outer-name
+
 # TODO test aac / m4a itunes tags
 
 TRACKS_DIR_PATH = os.path.join(os.path.dirname(__file__), 'tracks')
@@ -17,13 +18,8 @@ def utc_dt(hour=0):
 
 
 @pytest.fixture
-def empty_id3_track(tmpdir):
-    path = tmpdir.join('empty.mp3').strpath
-    shutil.copyfile(
-        src=os.path.join(TRACKS_DIR_PATH, 'id3v2.4-empty.mp3'),
-        dst=path,
-    )
-    return symuid.Track(path)
+def empty_id3_track(empty_id3_path):
+    return symuid.Track(empty_id3_path)
 
 
 @pytest.mark.parametrize('path', [