class TestSpeakerWithSay(TestCase): def setUp(self): self.speaker = Speaker(service='say') def test_create(self): self.assertIsInstance(self.speaker, Speaker) @patch('os.system') def test_speak(self, mock_os): text = 'Text for testing with say' self.speaker.speak(text) mock_os.assert_has_calls([call("say '{text}'".format(text=text))])
def __init__(self, listener=None, speaker=None): self.__listener = listener or Listener( service='sphinx') # sphinx | google self.__speaker = speaker or Speaker(service='say') # say | espeak
def setUp(self): self.speaker = Speaker(service='say')
def test_create(self): with self.assertRaises(NotImplementedError) as context: Speaker() self.assertIn('No available text to speech service chosen.', str(context.exception))
def setUp(self): self.speaker = Speaker(service='espeak')