Commits

Jason R. Coombs committed 60aeb2c

Test now constructs the tarfile completely in memory (avoiding accidentally writing over our own setup.py)

Comments (0)

Files changed (1)

setuptools/tests/test_easy_install.py

 import textwrap
 import tarfile
 import urlparse
+import StringIO
 
 from setuptools.command.easy_install import easy_install, get_script_args, main
 from setuptools.command.easy_install import  PthDistributions
         doesn't exist)
         """
         with tempdir_context() as d:
-            with open('setup.py', 'wb') as setup_script:
-                setup_script.write(textwrap.dedent("""
-                    import setuptools
-                    setuptools.setup(
-                        name="distribute-test-fetcher",
-                        version="1.0",
-                        setup_requires = ['does-not-exist'],
-                    )
-                    """).lstrip())
+            setup_py = tarfile.TarInfo(name="setup.py")
+            setup_py_bytes = StringIO.StringIO(textwrap.dedent("""
+                import setuptools
+                setuptools.setup(
+                    name="distribute-test-fetcher",
+                    version="1.0",
+                    setup_requires = ['does-not-exist'],
+                )
+                """).lstrip())
+            setup_py.size = len(setup_py_bytes.buf)
             dist_path = os.path.join(d, 'distribute-test-fetcher-1.0.tar.gz')
             with tarfile.open(dist_path, 'w:gz') as dist:
-                dist.add('setup.py')
+                dist.addfile(setup_py, fileobj=setup_py_bytes)
             yield dist_path
 
 @contextlib.contextmanager