Esempio n. 1
0
    def test_detect(self, mock_do_work):
        translator = GoogleTranslator()

        self.assertEqual(translator.detect("test"), mock_do_work.return_value)
        mock_do_work.assert_called_once_with(translator._detect, "test",
                                             "text")

        mock_do_work.reset_mock()

        self.assertEqual(translator.detect("test", output="dict"),
                         mock_do_work.return_value)
        mock_do_work.assert_called_once_with(translator._detect, "test",
                                             "dict")
Esempio n. 2
0
    def test_detect_full(self):
        translator = GoogleTranslator()

        self.assertEqual(translator.detect("hi"), "english")
        self.assertEqual(translator.detect("犬"), "japanese")
        self.assertEqual(translator.detect("σπίτη"), "greek")  # With typo