Jason R. Coombs committed 903b483

Added test to capture issue #118

Comments (0)

Files changed (1)


 import unittest
 import tempfile
-from setuptools.sandbox import DirectorySandbox
+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:
+        mod = __import__('win32com')
+    except ImportError:
+        return False
+    return True
 class TestSandbox(unittest.TestCase):
     def test_devnull(self):
         sandbox = DirectorySandbox(self.dir)
-        def _write():
-            f = open(os.devnull, 'w')
+    @staticmethod
+    def _file_writer(path):
+        def do_write():
+            f = open(path, 'w')
+        return do_write
+    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)
+            try:
+            except SandboxViolation:
+      "Could not create gen_py file due to SandboxViolation")
+            finally:
+                if os.path.exists(target): os.remove(target)
+if __name__ == '__main__':
+    unittest.main()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.