Skip to content

Commit

Permalink
quodlibet#207: respect E501 max line length of 79
Browse files Browse the repository at this point in the history
  • Loading branch information
Borewit committed Aug 16, 2017
1 parent 7c815fb commit be436d1
Showing 1 changed file with 42 additions and 23 deletions.
65 changes: 42 additions & 23 deletions tests/test_wave.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,51 @@

class TWave(TestCase):
def setUp(self):
fn_wav_pcm_2s_16000_08_ID3v23 = os.path.join(DATA_DIR, "silence-2s-PCM-16000-08-ID3v23.wav")
self.wav_pcm_2s_16000_08_ID3v23 = WAVE(fn_wav_pcm_2s_16000_08_ID3v23)

self.tmp_fn_pcm_2s_16000_08_ID3v23 = get_temp_copy(fn_wav_pcm_2s_16000_08_ID3v23)
self.tmp_wav_pcm_2s_16000_08_ID3v23 = WAVE(self.tmp_fn_pcm_2s_16000_08_ID3v23)

fn_wav_pcm_2s_16000_08_notags = os.path.join(DATA_DIR, "silence-2s-PCM-16000-08-notags.wav")
self.wav_pcm_2s_16000_08_notags = WAVE(fn_wav_pcm_2s_16000_08_notags)

self.tmp_fn_pcm_2s_16000_08_notag = get_temp_copy(fn_wav_pcm_2s_16000_08_notags)
self.tmp_wav_pcm_2s_16000_08_notag = WAVE(self.tmp_fn_pcm_2s_16000_08_notag)

fn_wav_pcm_2s_44100_16_ID3v23 = os.path.join(DATA_DIR, "silence-2s-PCM-44100-16-ID3v23.wav")
fn_wav_pcm_2s_16000_08_ID3v23 = \
os.path.join(DATA_DIR, "silence-2s-PCM-16000-08-ID3v23.wav")
self.wav_pcm_2s_16000_08_ID3v23 = \
WAVE(fn_wav_pcm_2s_16000_08_ID3v23)

self.tmp_fn_pcm_2s_16000_08_ID3v23 = \
get_temp_copy(fn_wav_pcm_2s_16000_08_ID3v23)
self.tmp_wav_pcm_2s_16000_08_ID3v23 = \
WAVE(self.tmp_fn_pcm_2s_16000_08_ID3v23)

fn_wav_pcm_2s_16000_08_notags = \
os.path.join(DATA_DIR, "silence-2s-PCM-16000-08-notags.wav")
self.wav_pcm_2s_16000_08_notags = \
WAVE(fn_wav_pcm_2s_16000_08_notags)

self.tmp_fn_pcm_2s_16000_08_notag = \
get_temp_copy(fn_wav_pcm_2s_16000_08_notags)
self.tmp_wav_pcm_2s_16000_08_notag = \
WAVE(self.tmp_fn_pcm_2s_16000_08_notag)

fn_wav_pcm_2s_44100_16_ID3v23 = \
os.path.join(DATA_DIR, "silence-2s-PCM-44100-16-ID3v23.wav")
self.wav_pcm_2s_44100_16_ID3v23 = WAVE(fn_wav_pcm_2s_44100_16_ID3v23)

def test_channels(self):
self.failUnlessEqual(self.wav_pcm_2s_16000_08_ID3v23.info.channels, 2)
self.failUnlessEqual(self.wav_pcm_2s_44100_16_ID3v23.info.channels, 2)

def test_sample_rate(self):
self.failUnlessEqual(self.wav_pcm_2s_16000_08_ID3v23.info.sample_rate, 16000)
self.failUnlessEqual(self.wav_pcm_2s_44100_16_ID3v23.info.sample_rate, 44100)
self.failUnlessEqual(self.wav_pcm_2s_16000_08_ID3v23.info.sample_rate,
16000)
self.failUnlessEqual(self.wav_pcm_2s_44100_16_ID3v23.info.sample_rate,
44100)

def test_number_of_samples(self):
self.failUnlessEqual(self.wav_pcm_2s_16000_08_ID3v23.info.number_of_samples, 32000)
self.failUnlessEqual(self.wav_pcm_2s_44100_16_ID3v23.info.number_of_samples, 88200)
self.failUnlessEqual(self.wav_pcm_2s_16000_08_ID3v23.info.number_of_samples,
32000)
self.failUnlessEqual(self.wav_pcm_2s_44100_16_ID3v23.info.number_of_samples,
88200)

def test_length(self):
self.failUnlessAlmostEqual(self.wav_pcm_2s_16000_08_ID3v23.info.length, 2.0, 2)
self.failUnlessAlmostEqual(self.wav_pcm_2s_44100_16_ID3v23.info.length, 2.0, 2)
self.failUnlessAlmostEqual(self.wav_pcm_2s_16000_08_ID3v23.info.length,
2.0, 2)
self.failUnlessAlmostEqual(self.wav_pcm_2s_44100_16_ID3v23.info.length,
2.0, 2)

def test_not_my_file(self):
self.failUnlessRaises(
Expand Down Expand Up @@ -70,10 +85,12 @@ def test_save_no_tags(self):

def test_add_tags_already_there(self):
self.failUnless(self.tmp_wav_pcm_2s_16000_08_ID3v23.tags)
self.failUnlessRaises(Exception, self.tmp_wav_pcm_2s_16000_08_ID3v23.add_tags)
self.failUnlessRaises(Exception,
self.tmp_wav_pcm_2s_16000_08_ID3v23.add_tags)

def test_roundtrip(self):
self.failUnlessEqual(self.tmp_wav_pcm_2s_16000_08_ID3v23["TIT2"], ["Silence"])
self.failUnlessEqual(self.tmp_wav_pcm_2s_16000_08_ID3v23["TIT2"],
["Silence"])
self.tmp_wav_pcm_2s_16000_08_ID3v23.save()
new = WAVE(self.tmp_wav_pcm_2s_16000_08_ID3v23.filename)
self.failUnlessEqual(new["TIT2"], ["Silence"])
Expand All @@ -89,6 +106,8 @@ def test_save_tags(self):

def test_save_without_ID3_chunk(self):
from mutagen.id3 import TIT1
self.tmp_wav_pcm_2s_16000_08_notag["TIT1"] = TIT1(encoding=3, text="foobar")
self.tmp_wav_pcm_2s_16000_08_notag["TIT1"] = TIT1(encoding=3,
text="foobar")
self.tmp_wav_pcm_2s_16000_08_notag.save()
self.failUnless(WAVE(self.tmp_fn_pcm_2s_16000_08_notag)["TIT1"] == "foobar")
self.failUnless(WAVE(self.tmp_fn_pcm_2s_16000_08_notag)["TIT1"]
== "foobar")

0 comments on commit be436d1

Please sign in to comment.