Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
4dbbb413
Commit
4dbbb413
authored
Aug 02, 2010
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#3821: beginnings of a trace.py unittest.
parent
9cb9927e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
Lib/test/test_trace.py
Lib/test/test_trace.py
+47
-0
No files found.
Lib/test/test_trace.py
0 → 100644
View file @
4dbbb413
# Testing the trace module
from
test.support
import
run_unittest
,
TESTFN
,
rmtree
,
unlink
,
captured_stdout
import
unittest
import
trace
import
os
,
sys
class
TestCoverage
(
unittest
.
TestCase
):
def
tearDown
(
self
):
rmtree
(
TESTFN
)
unlink
(
TESTFN
)
def
_coverage
(
self
,
tracer
):
tracer
.
run
(
'from test import test_pprint; test_pprint.test_main()'
)
r
=
tracer
.
results
()
r
.
write_results
(
show_missing
=
True
,
summary
=
True
,
coverdir
=
TESTFN
)
def
test_coverage
(
self
):
tracer
=
trace
.
Trace
(
trace
=
0
,
count
=
1
)
with
captured_stdout
()
as
stdout
:
self
.
_coverage
(
tracer
)
stdout
=
stdout
.
getvalue
()
self
.
assertTrue
(
"pprint.py"
in
stdout
)
self
.
assertTrue
(
"case.py"
in
stdout
)
# from unittest
files
=
os
.
listdir
(
TESTFN
)
self
.
assertTrue
(
"pprint.cover"
in
files
)
self
.
assertTrue
(
"unittest.case.cover"
in
files
)
def
test_coverage_ignore
(
self
):
# Ignore all files, nothing should be traced nor printed
libpath
=
os
.
path
.
normpath
(
os
.
path
.
dirname
(
os
.
__file__
))
# sys.prefix does not work when running from a checkout
tracer
=
trace
.
Trace
(
ignoredirs
=
[
sys
.
prefix
,
sys
.
exec_prefix
,
libpath
],
trace
=
0
,
count
=
1
)
with
captured_stdout
()
as
stdout
:
self
.
_coverage
(
tracer
)
self
.
assertEquals
(
stdout
.
getvalue
(),
""
)
if
os
.
path
.
exists
(
TESTFN
):
files
=
os
.
listdir
(
TESTFN
)
self
.
assertEquals
(
files
,
[])
def
test_main
():
run_unittest
(
__name__
)
if
__name__
==
"__main__"
:
test_main
()
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