Commit 48377769 authored by Jason R. Coombs's avatar Jason R. Coombs

Use importorskip to detect/load win32com

parent c3e74e46
...@@ -6,22 +6,12 @@ import shutil ...@@ -6,22 +6,12 @@ import shutil
import tempfile import tempfile
import types import types
import pytest
import pkg_resources import pkg_resources
import setuptools.sandbox import setuptools.sandbox
from setuptools.sandbox import DirectorySandbox, SandboxViolation 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: class TestSandbox:
...@@ -44,23 +34,22 @@ class TestSandbox: ...@@ -44,23 +34,22 @@ class TestSandbox:
_file_writer = staticmethod(_file_writer) _file_writer = staticmethod(_file_writer)
if has_win32com(): def test_win32com(self):
def test_win32com(self): """
""" win32com should not be prevented from caching COM interfaces
win32com should not be prevented from caching COM interfaces in gen_py.
in gen_py. """
""" win32com = pytest.importorskip('win32com')
import win32com gen_py = win32com.__gen_path__
gen_py = win32com.__gen_path__ target = os.path.join(gen_py, 'test_write')
target = os.path.join(gen_py, 'test_write') sandbox = DirectorySandbox(self.dir)
sandbox = DirectorySandbox(self.dir) try:
try: try:
try: sandbox.run(self._file_writer(target))
sandbox.run(self._file_writer(target)) except SandboxViolation:
except SandboxViolation: self.fail("Could not create gen_py file due to SandboxViolation")
self.fail("Could not create gen_py file due to SandboxViolation") finally:
finally: if os.path.exists(target): os.remove(target)
if os.path.exists(target): os.remove(target)
def test_setup_py_with_BOM(self): def test_setup_py_with_BOM(self):
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment