[pypy-svn] rev 471 - in pypy/trunk/src/pypy: interpreter interpreter/testmodule/test objspace/std/test

alex at codespeak.net alex at codespeak.net
Mon May 26 18:41:52 CEST 2003


Author: alex
Date: Mon May 26 18:41:51 2003
New Revision: 471

Added:
   pypy/trunk/src/pypy/interpreter/test/testsupport.py
Removed:
   pypy/trunk/src/pypy/interpreter/testsupport.py
Modified:
   pypy/trunk/src/pypy/module/test/testsupport.py
   pypy/trunk/src/pypy/objspace/std/test/testsupport.py
Log:
copy master testsupport in all test directories that need it



Added: pypy/trunk/src/pypy/interpreter/test/testsupport.py
==============================================================================
--- (empty file)
+++ pypy/trunk/src/pypy/interpreter/test/testsupport.py	Mon May 26 18:41:51 2003
@@ -0,0 +1,17 @@
+"""
+Master version of testsupport.py: copy into any subdirectory of pypy
+from which scripts need to be run (typically all of the 'test' subdirs)
+so that any test can "import testsupport" to ensure the parent of pypy
+is on the sys.path -- so that "import pypy.etc.etc." always works.
+"""
+import sys, os
+
+head = this_path = os.path.abspath(__file__)
+while 1:
+    head, tail = os.path.split(head)
+    if not tail:
+        raise EnvironmentError, "pypy not among parents of %r!" % this_path
+    elif tail.lower()=='pypy':
+        sys.path.insert(0, head)
+        break
+

Deleted: pypy/trunk/src/pypy/interpreter/testsupport.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/testsupport.py	Mon May 26 18:41:51 2003
+++ (empty file)
@@ -1,38 +0,0 @@
-import sys, os
-import unittest
-
-testdir   = os.path.dirname(os.path.abspath(__file__))
-parentdir = os.path.dirname(testdir)
-rootdir   = os.path.dirname(os.path.dirname(parentdir))
-
-sys.path.insert(0, os.path.dirname(rootdir))
-
-class TestCase_w(unittest.TestCase):
-    """ enrich TestCase with wrapped-methods """
-
-    def failUnless_w(self, w_condition, msg=None):
-        condition = self.space.is_true(w_condition)
-        return self.failUnless(condition, msg)
-
-    def failIf_w(self, w_condition, msg=None):
-        condition = self.space.is_true(w_condition)
-        return self.failIf(condition, msg)
-
-    def assertEqual_w(self, w_first, w_second, msg=None):
-        w_condition = self.space.eq(w_first, w_second)
-        condition = self.space.is_true(w_condition)
-        return self.failUnless(condition, msg)
-
-    def assertNotEqual_w(self, w_first, w_second, msg=None):
-        w_condition = self.space.eq(w_first, w_second)
-        condition = self.space.is_true(w_condition)
-        return self.failIf(condition, msg)
-
-    def assertRaises_w(self, w_exc_class, callable, *args, **kw):
-        from pypy.objspace.std.objspace import OperationError
-        try:
-            callable(*args, **kw)
-        except OperationError, e:
-            self.failUnless(e.match(self.space, w_exc_class))
-        else:
-            self.fail('should have got an exception')

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	Mon May 26 18:41:51 2003
@@ -1,9 +1,17 @@
-import sys, os
-
-opd = os.path.dirname
-
-testdir   = opd(os.path.abspath(__file__))
-parentdir = opd(testdir)
-rootdir   = opd(parentdir)
-
-sys.path.insert(0, opd(rootdir))
+"""
+Master version of testsupport.py: copy into any subdirectory of pypy
+from which scripts need to be run (typically all of the 'test' subdirs)
+so that any test can "import testsupport" to ensure the parent of pypy
+is on the sys.path -- so that "import pypy.etc.etc." always works.
+"""
+import sys, os
+
+head = this_path = os.path.abspath(__file__)
+while 1:
+    head, tail = os.path.split(head)
+    if not tail:
+        raise EnvironmentError, "pypy not among parents of %r!" % this_path
+    elif tail.lower()=='pypy':
+        sys.path.insert(0, head)
+        break
+

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	Mon May 26 18:41:51 2003
@@ -1,9 +1,17 @@
+"""
+Master version of testsupport.py: copy into any subdirectory of pypy
+from which scripts need to be run (typically all of the 'test' subdirs)
+so that any test can "import testsupport" to ensure the parent of pypy
+is on the sys.path -- so that "import pypy.etc.etc." always works.
+"""
 import sys, os
-import unittest
 
-testdir   = os.path.dirname(os.path.abspath(__file__))
-parentdir = os.path.dirname(testdir)
-rootdir   = os.path.dirname(os.path.dirname(parentdir))
-
-sys.path.insert(0, os.path.dirname(rootdir))
+head = this_path = os.path.abspath(__file__)
+while 1:
+    head, tail = os.path.split(head)
+    if not tail:
+        raise EnvironmentError, "pypy not among parents of %r!" % this_path
+    elif tail.lower()=='pypy':
+        sys.path.insert(0, head)
+        break
 


More information about the Pypy-commit mailing list