[pypy-svn] rev 777 - in pypy/trunk/src/pypy: . appspace/test interpreterinterpreter/test module/test objspace/std/test
mwh at codespeak.net
mwh at codespeak.net
Sat Jun 7 20:24:30 CEST 2003
Author: mwh
Date: Sat Jun 7 20:24:29 2003
New Revision: 777
Modified:
pypy/trunk/src/pypy/appspace/test/testsupport.py
pypy/trunk/src/pypy/interpreter/test/testsupport.py
pypy/trunk/src/pypy/interpreter/testsupport.py
pypy/trunk/src/pypy/interpreter/testtools.py
pypy/trunk/src/pypy/module/test/testsupport.py
pypy/trunk/src/pypy/objspace/std/test/testsupport.py
pypy/trunk/src/pypy/testsupport.py
Log:
testsupport tweaks
notable changes:
- this doesn't bother to interpret the contents of $OBJSPACE as
much as before, it just assumes that if it's present
and contains a dot you want the standard object space.
- we now use the same objspace object for each test
Modified: pypy/trunk/src/pypy/appspace/test/testsupport.py
==============================================================================
--- pypy/trunk/src/pypy/appspace/test/testsupport.py (original)
+++ pypy/trunk/src/pypy/appspace/test/testsupport.py Sat Jun 7 20:24:29 2003
@@ -21,7 +21,9 @@
When run as a script, runs all tests found in files called 'test_*.py'
in the same directory.
"""
-import sys, os
+import sys
+import os
+import unittest
try:
head = this_path = os.path.abspath(__file__)
@@ -39,26 +41,11 @@
break
import pypy.interpreter.unittest_w
+from pypy.interpreter.testtools import *
+
TestCase = pypy.interpreter.unittest_w.TestCase_w
-import unittest
main = unittest.main
-from pypy.interpreter import testtools
-
-def objspace():
- objspace_path = os.environ.get('OBJSPACE')
- if not objspace_path or '.' not in objspace_path:
- import pypy.objspace.trivial
- return pypy.objspace.trivial.TrivialObjSpace()
- else:
- objspace_pieces = objspace_path.split('.')
- objspace_path = '.'.join(objspace_pieces[:-1])
- objspace_module = __import__(objspace_path)
- for piece in objspace_pieces[1:-1]:
- objspace_module = getattr(objspace_module, piece)
- objspace_classname = objspace_pieces[-1]
- return getattr(objspace_module, objspace_classname)()
-
if __name__ == '__main__':
runner = unittest.TextTestRunner()
- runner.run(testtools.get_tests_for_dir(os.path.dirname(sys.argv[0])))
+ runner.run(get_tests_for_dir(os.path.dirname(sys.argv[0])))
Modified: pypy/trunk/src/pypy/interpreter/test/testsupport.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/test/testsupport.py (original)
+++ pypy/trunk/src/pypy/interpreter/test/testsupport.py Sat Jun 7 20:24:29 2003
@@ -21,7 +21,9 @@
When run as a script, runs all tests found in files called 'test_*.py'
in the same directory.
"""
-import sys, os
+import sys
+import os
+import unittest
try:
head = this_path = os.path.abspath(__file__)
@@ -39,26 +41,11 @@
break
import pypy.interpreter.unittest_w
+from pypy.interpreter.testtools import *
+
TestCase = pypy.interpreter.unittest_w.TestCase_w
-import unittest
main = unittest.main
-from pypy.interpreter import testtools
-
-def objspace():
- objspace_path = os.environ.get('OBJSPACE')
- if not objspace_path or '.' not in objspace_path:
- import pypy.objspace.trivial
- return pypy.objspace.trivial.TrivialObjSpace()
- else:
- objspace_pieces = objspace_path.split('.')
- objspace_path = '.'.join(objspace_pieces[:-1])
- objspace_module = __import__(objspace_path)
- for piece in objspace_pieces[1:-1]:
- objspace_module = getattr(objspace_module, piece)
- objspace_classname = objspace_pieces[-1]
- return getattr(objspace_module, objspace_classname)()
-
if __name__ == '__main__':
runner = unittest.TextTestRunner()
- runner.run(testtools.get_tests_for_dir(os.path.dirname(sys.argv[0])))
+ runner.run(get_tests_for_dir(os.path.dirname(sys.argv[0])))
Modified: pypy/trunk/src/pypy/interpreter/testsupport.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/testsupport.py (original)
+++ pypy/trunk/src/pypy/interpreter/testsupport.py Sat Jun 7 20:24:29 2003
@@ -21,7 +21,9 @@
When run as a script, runs all tests found in files called 'test_*.py'
in the same directory.
"""
-import sys, os
+import sys
+import os
+import unittest
try:
head = this_path = os.path.abspath(__file__)
@@ -39,26 +41,11 @@
break
import pypy.interpreter.unittest_w
+from pypy.interpreter.testtools import *
+
TestCase = pypy.interpreter.unittest_w.TestCase_w
-import unittest
main = unittest.main
-from pypy.interpreter import testtools
-
-def objspace():
- objspace_path = os.environ.get('OBJSPACE')
- if not objspace_path or '.' not in objspace_path:
- import pypy.objspace.trivial
- return pypy.objspace.trivial.TrivialObjSpace()
- else:
- objspace_pieces = objspace_path.split('.')
- objspace_path = '.'.join(objspace_pieces[:-1])
- objspace_module = __import__(objspace_path)
- for piece in objspace_pieces[1:-1]:
- objspace_module = getattr(objspace_module, piece)
- objspace_classname = objspace_pieces[-1]
- return getattr(objspace_module, objspace_classname)()
-
if __name__ == '__main__':
runner = unittest.TextTestRunner()
- runner.run(testtools.get_tests_for_dir(os.path.dirname(sys.argv[0])))
+ runner.run(get_tests_for_dir(os.path.dirname(sys.argv[0])))
Modified: pypy/trunk/src/pypy/interpreter/testtools.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/testtools.py (original)
+++ pypy/trunk/src/pypy/interpreter/testtools.py Sat Jun 7 20:24:29 2003
@@ -3,7 +3,8 @@
def get_tests_for_dir(directory):
files = os.listdir(directory)
- testfiles = [f[:-3] for f in files if f.startswith('test_') and f.endswith('.py')]
+ testfiles = [f[:-3] for f in files
+ if f.startswith('test_') and f.endswith('.py')]
ts = unittest.TestSuite()
@@ -14,5 +15,30 @@
ts.addTest(tl.loadTestsFromModule(mod))
return ts
-
-
+
+def objspace():
+ objspace_path = os.environ.get('OBJSPACE')
+ if not objspace_path or '.' not in objspace_path:
+ return trivobjspace()
+ else:
+ return stdobjspace()
+
+_trivobjspace = None
+
+def trivobjspace():
+ global _trivobjspace
+ if _trivobjspace:
+ return _trivobjspace
+ from pypy.objspace.trivial import TrivialObjSpace
+ _trivobjspace = TrivialObjSpace()
+ return _trivobjspace
+
+_stdobjspace = None
+
+def stdobjspace():
+ global _stdobjspace
+ if _stdobjspace:
+ return _stdobjspace
+ from pypy.objspace.std import StdObjSpace
+ _stdobjspace = StdObjSpace()
+ return _stdobjspace
Modified: pypy/trunk/src/pypy/module/test/testsupport.py
==============================================================================
--- pypy/trunk/src/pypy/module/test/testsupport.py (original)
+++ pypy/trunk/src/pypy/module/test/testsupport.py Sat Jun 7 20:24:29 2003
@@ -21,7 +21,9 @@
When run as a script, runs all tests found in files called 'test_*.py'
in the same directory.
"""
-import sys, os
+import sys
+import os
+import unittest
try:
head = this_path = os.path.abspath(__file__)
@@ -39,26 +41,11 @@
break
import pypy.interpreter.unittest_w
+from pypy.interpreter.testtools import *
+
TestCase = pypy.interpreter.unittest_w.TestCase_w
-import unittest
main = unittest.main
-from pypy.interpreter import testtools
-
-def objspace():
- objspace_path = os.environ.get('OBJSPACE')
- if not objspace_path or '.' not in objspace_path:
- import pypy.objspace.trivial
- return pypy.objspace.trivial.TrivialObjSpace()
- else:
- objspace_pieces = objspace_path.split('.')
- objspace_path = '.'.join(objspace_pieces[:-1])
- objspace_module = __import__(objspace_path)
- for piece in objspace_pieces[1:-1]:
- objspace_module = getattr(objspace_module, piece)
- objspace_classname = objspace_pieces[-1]
- return getattr(objspace_module, objspace_classname)()
-
if __name__ == '__main__':
runner = unittest.TextTestRunner()
- runner.run(testtools.get_tests_for_dir(os.path.dirname(sys.argv[0])))
+ runner.run(get_tests_for_dir(os.path.dirname(sys.argv[0])))
Modified: pypy/trunk/src/pypy/objspace/std/test/testsupport.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/test/testsupport.py (original)
+++ pypy/trunk/src/pypy/objspace/std/test/testsupport.py Sat Jun 7 20:24:29 2003
@@ -21,7 +21,9 @@
When run as a script, runs all tests found in files called 'test_*.py'
in the same directory.
"""
-import sys, os
+import sys
+import os
+import unittest
try:
head = this_path = os.path.abspath(__file__)
@@ -39,26 +41,11 @@
break
import pypy.interpreter.unittest_w
+from pypy.interpreter.testtools import *
+
TestCase = pypy.interpreter.unittest_w.TestCase_w
-import unittest
main = unittest.main
-from pypy.interpreter import testtools
-
-def objspace():
- objspace_path = os.environ.get('OBJSPACE')
- if not objspace_path or '.' not in objspace_path:
- import pypy.objspace.trivial
- return pypy.objspace.trivial.TrivialObjSpace()
- else:
- objspace_pieces = objspace_path.split('.')
- objspace_path = '.'.join(objspace_pieces[:-1])
- objspace_module = __import__(objspace_path)
- for piece in objspace_pieces[1:-1]:
- objspace_module = getattr(objspace_module, piece)
- objspace_classname = objspace_pieces[-1]
- return getattr(objspace_module, objspace_classname)()
-
if __name__ == '__main__':
runner = unittest.TextTestRunner()
- runner.run(testtools.get_tests_for_dir(os.path.dirname(sys.argv[0])))
+ runner.run(get_tests_for_dir(os.path.dirname(sys.argv[0])))
Modified: pypy/trunk/src/pypy/testsupport.py
==============================================================================
--- pypy/trunk/src/pypy/testsupport.py (original)
+++ pypy/trunk/src/pypy/testsupport.py Sat Jun 7 20:24:29 2003
@@ -21,7 +21,9 @@
When run as a script, runs all tests found in files called 'test_*.py'
in the same directory.
"""
-import sys, os
+import sys
+import os
+import unittest
try:
head = this_path = os.path.abspath(__file__)
@@ -39,26 +41,11 @@
break
import pypy.interpreter.unittest_w
+from pypy.interpreter.testtools import *
+
TestCase = pypy.interpreter.unittest_w.TestCase_w
-import unittest
main = unittest.main
-from pypy.interpreter import testtools
-
-def objspace():
- objspace_path = os.environ.get('OBJSPACE')
- if not objspace_path or '.' not in objspace_path:
- import pypy.objspace.trivial
- return pypy.objspace.trivial.TrivialObjSpace()
- else:
- objspace_pieces = objspace_path.split('.')
- objspace_path = '.'.join(objspace_pieces[:-1])
- objspace_module = __import__(objspace_path)
- for piece in objspace_pieces[1:-1]:
- objspace_module = getattr(objspace_module, piece)
- objspace_classname = objspace_pieces[-1]
- return getattr(objspace_module, objspace_classname)()
-
if __name__ == '__main__':
runner = unittest.TextTestRunner()
- runner.run(testtools.get_tests_for_dir(os.path.dirname(sys.argv[0])))
+ runner.run(get_tests_for_dir(os.path.dirname(sys.argv[0])))
More information about the Pypy-commit
mailing list