[pypy-svn] r46345 - in pypy/dist/pypy/translator: cli/test jvm/test oosupport/test_template

antocuni at codespeak.net antocuni at codespeak.net
Wed Sep 5 15:20:24 CEST 2007


Author: antocuni
Date: Wed Sep  5 15:20:24 2007
New Revision: 46345

Added:
   pypy/dist/pypy/translator/oosupport/test_template/runtest.py   (contents, props changed)
Modified:
   pypy/dist/pypy/translator/cli/test/test_runtest.py
   pypy/dist/pypy/translator/jvm/test/test_runtest.py
Log:
port test_runtest to oosupport, and remove duplicated code



Modified: pypy/dist/pypy/translator/cli/test/test_runtest.py
==============================================================================
--- pypy/dist/pypy/translator/cli/test/test_runtest.py	(original)
+++ pypy/dist/pypy/translator/cli/test/test_runtest.py	Wed Sep  5 15:20:24 2007
@@ -1,74 +1,11 @@
 import py
+from pypy.translator.oosupport.test_template.runtest import BaseTestRunTest
 from pypy.translator.cli.test.runtest import CliTest
-from pypy.translator.cli.test.runtest import FLOAT_PRECISION
-from pypy.annotation.listdef import s_list_of_strings
 
-def ident(x):
-    return x
-
-class TestRunTest(CliTest):
-
-    def test_patch_os(self):
-        import os
-        from pypy.translator.cli.support import patch, unpatch, NT_OS
-        original_O_CREAT = os.O_CREAT
-        olddefs = patch()
-        assert os.O_CREAT == NT_OS['O_CREAT']
-        unpatch(*olddefs)
-        assert os.O_CREAT == original_O_CREAT
-
-    def test_int(self):
-        assert self.interpret(ident, [42]) == 42
-    
-    def test_bool(self):
-        assert self.interpret(ident, [True]) == True
-        assert self.interpret(ident, [False]) == False
-
-    def test_float(self):
-        x = 10/3.0
-        res = self.interpret(ident, [x])
-        assert self.float_eq(x, res)
-
-    def test_char(self):
-        assert self.interpret(ident, ['a']) == 'a'
-
-    def test_list(self):
-        def fn():
-            return [1, 2, 3]
-        assert self.interpret(fn, []) == [1, 2, 3]
-
-    def test_tuple(self):
-        def fn():
-            return 1, 2
-        assert self.interpret(fn, []) == (1, 2)
-
-    def test_string(self):
-        def fn():
-            return 'foo'
-        res = self.interpret(fn, [])
-        assert self.ll_to_string(res) == 'foo'
-
-    def test_exception(self):
-        def fn():
-            raise ValueError
-        self.interpret_raises(ValueError, fn, [])
-
-    def test_exception_subclass(self):
-        def fn():
-            raise IndexError
-        self.interpret_raises(LookupError, fn, [])
-
-    def test_object_or_none(self):
-        def fn(flag):
-            if flag:
-                return "hello";
-            else:
-                return None
-        assert self.interpret(fn, [False]) is None
+class TestRunTest(BaseTestRunTest, CliTest):
 
     def test_auto_raise_exc(self):
         def fn():
             raise ValueError
         f = self._compile(fn, [], auto_raise_exc=True)
         py.test.raises(ValueError, f)
-        

Modified: pypy/dist/pypy/translator/jvm/test/test_runtest.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/test/test_runtest.py	(original)
+++ pypy/dist/pypy/translator/jvm/test/test_runtest.py	Wed Sep  5 15:20:24 2007
@@ -1,71 +1,5 @@
-import sys
+from pypy.translator.oosupport.test_template.runtest import BaseTestRunTest
 from pypy.translator.jvm.test.runtest import JvmTest
-from pypy.translator.jvm.test.runtest import FLOAT_PRECISION
-from pypy.annotation.listdef import s_list_of_strings
-from pypy.rlib.rarithmetic import r_ulonglong
 
