def test_no_text_parts(tmp_path): """Raises AssertionError on no content to send to API (no text_parts)""" text = " ..,\n" with pytest.raises(AssertionError): filename = tmp_path / 'no_content.txt' tts = NaverTTS(text=text) tts.save(filename)
def test_save(tmp_path): """Save .mp3 file successfully""" filename = tmp_path / 'save.mp3' # Create NaverTTS and save tts = NaverTTS(text='test') tts.save(filename) # Check if file created is > 2k assert filename.stat().st_size > 2000
def test_TTS(tmp_path, lang): """Test all supported languages and file save.""" text = "This is a test" """Create output .mp3 file successfully""" for speed in ("normal", "slow", "fast"): filename = tmp_path / "test_{}_.mp3".format(lang) # Create NaverTTS and save tts = NaverTTS(text=text, lang=lang, speed=speed) tts.save(filename) # Check if files created is > 2k assert filename.stat().st_size > 2000
def test_WebRequest(tmp_path): """Test Web Requests""" text = "Lorem ipsum" """Raise NaverTTSError on unsupported language (without language check)""" lang = 'xx' check = False with pytest.raises(ValueError): filename = tmp_path / 'xx.txt' # Create NaverTTS tts = NaverTTS(text=text, lang=lang, lang_check=check) tts.save(filename)
def test_unsupported_language_check(): """Raise ValueError on unsupported language (with language check)""" lang = 'xx' text = "Lorem ipsum" check = True with pytest.raises(ValueError): NaverTTS(text=text, lang=lang, lang_check=check)
def test_bad_fp_type(): """Raise TypeError if fp is not a file-like object (no .write())""" # Create gTTS and save tts = NaverTTS(text='test') with pytest.raises(TypeError): tts.write_to_fp(5)
def test_empty_string(): """Raise AssertionError on empty string""" text = "" with pytest.raises(AssertionError): NaverTTS(text=text)