Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
2776eeb8
Commit
2776eeb8
authored
Aug 29, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test for __debug__ and asserts with Python's -O/-OO options
parent
738ce404
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
0 deletions
+65
-0
tests/run/__debug__.srctree
tests/run/__debug__.srctree
+65
-0
No files found.
tests/run/__debug__.srctree
0 → 100644
View file @
2776eeb8
"""
PYTHON setup.py build_ext -i
PYTHON debug_test.py
PYTHON -O debug_test.py
PYTHON -OO debug_test.py
"""
######## setup.py ########
from distutils.core import setup
from Cython.Build import cythonize
setup(ext_modules = cythonize('debug_test_cython.pyx'))
######## debug_test.py ########
if __debug__:
DBG = True
else:
DBG = False
import sys
if DBG == sys.flags.optimize:
raise RuntimeError(
"PYTHON: unexpected debug value %s, expected %s" % (
DBG, sys.flags.optimize))
ASSERT_CALLED = False
def sideeffect():
global ASSERT_CALLED
ASSERT_CALLED = True
return True
assert sideeffect()
if ASSERT_CALLED and sys.flags.optimize:
raise RuntimeError("Assert called in optimised Python run")
import debug_test_cython
if debug_test_cython.DBG == sys.flags.optimize:
raise RuntimeError(
"CYTHON: unexpected debug value %s, expected %s" % (
debug_test_cython.DBG, sys.flags.optimize))
######## debug_test_cython.pyx ########
if __debug__:
DBG = True
else:
DBG = False
ASSERT_CALLED = False
def sideeffect():
global ASSERT_CALLED
ASSERT_CALLED = True
return True
import sys
if DBG == sys.flags.optimize:
raise RuntimeError("Unexpected debug value %s, expected %s" % (
DBG, sys.flags.optimize))
assert sideeffect()
if ASSERT_CALLED and sys.flags.optimize:
raise RuntimeError("Assert called in optimised Python run")
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment