[Checkins] SVN: zc.buildout/trunk/testrunnerrecipe/src/zc/recipe/testrunner/ Fixed a bug that caused dependency tests to be run.

Jim Fulton jim at zope.com
Wed Jun 28 15:21:38 EDT 2006


Log message for revision 68884:
  Fixed a bug that caused dependency tests to be run.
  

Changed:
  U   zc.buildout/trunk/testrunnerrecipe/src/zc/recipe/testrunner/README.txt
  U   zc.buildout/trunk/testrunnerrecipe/src/zc/recipe/testrunner/__init__.py

-=-
Modified: zc.buildout/trunk/testrunnerrecipe/src/zc/recipe/testrunner/README.txt
===================================================================
--- zc.buildout/trunk/testrunnerrecipe/src/zc/recipe/testrunner/README.txt	2006-06-28 17:54:01 UTC (rev 68883)
+++ zc.buildout/trunk/testrunnerrecipe/src/zc/recipe/testrunner/README.txt	2006-06-28 19:21:37 UTC (rev 68884)
@@ -24,16 +24,18 @@
 buildout:
 
     >>> mkdir(sample_buildout, 'demo')
-    >>> write(sample_buildout, 'demo', 'tests.py',
+    >>> mkdir(sample_buildout, 'demo', 'demo')
+    >>> write(sample_buildout, 'demo', 'demo', '__init__.py', '')
+    >>> write(sample_buildout, 'demo', 'demo', 'tests.py',
     ... '''
     ... import unittest
     ...
-    ... class TestSomething(unittest.TestCase):
-    ...    def test_something(self):
+    ... class TestDemo(unittest.TestCase):
+    ...    def test(self):
     ...        pass
     ...
     ... def test_suite():
-    ...     return unittest.makeSuite(TestSomething)
+    ...     return unittest.makeSuite(TestDemo)
     ... ''')
 
     >>> write(sample_buildout, 'demo', 'setup.py',
@@ -46,34 +48,62 @@
     >>> write(sample_buildout, 'demo', 'README.txt', '')
 
     >>> mkdir(sample_buildout, 'demo2')
-    >>> write(sample_buildout, 'demo2', 'tests.py',
+    >>> mkdir(sample_buildout, 'demo2', 'demo2')
+    >>> write(sample_buildout, 'demo2', 'demo2', '__init__.py', '')
+    >>> write(sample_buildout, 'demo2', 'demo2', 'tests.py',
     ... '''
     ... import unittest
     ...
-    ... class TestSomething(unittest.TestCase):
-    ...    def test_something(self):
+    ... class Demo2Tests(unittest.TestCase):
+    ...    def test2(self):
     ...        pass
     ...
     ... def test_suite():
-    ...     return unittest.makeSuite(TestSomething)
+    ...     return unittest.makeSuite(Demo2Tests)
     ... ''')
 
     >>> write(sample_buildout, 'demo2', 'setup.py',
     ... """
     ... from setuptools import setup
     ... 
-    ... setup(name = "demo2")
+    ... setup(name = "demo2", install_requires= ['demoneeded'])
     ... """)
 
     >>> write(sample_buildout, 'demo2', 'README.txt', '')
 
+Demo 2 depends on demoneeded:
+
+    >>> mkdir(sample_buildout, 'demoneeded')
+    >>> mkdir(sample_buildout, 'demoneeded', 'demoneeded')
+    >>> write(sample_buildout, 'demoneeded', 'demoneeded', '__init__.py', '')
+    >>> write(sample_buildout, 'demoneeded', 'demoneeded', 'tests.py',
+    ... '''
+    ... import unittest
+    ...
+    ... class TestNeeded(unittest.TestCase):
+    ...    def test_needed(self):
+    ...        pass
+    ...
+    ... def test_suite():
+    ...     return unittest.makeSuite(TestNeeded)
+    ... ''')
+
+    >>> write(sample_buildout, 'demoneeded', 'setup.py',
+    ... """
+    ... from setuptools import setup
+    ... 
+    ... setup(name = "demoneeded")
+    ... """)
+
+    >>> write(sample_buildout, 'demoneeded', 'README.txt', '')
+
 We'll update our buildout to install the demo project as a
 develop egg and to create the test script:
 
     >>> write(sample_buildout, 'buildout.cfg',
     ... """
     ... [buildout]
-    ... develop = demo demo2
+    ... develop = demo demoneeded demo2
     ... parts = testdemo
     ... offline = true
     ...
@@ -104,10 +134,17 @@
 
 We can run the test script to run our demo test:
 
-    >>> print system(os.path.join(sample_buildout, 'bin', 'test')),
+    >>> print system(os.path.join(sample_buildout, 'bin', 'test') + ' -vv'),
+    Running tests at level 1
     Running unit tests:
+      Running:
+     test (demo.tests.TestDemo)
+     test2 (demo2.tests.Demo2Tests)
       Ran 2 tests with 0 failures and 0 errors in 0.000 seconds.
 
+Note that we didn't run the demoneeded tests.  Tests are only run for
+the distributions listed, not for their dependencies.
+
 If we leave the script option out of the configuration, then the test
 script will get it's name from the part:
 

Modified: zc.buildout/trunk/testrunnerrecipe/src/zc/recipe/testrunner/__init__.py
===================================================================
--- zc.buildout/trunk/testrunnerrecipe/src/zc/recipe/testrunner/__init__.py	2006-06-28 17:54:01 UTC (rev 68883)
+++ zc.buildout/trunk/testrunnerrecipe/src/zc/recipe/testrunner/__init__.py	2006-06-28 19:21:37 UTC (rev 68884)
@@ -40,15 +40,19 @@
         requirements = [r.strip()
                         for r in options['distributions'].split('\n')
                         if r.strip()]
-        
         ws = zc.buildout.easy_install.working_set(
             requirements+['zope.testing'],
             executable = options['executable'],
             path=[options['_d'], options['_e']]
             )
         path = [dist.location for dist in ws]
+        project_names = [
+            pkg_resources.Requirement.parse(r).project_name
+            for r in requirements
+            ]
+        
         locations = [dist.location for dist in ws
-                     if dist.project_name != 'zope.testing']
+                     if dist.project_name in project_names]
 
         script = options['script']
         open(script, 'w').write(tests_template % dict(



More information about the Checkins mailing list