[pypy-svn] r35253 - pypy/dist/pypy/objspace/test

auc at codespeak.net auc at codespeak.net
Mon Dec 4 14:30:37 CET 2006


Author: auc
Date: Mon Dec  4 14:30:35 2006
New Revision: 35253

Added:
   pypy/dist/pypy/objspace/test/problems.py
      - copied unchanged from r32835, pypy/dist/pypy/objspace/constraint/applevel/problems.py
Modified:
   pypy/dist/pypy/objspace/test/_test_logic_build.py
   pypy/dist/pypy/objspace/test/test_logicobjspace.py
Log:
test fixes


Modified: pypy/dist/pypy/objspace/test/_test_logic_build.py
==============================================================================
--- pypy/dist/pypy/objspace/test/_test_logic_build.py	(original)
+++ pypy/dist/pypy/objspace/test/_test_logic_build.py	Mon Dec  4 14:30:35 2006
@@ -24,7 +24,7 @@
             for name, meth in inspect.getmembers(klass())
             if not name.startswith('_')]
 
-def run_tests(tm):
+def run_tests(tm, selected_tests):
     
     tm.raises = raises
     tm.skip = skip
@@ -32,13 +32,18 @@
     successes = []
     failures = []
     skipped = []
-
-    for tests in [get_test_methods(cl) for cl in get_test_classes()] :
+    all_tests = [get_test_methods(cl) for cl in get_test_classes()]
+    print "testing %s test(s) classe(s)" % len(all_tests)
+    for tests in all_tests:
         for name, meth in tests:
             if name == 'setup_class': continue
+            if selected_tests and name not in selected_tests:
+                continue
             try:
                 meth()
             except Skip:
+##                 import traceback
+##                 traceback.print_exc()
                 skipped.append(name)
             except Exception, e:
                 failures.append((name, meth, e))
@@ -66,4 +71,9 @@
 if __name__ == __name__:
     import sys
     tm = __import__(sys.argv[1])
-    run_tests(tm)
+    tests = []
+    try:
+        tests += (sys.argv[2:])
+    except:
+        pass
+    run_tests(tm, tests)

Modified: pypy/dist/pypy/objspace/test/test_logicobjspace.py
==============================================================================
--- pypy/dist/pypy/objspace/test/test_logicobjspace.py	(original)
+++ pypy/dist/pypy/objspace/test/test_logicobjspace.py	Mon Dec  4 14:30:35 2006
@@ -438,7 +438,9 @@
         assert len(sched_info()['blocked_byneed']) == 1
         reset_scheduler()
         assert len(sched_info()['blocked_byneed']) == 0
-        assert len(sched_info().values()[0]['threads']) == 1
+        sp_info = [y for x, y in sched_info().items()
+                   if isinstance(x, int)][0]
+        assert len(sp_info['threads']) == 1
 
     def test_wait_two(self):
 
@@ -461,7 +463,9 @@
         unify(Y, 42)
         assert X == Y == 42
         assert o == 2
-        assert len(sched_info().values()[0]['threads']) == 1
+        sp_info = [y for x, y in sched_info().items()
+                   if isinstance(x, int)][0]
+        assert len(sp_info['threads']) == 1
         
     def test_fib(self):
         def fib(X):
@@ -498,14 +502,17 @@
         assert count[0] == max_spawn + erring
         try:
             wait(Failed)
-        except RebindingError, e: 
-            assert len(sched_info().values()[0]['threads']) == 1
+        except RebindingError, e:
+            sp_info = [y for x, y in sched_info().items()
+                       if isinstance(x, int)][0]
+            assert len(sp_info['threads']) == 1
             return
         assert False
                 
     def test_nd_append(self):
         skip("non determnistic choice: yet to come")
         #from CTM p.639
+        #write me correctly...
         """
         def append(A, B, C):
             choice:
@@ -793,9 +800,10 @@
         
         
     def test_default_solver(self):
-        skip("segfaulting")
         if is_interpreted():
             skip("will loop infinitely (bug in space.clone())")
+        else:
+            skip("clone segfaults")
         from constraint.examples import conference_scheduling
         from constraint import solver
 
@@ -878,9 +886,7 @@
             solve(s, commit_to, Solution)
             assert Solution in (False, ('beige', 'mauve', 'coral'))
 
-    def test_queens1(self):
-        if not is_interpreted():
-            skip("segfaulting")
+    def test_queens(self):
         from constraint.examples import queens1, queens2
 
         def solve(spc, commitment, Sol):
@@ -919,3 +925,20 @@
                 if Solution:
                     sols.add(tuple(Solution))
             assert len(sols) == 2
+
+
+    def test_cloning_queens(self):
+        if is_interpreted():
+            skip("no cloning feature")
+        from constraint.examples import queens1, queens2
+        from constraint.solver import solve
+
+        #switch_debug_info()
+        for queen in (queens1,):# queens2):
+            sols = set()
+            s = newspace(queens1, {'size':8})
+            for sol in solve(s):
+                sols.add(sol)
+                print sol
+            #assert len(sols) == 2
+



More information about the Pypy-commit mailing list