Lennart Regebro avatar Lennart Regebro committed d2e23f3

Added failing test for #299.

Comments (0)

Files changed (2)

setuptools/tests/test_develop.py

 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'):
         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 "

setuptools/tests/test_test.py

             pass
         finally:
             sys.stdout = old_stdout
-
-test_suite = unittest.makeSuite(TestTestTest)
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 ProjectModifiedEvent.java.
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.