summaryrefslogtreecommitdiff
path: root/tests/plugins/yamlrdr.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/plugins/yamlrdr.py')
-rw-r--r--tests/plugins/yamlrdr.py69
1 files changed, 14 insertions, 55 deletions
diff --git a/tests/plugins/yamlrdr.py b/tests/plugins/yamlrdr.py
index 47f02ba..b9a99a2 100644
--- a/tests/plugins/yamlrdr.py
+++ b/tests/plugins/yamlrdr.py
@@ -16,27 +16,21 @@ class TestYamlReader(ChrysalideTestCase):
super(TestYamlReader, cls).setUpClass()
- cls._simple_map = tempfile.NamedTemporaryFile()
-
- cls._simple_map_data = b'''
+ cls._simple_map_data = '''
a: av
b: bv
c: cv
'''
- cls._simple_seq = tempfile.NamedTemporaryFile()
-
- cls._simple_seq_data = b'''
+ cls._simple_seq_data = '''
- a: av
- b: bv
- c: cv
'''
- cls._nested = tempfile.NamedTemporaryFile()
-
- cls._nested_data = b'''
+ cls._nested_data = '''
root:
a: v0
b: v1
@@ -52,9 +46,7 @@ root:
'''
- cls._mixed = tempfile.NamedTemporaryFile()
-
- cls._mixed_data = b'''
+ cls._mixed_data = '''
root:
- a: av
aa: aav
@@ -65,39 +57,6 @@ root:
'''
- tmp = [
- [ cls._simple_map, cls._simple_map_data ],
- [ cls._simple_seq, cls._simple_seq_data ],
- [ cls._nested, cls._nested_data ],
- [ cls._mixed, cls._mixed_data ],
- ]
-
- for f, d in tmp:
-
- f.write(d)
- f.flush()
-
- cls.log('Using temporary file "%s"' % f.name)
-
-
- @classmethod
- def tearDownClass(cls):
-
- super(TestYamlReader, cls).tearDownClass()
-
- tmp = [
- cls._simple_map,
- cls._simple_seq,
- cls._nested,
- cls._mixed,
- ]
-
- for f in tmp:
-
- cls.log('Delete file "%s"' % f.name)
-
- f.close()
-
def testSimpleYamlContent(self):
"""Validate Yaml content readers."""
@@ -133,43 +92,43 @@ root:
return desc
- reader = YamlReader.new_from_path(self._simple_map.name)
+ reader = YamlReader(text=self._simple_map_data)
self.assertIsNotNone(reader)
self.assertIsNotNone(reader.tree)
fulldesc = _build_node_desc(reader.tree.root, '')
- self.assertEqual('\n' + fulldesc + '\n', self._simple_map_data.decode('ascii'))
+ self.assertEqual('\n' + fulldesc + '\n', self._simple_map_data)
- reader = YamlReader.new_from_path(self._simple_seq.name)
+ reader = YamlReader(text=self._simple_seq_data)
self.assertIsNotNone(reader)
self.assertIsNotNone(reader.tree)
fulldesc = _build_node_desc(reader.tree.root, '')
- self.assertEqual('\n' + fulldesc + '\n', self._simple_seq_data.decode('ascii'))
+ self.assertEqual('\n' + fulldesc + '\n', self._simple_seq_data)
- reader = YamlReader.new_from_path(self._nested.name)
+ reader = YamlReader(text=self._nested_data)
self.assertIsNotNone(reader)
self.assertIsNotNone(reader.tree)
fulldesc = _build_node_desc(reader.tree.root, '')
- self.assertEqual('\n' + fulldesc + '\n', self._nested_data.decode('ascii'))
+ self.assertEqual('\n' + fulldesc + '\n', self._nested_data)
- reader = YamlReader.new_from_path(self._mixed.name)
+ reader = YamlReader(text=self._mixed_data)
self.assertIsNotNone(reader)
self.assertIsNotNone(reader.tree)
fulldesc = _build_node_desc(reader.tree.root, '')
- self.assertEqual('\n' + fulldesc + '\n', self._mixed_data.decode('ascii'))
+ self.assertEqual('\n' + fulldesc + '\n', self._mixed_data)
def testSimpleYamlContentFinder(self):
"""Validate Yaml nested content search."""
- reader = YamlReader.new_from_path(self._nested.name)
+ reader = YamlReader(text=self._nested_data)
self.assertIsNotNone(reader)
found = reader.tree.find_by_path('/root/sub')
@@ -234,7 +193,7 @@ root:
def testMixedYamlContentFinder(self):
"""Validate Yaml mixed content search."""
- reader = YamlReader.new_from_path(self._mixed.name)
+ reader = YamlReader(text=self._mixed_data)
self.assertIsNotNone(reader)
found = reader.tree.find_by_path('/root')