def test_path_good(): espeak = EspeakBackend.library() try: EspeakBackend.set_library(None) assert espeak == EspeakBackend.library() library = EspeakWrapper().library_path EspeakBackend.set_library(library) test_english() # restore the espeak path to default finally: EspeakBackend.set_library(None)
def test_path_bad(): try: # corrupt the default espeak path, try to use python executable instead binary = shutil.which('python') EspeakBackend.set_library(binary) with pytest.raises(RuntimeError): EspeakBackend('en-us') with pytest.raises(RuntimeError): EspeakBackend.version() EspeakBackend.set_library(__file__) with pytest.raises(RuntimeError): EspeakBackend('en-us') # restore the espeak path to default finally: EspeakBackend.set_library(None)