[Zope3-checkins] SVN: zope.testing/tags/regebro-python3-reloaded/s This is an attempt to make it possible to run the tests without having buildout.

Lennart Regebro regebro at gmail.com
Mon Dec 7 11:02:04 EST 2009


Log message for revision 106250:
  This is an attempt to make it possible to run the tests without having buildout.
  Not entirely there yet.
  
  

Changed:
  U   zope.testing/tags/regebro-python3-reloaded/setup.py
  U   zope.testing/tags/regebro-python3-reloaded/src/zope/testing/testrunner/runner.py
  U   zope.testing/tags/regebro-python3-reloaded/src/zope/testing/tests.py

-=-
Modified: zope.testing/tags/regebro-python3-reloaded/setup.py
===================================================================
--- zope.testing/tags/regebro-python3-reloaded/setup.py	2009-12-07 14:09:42 UTC (rev 106249)
+++ zope.testing/tags/regebro-python3-reloaded/setup.py	2009-12-07 16:02:04 UTC (rev 106250)
@@ -38,6 +38,13 @@
     from distutils.core import setup
     extra = {}
 
+import sys
+if sys.version_info >= (3,):
+    # Python 3 support:
+    extra['use_2to3'] = True
+    extra['setup_requires'] = ['zope.fixers']
+    extra['use_2to3_fixers'] = ['zope.fixers']    
+
 chapters = '\n'.join([
     open(os.path.join('src', 'zope', 'testing', 'testrunner', name)).read()
     for name in (
@@ -109,5 +116,5 @@
         "Topic :: Software Development :: Libraries :: Python Modules",
         "Topic :: Software Development :: Testing",
         ],
-
+    test_suite='zope.testing.tests',
     **extra)

Modified: zope.testing/tags/regebro-python3-reloaded/src/zope/testing/testrunner/runner.py
===================================================================
--- zope.testing/tags/regebro-python3-reloaded/src/zope/testing/testrunner/runner.py	2009-12-07 14:09:42 UTC (rev 106249)
+++ zope.testing/tags/regebro-python3-reloaded/src/zope/testing/testrunner/runner.py	2009-12-07 16:02:04 UTC (rev 106250)
@@ -23,7 +23,9 @@
 import gc
 import Queue
 import re
+import os
 import sys
+import tempfile
 import threading
 import time
 import traceback
@@ -380,23 +382,45 @@
     def runTest(self):
         "Layer set up failure."
 
+def make_testrunner_script(filename):
+    #!/opt/python24/bin/python
 
+    template = """
+import sys
+sys.path = %s
+
+import os
+os.chdir('%s')
+
+import zope.testing.testrunner
+if __name__ == '__main__':
+    zope.testing.testrunner.run([
+        '--test-path', '%s',
+        ])
+"""
+    scriptfile = open(filename, 'w')
+    script = template % (sys.path, os.path.abspath(os.curdir), sys.path[0])
+    scriptfile.write(script)
+    scriptfile.close()
+
 def spawn_layer_in_subprocess(result, script_parts, options, features,
                               layer_name, layer, failures, errors,
                               resume_number):
     output = options.output
 
     try:
+        fd, temprunner = tempfile.mkstemp(prefix='temprunner', text=True)
+        make_testrunner_script(temprunner)
+        
         # BBB
         if script_parts is None:
             script_parts = sys.argv[0:1]
-        args = [sys.executable]
-        args.extend(script_parts)
+        args = [sys.executable, temprunner]
         args.extend(['--resume-layer', layer_name, str(resume_number)])
         for d in options.testrunner_defaults:
             args.extend(['--default', d])
 
-        args.extend(options.original_testrunner_args[1:])
+        args.extend(options.original_testrunner_args[2:])
 
         # this is because of a bug in Python (http://www.python.org/sf/900092)
         if (options.profile == 'hotshot'
@@ -461,6 +485,7 @@
             errors.append((erriter.next().strip(), None))
 
     finally:
+        os.unlink(temprunner)
         result.done = True
 
 

Modified: zope.testing/tags/regebro-python3-reloaded/src/zope/testing/tests.py
===================================================================
--- zope.testing/tags/regebro-python3-reloaded/src/zope/testing/tests.py	2009-12-07 14:09:42 UTC (rev 106249)
+++ zope.testing/tags/regebro-python3-reloaded/src/zope/testing/tests.py	2009-12-07 16:02:04 UTC (rev 106250)
@@ -39,3 +39,9 @@
         doctest.DocFileSuite('setupstack.txt'),
         doctest.DocTestSuite(doctest, optionflags=doctest.INTERPRET_FOOTNOTES),
         ))
+
+def additional_tests(): # For setuptools testrunner
+    from zope.testing.testrunner import tests
+    res = test_suite()
+    res.addTests(tests.test_suite())
+    return res
\ No newline at end of file



More information about the Zope3-Checkins mailing list