[pypy-commit] pypy repeatlist_strategy: Add support to skip tests if some list strategies are available in the interpreter

Vincent Legoll pypy.commits at gmail.com
Tue Jan 12 14:40:43 EST 2016


Author: Vincent Legoll <vincent.legoll at idgrilles.fr>
Branch: repeatlist_strategy
Changeset: r81689:c8c3db337ed7
Date: 2016-01-12 16:52 +0100
http://bitbucket.org/pypy/pypy/changeset/c8c3db337ed7/

Log:	Add support to skip tests if some list strategies are available in
	the interpreter Use that to skip tests obsoleted by
	RepeatListStrategy

diff --git a/lib-python/2.7/test/seq_tests.py b/lib-python/2.7/test/seq_tests.py
--- a/lib-python/2.7/test/seq_tests.py
+++ b/lib-python/2.7/test/seq_tests.py
@@ -5,6 +5,8 @@
 import unittest
 import sys
 
+from test import test_support
+
 # Various iterables
 # This is used for checking the constructor (here and in test_deque.py)
 def iterfunc(seqn):
@@ -305,6 +307,8 @@
             self.assertEqual(self.type2test(s)*(-4), self.type2test([]))
             self.assertEqual(id(s), id(s*1))
 
+    @unittest.skipIf(test_support.list_strategy('RepeatListStrategy'),
+                     "This test is obsoleted by RepeatListStrategy")
     def test_bigrepeat(self):
         import sys
         # we chose an N such as 2**16 * N does not fit into a cpu word
diff --git a/lib-python/2.7/test/test_support.py b/lib-python/2.7/test/test_support.py
--- a/lib-python/2.7/test/test_support.py
+++ b/lib-python/2.7/test/test_support.py
@@ -1366,6 +1366,32 @@
     return guards.get(platform.python_implementation().lower(), default)
 
 # ----------------------------------
+# List strategies can make tests wrong
+# This helper makes it easy to skip those
+
+def list_strategy(st=None):
+    try:
+        import __pypy__
+        # This will return 'object' if pypy is translated without
+        # list strategies enabled
+        if 'list_strategy' in dir(__pypy__):
+            # Python 2.7.3 (2.2.1+dfsg-1ubuntu0.3, Sep 30 2015, 15:18:40)
+            # [PyPy 2.2.1 with GCC 4.8.4]
+            strategy = __pypy__.list_strategy
+            expected = 'empty'
+        elif 'strategy' in dir(__pypy__):
+            # Python 2.7.10 (71b4bf53487c, Jan 05 2016, 23:00:18)
+            # [PyPy 4.1.0-alpha0 with GCC 4.8.4]
+            strategy = __pypy__.strategy
+            expected = 'EmptyListStrategy'
+        if strategy([]) == expected:
+            if st is None or strategy([None] * 2) == st:
+                return True
+    except ImportError:
+        pass
+    return False
+
+# ----------------------------------
 # PyPy extension: you can run::
 #     python ..../test_foo.py --pdb
 # to get a pdb prompt in case of exceptions


More information about the pypy-commit mailing list