コード例 #1
0
    def testTmpdir(self):
        """Verify `ctx.tmpdir`"""
        with ctx.tmpdir() as path:
            path_copy = path
            self.assertExists(path)

        self.assertNotExists(path_copy)
コード例 #2
0
ファイル: test_ctx.py プロジェクト: agargiulo/sparts
    def testTmpdir(self):
        """Verify `ctx.tmpdir`"""
        with ctx.tmpdir() as path:
            path_copy = path
            self.assertExists(path)

        self.assertNotExists(path_copy)
コード例 #3
0
    def testAddPath(self):
        """Verify `ctx.add_path`"""
        # Create a temp directory
        with ctx.tmpdir() as path:
            # The temp dir should not be in the path yet.
            self.assertNotIn(path, sys.path)

            with ctx.add_path(path):
                # Now it should be in the path
                self.assertIn(path, sys.path)

            # After exiting the context, it should be gone again
            self.assertNotIn(path, sys.path)
コード例 #4
0
ファイル: test_ctx.py プロジェクト: agargiulo/sparts
    def testAddPath(self):
        """Verify `ctx.add_path`"""
        # Create a temp directory
        with ctx.tmpdir() as path:
            # The temp dir should not be in the path yet.
            self.assertNotIn(path, sys.path)

            with ctx.add_path(path):
                # Now it should be in the path
                self.assertIn(path, sys.path)

            # After exiting the context, it should be gone again
            self.assertNotIn(path, sys.path)
コード例 #5
0
    def testChdir(self):
        """Verify `ctx.chdir`"""
        with ctx.tmpdir() as path:
            orig_dir = os.getcwd()

            # Make sure we're not in the new tmpdir.  This should be impossible.
            self.assertNotEquals(orig_dir, path)

            with ctx.chdir(path):
                # Make sure we changed correctly
                self.assertEquals(os.getcwd(), path)

            # Make sure we're not there anymore
            self.assertNotEquals(os.getcwd(), path)

            # Make sure we returned to the original location
            self.assertEquals(os.getcwd(), orig_dir)
コード例 #6
0
ファイル: test_ctx.py プロジェクト: agargiulo/sparts
    def testChdir(self):
        """Verify `ctx.chdir`"""
        with ctx.tmpdir() as path:
            orig_dir = os.getcwd()

            # Make sure we're not in the new tmpdir.  This should be impossible.
            self.assertDifferentPath(orig_dir, path)

            with ctx.chdir(path):
                # Make sure we changed correctly
                self.assertSamePath(os.getcwd(), path)

            # Make sure we're not there anymore
            self.assertDifferentPath(os.getcwd(), path)

            # Make sure we returned to the original location
            self.assertSamePath(os.getcwd(), orig_dir)