[Zope3-checkins] SVN: zope.testing/tags/regebro-python3-reloaded/s There we go, we can now run the tests without buildout.
Lennart Regebro
regebro at gmail.com
Mon Dec 7 12:41:08 EST 2009
Log message for revision 106251:
There we go, we can now run the tests without buildout.
Changed:
U zope.testing/tags/regebro-python3-reloaded/setup.py
U zope.testing/tags/regebro-python3-reloaded/src/zope/testing/testrunner/runner.py
-=-
Modified: zope.testing/tags/regebro-python3-reloaded/setup.py
===================================================================
--- zope.testing/tags/regebro-python3-reloaded/setup.py 2009-12-07 16:02:04 UTC (rev 106250)
+++ zope.testing/tags/regebro-python3-reloaded/setup.py 2009-12-07 17:41:08 UTC (rev 106251)
@@ -45,6 +45,46 @@
extra['setup_requires'] = ['zope.fixers']
extra['use_2to3_fixers'] = ['zope.fixers']
+from setuptools.command.test import test
+
+class custom_test(test):
+ # The zope.testing tests MUST be run using it's own testrunner. This is
+ # because it's subprocess testing will call the script it was run with. We
+ # therefore create a script to run the testrunner, and call that.
+ def run(self):
+ if self.distribution.install_requires:
+ self.distribution.fetch_build_eggs(self.distribution.install_requires)
+ if self.distribution.tests_require:
+ self.distribution.fetch_build_eggs(self.distribution.tests_require)
+ self.with_project_on_sys_path(self.run_tests)
+
+ def run_tests(self):
+ 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',
+ ])
+ """
+ import tempfile
+ fd, filename = tempfile.mkstemp(prefix='temprunner', text=True)
+ scriptfile = open(filename, 'w')
+ script = template % (sys.path, os.path.abspath(os.curdir), os.path.abspath('src'))
+ scriptfile.write(script)
+ scriptfile.close()
+
+ import subprocess
+ process = subprocess.Popen([sys.executable, filename])
+ process.wait()
+ os.unlink(filename)
+
+
chapters = '\n'.join([
open(os.path.join('src', 'zope', 'testing', 'testrunner', name)).read()
for name in (
@@ -116,5 +156,5 @@
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Testing",
],
- test_suite='zope.testing.tests',
+ cmdclass = {'test': custom_test},
**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 16:02:04 UTC (rev 106250)
+++ zope.testing/tags/regebro-python3-reloaded/src/zope/testing/testrunner/runner.py 2009-12-07 17:41:08 UTC (rev 106251)
@@ -23,9 +23,7 @@
import gc
import Queue
import re
-import os
import sys
-import tempfile
import threading
import time
import traceback
@@ -382,45 +380,23 @@
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, temprunner]
+ args = [sys.executable]
+ args.extend(script_parts)
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[2:])
+ args.extend(options.original_testrunner_args[1:])
# this is because of a bug in Python (http://www.python.org/sf/900092)
if (options.profile == 'hotshot'
@@ -485,7 +461,6 @@
errors.append((erriter.next().strip(), None))
finally:
- os.unlink(temprunner)
result.done = True
More information about the Zope3-Checkins
mailing list