Added fast tests.
This commit is contained in:
parent
8554ef8d81
commit
d48394a522
3 changed files with 45 additions and 20 deletions
|
@ -1,15 +1,35 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import pytest
|
||||
from io import BytesIO
|
||||
|
||||
from smalltag import SmallTag
|
||||
|
||||
|
||||
# chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_ "
|
||||
def test_written_gets_recognized():
|
||||
# avoid writing to the real file by using a BytesIO
|
||||
tag = SmallTag.get("formats/test.mp3", file_obj=BytesIO(b""))
|
||||
|
||||
tag.title = "A normal title."
|
||||
tag.artist = "An artist."
|
||||
tag.album = "The album."
|
||||
tag.track = 1234
|
||||
|
||||
tag = SmallTag.get("formats/test.mp3", file_obj=BytesIO(tag._compose_id3v2_tag()))
|
||||
|
||||
assert tag.title == "A normal title."
|
||||
assert tag.artist == "An artist."
|
||||
assert tag.album == "The album."
|
||||
assert tag.track == 1234
|
||||
|
||||
|
||||
# chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_ "
|
||||
# no "b" because there is a bug in TinyTag 2.1.0 that removes "b"s if they are at the beginning of a string
|
||||
chars = "acdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 _-"
|
||||
|
||||
|
||||
def test_written_gets_recognized():
|
||||
@pytest.mark.slow
|
||||
def test_full_written_gets_recognized():
|
||||
for char1 in chars:
|
||||
for char2 in chars:
|
||||
field_content = f"{char1}{char2}Test{char2}{char1}"
|
||||
|
@ -27,15 +47,3 @@ def test_written_gets_recognized():
|
|||
assert tag.title == field_content
|
||||
assert tag.artist == field_content
|
||||
assert tag.album == field_content
|
||||
|
||||
|
||||
def test_int_converted_to_numerical_string():
|
||||
tag = SmallTag.get("formats/test.mp3")
|
||||
|
||||
tag.track = 123
|
||||
|
||||
tag.write()
|
||||
|
||||
tag = SmallTag.get("formats/test.mp3")
|
||||
|
||||
assert tag.track == 123
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue