Пример #1
0
 def test_pushd_cwd_removed(self):
     with tempfile.TemporaryDirectory(prefix='unittest-') as cwd:
         os.chdir(cwd)
         with self.assertRaises(OSError):
             with pushd(self.testdir):
                 os.rmdir(cwd)
         self.assertEqual(os.getcwd(), self.testdir)
         os.mkdir(cwd)
Пример #2
0
 def test_pushd_cwd_nonexistant(self):
     with tempfile.TemporaryDirectory(prefix='unittest-') as cwd:
         os.chdir(cwd)
         os.rmdir(cwd)
         with self.assertRaises(OSError):
             os.getcwd()
         with self.assertRaises(OSError):
             with pushd(self.testdir):
                 self.fail('this should not be reached')
         with self.assertRaises(OSError):
             os.getcwd()
         os.mkdir(cwd)