diff options
author | Lennart Regebro <regebro@gmail.com> | 2012-08-21 19:05:36 +0200 |
---|---|---|
committer | Lennart Regebro <regebro@gmail.com> | 2012-08-21 19:05:36 +0200 |
commit | 61f4c9c4cbf148253c9e06f3e05757e01affeb6e (patch) | |
tree | 2038e92cede7902db49a697713b88dd85b409c9e /setuptools/tests/test_develop.py | |
parent | 78ac59d4ab00868456155cd3f83be15f78acccf3 (diff) | |
download | external_python_setuptools-61f4c9c4cbf148253c9e06f3e05757e01affeb6e.tar.gz external_python_setuptools-61f4c9c4cbf148253c9e06f3e05757e01affeb6e.tar.bz2 external_python_setuptools-61f4c9c4cbf148253c9e06f3e05757e01affeb6e.zip |
Added failing test for #299.
--HG--
branch : distribute
extra : rebase_source : 4a3ac76a6a49e06e1fecd1d6f4e08fa922f82f73
Diffstat (limited to 'setuptools/tests/test_develop.py')
-rw-r--r-- | setuptools/tests/test_develop.py | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 5576d5e5..f345d8fc 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -14,33 +14,51 @@ from setuptools.dist import Distribution SETUP_PY = """\ from setuptools import setup -setup(name='foo') +setup(name='foo', + packages=['foo'], +) +""" + +INIT_PY = """print "foo" """ class TestDevelopTest(unittest.TestCase): def setUp(self): + if sys.version < "2.6" or hasattr(sys, 'real_prefix'): + return + + # Directory structure self.dir = tempfile.mkdtemp() + os.mkdir(os.path.join(self.dir, 'foo')) + # setup.py setup = os.path.join(self.dir, 'setup.py') f = open(setup, 'w') f.write(SETUP_PY) f.close() self.old_cwd = os.getcwd() + # foo/__init__.py + init = os.path.join(self.dir, 'foo', '__init__.py') + f = open(init, 'w') + f.write(INIT_PY) + f.close() + os.chdir(self.dir) - if sys.version >= "2.6": - self.old_base = site.USER_BASE - site.USER_BASE = tempfile.mkdtemp() - self.old_site = site.USER_SITE - site.USER_SITE = tempfile.mkdtemp() + self.old_base = site.USER_BASE + site.USER_BASE = tempfile.mkdtemp() + self.old_site = site.USER_SITE + site.USER_SITE = tempfile.mkdtemp() def tearDown(self): + if sys.version < "2.6" or hasattr(sys, 'real_prefix'): + return + os.chdir(self.old_cwd) shutil.rmtree(self.dir) - if sys.version >= "2.6": - shutil.rmtree(site.USER_BASE) - shutil.rmtree(site.USER_SITE) - site.USER_BASE = self.old_base - site.USER_SITE = self.old_site + shutil.rmtree(site.USER_BASE) + shutil.rmtree(site.USER_SITE) + site.USER_BASE = self.old_base + site.USER_SITE = self.old_site def test_develop(self): if sys.version < "2.6" or hasattr(sys, 'real_prefix'): @@ -64,6 +82,14 @@ class TestDevelopTest(unittest.TestCase): content.sort() self.assertEquals(content, ['UNKNOWN.egg-link', 'easy-install.pth']) + # Check that we are using the right code. + path = open(os.path.join(site.USER_SITE, 'UNKNOWN.egg-link'), 'rt').read().split()[0].strip() + init = open(os.path.join(path, 'foo', '__init__.py'), 'rt').read().strip() + if sys.version < "3": + self.assertEquals(init, 'print "foo"') + else: + self.assertEquals(init, 'print("foo")') + def test_develop_with_setup_requires(self): wanted = ("Could not find suitable distribution for " |