Best Python code snippet using avocado_python
test_phonemizer.py
Source:test_phonemizer.py
...43 def test_name(self):44 self.assertEqual(self.phonemizer.name(), "espeak")45 def test_get_supported_languages(self):46 self.assertIsInstance(self.phonemizer.supported_languages(), dict)47 def test_get_version(self):48 self.assertIsInstance(self.phonemizer.version(), str)49 def test_is_available(self):50 self.assertTrue(self.phonemizer.is_available())51class TestEspeakNgPhonemizer(unittest.TestCase):52 def setUp(self):53 self.phonemizer = ESpeak(language="en-us", backend="espeak-ng")54 for text, ph in zip(EXAMPLE_TEXTs, EXPECTED_ESPEAKNG_PHONEMES):55 phonemes = self.phonemizer.phonemize(text)56 self.assertEqual(phonemes, ph)57 # multiple punctuations58 text = "Be a voice, not an! echo?"59 gt = "biË É vËÉɪs, nËÉËt æn! ËÉkoÊ?"60 output = self.phonemizer.phonemize(text, separator="|")61 output = output.replace("|", "")62 self.assertEqual(output, gt)63 # not ending with punctuation64 text = "Be a voice, not an! echo"65 gt = "biË É vËÉɪs, nËÉËt æn! ËÉkoÊ"66 output = self.phonemizer.phonemize(text, separator="")67 self.assertEqual(output, gt)68 # extra space after the sentence69 text = "Be a voice, not an! echo. "70 gt = "biË É vËÉɪs, nËÉËt æn! ËÉkoÊ."71 output = self.phonemizer.phonemize(text, separator="")72 self.assertEqual(output, gt)73 def test_name(self):74 self.assertEqual(self.phonemizer.name(), "espeak")75 def test_get_supported_languages(self):76 self.assertIsInstance(self.phonemizer.supported_languages(), dict)77 def test_get_version(self):78 self.assertIsInstance(self.phonemizer.version(), str)79 def test_is_available(self):80 self.assertTrue(self.phonemizer.is_available())81class TestGruutPhonemizer(unittest.TestCase):82 def setUp(self):83 self.phonemizer = Gruut(language="en-us", use_espeak_phonemes=True, keep_stress=False)84 self.EXPECTED_PHONEMES = [85 "ɹ|i|Ë|s|É|n|t| ɹ|áµ»|s|É|Ë|t|Ê| æ|ɾ| h|É|Ë|ɹ|v|É|d| h|É|z| Ê|o|Ê|n| m|É|d|áµ»|t|e|ɪ|ɾ|ɪ|Å",86 "f|É|Ë|ɹ| æ|z| l|ɪ|ɾ|É|l| æ|z| e|ɪ|t| w|i|Ë|k|s| k|æ|Å| æ|k|t|Ê|u|Ë|É|l|i| ɪ|Å|k|ɹ|i|Ë|s, ð|É| É¡|ɹ|e|ɪ| m|æ|ɾ|É",87 "ɪ|n| ð|É| p|É|Ë|ɹ|t|s| Ê|v| ð|É| b|ɹ|e|ɪ|n| ɹ|áµ»|s|p|É|Ë|n|s|áµ»|b|É|l",88 "f|É|Ë|ɹ| ɪ|m|o|Ê|Ê|É|n|É|l| ɹ|É|É¡|j|Ê|l|e|ɪ|Ê|É|n| æ|n|d| l|É|Ë|n|ɪ|Å!",89 ]90 def test_phonemize(self):91 for text, ph in zip(EXAMPLE_TEXTs, self.EXPECTED_PHONEMES):92 phonemes = self.phonemizer.phonemize(text, separator="|")93 self.assertEqual(phonemes, ph)94 # multiple punctuations95 text = "Be a voice, not an! echo?"96 gt = "biË É vÉɪs, nÉËt Én! ÉkoÊ?"97 output = self.phonemizer.phonemize(text, separator="|")98 output = output.replace("|", "")99 self.assertEqual(output, gt)100 # not ending with punctuation101 text = "Be a voice, not an! echo"102 gt = "biË É vÉɪs, nÉËt Én! ÉkoÊ"103 output = self.phonemizer.phonemize(text, separator="")104 self.assertEqual(output, gt)105 # extra space after the sentence106 text = "Be a voice, not an! echo. "107 gt = "biË É vÉɪs, nÉËt Én! ÉkoÊ."108 output = self.phonemizer.phonemize(text, separator="")109 self.assertEqual(output, gt)110 def test_name(self):111 self.assertEqual(self.phonemizer.name(), "gruut")112 def test_get_supported_languages(self):113 self.assertIsInstance(self.phonemizer.supported_languages(), list)114 def test_get_version(self):115 self.assertIsInstance(self.phonemizer.version(), str)116 def test_is_available(self):117 self.assertTrue(self.phonemizer.is_available())118class TestJA_JPPhonemizer(unittest.TestCase):119 def setUp(self):120 self.phonemizer = JA_JP_Phonemizer()121 self._TEST_CASES = """122 ã©ã¡ãã«è¡ãã¾ããï¼/dochiraniikimasuka?123 ä»æ¥ã¯æ¸©æ³ã«ãè¡ãã¾ãã/kyo:waoNseNni,ikimasu.124 ãAããããZãã¾ã§ã§ãã/e:karazeqtomadedesu.125 ããã§ããï¼/so:desune!126 ã¯ã¸ã©ã¯åºä¹³é¡ã§ãã/kujirawahonyu:ruidesu.127 ã´ã£ãã£ãªãè¦ã¾ãã/bidioomimasu.128 ä»æ¥ã¯ï¼æ22æ¥ã§ã/kyo:wahachigatsuniju:ninichidesu129 xyzã¨Î±Î²Î³/eqkusuwaizeqtotoarufabe:tagaNma130 å¤æ®µã¯$12.34ã§ã/nedaNwaju:niteNsaNyoNdorudesu131 """132 def test_phonemize(self):133 for line in self._TEST_CASES.strip().split("\n"):134 text, phone = line.split("/")135 self.assertEqual(self.phonemizer.phonemize(text, separator=""), phone)136 def test_name(self):137 self.assertEqual(self.phonemizer.name(), "ja_jp_phonemizer")138 def test_get_supported_languages(self):139 self.assertIsInstance(self.phonemizer.supported_languages(), dict)140 def test_get_version(self):141 self.assertIsInstance(self.phonemizer.version(), str)142 def test_is_available(self):143 self.assertTrue(self.phonemizer.is_available())144class TestZH_CN_Phonemizer(unittest.TestCase):145 def setUp(self):146 self.phonemizer = ZH_CN_Phonemizer()147 self._TEST_CASES = ""148 def test_phonemize(self):149 # TODO: implement ZH phonemizer tests150 pass151 def test_name(self):152 self.assertEqual(self.phonemizer.name(), "zh_cn_phonemizer")153 def test_get_supported_languages(self):154 self.assertIsInstance(self.phonemizer.supported_languages(), dict)155 def test_get_version(self):156 self.assertIsInstance(self.phonemizer.version(), str)157 def test_is_available(self):...
test_setup.py
Source:test_setup.py
...48 version_file.write(cls.version_data)49class TestValidVersion(TestCase):50 """Test a valid version number with an epoch."""51 version_data = "__version__ = '1.2.3'\n"52 def test_get_version(self):53 self.assertEqual('1.2.3', get_version("dummy"))54class TestEpochVersion(TestCase):55 """Test a valid version number with an epoch."""56 version_data = "__version__ = '2!2016.1.27rc2'\n"57 def test_get_version(self):58 self.assertEqual('2!2016.1.27rc2', get_version("dummy"))59class TestDoubleQuotes(TestCase):60 """Test a version number enclosed by double quotes."""61 version_data = '__version__ = "1.2.3"\n'62 def test_get_version(self):63 self.assertEqual('1.2.3', get_version("dummy"))64class TestTripleQuotes(TestCase):65 """Test a version number enclosed by triple quotes."""66 version_data = '__version__ = """1.2.3"""\n'67 def test_get_version(self):68 self.assertEqual('1.2.3', get_version("dummy"))69class TestRawString(TestCase):70 """Test a version number enclosed by a raw quoted string."""71 version_data = "__version__ = r'1.2.3'\n"72 def test_get_version(self):73 self.assertEqual('1.2.3', get_version("dummy"))74class TestMismatchedQuotes(TestCase):75 """Test a version number enclosed by mismatched quotes.76 In this case the version number is invalid and get_version77 returns None.78 """79 version_data = '__version__ = "1.2.3\'\n'80 def test_get_version(self):81 self.assertIsNone(get_version("dummy"))82if __name__ == "__main__":...
test_version.py
Source:test_version.py
...16# under the License.17# 18from version import get_version19from pytest_mock import mocker20def test_get_version(mocker):21 mock_check_output = mocker.patch("version.check_output")22 mock_check_output.return_value = "v0.4.2-32-ga2ccd08"23 version = get_version()24 assert version == "0.4.2.post32"25def test_get_version(mocker):26 mock_check_output = mocker.patch("version.check_output")27 mock_check_output.return_value = "v0.4.2-32-ga2ccd08-dirty"28 version = get_version()...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!