Skip to content

Commit

Permalink
Overhaul tests to use .format() instead of % where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
tuffy committed Nov 20, 2015
1 parent 7df7ce6 commit fb97199
Show file tree
Hide file tree
Showing 7 changed files with 597 additions and 623 deletions.
8 changes: 4 additions & 4 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -7579,11 +7579,11 @@
- [ ] tokrules.py
- [ ] yaccrules.py
*** TODO Update unit tests
- [ ] test.py
- [ ] test_core.py
- [ ] test_formats.py
- [X] test.py
- [X] test_core.py
- [X] test_formats.py
- [ ] test_metadata.py
- [ ] test_streams.py
- [X] test_streams.py
- [ ] test_utils.py
** TODO Support MBID tags
These are basically direct MusicBrainz links rather than using
Expand Down
20 changes: 8 additions & 12 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ def do_nothing(self):
for section in parser.sections():
for option in parser.options(section):
if parser.getboolean(section, option):
vars()["%s_%s" % (section.upper(),
option.upper())] = lambda function: function
vars()["{}_{}".format(section.upper(), option.upper())] = \
lambda function: function
else:
vars()["%s_%s" % (section.upper(),
option.upper())] = lambda function: do_nothing
vars()["{}_{}".format(section.upper(), option.upper())] = \
lambda function: do_nothing


def BLANK_PCM_Reader(length, sample_rate=44100, channels=2,
Expand Down Expand Up @@ -174,9 +174,8 @@ def __init__(self, pcmreader):
self.md5 = md5()

def __repr__(self):
return "MD5Reader(%s,%s,%s)" % (self.sample_rate,
self.channels,
self.bits_per_sample)
return "MD5Reader({!r},{!r},{!r})".format(
self.sample_rate, self.channels, self.bits_per_sample)

def reset(self):
if hasattr(self.pcmreader, "reset"):
Expand Down Expand Up @@ -263,11 +262,8 @@ def __init__(self, channels, bits_per_sample, sample_rate, value=0):
self.value = value

def __repr__(self):
return "FrameCounter(%d %d %d %d)" % \
(self.channels,
self.bits_per_sample,
self.sample_rate,
self.value)
return "FrameCounter({!r}, {!r}, {!r}, {!r})".format(
self.channels, self.bits_per_sample, self.sample_rate, self.value)

def update(self, f):
self.value += len(f)
Expand Down
Loading

0 comments on commit fb97199

Please sign in to comment.