class TestTransformationDrill: def setup(self): self.recdir, self.tmp = mkdtemp(), mkdtemp() config = SoundConfig(recdir=self.recdir, tmpdir=self.tmp) data = [ (Recording(config, 'He_is', 'He is.'), Recording(config, 'He_is,_isn\'t_he_?', 'He is, isn\'t he ?')), (Recording(config, 'She_wasn\'t', 'She wasn\'t.'), Recording(config, 'She_wasn\'t,_was_she_?', 'She wasn\'t, was she ?')) ] self.drill = TransformationDrill(config, data) def teardown(self): rmtree(self.recdir, self.tmp) def test_filename(self): assert_equal("trans-He_is,_isn't_he_?", self.drill.filename) def test_recordings(self): recs = self.drill.recordings() assert_equal(recs[0].text, "He is.") assert_equal(recs[1].text, "He is, isn't he ?") assert_equal(recs[2].text, "She wasn't.") assert_equal(recs[3].text, "She wasn't, was she ?") def test_sound(self): assert_is_instance(self.drill.sound(test=True), Sound)
def setup(self): self.recdir, self.tmp = mkdtemp(), mkdtemp() config = SoundConfig(recdir=self.recdir, tmpdir=self.tmp) data = [ (Recording(config, 'He_is', 'He is.'), Recording(config, 'He_is,_isn\'t_he_?', 'He is, isn\'t he ?')), (Recording(config, 'She_wasn\'t', 'She wasn\'t.'), Recording(config, 'She_wasn\'t,_was_she_?', 'She wasn\'t, was she ?')) ] self.drill = TransformationDrill(config, data)
def parse(self): drills = [] drill_data = [] for i, line in enumerate(self.stream): if self.is_blank(line): if drill_data: drill = TransformationDrill(self.config, drill_data) drills.append(drill) drill_data = [] else: drill_data.append(self.recordings(line)) if drill_data: drill = TransformationDrill(self.config, drill_data) drills.append(drill) return drills