forked from hedyorg/hedy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_translation_level_16.py
47 lines (34 loc) · 1.45 KB
/
test_translation_level_16.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import hedy
from test_level_01 import HedyTester
import hedy_translation
import textwrap
# tests should be ordered as follows:
# * Translation from English to Dutch
# * Translation from Dutch to English
# * Translation to several languages
# * Error handling
class TestsTranslationLevel16(HedyTester):
level = 16
def test_assign_list_english_dutch(self):
code = "fruit = ['appel', 'banaan', 'kers']"
result = hedy_translation.translate_keywords(code, from_lang="en", to_lang="nl", level=self.level)
expected = "fruit = ['appel', 'banaan', 'kers']"
self.assertEqual(expected, result)
def test_access_list_english_dutch(self):
code = textwrap.dedent("""\
fruit = ['appel', 'banaan', 'kers']
print fruit[2]""")
result = hedy_translation.translate_keywords(code, from_lang="en", to_lang="nl", level=self.level)
expected = textwrap.dedent("""\
fruit = ['appel', 'banaan', 'kers']
print fruit[2]""")
self.assertEqual(expected, result)
def test_access_list_random_dutch_english(self):
code = textwrap.dedent("""\
fruit = ['appel', 'banaan', 'kers']
print fruit[willekeurig]""")
result = hedy_translation.translate_keywords(code, from_lang="nl", to_lang="en", level=self.level)
expected = textwrap.dedent("""\
fruit = ['appel', 'banaan', 'kers']
print fruit[random]""")
self.assertEqual(expected, result)