Skip to content

Commit

Permalink
new: dev: New test and prep. Closes #76
Browse files Browse the repository at this point in the history
  • Loading branch information
nicfit committed Mar 28, 2018
1 parent 1d3eb74 commit db3a369
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/eyed3/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def __parse_version(v): # pragma: nocover
return ver, rel, ver_info


__version__ = "0.8.4"
__release_name__ = "The Cold Vein"
__years__ = "2002-2017"
__version__ = "0.8.5"
__release_name__ = "30$ Bag"
__years__ = "2002-2018"

_, __release__, __version_info__ = __parse_version(__version__)
__project_name__ = "eyeD3"
Expand Down
8 changes: 4 additions & 4 deletions src/eyed3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ def __init__(self, *args):
self.message = args[0]


from .utils.log import log
from .core import load
from .utils.log import log # noqa: E402
from .core import load # noqa: E402

del sys
del locale

__all__= ["log", "load", "version", "LOCAL_ENCODING", "LOCAL_FS_ENCODING",
"Error"]
__all__ = ["log", "load", "version", "LOCAL_ENCODING", "LOCAL_FS_ENCODING",
"Error"]
20 changes: 10 additions & 10 deletions src/eyed3/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,19 +347,19 @@ def __lt__(self, rhs):
if not rhs:
return False

for l, r in ((self.year, rhs.year),
(self.month, rhs.month),
(self.day, rhs.day),
(self.hour, rhs.hour),
(self.minute, rhs.minute),
(self.second, rhs.second)):
for left, right in ((self.year, rhs.year),
(self.month, rhs.month),
(self.day, rhs.day),
(self.hour, rhs.hour),
(self.minute, rhs.minute),
(self.second, rhs.second)):

l = l if l is not None else -1
r = r if r is not None else -1
left = left if left is not None else -1
right = right if right is not None else -1

if l < r:
if left < right:
return True
elif l > r:
elif left > right:
return False

return False
Expand Down
49 changes: 49 additions & 0 deletions src/test/id3/test_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import eyed3
from eyed3.core import Date
from eyed3.id3 import frames
from eyed3.mp3 import Mp3AudioFile
from eyed3.compat import unicode, BytesType
from eyed3.id3 import Tag, ID3_DEFAULT_VERSION, ID3_V2_3, ID3_V2_4
from ..compat import *
Expand Down Expand Up @@ -1192,3 +1193,51 @@ def testReadOnly():
with pytest.raises(RuntimeError):
t._saveV2Tag(None, None, None)


def testIssue76(audiofile: Mp3AudioFile):
"""
https://github.com/nicfit/eyeD3/issues/76
"""
tag = audiofile.initTag(ID3_V2_4)
tag.setTextFrame("TPE1", "Confederacy of Ruined Lives")
tag.setTextFrame("TPE2", "Take as needed for pain")
tag.setTextFrame("TSOP", "In the name of suffering")
tag.setTextFrame("TSO2", "Dope sick")
tag.save()

audiofile = eyed3.load(audiofile.path)
tag = audiofile.tag
assert set(tag.frame_set.keys()) == {b"TPE1", b"TPE2", b"TSOP", b"TSO2"}
assert tag.getTextFrame("TSO2") == "Dope sick"
assert tag.getTextFrame("TSOP") == "In the name of suffering"
assert tag.getTextFrame("TPE2") == "Take as needed for pain"
assert tag.getTextFrame("TPE1") == "Confederacy of Ruined Lives"

audiofile.tag.lyrics.set("some lyrics")
audiofile = eyed3.load(audiofile.path)
tag = audiofile.tag
assert set(tag.frame_set.keys()) == {b"TPE1", b"TPE2", b"TSOP", b"TSO2"}
assert tag.getTextFrame("TSO2") == "Dope sick"
assert tag.getTextFrame("TSOP") == "In the name of suffering"
assert tag.getTextFrame("TPE2") == "Take as needed for pain"
assert tag.getTextFrame("TPE1") == "Confederacy of Ruined Lives"

# Convert to v2.3 and verify conversions
tag.save(version=ID3_V2_3)
audiofile = eyed3.load(audiofile.path)
tag = audiofile.tag
assert set(tag.frame_set.keys()) == {b"TPE1", b"TPE2", b"XSOP", b"TSO2"}
assert tag.getTextFrame("TSO2") == "Dope sick"
assert tag.getTextFrame("TPE2") == "Take as needed for pain"
assert tag.getTextFrame("TPE1") == "Confederacy of Ruined Lives"
assert tag.frame_set[b"XSOP"][0].text == "In the name of suffering"

# Convert to v2.4 and verify conversions
tag.save(version=ID3_V2_4)
audiofile = eyed3.load(audiofile.path)
tag = audiofile.tag
assert set(tag.frame_set.keys()) == {b"TPE1", b"TPE2", b"TSOP", b"TSO2"}
assert tag.getTextFrame("TSO2") == "Dope sick"
assert tag.getTextFrame("TPE2") == "Take as needed for pain"
assert tag.getTextFrame("TPE1") == "Confederacy of Ruined Lives"
assert tag.getTextFrame("TSOP") == "In the name of suffering"

0 comments on commit db3a369

Please sign in to comment.