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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
3c58789f
Commit
3c58789f
authored
Feb 07, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add coverage test
parent
cfe68067
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
0 deletions
+67
-0
runtests.py
runtests.py
+1
-0
tests/bugs.txt
tests/bugs.txt
+2
-0
tests/run/coverage.srctree
tests/run/coverage.srctree
+64
-0
No files found.
runtests.py
View file @
3c58789f
...
...
@@ -102,6 +102,7 @@ EXT_DEP_MODULES = {
'tag:pstats'
:
'pstats'
,
'tag:posix'
:
'posix'
,
'tag:array'
:
'array'
,
'tag:coverage'
:
'coverage'
,
'tag:ipython'
:
'IPython'
,
'tag:jedi'
:
'jedi'
,
}
...
...
tests/bugs.txt
View file @
3c58789f
...
...
@@ -14,6 +14,8 @@ inherited_final_method
tryfinallychaining # also see FIXME in "yield_from_pep380" test
cimport_alias_subclass
coverage # depends on newer coverage.py version
# CPython regression tests that don't current work:
pyregr.test_signal
pyregr.test_capi
...
...
tests/run/coverage.srctree
0 → 100644
View file @
3c58789f
# mode: run
# tag: coverage,trace
"""
PYTHON setup.py build_ext -i
PYTHON coverage_test.py
"""
######## setup.py ########
from distutils.core import setup
from Cython.Build import cythonize
setup(ext_modules = cythonize('coverage_test_cy.py'))
######## coverage_test_cy.py ########
# cython: linetrace=True
# distutils: define_macros=CYTHON_TRACE=1
def func1(a, b):
x = 1 # 5
c = func2(a) + b # 6
return x + c # 7
def func2(a):
return a * 2 # 11
######## coverage_test.py ########
try:
# io.StringIO in Py2.x cannot handle str ...
from StringIO import StringIO
except ImportError:
from io import StringIO
from coverage import coverage
import coverage_test_cy
def run_coverage():
cov = coverage()
cov.start()
assert coverage_test_cy.func1(1, 2) == 5
assert coverage_test_cy.func2(2) == 4
cov.stop()
out = StringIO()
cov.report([coverage_test_cy], file=out)
lines = out.getvalue().splitlines()
assert any('coverage_test_cy' in line for line in lines), "coverage_test_cy not found in coverage"
mod_file, exec_lines, excl_lines, missing_lines, _ = cov.analysis2(coverage_test_cy)
assert 'coverage_test_cy' in mod_file
executed = set(exec_lines) - set(missing_lines)
assert all(line in executed for line in [5, 6, 7, 11]), '%s / %s' % (exec_lines, missing_lines)
if __name__ == '__main__':
run_coverage()
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