File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ """
2+ This module supplies basic tests for the odml.dict_parser.DictReader
3+ reading from yaml files.
4+ """
5+
16import os
7+ import tempfile
28import unittest
39import yaml
410
@@ -14,6 +20,25 @@ def setUp(self):
1420
1521 self .yaml_reader = dict_parser .DictReader ()
1622
23+ dir_name = "odml_%s" % os .path .basename (os .path .splitext (__file__ )[0 ])
24+ tmp_dir_path = os .path .join (tempfile .gettempdir (), dir_name )
25+
26+ if not os .path .exists (tmp_dir_path ):
27+ os .mkdir (tmp_dir_path )
28+
29+ self .tmp_dir_path = tmp_dir_path
30+
31+ def _prepare_doc (self , file_name , file_content ):
32+ file_path = os .path .join (self .tmp_dir_path , file_name )
33+
34+ with open (file_path , "w" ) as dump_file :
35+ dump_file .write (file_content )
36+
37+ with open (file_path ) as raw_data :
38+ parsed_doc = yaml .safe_load (raw_data )
39+
40+ return parsed_doc
41+
1742 def test_missing_root (self ):
1843 filename = "missing_root.yaml"
1944 message = "Missing root element"
You can’t perform that action at this time.
0 commit comments