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
62f68ed3
Commit
62f68ed3
authored
Aug 04, 2010
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factor out stripping of interpreter debug output in test.support.strip_python_stderr()
parent
f96482e9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
3 deletions
+13
-3
Lib/test/support.py
Lib/test/support.py
+10
-0
Lib/test/test_subprocess.py
Lib/test/test_subprocess.py
+1
-1
Lib/test/test_threading.py
Lib/test/test_threading.py
+2
-2
No files found.
Lib/test/support.py
View file @
62f68ed3
...
...
@@ -1243,3 +1243,13 @@ def swap_item(obj, item, new_val):
yield
finally
:
del
obj
[
item
]
def
strip_python_stderr
(
stderr
):
"""Strip the stderr of a Python process from potential debug output
emitted by the interpreter.
This will typically be run on the result of the communicate() method
of a subprocess.Popen object.
"""
stderr
=
re
.
sub
(
br"\
[
\d+ refs\
]
\r?\n?$"
,
b""
,
stderr
).
strip
()
return
stderr
Lib/test/test_subprocess.py
View file @
62f68ed3
...
...
@@ -53,7 +53,7 @@ class BaseTestCase(unittest.TestCase):
# In a debug build, stuff like "[6580 refs]" is printed to stderr at
# shutdown time. That frustrates tests trying to check stderr produced
# from a spawned Python process.
actual
=
re
.
sub
(
"
\
[
\
d+ refs
\
]
\
r?
\
n
?$"
,
""
,
stderr
.
decode
()).
encode
(
)
actual
=
support
.
strip_python_stderr
(
stderr
)
self
.
assertEqual
(
actual
,
expected
,
msg
)
...
...
Lib/test/test_threading.py
View file @
62f68ed3
# Very rudimentary test of threading module
import
test.support
from
test.support
import
verbose
from
test.support
import
verbose
,
strip_python_stderr
import
random
import
re
import
sys
...
...
@@ -350,7 +350,7 @@ class ThreadTests(BaseTestCase):
stdout
,
stderr
=
p
.
communicate
()
self
.
assertEqual
(
stdout
.
strip
(),
b"Woke up, sleep function is: <built-in function sleep>"
)
stderr
=
re
.
sub
(
br"^\
[
\d+ refs\
]
", b"", stderr, re.MULTILINE).strip(
)
stderr
=
strip_python_stderr
(
stderr
)
self
.
assertEqual
(
stderr
,
b""
)
def
test_enumerate_after_join
(
self
):
...
...
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