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
4ed3bb7f
Commit
4ed3bb7f
authored
Feb 23, 2013
by
Ezio Melotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#17249: convert a test in test_capi to use unittest and reap threads.
parent
7dddbb2b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
28 deletions
+30
-28
Lib/test/test_capi.py
Lib/test/test_capi.py
+28
-28
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/test/test_capi.py
View file @
4ed3bb7f
...
...
@@ -8,6 +8,7 @@ import random
import
subprocess
import
sys
import
time
import
_thread
import
unittest
from
test
import
support
try
:
...
...
@@ -222,21 +223,13 @@ class EmbeddingTest(unittest.TestCase):
os
.
chdir
(
oldcwd
)
def
test_main
():
support
.
run_unittest
(
CAPITest
,
TestPendingCalls
,
Test6012
,
EmbeddingTest
)
for
name
in
dir
(
_testcapi
):
if
name
.
startswith
(
'test_'
):
test
=
getattr
(
_testcapi
,
name
)
if
support
.
verbose
:
print
(
"internal"
,
name
)
test
()
@
unittest
.
skipUnless
(
threading
,
'Threading required for this test.'
)
class
TestThreadState
(
unittest
.
TestCase
):
@
support
.
reap_threads
def
test_thread_state
(
self
):
# some extra thread-state tests driven via _testcapi
def
TestThreadState
():
if
support
.
verbose
:
print
(
"auto-thread-state"
)
def
target
():
idents
=
[]
def
callback
():
...
...
@@ -246,18 +239,25 @@ def test_main():
a
=
b
=
callback
time
.
sleep
(
1
)
# Check our main thread is in the list exactly 3 times.
if
idents
.
count
(
_thread
.
get_ident
())
!=
3
:
raise
support
.
TestFailed
(
self
.
assertEqual
(
idents
.
count
(
_thread
.
get_ident
()),
3
,
"Couldn't find main thread correctly in the list"
)
if
threading
:
import
_thread
import
time
TestThreadState
()
t
=
threading
.
Thread
(
target
=
TestThreadState
)
target
()
t
=
threading
.
Thread
(
target
=
target
)
t
.
start
()
t
.
join
()
def
test_main
():
support
.
run_unittest
(
CAPITest
,
TestPendingCalls
,
Test6012
,
EmbeddingTest
,
TestThreadState
)
for
name
in
dir
(
_testcapi
):
if
name
.
startswith
(
'test_'
):
test
=
getattr
(
_testcapi
,
name
)
if
support
.
verbose
:
print
(
"internal"
,
name
)
test
()
if
__name__
==
"__main__"
:
test_main
()
Misc/NEWS
View file @
4ed3bb7f
...
...
@@ -936,6 +936,8 @@ Extension Modules
Tests
-----
- Issue #17249: convert a test in test_capi to use unittest and reap threads.
- Issue #17041: Fix testing when Python is configured with the
--without-doc-strings.
...
...
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