Commits

Armin Rigo committed bc7e16d

Speed-ups for testing on top of an untranslated PyPy.

Comments (0)

Files changed (1)

     assert str(e.value) == "'int(*)(int)' expects 1 arguments, got 0"
 
 def test_callback_exception():
-    import cStringIO
+    import cStringIO, linecache
     def matches(str, pattern):
         while '$' in pattern:
             i = pattern.index('$')
             assert str[:i] == pattern[:i]
             j = str.find(pattern[i+1], i)
-            assert i + 1 <= j < str.find('\n', i)
+            assert i + 1 <= j <= str.find('\n', i)
             str = str[j:]
             pattern = pattern[i+1:]
         assert str == pattern
     def cb1(x):
         check_value(x)
         return x * 3
-    BInt = new_primitive_type("int")
-    BFunc = new_function_type((BInt,), BInt, False)
+    BShort = new_primitive_type("short")
+    BFunc = new_function_type((BShort,), BShort, False)
     f = callback(BFunc, cb1, -42)
     orig_stderr = sys.stderr
+    orig_getline = linecache.getline
     try:
+        linecache.getline = lambda *args: 'LINE'    # hack: speed up PyPy tests
         sys.stderr = cStringIO.StringIO()
         assert f(100) == 300
         assert sys.stderr.getvalue() == ''
 From callback <function cb1 at 0x$>:
 Traceback (most recent call last):
   File "$", line $, in cb1
-    check_value(x)
+    $
   File "$", line $, in check_value
-    raise ValueError(42)
+    $
 ValueError: 42
 """)
         sys.stderr = cStringIO.StringIO()
-        bigvalue = 1 << (8 * size_of_int() - 2)
+        bigvalue = 20000
         assert f(bigvalue) == -42
         assert matches(sys.stderr.getvalue(), """\
 From callback <function cb1 at 0x$>:
-OverflowError: integer %d does not fit 'int'
-""" % (bigvalue * 3,))
+OverflowError: integer 60000 does not fit 'short'
+""")
     finally:
         sys.stderr = orig_stderr
+        linecache.getline = orig_getline
 
 def test_callback_return_type():
     for rettype in ["signed char", "short", "int", "long", "long long",
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.