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
48fbe52a
Kaydet (Commit)
48fbe52a
authored
Haz 23, 2017
tarafından
Serhiy Storchaka
Kaydeden (comit)
GitHub
Haz 23, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-30664: The description of a unittest subtest now preserves the (#2265)
order of keyword arguments of TestCase.subTest().
üst
c38e32a1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
7 deletions
+29
-7
case.py
Lib/unittest/case.py
+12
-2
test_result.py
Lib/unittest/test/test_result.py
+14
-5
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/unittest/case.py
Dosyayı görüntüle @
48fbe52a
...
...
@@ -338,6 +338,16 @@ class _AssertLogsContext(_BaseTestCaseContext):
.
format
(
logging
.
getLevelName
(
self
.
level
),
self
.
logger
.
name
))
class
_OrderedChainMap
(
collections
.
ChainMap
):
def
__iter__
(
self
):
seen
=
set
()
for
mapping
in
self
.
maps
:
for
k
in
mapping
:
if
k
not
in
seen
:
seen
.
add
(
k
)
yield
k
class
TestCase
(
object
):
"""A class whose instances are single test cases.
...
...
@@ -514,7 +524,7 @@ class TestCase(object):
return
parent
=
self
.
_subtest
if
parent
is
None
:
params_map
=
collections
.
ChainMap
(
params
)
params_map
=
_Ordered
ChainMap
(
params
)
else
:
params_map
=
parent
.
params
.
new_child
(
params
)
self
.
_subtest
=
_SubTest
(
self
,
msg
,
params_map
)
...
...
@@ -1418,7 +1428,7 @@ class _SubTest(TestCase):
if
self
.
params
:
params_desc
=
', '
.
join
(
"{}={!r}"
.
format
(
k
,
v
)
for
(
k
,
v
)
in
s
orted
(
self
.
params
.
items
()
))
for
(
k
,
v
)
in
s
elf
.
params
.
items
(
))
parts
.
append
(
"({})"
.
format
(
params_desc
))
return
" "
.
join
(
parts
)
or
'(<subtest>)'
...
...
Lib/unittest/test/test_result.py
Dosyayı görüntüle @
48fbe52a
...
...
@@ -307,7 +307,7 @@ class Test_TestResult(unittest.TestCase):
self
.
assertEqual
(
result
.
getDescription
(
self
.
_subtest
),
'testGetSubTestDescriptionWithoutDocstring ('
+
__name__
+
'.Test_TestResult) (
bar=2, foo=1
)'
)
'.Test_TestResult) (
foo=1, bar=2
)'
)
with
self
.
subTest
(
'some message'
):
result
=
unittest
.
TextTestResult
(
None
,
True
,
1
)
self
.
assertEqual
(
...
...
@@ -335,12 +335,21 @@ class Test_TestResult(unittest.TestCase):
def
testGetNestedSubTestDescriptionWithoutDocstring
(
self
):
with
self
.
subTest
(
foo
=
1
):
with
self
.
subTest
(
ba
r
=
2
):
with
self
.
subTest
(
ba
z
=
2
,
bar
=
3
):
result
=
unittest
.
TextTestResult
(
None
,
True
,
1
)
self
.
assertEqual
(
result
.
getDescription
(
self
.
_subtest
),
'testGetNestedSubTestDescriptionWithoutDocstring '
'('
+
__name__
+
'.Test_TestResult) (bar=2, foo=1)'
)
'('
+
__name__
+
'.Test_TestResult) (baz=2, bar=3, foo=1)'
)
def
testGetDuplicatedNestedSubTestDescriptionWithoutDocstring
(
self
):
with
self
.
subTest
(
foo
=
1
,
bar
=
2
):
with
self
.
subTest
(
baz
=
3
,
bar
=
4
):
result
=
unittest
.
TextTestResult
(
None
,
True
,
1
)
self
.
assertEqual
(
result
.
getDescription
(
self
.
_subtest
),
'testGetDuplicatedNestedSubTestDescriptionWithoutDocstring '
'('
+
__name__
+
'.Test_TestResult) (baz=3, bar=4, foo=1)'
)
@unittest.skipIf
(
sys
.
flags
.
optimize
>=
2
,
"Docstrings are omitted with -O2 and above"
)
...
...
@@ -362,7 +371,7 @@ class Test_TestResult(unittest.TestCase):
self
.
assertEqual
(
result
.
getDescription
(
self
.
_subtest
),
(
'testGetSubTestDescriptionWithOneLineDocstring '
'('
+
__name__
+
'.Test_TestResult) (
bar=2, foo=1
)
\n
'
'('
+
__name__
+
'.Test_TestResult) (
foo=1, bar=2
)
\n
'
'Tests getDescription() for a method with a docstring.'
))
@unittest.skipIf
(
sys
.
flags
.
optimize
>=
2
,
...
...
@@ -390,7 +399,7 @@ class Test_TestResult(unittest.TestCase):
self
.
assertEqual
(
result
.
getDescription
(
self
.
_subtest
),
(
'testGetSubTestDescriptionWithMultiLineDocstring '
'('
+
__name__
+
'.Test_TestResult) (
bar=2, foo=1
)
\n
'
'('
+
__name__
+
'.Test_TestResult) (
foo=1, bar=2
)
\n
'
'Tests getDescription() for a method with a longer '
'docstring.'
))
...
...
Misc/NEWS
Dosyayı görüntüle @
48fbe52a
...
...
@@ -374,6 +374,9 @@ Extension Modules
Library
-------
- bpo-30664: The description of a unittest subtest now preserves the order of
keyword arguments of TestCase.subTest().
- [Security] bpo-30730: Prevent environment variables injection in subprocess on
Windows. Prevent passing other environment variables and command arguments.
...
...
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