1
2
3
4 from translate.storage import test_base
5 from translate.storage import wordfast as wf
6
8
10 """Setting and getting times set using a timestring"""
11 wftime = wf.WordfastTime()
12 assert wftime.timestring == None
13 wftime.timestring = "19710820~050000"
14 assert wftime.time[:6] == (1971, 8, 20, 5, 0, 0)
15
17 """Setting and getting times set using time tuple"""
18 wftime = wf.WordfastTime()
19 assert wftime.time == None
20 wftime.time = (1999, 3, 27)
21 wftime.timestring = "19990327~000000"
22
24 UnitClass = wf.WordfastUnit
25
27 """Wordfast files need to perform magic with escapes.
28
29 Wordfast does not accept line breaks in its TM (even though they would be
30 valid in CSV) thus we turn \\n into \n and reimplement the base class test but
31 eliminate a few of the actual tests.
32 """
33 unit = self.unit
34 specials = ['\\"', '\\ ',
35 '\\\n', '\\\t', '\\\\r', '\\\\"']
36 for special in specials:
37 unit.source = special
38 print "unit.source:", repr(unit.source) + '|'
39 print "special:", repr(special) + '|'
40 assert unit.source == special
41
43 """Check handling of &'NN; style escaping"""
44 def compare(real, escaped):
45 unit = self.UnitClass(real)
46 print real.encode('utf-8'), unit.source.encode('utf-8')
47 assert unit.source == real
48 assert unit.dict['source'] == escaped
49 unit.target = real
50 assert unit.target == real
51 assert unit.dict['target'] == escaped
52 for escaped, real in wf.WF_ESCAPE_MAP[:16]:
53 compare(real, escaped)
54
55 unit = self.UnitClass("Open &File. ’n Probleem.")
56 assert unit.dict['source'] == "Open &'26;File. &'92;n Probleem."
57
59 """Wordfast does not like real newlines"""
60 unit = self.UnitClass("One\nTwo")
61 assert unit.dict['source'] == "One\\nTwo"
62
64 """Check that we can set the target language"""
65 unit = self.UnitClass("Test")
66 unit.targetlang = "AF"
67 assert unit.dict['target-lang'] == 'AF'
68
76
79