= commited on
Commit
8ecada8
·
1 Parent(s): 97fe725

added more tests

Browse files
deep_translator/tests/test_linguee.py CHANGED
@@ -8,7 +8,7 @@ from deep_translator import exceptions, LingueeTranslator
8
 
9
  @pytest.fixture
10
  def linguee():
11
- return LingueeTranslator(target='fr')
12
 
13
 
14
  def test_content(linguee):
 
8
 
9
  @pytest.fixture
10
  def linguee():
11
+ return LingueeTranslator(source="en", target='fr')
12
 
13
 
14
  def test_content(linguee):
deep_translator/tests/test_mymemory.py CHANGED
@@ -8,7 +8,7 @@ from deep_translator import exceptions, GoogleTranslator, MyMemoryTranslator
8
 
9
  @pytest.fixture
10
  def mymemory():
11
- return MyMemoryTranslator(target='fr')
12
 
13
 
14
  def test_content(mymemory):
 
8
 
9
  @pytest.fixture
10
  def mymemory():
11
+ return MyMemoryTranslator(source="en", target='fr')
12
 
13
 
14
  def test_content(mymemory):
deep_translator/tests/test_pons.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ """Tests for `deep_translator` package."""
4
+
5
+ import pytest
6
+ from deep_translator import exceptions, PonsTranslator
7
+
8
+
9
+ @pytest.fixture
10
+ def pons():
11
+ return PonsTranslator(source="en", target='fr')
12
+
13
+
14
+ def test_content(pons):
15
+ """Sample pytest test function with the pytest fixture as an argument."""
16
+ # from bs4 import BeautifulSoup
17
+ # assert 'GitHub' in BeautifulSoup(response.content).title.string
18
+ assert pons.translate(word='good') is not None
19
+
20
+
21
+ def test_inputs():
22
+ with pytest.raises(exceptions.LanguageNotSupportedException):
23
+ pons(source="", target="")
24
+
25
+ with pytest.raises(exceptions.LanguageNotSupportedException):
26
+ pons(source="auto", target="nothing")
27
+
28
+
29
+ def test_payload(pons):
30
+
31
+ with pytest.raises(exceptions.NotValidPayload):
32
+ pons.translate("")
33
+
34
+ with pytest.raises(exceptions.NotValidPayload):
35
+ pons.translate(123)
36
+
37
+ with pytest.raises(exceptions.NotValidPayload):
38
+ pons.translate({})
39
+
40
+ with pytest.raises(exceptions.NotValidPayload):
41
+ pons.translate([])