Exemplo n.º 1
0
    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()
Exemplo n.º 2
0
    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()
Exemplo n.º 3
0
    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()
Exemplo n.º 4
0
    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()
Exemplo n.º 5
0
    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'))
Exemplo n.º 6
0
    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'))
Exemplo n.º 7
0
    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'))
Exemplo n.º 8
0
    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'))