17
17
except NameError :
18
18
unicode = str
19
19
20
- VC = VersionConverter
21
-
22
20
23
21
class TestVersionConverter (unittest .TestCase ):
24
22
def setUp (self ):
23
+ dir_path = os .path .dirname (os .path .realpath (__file__ ))
24
+ self .basepath = os .path .join (dir_path , "resources" )
25
+
26
+ self .VC = VersionConverter
27
+
25
28
self .doc = """
26
29
<odML version="1">
27
30
<date>2008-07-07</date>
@@ -72,7 +75,7 @@ def test_replace_same_name_entites(self):
72
75
self .assertEqual (props_names [0 ], props_names [1 ])
73
76
74
77
tree = ET .ElementTree (root )
75
- tree = VC ._replace_same_name_entities (tree )
78
+ tree = self . VC ._replace_same_name_entities (tree )
76
79
root = tree .getroot ()
77
80
sec_names = []
78
81
sec_elems = []
@@ -90,7 +93,7 @@ def test_replace_same_name_entites(self):
90
93
91
94
def test_convert_odml_file (self ):
92
95
with self .assertRaises (Exception ) as exc :
93
- VC ("/not_valid_path" ).convert ()
96
+ self . VC ("/not_valid_path" ).convert ()
94
97
self .assertIn ("Cannot parse provided file" , str (exc .exception ))
95
98
96
99
root = ET .fromstring (self .doc )
@@ -106,7 +109,7 @@ def test_convert_odml_file(self):
106
109
self .assertEqual (prop .find ("type" ), None )
107
110
108
111
file = io .StringIO (unicode (self .doc ))
109
- vc = VC (file )
112
+ vc = self . VC (file )
110
113
tree = vc ._convert (vc ._parse_xml ())
111
114
root = tree .getroot ()
112
115
prop = root .find ("section" ).find ("property" )
@@ -173,7 +176,7 @@ def test_convert_odml_file_document(self):
173
176
""" % local_old_url
174
177
175
178
file = io .StringIO (unicode (doc ))
176
- vc = VC (file )
179
+ vc = self . VC (file )
177
180
conv_doc = vc ._convert (vc ._parse_xml ())
178
181
root = conv_doc .getroot ()
179
182
# Test export of Document tags, repository is excluded
@@ -189,15 +192,15 @@ def test_convert_odml_file_document(self):
189
192
190
193
# Test warning message on non-importable repository
191
194
file = io .StringIO (unicode (invalid_repo_doc ))
192
- vc = VC (file )
195
+ vc = self . VC (file )
193
196
conv_doc = vc ._convert (vc ._parse_xml ())
194
197
root = conv_doc .getroot ()
195
198
self .assertEqual (root .findall ("repository" )[0 ].text , "Unresolvable" )
196
199
self .assertIn ("not odML v1.1 compatible" , vc .conversion_log [0 ])
197
200
198
201
# Test warning message on old repository
199
202
file = io .StringIO (unicode (old_repo_doc ))
200
- vc = VC (file )
203
+ vc = self . VC (file )
201
204
conv_doc = vc ._convert (vc ._parse_xml ())
202
205
root = conv_doc .getroot ()
203
206
self .assertEqual (root .findall ("repository" )[0 ].text , local_old_url )
@@ -256,7 +259,7 @@ def test_convert_odml_file_section(self):
256
259
""" % (local_url , local_url )
257
260
258
261
file = io .StringIO (unicode (doc ))
259
- vc = VC (file )
262
+ vc = self . VC (file )
260
263
conv_doc = vc ._convert (vc ._parse_xml ())
261
264
root = conv_doc .getroot ()
262
265
@@ -301,7 +304,7 @@ def test_convert_odml_file_section(self):
301
304
</odML>""" % local_old_url
302
305
303
306
file = io .StringIO (unicode (doc ))
304
- vc = VC (file )
307
+ vc = self . VC (file )
305
308
conv_doc = vc ._convert (vc ._parse_xml ())
306
309
sec = conv_doc .getroot ().findall ("section" )
307
310
self .assertEqual (sec [0 ].find ("repository" ).text , local_old_url )
@@ -317,7 +320,7 @@ def test_convert_odml_file_section(self):
317
320
</odML>""" % local_old_url
318
321
319
322
file = io .StringIO (unicode (doc ))
320
- vc = VC (file )
323
+ vc = self . VC (file )
321
324
conv_doc = vc ._convert (vc ._parse_xml ())
322
325
sec = conv_doc .getroot ().findall ("section" )
323
326
@@ -358,7 +361,7 @@ def test_convert_odml_file_property(self):
358
361
"""
359
362
360
363
file = io .StringIO (unicode (doc ))
361
- vc = VC (file )
364
+ vc = self . VC (file )
362
365
conv_doc = vc ._convert (vc ._parse_xml ())
363
366
root = conv_doc .getroot ()
364
367
sec = root .findall ("section" )
@@ -461,7 +464,7 @@ def test_convert_odml_file_value(self):
461
464
"""
462
465
463
466
file = io .StringIO (unicode (doc ))
464
- vc = VC (file )
467
+ vc = self . VC (file )
465
468
conv_doc = vc ._convert (vc ._parse_xml ())
466
469
root = conv_doc .getroot ()
467
470
sec = root .find ("section" )
0 commit comments