Exemple #1
0
 def test_win32com(self, tmpdir):
     """
     win32com should not be prevented from caching COM interfaces
     in gen_py.
     """
     win32com = pytest.importorskip('win32com')
     gen_py = win32com.__gen_path__
     target = os.path.join(gen_py, 'test_write')
     sandbox = DirectorySandbox(str(tmpdir))
     try:
         # attempt to create gen_py file
         sandbox.run(self._file_writer(target))
     finally:
         if os.path.exists(target):
             os.remove(target)
Exemple #2
0
 def test_win32com(self, tmpdir):
     """
     win32com should not be prevented from caching COM interfaces
     in gen_py.
     """
     win32com = pytest.importorskip('win32com')
     gen_py = win32com.__gen_path__
     target = os.path.join(gen_py, 'test_write')
     sandbox = DirectorySandbox(str(tmpdir))
     try:
         # attempt to create gen_py file
         sandbox.run(self._file_writer(target))
     finally:
         if os.path.exists(target):
             os.remove(target)
Exemple #3
0
 def test_win32com(self):
     """
     win32com should not be prevented from caching COM interfaces
     in gen_py.
     """
     import win32com
     gen_py = win32com.__gen_path__
     target = os.path.join(gen_py, 'test_write')
     sandbox = DirectorySandbox(self.dir)
     try:
         try:
             sandbox.run(self._file_writer(target))
         except SandboxViolation:
             self.fail("Could not create gen_py file due to SandboxViolation")
     finally:
         if os.path.exists(target): os.remove(target)
Exemple #4
0
 def test_win32com(self):
     """
     win32com should not be prevented from caching COM interfaces
     in gen_py.
     """
     import win32com
     gen_py = win32com.__gen_path__
     target = os.path.join(gen_py, 'test_write')
     sandbox = DirectorySandbox(self.dir)
     try:
         try:
             sandbox.run(self._file_writer(target))
         except SandboxViolation:
             self.fail("Could not create gen_py file due to SandboxViolation")
     finally:
         if os.path.exists(target): os.remove(target)
Exemple #5
0
    def test_sandbox_violation_raised_hiding_setuptools(self, tmpdir):
        """
        When in a sandbox with setuptools hidden, a SandboxViolation
        should reflect a proper exception and not be wrapped in
        an UnpickleableException.
        """
        def write_file():
            "Trigger a SandboxViolation by writing outside the sandbox"
            with open('/etc/foo', 'w'):
                pass
        sandbox = DirectorySandbox(str(tmpdir))
        with pytest.raises(setuptools.sandbox.SandboxViolation) as caught:
            with setuptools.sandbox.save_modules():
                setuptools.sandbox.hide_setuptools()
                sandbox.run(write_file)

        cmd, args, kwargs = caught.value.args
        assert cmd == 'open'
        assert args == ('/etc/foo', 'w')
        assert kwargs == {}
Exemple #6
0
 def test_devnull(self):
     if sys.version < '2.4':
         return
     sandbox = DirectorySandbox(self.dir)
     sandbox.run(self._file_writer(os.devnull))
Exemple #7
0
 def test_devnull(self):
     if sys.version < '2.4':
         return
     sandbox = DirectorySandbox(self.dir)
     sandbox.run(self._file_writer(os.devnull))
Exemple #8
0
 def test_devnull(self, tmpdir):
     sandbox = DirectorySandbox(str(tmpdir))
     sandbox.run(self._file_writer(os.devnull))
Exemple #9
0
 def test_devnull(self, tmpdir):
     sandbox = DirectorySandbox(str(tmpdir))
     sandbox.run(self._file_writer(os.devnull))
Exemple #10
0
 def test_devnull(self):
     sandbox = DirectorySandbox(self.dir)
     sandbox.run(self._file_writer(os.devnull))
Exemple #11
0
 def test_devnull(self):
     sandbox = DirectorySandbox(self.dir)
     sandbox.run(self._file_writer(os.devnull))