aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/tests/test_sandbox.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2015-01-02 11:45:35 -0500
committerJason R. Coombs <jaraco@jaraco.com>2015-01-02 11:45:35 -0500
commit4837776968b41fd22d74e560f07e554fcff47d72 (patch)
tree1c2312ce932e6544b3e7ce82a38f7ee388599051 /setuptools/tests/test_sandbox.py
parentc3e74e46e20ceb7cc126f28611d0b9c098a333f2 (diff)
downloadexternal_python_setuptools-4837776968b41fd22d74e560f07e554fcff47d72.tar.gz
external_python_setuptools-4837776968b41fd22d74e560f07e554fcff47d72.tar.bz2
external_python_setuptools-4837776968b41fd22d74e560f07e554fcff47d72.zip
Use importorskip to detect/load win32com
Diffstat (limited to 'setuptools/tests/test_sandbox.py')
-rw-r--r--setuptools/tests/test_sandbox.py45
1 files changed, 17 insertions, 28 deletions
diff --git a/setuptools/tests/test_sandbox.py b/setuptools/tests/test_sandbox.py
index 138e7f87..426c5614 100644
--- a/setuptools/tests/test_sandbox.py
+++ b/setuptools/tests/test_sandbox.py
@@ -6,22 +6,12 @@ import shutil
import tempfile
import types
+import pytest
+
import pkg_resources
import setuptools.sandbox
from setuptools.sandbox import DirectorySandbox, SandboxViolation
-def has_win32com():
- """
- Run this to determine if the local machine has win32com, and if it
- does, include additional tests.
- """
- if not sys.platform.startswith('win32'):
- return False
- try:
- __import__('win32com')
- except ImportError:
- return False
- return True
class TestSandbox:
@@ -44,23 +34,22 @@ class TestSandbox:
_file_writer = staticmethod(_file_writer)
- if has_win32com():
- 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)
+ def test_win32com(self):
+ """
+ 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(self.dir)
+ try:
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)
+ 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)
def test_setup_py_with_BOM(self):
"""