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
561eb5cb
Kaydet (Commit)
561eb5cb
authored
Eki 26, 2013
tarafından
Nick Coghlan
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #19330: Handle the no-docstrings case in tests
üst
40820f8f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
19 deletions
+19
-19
__init__.py
Lib/test/support/__init__.py
+7
-3
test_contextlib.py
Lib/test/test_contextlib.py
+12
-16
No files found.
Lib/test/support/__init__.py
Dosyayı görüntüle @
561eb5cb
...
...
@@ -1697,9 +1697,13 @@ def run_unittest(*classes):
#=======================================================================
# Check for the presence of docstrings.
HAVE_DOCSTRINGS
=
(
check_impl_detail
(
cpython
=
False
)
or
sys
.
platform
==
'win32'
or
sysconfig
.
get_config_var
(
'WITH_DOC_STRINGS'
))
# Rather than trying to enumerate all the cases where docstrings may be
# disabled, we just check for that directly
def
_check_docstrings
():
"""Just used to check if docstrings are enabled"""
HAVE_DOCSTRINGS
=
(
_check_docstrings
.
__doc__
is
not
None
)
requires_docstrings
=
unittest
.
skipUnless
(
HAVE_DOCSTRINGS
,
"test requires docstrings"
)
...
...
Lib/test/test_contextlib.py
Dosyayı görüntüle @
561eb5cb
...
...
@@ -14,20 +14,6 @@ except ImportError:
class
ContextManagerTestCase
(
unittest
.
TestCase
):
def
test_instance_docstring_given_function_docstring
(
self
):
# Issue 19330: ensure context manager instances have good docstrings
# See http://bugs.python.org/issue19404 for why this doesn't currently
# affect help() output :(
def
gen_with_docstring
():
"""This has a docstring"""
yield
gen_docstring
=
gen_with_docstring
.
__doc__
cm_with_docstring
=
contextmanager
(
gen_with_docstring
)
self
.
assertEqual
(
cm_with_docstring
.
__doc__
,
gen_docstring
)
obj
=
cm_with_docstring
()
self
.
assertEqual
(
obj
.
__doc__
,
gen_docstring
)
self
.
assertNotEqual
(
obj
.
__doc__
,
type
(
obj
)
.
__doc__
)
def
test_contextmanager_plain
(
self
):
state
=
[]
@contextmanager
...
...
@@ -115,14 +101,20 @@ class ContextManagerTestCase(unittest.TestCase):
self
.
assertEqual
(
baz
.
__name__
,
'baz'
)
self
.
assertEqual
(
baz
.
foo
,
'bar'
)
@unittest.skipIf
(
sys
.
flags
.
optimize
>=
2
,
"Docstrings are omitted with -O2 and above"
)
@support.requires_docstrings
def
test_contextmanager_doc_attrib
(
self
):
baz
=
self
.
_create_contextmanager_attribs
()
self
.
assertEqual
(
baz
.
__doc__
,
"Whee!"
)
@support.requires_docstrings
def
test_instance_docstring_given_cm_docstring
(
self
):
baz
=
self
.
_create_contextmanager_attribs
()(
None
)
self
.
assertEqual
(
baz
.
__doc__
,
"Whee!"
)
class
ClosingTestCase
(
unittest
.
TestCase
):
@support.requires_docstrings
def
test_instance_docs
(
self
):
# Issue 19330: ensure context manager instances have good docstrings
cm_docstring
=
closing
.
__doc__
...
...
@@ -239,6 +231,7 @@ class mycontext(ContextDecorator):
class
TestContextDecorator
(
unittest
.
TestCase
):
@support.requires_docstrings
def
test_instance_docs
(
self
):
# Issue 19330: ensure context manager instances have good docstrings
cm_docstring
=
mycontext
.
__doc__
...
...
@@ -398,6 +391,7 @@ class TestContextDecorator(unittest.TestCase):
class
TestExitStack
(
unittest
.
TestCase
):
@support.requires_docstrings
def
test_instance_docs
(
self
):
# Issue 19330: ensure context manager instances have good docstrings
cm_docstring
=
ExitStack
.
__doc__
...
...
@@ -665,6 +659,7 @@ class TestExitStack(unittest.TestCase):
class
TestRedirectStdout
(
unittest
.
TestCase
):
@support.requires_docstrings
def
test_instance_docs
(
self
):
# Issue 19330: ensure context manager instances have good docstrings
cm_docstring
=
redirect_stdout
.
__doc__
...
...
@@ -708,6 +703,7 @@ class TestRedirectStdout(unittest.TestCase):
class
TestSuppress
(
unittest
.
TestCase
):
@support.requires_docstrings
def
test_instance_docs
(
self
):
# Issue 19330: ensure context manager instances have good docstrings
cm_docstring
=
suppress
.
__doc__
...
...
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