Commit a6332d43 authored by Stefan Behnel's avatar Stefan Behnel

Py2.5 test fix

parent 2776eeb8
...@@ -20,10 +20,16 @@ else: ...@@ -20,10 +20,16 @@ else:
DBG = False DBG = False
import sys import sys
if DBG == sys.flags.optimize: try:
optimised = bool(sys.flags.optimize)
except AttributeError:
# Py2.[45]
optimised = eval('not __debug__')
if DBG == optimised:
raise RuntimeError( raise RuntimeError(
"PYTHON: unexpected debug value %s, expected %s" % ( "PYTHON: unexpected debug value %s, expected %s" % (
DBG, sys.flags.optimize)) DBG, optimised))
ASSERT_CALLED = False ASSERT_CALLED = False
def sideeffect(): def sideeffect():
...@@ -32,14 +38,14 @@ def sideeffect(): ...@@ -32,14 +38,14 @@ def sideeffect():
return True return True
assert sideeffect() assert sideeffect()
if ASSERT_CALLED and sys.flags.optimize: if ASSERT_CALLED == optimised:
raise RuntimeError("Assert called in optimised Python run") raise RuntimeError("Assert called in optimised Python run")
import debug_test_cython import debug_test_cython
if debug_test_cython.DBG == sys.flags.optimize: if debug_test_cython.DBG == optimised:
raise RuntimeError( raise RuntimeError(
"CYTHON: unexpected debug value %s, expected %s" % ( "CYTHON: unexpected debug value %s, expected %s" % (
debug_test_cython.DBG, sys.flags.optimize)) debug_test_cython.DBG, optimised))
######## debug_test_cython.pyx ######## ######## debug_test_cython.pyx ########
...@@ -49,17 +55,23 @@ if __debug__: ...@@ -49,17 +55,23 @@ if __debug__:
else: else:
DBG = False DBG = False
import sys
try:
optimised = bool(sys.flags.optimize)
except AttributeError:
# Py2.[45]
optimised = eval('not __debug__')
ASSERT_CALLED = False ASSERT_CALLED = False
def sideeffect(): def sideeffect():
global ASSERT_CALLED global ASSERT_CALLED
ASSERT_CALLED = True ASSERT_CALLED = True
return True return True
import sys if DBG == optimised:
if DBG == sys.flags.optimize:
raise RuntimeError("Unexpected debug value %s, expected %s" % ( raise RuntimeError("Unexpected debug value %s, expected %s" % (
DBG, sys.flags.optimize)) DBG, optimised))
assert sideeffect() assert sideeffect()
if ASSERT_CALLED and sys.flags.optimize: if ASSERT_CALLED == optimised:
raise RuntimeError("Assert called in optimised Python run") raise RuntimeError("Assert called in optimised Python run")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment