예제 #1
0
def test_path_good():
    espeak = EspeakBackend.espeak_path()
    try:
        EspeakBackend.set_espeak_path(None)
        assert espeak == EspeakBackend.espeak_path()

        binary = distutils.spawn.find_executable('espeak')
        EspeakBackend.set_espeak_path(binary)

        test_english()

    # restore the espeak path to default
    finally:
        EspeakBackend.set_espeak_path(espeak)
예제 #2
0
def test_path_bad():
    espeak = EspeakBackend.espeak_path()
    try:
        # corrupt the default espeak path, try to use python executable instead
        binary = distutils.spawn.find_executable('python')
        EspeakBackend.set_espeak_path(binary)

        with pytest.raises(RuntimeError):
            EspeakBackend('en-us').phonemize('hello')
        with pytest.raises(RuntimeError):
            EspeakBackend.version()

        with pytest.raises(ValueError):
            EspeakBackend.set_espeak_path(__file__)

    # restore the espeak path to default
    finally:
        EspeakBackend.set_espeak_path(espeak)