diff options
Diffstat (limited to 'setuptools')
-rw-r--r-- | setuptools/tests/test_develop.py | 48 | ||||
-rw-r--r-- | setuptools/tests/test_test.py | 2 |
2 files changed, 37 insertions, 13 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 " diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 5000f234..87ccaf44 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -112,5 +112,3 @@ class TestTestTest(unittest.TestCase): pass finally: sys.stdout = old_stdout - -test_suite = unittest.makeSuite(TestTestTest) |