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
de2800f8
Kaydet (Commit)
de2800f8
authored
Agu 29, 2013
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #17974: Switch unittest from using getopt to using argparse.
üst
64f7c4e4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
40 deletions
+57
-40
__main__.py
Lib/unittest/__main__.py
+1
-2
main.py
Lib/unittest/main.py
+0
-0
test_discovery.py
Lib/unittest/test/test_discovery.py
+26
-29
test_program.py
Lib/unittest/test/test_program.py
+28
-9
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/unittest/__main__.py
Dosyayı görüntüle @
de2800f8
...
@@ -13,7 +13,6 @@ if sys.argv[0].endswith("__main__.py"):
...
@@ -13,7 +13,6 @@ if sys.argv[0].endswith("__main__.py"):
__unittest
=
True
__unittest
=
True
from
.main
import
main
,
TestProgram
,
USAGE_AS_MAIN
from
.main
import
main
,
TestProgram
TestProgram
.
USAGE
=
USAGE_AS_MAIN
main
(
module
=
None
)
main
(
module
=
None
)
Lib/unittest/main.py
Dosyayı görüntüle @
de2800f8
This diff is collapsed.
Click to expand it.
Lib/unittest/test/test_discovery.py
Dosyayı görüntüle @
de2800f8
import
os
import
os
import
re
import
re
import
sys
import
sys
from
test
import
support
import
unittest
import
unittest
class
TestableTestProgram
(
unittest
.
TestProgram
):
class
TestableTestProgram
(
unittest
.
TestProgram
):
module
=
'__main__'
module
=
None
exit
=
True
exit
=
True
defaultTest
=
failfast
=
catchbreak
=
buffer
=
None
defaultTest
=
failfast
=
catchbreak
=
buffer
=
None
verbosity
=
1
verbosity
=
1
...
@@ -232,58 +233,54 @@ class TestDiscovery(unittest.TestCase):
...
@@ -232,58 +233,54 @@ class TestDiscovery(unittest.TestCase):
program
=
TestableTestProgram
()
program
=
TestableTestProgram
()
args
=
[]
args
=
[]
def
do_discovery
(
argv
):
program
.
_do_discovery
=
args
.
append
args
.
extend
(
argv
)
program
.
_do_discovery
=
do_discovery
program
.
parseArgs
([
'something'
,
'discover'
])
program
.
parseArgs
([
'something'
,
'discover'
])
self
.
assertEqual
(
args
,
[])
self
.
assertEqual
(
args
,
[
[]
])
args
[:]
=
[]
program
.
parseArgs
([
'something'
,
'discover'
,
'foo'
,
'bar'
])
program
.
parseArgs
([
'something'
,
'discover'
,
'foo'
,
'bar'
])
self
.
assertEqual
(
args
,
[
'foo'
,
'bar'
])
self
.
assertEqual
(
args
,
[
[
'foo'
,
'bar'
]
])
def
test_command_line_handling_discover_by_default
(
self
):
def
test_command_line_handling_discover_by_default
(
self
):
program
=
TestableTestProgram
()
program
=
TestableTestProgram
()
program
.
module
=
None
self
.
called
=
False
args
=
[]
def
do_discovery
(
argv
):
program
.
_do_discovery
=
args
.
append
self
.
called
=
True
self
.
assertEqual
(
argv
,
[])
program
.
_do_discovery
=
do_discovery
program
.
parseArgs
([
'something'
])
program
.
parseArgs
([
'something'
])
self
.
assertTrue
(
self
.
called
)
self
.
assertEqual
(
args
,
[[]])
self
.
assertEqual
(
program
.
verbosity
,
1
)
self
.
assertIs
(
program
.
buffer
,
False
)
self
.
assertIs
(
program
.
catchbreak
,
False
)
self
.
assertIs
(
program
.
failfast
,
False
)
def
test_command_line_handling_discover_by_default_with_options
(
self
):
def
test_command_line_handling_discover_by_default_with_options
(
self
):
program
=
TestableTestProgram
()
program
=
TestableTestProgram
()
program
.
module
=
None
args
=
[
'something'
,
'-v'
,
'-b'
,
'-v'
,
'-c'
,
'-f'
]
args
=
[]
self
.
called
=
False
program
.
_do_discovery
=
args
.
append
def
do_discovery
(
argv
):
program
.
parseArgs
([
'something'
,
'-v'
,
'-b'
,
'-v'
,
'-c'
,
'-f'
])
self
.
called
=
True
self
.
assertEqual
(
args
,
[[]])
self
.
assertEqual
(
argv
,
args
[
1
:]
)
self
.
assertEqual
(
program
.
verbosity
,
2
)
program
.
_do_discovery
=
do_discovery
self
.
assertIs
(
program
.
buffer
,
True
)
program
.
parseArgs
(
args
)
self
.
assertIs
(
program
.
catchbreak
,
True
)
self
.
assert
True
(
self
.
called
)
self
.
assert
Is
(
program
.
failfast
,
True
)
def
test_command_line_handling_do_discovery_too_many_arguments
(
self
):
def
test_command_line_handling_do_discovery_too_many_arguments
(
self
):
class
Stop
(
Exception
):
pass
def
usageExit
():
raise
Stop
program
=
TestableTestProgram
()
program
=
TestableTestProgram
()
program
.
usageExit
=
usageExit
program
.
testLoader
=
None
program
.
testLoader
=
None
with
self
.
assertRaises
(
Stop
):
with
support
.
captured_stderr
()
as
stderr
,
\
self
.
assertRaises
(
SystemExit
)
as
cm
:
# too many args
# too many args
program
.
_do_discovery
([
'one'
,
'two'
,
'three'
,
'four'
])
program
.
_do_discovery
([
'one'
,
'two'
,
'three'
,
'four'
])
self
.
assertEqual
(
cm
.
exception
.
args
,
(
2
,))
self
.
assertIn
(
'usage:'
,
stderr
.
getvalue
())
def
test_command_line_handling_do_discovery_uses_default_loader
(
self
):
def
test_command_line_handling_do_discovery_uses_default_loader
(
self
):
program
=
object
.
__new__
(
unittest
.
TestProgram
)
program
=
object
.
__new__
(
unittest
.
TestProgram
)
program
.
_initArgParsers
()
class
Loader
(
object
):
class
Loader
(
object
):
args
=
[]
args
=
[]
...
...
Lib/unittest/test/test_program.py
Dosyayı görüntüle @
de2800f8
...
@@ -2,6 +2,7 @@ import io
...
@@ -2,6 +2,7 @@ import io
import
os
import
os
import
sys
import
sys
from
test
import
support
import
unittest
import
unittest
...
@@ -186,20 +187,38 @@ class TestCommandLineArgs(unittest.TestCase):
...
@@ -186,20 +187,38 @@ class TestCommandLineArgs(unittest.TestCase):
if
attr
==
'catch'
and
not
hasInstallHandler
:
if
attr
==
'catch'
and
not
hasInstallHandler
:
continue
continue
setattr
(
program
,
attr
,
None
)
program
.
parseArgs
([
None
])
self
.
assertIs
(
getattr
(
program
,
attr
),
False
)
false
=
[]
setattr
(
program
,
attr
,
false
)
program
.
parseArgs
([
None
])
self
.
assertIs
(
getattr
(
program
,
attr
),
false
)
true
=
[
42
]
setattr
(
program
,
attr
,
true
)
program
.
parseArgs
([
None
])
self
.
assertIs
(
getattr
(
program
,
attr
),
true
)
short_opt
=
'-
%
s'
%
arg
[
0
]
short_opt
=
'-
%
s'
%
arg
[
0
]
long_opt
=
'--
%
s'
%
arg
long_opt
=
'--
%
s'
%
arg
for
opt
in
short_opt
,
long_opt
:
for
opt
in
short_opt
,
long_opt
:
setattr
(
program
,
attr
,
None
)
setattr
(
program
,
attr
,
None
)
program
.
parseArgs
([
None
,
opt
])
self
.
assertTrue
(
getattr
(
program
,
attr
))
for
opt
in
short_opt
,
long_opt
:
not_none
=
object
()
setattr
(
program
,
attr
,
not_none
)
program
.
parseArgs
([
None
,
opt
])
program
.
parseArgs
([
None
,
opt
])
self
.
assertEqual
(
getattr
(
program
,
attr
),
not_none
)
self
.
assertIs
(
getattr
(
program
,
attr
),
True
)
setattr
(
program
,
attr
,
False
)
with
support
.
captured_stderr
()
as
stderr
,
\
self
.
assertRaises
(
SystemExit
)
as
cm
:
program
.
parseArgs
([
None
,
opt
])
self
.
assertEqual
(
cm
.
exception
.
args
,
(
2
,))
setattr
(
program
,
attr
,
True
)
with
support
.
captured_stderr
()
as
stderr
,
\
self
.
assertRaises
(
SystemExit
)
as
cm
:
program
.
parseArgs
([
None
,
opt
])
self
.
assertEqual
(
cm
.
exception
.
args
,
(
2
,))
def
testWarning
(
self
):
def
testWarning
(
self
):
"""Test the warnings argument"""
"""Test the warnings argument"""
...
...
Misc/NEWS
Dosyayı görüntüle @
de2800f8
...
@@ -51,6 +51,8 @@ Core and Builtins
...
@@ -51,6 +51,8 @@ Core and Builtins
Library
Library
-------
-------
- Issue #17974: Switch unittest from using getopt to using argparse.
- Issue #11798: TestSuite now drops references to own tests after execution.
- Issue #11798: TestSuite now drops references to own tests after execution.
- Issue #16611: http.cookie now correctly parses the '
secure
' and '
httponly
'
- Issue #16611: http.cookie now correctly parses the '
secure
' and '
httponly
'
...
...
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