Ejemplo n.º 1
0
 def test_cd_without_cleanup(self):
     cwd = os.getcwd()
     tmp_dir = tempfile.mkdtemp()
     with cd(tmp_dir):
         self.assertEqual(tmp_dir, os.getcwd())
     self.assertEqual(cwd, os.getcwd())
     self.assertTrue(os.path.exists(tmp_dir))
     shutil.rmtree(tmp_dir)
Ejemplo n.º 2
0
 def test_cd_without_cleanup_macOS(self):
     cwd = os.getcwd()
     tmp_dir = tempfile.mkdtemp()
     with cd(tmp_dir):
         t_dir = "/private{}".format(tmp_dir)
         self.assertEqual(t_dir, os.getcwd())
     self.assertEqual(cwd, os.getcwd())
     self.assertTrue(os.path.exists(tmp_dir))
     shutil.rmtree(tmp_dir)
Ejemplo n.º 3
0
    def test_cd_with_cleanup(self):
        def cleanup():
            shutil.rmtree(tmp_dir)
            return True

        cwd = os.getcwd()
        tmp_dir = tempfile.mkdtemp()
        with cd(tmp_dir, cleanup):
            self.assertEqual(tmp_dir, os.getcwd())
        self.assertEqual(cwd, os.getcwd())
        self.assertFalse(os.path.exists(tmp_dir))