-def ident(x):
-    return x
-
-class TestRunTest(JvmTest):
-
-    def test_patch_os(self):
-        import os
-        from pypy.translator.cli.support import patch, unpatch, NT_OS
-        original_O_CREAT = os.O_CREAT
-        olddefs = patch()
-        assert os.O_CREAT == NT_OS['O_CREAT']
-        unpatch(*olddefs)
-        assert os.O_CREAT == original_O_CREAT
-
-    def test_int(self):
-        assert self.interpret(ident, [42]) == 42
-    
-    def test_bool(self):
-        assert self.interpret(ident, [True]) == True
-        assert self.interpret(ident, [False]) == False
-
-    def test_float(self):
-        x = 10/3.0
-        res = self.interpret(ident, [x])
-        assert self.float_eq(x, res)
-
-    def test_char(self):
-        assert self.interpret(ident, ['a']) == 'a'
-
-    def test_list(self):
-        def fn():
-            return [1, 2, 3]
-        assert self.interpret(fn, []) == [1, 2, 3]
-
-    def test_tuple(self):
-        def fn():
-            return 1, 2
-        assert self.interpret(fn, []) == (1, 2)
-
-    def test_string(self):
-        def fn():
-            return 'foo'
-        res = self.interpret(fn, [])
-        assert self.ll_to_string(res) == 'foo'
-
-    def test_exception(self):
-        def fn():
-            raise ValueError
-        self.interpret_raises(ValueError, fn, [])
-
-    def test_exception_subclass(self):
-        def fn():
-            raise IndexError
-        self.interpret_raises(LookupError, fn, [])
-
-    def test_object_or_none(self):
-        def fn(flag):
-            if flag:
-                return "hello";
-            else:
-                return None
-        assert self.interpret(fn, [False]) is None
-
-    def test_ullong(self):
-        assert self.interpret(ident, [r_ulonglong(sys.maxint+1)]) == sys.maxint+1
+class TestRunTest(BaseTestRunTest, JvmTest):
+    pass

Added: pypy/dist/pypy/translator/oosupport/test_template/runtest.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/oosupport/test_template/runtest.py	Wed Sep  5 15:20:24 2007
@@ -0,0 +1,71 @@
+import sys
+import py
+from pypy.annotation.listdef import s_list_of_strings
+from pypy.rlib.rarithmetic import r_ulonglong
+
+def ident(x):
+    return x
+
+class BaseTestRunTest:
+
+    def test_patch_os(self):
+        import os
+        from pypy.translator.cli.support import patch, unpatch, NT_OS
+        original_O_CREAT = os.O_CREAT
+        olddefs = patch()
+        assert os.O_CREAT == NT_OS['O_CREAT']
+        unpatch(*olddefs)
+        assert os.O_CREAT == original_O_CREAT
+
+    def test_int(self):
+        assert self.interpret(ident, [42]) == 42
+    
+    def test_bool(self):
+        assert self.interpret(ident, [True]) == True
+        assert self.interpret(ident, [False]) == False
+
+    def test_float(self):
+        x = 10/3.0
+        res = self.interpret(ident, [x])
+        assert self.float_eq(x, res)
+
+    def test_char(self):
+        assert self.interpret(ident, ['a']) == 'a'
+
+    def test_list(self):
+        def fn():
+            return [1, 2, 3]
+        assert self.interpret(fn, []) == [1, 2, 3]
+
+    def test_tuple(self):
+        def fn():
+            return 1, 2
+        assert self.interpret(fn, []) == (1, 2)
+
+    def test_string(self):
+        def fn():
+            return 'foo'
+        res = self.interpret(fn, [])
+        assert self.ll_to_string(res) == 'foo'
+
+    def test_ullong(self):
+        assert self.interpret(ident, [r_ulonglong(sys.maxint+1)]) == sys.maxint+1
+
+    def test_exception(self):
+        def fn():
+            raise ValueError
+        self.interpret_raises(ValueError, fn, [])
+
+    def test_exception_subclass(self):
+        def fn():
+            raise IndexError
+        self.interpret_raises(LookupError, fn, [])
+
+    def test_object_or_none(self):
+        def fn(flag):
+            if flag:
+                return "hello";
+            else:
+                return None
+        assert self.interpret(fn, [False]) is None
+        



More information about the Pypy-commit mailing list