File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 1
1
import io
2
2
import os
3
+ import shutil
4
+ import tempfile
3
5
import unittest
4
6
try :
5
7
import urllib .request as urllib2
@@ -51,6 +53,12 @@ def setUp(self):
51
53
</odML>
52
54
"""
53
55
56
+ self .tmp_dir = None
57
+
58
+ def tearDown (self ):
59
+ if self .tmp_dir and os .path .exists (self .tmp_dir ):
60
+ shutil .rmtree (self .tmp_dir )
61
+
54
62
@contextmanager
55
63
def assertNotRaises (self , exc_type ):
56
64
try :
@@ -561,3 +569,20 @@ def test_convert_json_file(self):
561
569
prop = sec .find ("property" )
562
570
self .assertIsNotNone (prop .find ("name" ))
563
571
self .assertIsNotNone (prop .find ("value" ))
572
+
573
+ def test_write_to_file (self ):
574
+ infile = os .path .join (self .basepath , "version_conversion.xml" )
575
+ self .tmp_dir = tempfile .mkdtemp (suffix = ".odml" )
576
+
577
+ # Test write to named file
578
+ outfile = os .path .join (self .tmp_dir , "test.odml" )
579
+ self .VC (infile ).write_to_file (outfile )
580
+
581
+ self .assertTrue (os .path .exists (outfile ))
582
+
583
+ # Test file extension append write to named file w/o file extension
584
+ outfile = os .path .join (self .tmp_dir , "test" )
585
+ self .VC (infile ).write_to_file (outfile )
586
+
587
+ self .assertFalse (os .path .exists (outfile ))
588
+ self .assertTrue (os .path .exists ("%s.xml" % outfile ))
You can’t perform that action at this time.
0 commit comments