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
26f11665
Commit
26f11665
authored
Jan 27, 2013
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Plain Diff
Issue #17041: Fix testing when Python is configured with the
--without-doc-strings.
parents
60cc3238
9d0add0c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
28 deletions
+53
-28
Lib/ctypes/test/test_win32.py
Lib/ctypes/test/test_win32.py
+4
-1
Lib/distutils/tests/test_build_ext.py
Lib/distutils/tests/test_build_ext.py
+3
-2
Lib/test/support.py
Lib/test/support.py
+10
-4
Lib/test/test_functools.py
Lib/test/test_functools.py
+1
-0
Lib/test/test_pydoc.py
Lib/test/test_pydoc.py
+32
-21
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/ctypes/test/test_win32.py
View file @
26f11665
...
...
@@ -3,6 +3,7 @@
from
ctypes
import
*
from
ctypes.test
import
is_resource_enabled
import
unittest
,
sys
from
test
import
support
import
_ctypes_test
...
...
@@ -60,7 +61,9 @@ if sys.platform == "win32":
def
test_COMError
(
self
):
from
_ctypes
import
COMError
self
.
assertEqual
(
COMError
.
__doc__
,
"Raised when a COM method call failed."
)
if
support
.
HAVE_DOCSTRINGS
:
self
.
assertEqual
(
COMError
.
__doc__
,
"Raised when a COM method call failed."
)
ex
=
COMError
(
-
1
,
"text"
,
(
"details"
,))
self
.
assertEqual
(
ex
.
hresult
,
-
1
)
...
...
Lib/distutils/tests/test_build_ext.py
View file @
26f11665
...
...
@@ -73,8 +73,9 @@ class BuildExtTestCase(TempdirManager,
self
.
assertEqual
(
xx
.
foo
(
2
,
5
),
7
)
self
.
assertEqual
(
xx
.
foo
(
13
,
15
),
28
)
self
.
assertEqual
(
xx
.
new
().
demo
(),
None
)
doc
=
'This is a template module just for instruction.'
self
.
assertEqual
(
xx
.
__doc__
,
doc
)
if
support
.
HAVE_DOCSTRINGS
:
doc
=
'This is a template module just for instruction.'
self
.
assertEqual
(
xx
.
__doc__
,
doc
)
self
.
assertTrue
(
isinstance
(
xx
.
Null
(),
xx
.
Null
))
self
.
assertTrue
(
isinstance
(
xx
.
Str
(),
xx
.
Str
))
...
...
Lib/test/support.py
View file @
26f11665
...
...
@@ -590,10 +590,6 @@ requires_bz2 = unittest.skipUnless(bz2, 'requires bz2')
requires_lzma
=
unittest
.
skipUnless
(
lzma
,
'requires lzma'
)
requires_docstrings
=
unittest
.
skipUnless
(
sysconfig
.
get_config_var
(
'WITH_DOC_STRINGS'
),
"test requires docstrings"
)
is_jython
=
sys
.
platform
.
startswith
(
'java'
)
# Filename used for testing
...
...
@@ -1592,6 +1588,16 @@ def run_unittest(*classes):
_filter_suite
(
suite
,
case_pred
)
_run_suite
(
suite
)
#=======================================================================
# 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'
))
requires_docstrings
=
unittest
.
skipUnless
(
HAVE_DOCSTRINGS
,
"test requires docstrings"
)
#=======================================================================
# doctest driver.
...
...
Lib/test/test_functools.py
View file @
26f11665
...
...
@@ -290,6 +290,7 @@ class TestUpdateWrapper(unittest.TestCase):
with
self
.
assertRaises
(
AttributeError
):
functools
.
update_wrapper
(
wrapper
,
f
,
assign
,
update
)
@
support
.
requires_docstrings
@
unittest
.
skipIf
(
sys
.
flags
.
optimize
>=
2
,
"Docstrings are omitted with -O2 and above"
)
def
test_builtin_update
(
self
):
...
...
Lib/test/test_pydoc.py
View file @
26f11665
...
...
@@ -30,6 +30,14 @@ except ImportError:
if
hasattr
(
pydoc_mod
,
"__loader__"
):
del
pydoc_mod
.
__loader__
if
test
.
support
.
HAVE_DOCSTRINGS
:
expected_data_docstrings
=
(
'dictionary for instance variables (if defined)'
,
'list of weak references to the object (if defined)'
,
)
*
2
else
:
expected_data_docstrings
=
(
''
,
''
,
''
,
''
)
expected_text_pattern
=
"""
NAME
test.pydoc_mod - This is a test module for test_pydoc
...
...
@@ -50,20 +58,16 @@ CLASSES
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
\
x20
\
x20
| __dict__
| dictionary for instance variables (if defined)
| __dict__%s
|
\
x20
\
x20
| __weakref__
| list of weak references to the object (if defined)
| __weakref__%s
\
x20
\
x20
\
x20
\
x20
class B(builtins.object)
| Data descriptors defined here:
|
\
x20
\
x20
| __dict__
| dictionary for instance variables (if defined)
| __dict__%s
|
\
x20
\
x20
| __weakref__
| list of weak references to the object (if defined)
| __weakref__%s
|
\
x20
\
x20
| ----------------------------------------------------------------------
| Data and other attributes defined here:
...
...
@@ -95,6 +99,9 @@ FILE
%s
"""
.
strip
()
expected_text_data_docstrings
=
tuple
(
'
\
n
| '
+
s
if
s
else
''
for
s
in
expected_data_docstrings
)
expected_html_pattern
=
"""
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
...
...
@@ -134,10 +141,10 @@ expected_html_pattern = """
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>
dictionary for instance variables (if defined)
</tt></dd>
<dd><tt>
%s
</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>
list of weak references to the object (if defined)
</tt></dd>
<dd><tt>
%s
</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
...
...
@@ -148,10 +155,10 @@ Data descriptors defined here:<br>
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
<td width="100%%">Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>
dictionary for instance variables (if defined)
</tt></dd>
<dd><tt>
%s
</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>
list of weak references to the object (if defined)
</tt></dd>
<dd><tt>
%s
</tt></dd>
</dl>
<hr>
Data and other attributes defined here:<br>
...
...
@@ -193,6 +200,8 @@ war</tt></dd></dl>
<td width="100%%">Nobody</td></tr></table>
"""
.
strip
()
# ' <- emacs turd
expected_html_data_docstrings
=
tuple
(
s
.
replace
(
' '
,
' '
)
for
s
in
expected_data_docstrings
)
# output pattern for missing module
missing_pattern
=
"no Python documentation found for '%s'"
...
...
@@ -256,7 +265,6 @@ class PydocDocTest(unittest.TestCase):
"Docstrings are omitted with -O2 and above"
)
@
unittest
.
skipIf
(
hasattr
(
sys
,
'gettrace'
)
and
sys
.
gettrace
(),
'trace function introduces __locals__ unexpectedly'
)
@
test
.
support
.
requires_docstrings
def
test_html_doc
(
self
):
result
,
doc_loc
=
get_pydoc_html
(
pydoc_mod
)
mod_file
=
inspect
.
getabsfile
(
pydoc_mod
)
...
...
@@ -265,7 +273,9 @@ class PydocDocTest(unittest.TestCase):
mod_url
=
nturl2path
.
pathname2url
(
mod_file
)
else
:
mod_url
=
mod_file
expected_html
=
expected_html_pattern
%
(
mod_url
,
mod_file
,
doc_loc
)
expected_html
=
expected_html_pattern
%
(
(
mod_url
,
mod_file
,
doc_loc
)
+
expected_html_data_docstrings
)
if
result
!=
expected_html
:
print_diffs
(
expected_html
,
result
)
self
.
fail
(
"outputs are not equal, see diff above"
)
...
...
@@ -274,11 +284,12 @@ class PydocDocTest(unittest.TestCase):
"Docstrings are omitted with -O2 and above"
)
@
unittest
.
skipIf
(
hasattr
(
sys
,
'gettrace'
)
and
sys
.
gettrace
(),
'trace function introduces __locals__ unexpectedly'
)
@
test
.
support
.
requires_docstrings
def
test_text_doc
(
self
):
result
,
doc_loc
=
get_pydoc_text
(
pydoc_mod
)
expected_text
=
expected_text_pattern
%
\
(
doc_loc
,
inspect
.
getabsfile
(
pydoc_mod
))
expected_text
=
expected_text_pattern
%
(
(
doc_loc
,)
+
expected_text_data_docstrings
+
(
inspect
.
getabsfile
(
pydoc_mod
),))
if
result
!=
expected_text
:
print_diffs
(
expected_text
,
result
)
self
.
fail
(
"outputs are not equal, see diff above"
)
...
...
@@ -329,7 +340,6 @@ class PydocDocTest(unittest.TestCase):
'Docstrings are omitted with -O2 and above'
)
@
unittest
.
skipIf
(
hasattr
(
sys
,
'gettrace'
)
and
sys
.
gettrace
(),
'trace function introduces __locals__ unexpectedly'
)
@
test
.
support
.
requires_docstrings
def
test_help_output_redirect
(
self
):
# issue 940286, if output is set in Helper, then all output from
# Helper.help should be redirected
...
...
@@ -355,8 +365,10 @@ class PydocDocTest(unittest.TestCase):
captured_output
(
'stderr'
)
as
err
:
helper
.
help
(
module
)
result
=
buf
.
getvalue
().
strip
()
expected_text
=
expected_help_pattern
%
\
(
doc_loc
,
inspect
.
getabsfile
(
pydoc_mod
))
expected_text
=
expected_help_pattern
%
(
(
doc_loc
,)
+
expected_text_data_docstrings
+
(
inspect
.
getabsfile
(
pydoc_mod
),))
self
.
assertEqual
(
''
,
output
.
getvalue
())
self
.
assertEqual
(
''
,
err
.
getvalue
())
self
.
assertEqual
(
expected_text
,
result
)
...
...
@@ -499,7 +511,6 @@ class PydocUrlHandlerTest(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
f
,
'A'
,
''
)
self
.
assertRaises
(
TypeError
,
f
,
'B'
,
'foobar'
)
@
test
.
support
.
requires_docstrings
def
test_url_requests
(
self
):
# Test for the correct title in the html pages returned.
# This tests the different parts of the URL handler without
...
...
Misc/NEWS
View file @
26f11665
...
...
@@ -488,6 +488,9 @@ Library
Tests
-----
- Issue #17041: Fix testing when Python is configured with the
--without-doc-strings.
- Issue #16923: Fix ResourceWarnings in test_ssl.
- Issue #15539: Added regression tests for Tools/scripts/pindent.py.
...
...
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