Esempio n. 1
0
 def test_safe_write_files(self):
     file1 = os.path.join('foo', 'bar')
     file2 = os.path.join('foo', 'baz')
     newfiles = {file1: 'foobar', file2: 'barfoo'}
     try:
         rootdir = tempfile.mkdtemp()
         _safe_write_files(newfiles, rootdir)
         self.assertTrue(os.path.isfile(os.path.join(rootdir, file1)))
         self.assertTrue(os.path.isfile(os.path.join(rootdir, file2)))
         self.assertRaises(ValueError, _safe_write_files, newfiles, rootdir)
     finally:
         shutil.rmtree(rootdir)
Esempio n. 2
0
 def test_safe_write_files(self):
     file1 = os.path.join('foo', 'bar')
     file2 = os.path.join('foo', 'baz')
     newfiles = {file1: 'foobar', file2: 'barfoo'}
     try:
         rootdir = tempfile.mkdtemp()
         _safe_write_files(newfiles, rootdir)
         self.assertTrue(os.path.isfile(os.path.join(rootdir, file1)))
         self.assertTrue(os.path.isfile(os.path.join(rootdir, file2)))
         self.assertRaises(ValueError, _safe_write_files, newfiles, rootdir)
     finally:
         shutil.rmtree(rootdir)