def test_to_praat_starts_before(self): mock_tier = mock.Mock() mock_tier.xmin = 0 mock_tier.xmax = 1 tg = TextGrid(0.5, 1, [mock_tier]) with assert_raises(ValueError): tg.to_praat()
def test_to_praat_ends_after(self): mock_tier = mock.Mock() mock_tier.xmin = 0 mock_tier.xmax = 1 tg = TextGrid(0, 0.5, [mock_tier]) with assert_raises(ValueError): tg.to_praat()
def test_to_praat_with_path(self): mock_tier = mock.Mock() mock_tier.xmin = 0 mock_tier.xmax = 1 mock_tier.to_praat.return_value = 'a tier' tg = TextGrid(0, 1, [mock_tier, mock_tier]) tg.to_praat('tests/files/output.TextGrid') with open('tests/files/output.TextGrid') as output_file: res = output_file.read() assert_equal(res, ('"ooTextFile"\n"TextGrid"\n' '0 to 1 seconds <exists>\n' '2 tiers\n\na tier\n\na tier'))
def test_to_praat_with_path(self): mock_tier = mock.Mock() mock_tier.xmin = 0 mock_tier.xmax = 1 mock_tier.to_praat.return_value = 'a tier' tg = TextGrid(0, 1, [mock_tier, mock_tier]) tg.to_praat('test/files/output.TextGrid') with open('test/files/output.TextGrid') as output_file: res = output_file.read() assert_equal(res, ('"ooTextFile"\n"TextGrid"\n' '0 to 1 seconds <exists>\n' '2 tiers\n\na tier\n\na tier'))
def test_to_praat(self): mock_tier = mock.Mock() mock_tier.xmin = 0 mock_tier.xmax = 1 mock_tier.to_praat.return_value = 'a tier' tg = TextGrid(0, 1, [mock_tier, mock_tier]) res = tg.to_praat() assert_equal(res, ('"ooTextFile"\n"TextGrid"\n' '0 to 1 seconds <exists>\n' '2 tiers\n\na tier\n\na tier'))