Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
5f9d3acc
Kaydet (Commit)
5f9d3acc
authored
Eki 02, 2015
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #22806: Add ``python -m test --list-tests`` command to list tests.
üst
076fc872
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
26 deletions
+49
-26
cmdline.py
Lib/test/libregrtest/cmdline.py
+4
-7
main.py
Lib/test/libregrtest/main.py
+36
-19
test_regrtest.py
Lib/test/test_regrtest.py
+7
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/test/libregrtest/cmdline.py
Dosyayı görüntüle @
5f9d3acc
import
argparse
import
faulthandler
import
os
from
test
import
support
...
...
@@ -234,6 +233,9 @@ def _create_parser():
group
.
add_argument
(
'-F'
,
'--forever'
,
action
=
'store_true'
,
help
=
'run the specified tests in a loop, until an '
'error happens'
)
group
.
add_argument
(
'--list-tests'
,
action
=
'store_true'
,
help
=
"only write the name of tests that will be run, "
"don't execute them"
)
parser
.
add_argument
(
'args'
,
nargs
=
argparse
.
REMAINDER
,
help
=
argparse
.
SUPPRESS
)
...
...
@@ -301,12 +303,7 @@ def _parse_args(args, **kwargs):
if
ns
.
quiet
:
ns
.
verbose
=
0
if
ns
.
timeout
is
not
None
:
if
hasattr
(
faulthandler
,
'dump_traceback_later'
):
if
ns
.
timeout
<=
0
:
ns
.
timeout
=
None
else
:
print
(
"Warning: The timeout option requires "
"faulthandler.dump_traceback_later"
)
if
ns
.
timeout
<=
0
:
ns
.
timeout
=
None
if
ns
.
use_mp
is
not
None
:
if
ns
.
use_mp
<=
0
:
...
...
Lib/test/libregrtest/main.py
Dosyayı görüntüle @
5f9d3acc
import
faulthandler
import
os
import
platform
import
random
...
...
@@ -110,8 +111,13 @@ class Regrtest:
def
parse_args
(
self
,
kwargs
):
ns
=
_parse_args
(
sys
.
argv
[
1
:],
**
kwargs
)
if
ns
.
timeout
and
not
hasattr
(
faulthandler
,
'dump_traceback_later'
):
print
(
"Warning: The timeout option requires "
"faulthandler.dump_traceback_later"
,
file
=
sys
.
stderr
)
ns
.
timeout
=
None
if
ns
.
threshold
is
not
None
and
gc
is
None
:
print
(
'No GC available, ignore --threshold.'
)
print
(
'No GC available, ignore --threshold.'
,
file
=
sys
.
stderr
)
ns
.
threshold
=
None
if
ns
.
findleaks
:
...
...
@@ -122,7 +128,8 @@ class Regrtest:
pass
#gc.set_debug(gc.DEBUG_SAVEALL)
else
:
print
(
'No GC available, disabling --findleaks'
)
print
(
'No GC available, disabling --findleaks'
,
file
=
sys
.
stderr
)
ns
.
findleaks
=
False
# Strip .py extensions.
...
...
@@ -163,20 +170,6 @@ class Regrtest:
nottests
.
add
(
arg
)
self
.
ns
.
args
=
[]
# For a partial run, we do not need to clutter the output.
if
(
self
.
ns
.
verbose
or
self
.
ns
.
header
or
not
(
self
.
ns
.
quiet
or
self
.
ns
.
single
or
self
.
tests
or
self
.
ns
.
args
)):
# Print basic platform information
print
(
"=="
,
platform
.
python_implementation
(),
*
sys
.
version
.
split
())
print
(
"== "
,
platform
.
platform
(
aliased
=
True
),
"
%
s-endian"
%
sys
.
byteorder
)
print
(
"== "
,
"hash algorithm:"
,
sys
.
hash_info
.
algorithm
,
"64bit"
if
sys
.
maxsize
>
2
**
32
else
"32bit"
)
print
(
"== "
,
os
.
getcwd
())
print
(
"Testing with flags:"
,
sys
.
flags
)
# if testdir is set, then we are not running the python tests suite, so
# don't add default tests to be executed or skipped (pass empty values)
if
self
.
ns
.
testdir
:
...
...
@@ -199,15 +192,18 @@ class Regrtest:
del
self
.
selected
[:
self
.
selected
.
index
(
self
.
ns
.
start
)]
except
ValueError
:
print
(
"Couldn't find starting test (
%
s), using all tests"
%
self
.
ns
.
start
)
%
self
.
ns
.
start
,
file
=
sys
.
stderr
)
if
self
.
ns
.
randomize
:
if
self
.
ns
.
random_seed
is
None
:
self
.
ns
.
random_seed
=
random
.
randrange
(
10000000
)
random
.
seed
(
self
.
ns
.
random_seed
)
print
(
"Using random seed"
,
self
.
ns
.
random_seed
)
random
.
shuffle
(
self
.
selected
)
def
list_tests
(
self
):
for
name
in
self
.
selected
:
print
(
name
)
def
rerun_failed_tests
(
self
):
self
.
ns
.
verbose
=
True
self
.
ns
.
failfast
=
False
...
...
@@ -315,6 +311,23 @@ class Regrtest:
return
def
run_tests
(
self
):
# For a partial run, we do not need to clutter the output.
if
(
self
.
ns
.
verbose
or
self
.
ns
.
header
or
not
(
self
.
ns
.
quiet
or
self
.
ns
.
single
or
self
.
tests
or
self
.
ns
.
args
)):
# Print basic platform information
print
(
"=="
,
platform
.
python_implementation
(),
*
sys
.
version
.
split
())
print
(
"== "
,
platform
.
platform
(
aliased
=
True
),
"
%
s-endian"
%
sys
.
byteorder
)
print
(
"== "
,
"hash algorithm:"
,
sys
.
hash_info
.
algorithm
,
"64bit"
if
sys
.
maxsize
>
2
**
32
else
"32bit"
)
print
(
"== "
,
os
.
getcwd
())
print
(
"Testing with flags:"
,
sys
.
flags
)
if
self
.
ns
.
randomize
:
print
(
"Using random seed"
,
self
.
ns
.
random_seed
)
if
self
.
ns
.
forever
:
self
.
tests
=
self
.
_test_forever
(
list
(
self
.
selected
))
self
.
test_count
=
''
...
...
@@ -359,8 +372,12 @@ class Regrtest:
setup_tests
(
self
.
ns
)
self
.
find_tests
(
tests
)
self
.
run_tests
()
if
self
.
ns
.
list_tests
:
self
.
list_tests
()
sys
.
exit
(
0
)
self
.
run_tests
()
self
.
display_result
()
if
self
.
ns
.
verbose2
and
self
.
bad
:
...
...
Lib/test/test_regrtest.py
Dosyayı görüntüle @
5f9d3acc
...
...
@@ -672,6 +672,13 @@ class ArgsTestCase(BaseTestCase):
reflog
=
fp
.
read
()
self
.
assertEqual
(
reflog
,
line2
)
def
test_list_tests
(
self
):
# test --list-tests
tests
=
[
self
.
create_test
()
for
i
in
range
(
5
)]
output
=
self
.
run_tests
(
'--list-tests'
,
*
tests
)
self
.
assertEqual
(
output
.
rstrip
()
.
splitlines
(),
tests
)
if
__name__
==
'__main__'
:
unittest
.
main
()
Misc/NEWS
Dosyayı görüntüle @
5f9d3acc
...
...
@@ -170,6 +170,8 @@ Documentation
Tests
-----
-
Issue
#
22806
:
Add
``
python
-
m
test
--
list
-
tests
``
command
to
list
tests
.
-
Issue
#
18174
:
``
python
-
m
test
--
huntrleaks
...``
now
also
checks
for
leak
of
file
descriptors
.
Patch
written
by
Richard
Oudkerk
.
...
...
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