Пример #1
0
 def test_dirty_sandbox(self):
     '''If a sandbox is dirty on arrival, clean it first'''
     path = 'test/tmp/foo'
     with Worker.sandbox(path):
         for name in ['whiz', 'widget', 'bang']:
             with open(os.path.join(path, name), 'w+'):
                 pass
         # Now it's sullied. Clean it up
         self.assertNotEqual(os.listdir(path), [])
         with Worker.sandbox(path):
             self.assertEqual(os.listdir(path), [])
     os.rmdir(path)
Пример #2
0
 def test_dirty_sandbox(self):
     '''If a sandbox is dirty on arrival, clean it first'''
     path = 'test/tmp/foo'
     with Worker.sandbox(path):
         for name in ['whiz', 'widget', 'bang']:
             with open(os.path.join(path, name), 'w+'):
                 pass
         # Now it's sullied. Clean it up
         self.assertNotEqual(os.listdir(path), [])
         with Worker.sandbox(path):
             self.assertEqual(os.listdir(path), [])
     os.rmdir(path)
Пример #3
0
 def test_sandbox_exists(self):
     '''Sandbox creation should not throw an error if the path exists'''
     path = 'test/tmp'
     self.assertEqual(os.listdir(path), [])
     with Worker.sandbox(path):
         pass
     # If we get to this point, the test succeeds
     self.assertTrue(True)
Пример #4
0
 def test_sandbox_exists(self):
     '''Sandbox creation should not throw an error if the path exists'''
     path = 'test/tmp'
     self.assertEqual(os.listdir(path), [])
     with Worker.sandbox(path):
         pass
     # If we get to this point, the test succeeds
     self.assertTrue(True)
Пример #5
0
 def test_sandbox(self):
     '''The sandbox utility should work'''
     path = 'test/tmp/foo'
     self.assertFalse(os.path.exists(path))
     try:
         with Worker.sandbox(path):
             self.assertTrue(os.path.exists(path))
             for name in ['whiz', 'widget', 'bang']:
                 with open(os.path.join(path, name), 'w+'):
                     pass
             # Now raise an exception
             raise ValueError('foo')
     except ValueError:
         pass
     # Make sure the directory has been cleaned
     self.assertEqual(os.listdir(path), [])
     os.rmdir(path)
Пример #6
0
 def test_sandbox(self):
     '''The sandbox utility should work'''
     path = 'test/tmp/foo'
     self.assertFalse(os.path.exists(path))
     try:
         with Worker.sandbox(path):
             self.assertTrue(os.path.exists(path))
             for name in ['whiz', 'widget', 'bang']:
                 with open(os.path.join(path, name), 'w+'):
                     pass
             # Now raise an exception
             raise ValueError('foo')
     except ValueError:
         pass
     # Make sure the directory has been cleaned
     self.assertEqual(os.listdir(path), [])
     os.rmdir(path)