Skip to content

Commit 8520a2b

Browse files
committed
[test/versionConv] Refactor VC usage in file
1 parent 9280d6e commit 8520a2b

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

test/test_version_converter.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@
1717
except NameError:
1818
unicode = str
1919

20-
VC = VersionConverter
21-
2220

2321
class TestVersionConverter(unittest.TestCase):
2422
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+
2528
self.doc = """
2629
<odML version="1">
2730
<date>2008-07-07</date>
@@ -72,7 +75,7 @@ def test_replace_same_name_entites(self):
7275
self.assertEqual(props_names[0], props_names[1])
7376

7477
tree = ET.ElementTree(root)
75-
tree = VC._replace_same_name_entities(tree)
78+
tree = self.VC._replace_same_name_entities(tree)
7679
root = tree.getroot()
7780
sec_names = []
7881
sec_elems = []
@@ -90,7 +93,7 @@ def test_replace_same_name_entites(self):
9093

9194
def test_convert_odml_file(self):
9295
with self.assertRaises(Exception) as exc:
93-
VC("/not_valid_path").convert()
96+
self.VC("/not_valid_path").convert()
9497
self.assertIn("Cannot parse provided file", str(exc.exception))
9598

9699
root = ET.fromstring(self.doc)
@@ -106,7 +109,7 @@ def test_convert_odml_file(self):
106109
self.assertEqual(prop.find("type"), None)
107110

108111
file = io.StringIO(unicode(self.doc))
109-
vc = VC(file)
112+
vc = self.VC(file)
110113
tree = vc._convert(vc._parse_xml())
111114
root = tree.getroot()
112115
prop = root.find("section").find("property")
@@ -173,7 +176,7 @@ def test_convert_odml_file_document(self):
173176
""" % local_old_url
174177

175178
file = io.StringIO(unicode(doc))
176-
vc = VC(file)
179+
vc = self.VC(file)
177180
conv_doc = vc._convert(vc._parse_xml())
178181
root = conv_doc.getroot()
179182
# Test export of Document tags, repository is excluded
@@ -189,15 +192,15 @@ def test_convert_odml_file_document(self):
189192

190193
# Test warning message on non-importable repository
191194
file = io.StringIO(unicode(invalid_repo_doc))
192-
vc = VC(file)
195+
vc = self.VC(file)
193196
conv_doc = vc._convert(vc._parse_xml())
194197
root = conv_doc.getroot()
195198
self.assertEqual(root.findall("repository")[0].text, "Unresolvable")
196199
self.assertIn("not odML v1.1 compatible", vc.conversion_log[0])
197200

198201
# Test warning message on old repository
199202
file = io.StringIO(unicode(old_repo_doc))
200-
vc = VC(file)
203+
vc = self.VC(file)
201204
conv_doc = vc._convert(vc._parse_xml())
202205
root = conv_doc.getroot()
203206
self.assertEqual(root.findall("repository")[0].text, local_old_url)
@@ -256,7 +259,7 @@ def test_convert_odml_file_section(self):
256259
""" % (local_url, local_url)
257260

258261
file = io.StringIO(unicode(doc))
259-
vc = VC(file)
262+
vc = self.VC(file)
260263
conv_doc = vc._convert(vc._parse_xml())
261264
root = conv_doc.getroot()
262265

@@ -301,7 +304,7 @@ def test_convert_odml_file_section(self):
301304
</odML>""" % local_old_url
302305

303306
file = io.StringIO(unicode(doc))
304-
vc = VC(file)
307+
vc = self.VC(file)
305308
conv_doc = vc._convert(vc._parse_xml())
306309
sec = conv_doc.getroot().findall("section")
307310
self.assertEqual(sec[0].find("repository").text, local_old_url)
@@ -317,7 +320,7 @@ def test_convert_odml_file_section(self):
317320
</odML>""" % local_old_url
318321

319322
file = io.StringIO(unicode(doc))
320-
vc = VC(file)
323+
vc = self.VC(file)
321324
conv_doc = vc._convert(vc._parse_xml())
322325
sec = conv_doc.getroot().findall("section")
323326

@@ -358,7 +361,7 @@ def test_convert_odml_file_property(self):
358361
"""
359362

360363
file = io.StringIO(unicode(doc))
361-
vc = VC(file)
364+
vc = self.VC(file)
362365
conv_doc = vc._convert(vc._parse_xml())
363366
root = conv_doc.getroot()
364367
sec = root.findall("section")
@@ -461,7 +464,7 @@ def test_convert_odml_file_value(self):
461464
"""
462465

463466
file = io.StringIO(unicode(doc))
464-
vc = VC(file)
467+
vc = self.VC(file)
465468
conv_doc = vc._convert(vc._parse_xml())
466469
root = conv_doc.getroot()
467470
sec = root.find("section")

0 commit comments

Comments
 (0)