diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2012-04-07 12:40:19 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2012-04-07 12:40:19 -0400 |
commit | 1a9a961d96c1f9c11719356d6f375cdfc17e7e6d (patch) | |
tree | 8178f14a5508db3e0dc09a3a35aaa45da32d8433 | |
parent | dea4120fdc2cd90d9d68d3ffbc6e2118aadde125 (diff) | |
download | external_python_setuptools-1a9a961d96c1f9c11719356d6f375cdfc17e7e6d.tar.gz external_python_setuptools-1a9a961d96c1f9c11719356d6f375cdfc17e7e6d.tar.bz2 external_python_setuptools-1a9a961d96c1f9c11719356d6f375cdfc17e7e6d.zip |
Test now constructs the tarfile completely in memory (avoiding accidentally writing over our own setup.py)
--HG--
branch : distribute
extra : rebase_source : ad8ec142238405edeee6dce51c05d382e53d1299
-rw-r--r-- | setuptools/tests/test_easy_install.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 87d24bb7..3f38d50f 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -10,6 +10,7 @@ import contextlib 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 @@ -296,18 +297,19 @@ class TestSetupRequires(unittest.TestCase): 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 |