コード例 #1
0
ファイル: test_worker.py プロジェクト: pombredanne/qless-py
 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
ファイル: test_worker.py プロジェクト: multiwave/qless-py
 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
ファイル: test_worker.py プロジェクト: pombredanne/qless-py
 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
ファイル: test_worker.py プロジェクト: multiwave/qless-py
 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
ファイル: test_worker.py プロジェクト: pombredanne/qless-py
 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
ファイル: test_worker.py プロジェクト: multiwave/qless-py
 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)