This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Test failures with -OO
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.3, Python 3.4
Status: closed Resolution: fixed
Dependencies: 19626 Superseder:
Assigned To: serhiy.storchaka Nosy List: ezio.melotti, python-dev, r.david.murray, serhiy.storchaka, skrah, terry.reedy
Priority: normal Keywords: patch

Created on 2013-11-09 09:21 by serhiy.storchaka, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
issue19535.patch serhiy.storchaka, 2013-11-16 10:51 review
issue19535_2.patch serhiy.storchaka, 2013-11-16 17:47 review
issue19535_statistics.diff ezio.melotti, 2013-11-16 18:16 review
issue19535_3.patch serhiy.storchaka, 2013-11-16 19:42 review
Messages (10)
msg202476 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-11-09 09:21
$ ./python -OO -m test.regrtest test_docxmlrpc test_functools test_inspect test_pkg
[1/4] test_docxmlrpc
test test_docxmlrpc failed -- Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/test/", line 210, in test_annotations
AssertionError: b'<dl><dt><a name="-annotation"><strong>annotation</strong></a>(x: int)</dt><dd><tt>Use&nbsp;function&nbsp;annotations.</tt></dd></dl>\n<dl><dt><a name="-method_annotation"><strong>method_annotation</strong></a>(x: bytes)</dt></dl>' not found in b'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\n<html><head><title>Python: DocXMLRPCServer Test Documentation</title>\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\n</head><body bgcolor="#f0f0f8">\n\n<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">\n<tr bgcolor="#7799ee">\n<td valign=bottom>&nbsp;<br>\n<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>DocXMLRPCServer Test Docs</strong></big></big></font></td\n><td align=right valign=bottom\n><font color="#ffffff" face="helvetica, arial">&nbsp;</font></td></tr></table>\n    <p><tt>This&nbsp;is&nbsp;an&nbsp;XML-RPC&nbsp;server\'s&nbsp;documentation,&nbsp;but&nbsp;the&nbsp;server&nbsp;can&nbsp;be&nbsp;used&nbsp;by&nbsp;POSTing&nbsp;to&nbsp;/RPC2.&nbsp;Try&nbsp;self.<strong>add</strong>,&nbsp;too.</tt></p>\n<p>\n<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">\n<tr bgcolor="#eeaa77">\n<td colspan=3 valign=bottom>&nbsp;<br>\n<font color="#ffffff" face="helvetica, arial"><big><strong>Methods</strong></big></font></td></tr>\n    \n<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>\n<td width="100%"><dl><dt><a name="-&lt;lambda&gt;"><strong>&lt;lambda&gt;</strong></a>(x, y)</dt></dl>\n<dl><dt><a name="-add"><strong>add</strong></a>(x, y)</dt></dl>\n<dl><dt><a name="-annotation"><strong>annotation</strong></a>(x: int)</dt></dl>\n<dl><dt><a name="-method_annotation"><strong>method_annotation</strong></a>(x: bytes)</dt></dl>\n<dl><dt><a name="-system.listMethods"><strong>system.listMethods</strong></a>()</dt></dl>\n<dl><dt><a name="-system.methodHelp"><strong>system.methodHelp</strong></a>(method_name)</dt></dl>\n<dl><dt><a name="-system.methodSignature"><strong>system.methodSignature</strong></a>(method_name)</dt></dl>\n</td></tr></table>\n</body></html>'

[2/4/1] test_functools
test test_functools failed -- Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/test/", line 1127, in test_wrapping_attributes
    self.assertEqual(g.__doc__, "Simple test")
AssertionError: None != 'Simple test'

[3/4/2] test_inspect
test test_inspect failed -- Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/test/", line 2528, in test_details
    self.assertIn(module.__cached__, output)
AssertionError: '/home/serhiy/py/cpython/Lib/unittest/__pycache__/__init__.cpython-34.pyo' not found in "Target: unittest\nOrigin: /home/serhiy/py/cpython/Lib/unittest/\nCached: /home/serhiy/py/cpython/Lib/unittest/__pycache__/__init__.cpython-34.pyc\nLoader: <_frozen_importlib.SourceFileLoader object at 0xb7041c4c>\nSubmodule search path: ['/home/serhiy/py/cpython/Lib/unittest']\n\n\n"

[4/4/3] test_pkg
1 test OK.
3 tests failed:
    test_docxmlrpc test_functools test_inspect
msg202477 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-11-09 09:25
Failure of test_pkg is sporadic.

$ ./python -OO -m test.regrtest test_pkg
[1/1] test_pkg
test test_pkg failed -- Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/test/", line 259, in test_7
    '__name__', '__package__', '__path__'])
AssertionError: Lists differ: ['__c[22 chars]__file__', '__loader__', '__name__', '__package__'] != ['__c[22 chars]__file__', '__loader__', '__name__', '__package__', '__path__']

Second list contains 1 additional elements.
First extra element 6:

- ['__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__']
+ ['__cached__',
+  '__doc__',
+  '__file__',
+  '__loader__',
+  '__name__',
+  '__package__',
+  '__path__']

1 test failed:
msg202995 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-11-16 00:37
I presume a test could detect docstring stripping with

def f(): 'docstring'
if f.__doc__ is None: <skip test that expects them>

This would cover the test_functools case, but I don't know about the others.
msg203021 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-11-16 10:51
Here is a patch.
msg203067 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-11-16 17:47
Actually test_inspect is affected by -O. Here is updated patch.
msg203071 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-11-16 18:16
Patch LGTM.
I'm getting 4 additional failures on 3.4: test_asyncio test_contextlib test_email test_statistics

* test_statistics is fixed by the attached patch.
* test_email fails in Lib/email/ -- this probably deservers a separate issue.
* test_contextlib fails in Lib/test/ even though these tests are decorated with @support.requires_docstrings (defined in Lib/test/support/  Even with -00 the _check_docstrings function seems to have a docstring (the exact line I used to run the tests is "./python -OO -m test -v test_contextlib").
* test_asyncio has lot of failures, and most of them look like:
  ERROR: test_call_later (test.test_asyncio.test_events.PollEventLoopTests)
  Traceback (most recent call last):
    File "/home/wolf/dev/py/py3k/Lib/test/test_asyncio/", line 1315, in setUp
    File "/home/wolf/dev/py/py3k/Lib/test/test_asyncio/", line 188, in setUp
    File "/home/wolf/dev/py/py3k/Lib/asyncio/", line 423, in set_event_loop
  AttributeError: 'object' object has no attribute 'set_event_loop'
Without -OO test_asyncio works fine.  I haven't investigated this further.
msg203073 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-11-16 18:22
I created #19626 for the test_email failures.
msg203078 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-11-16 19:42
Updated patch fixes test_contextlib and test_statistics too. I think test_asyncio is worth separated issue too.
msg203079 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-11-16 19:45
Ah, test_contextlib shouldn't be fixed. It failed due to cached non-optimized
msg205578 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-12-08 16:16
New changeset 910b1cb5176c by Serhiy Storchaka in branch '3.3':
Issue #19535: Fixed test_docxmlrpc when python is run with -OO.

New changeset e71142abf8b6 by Serhiy Storchaka in branch 'default':
Issue #19535: Fixed test_docxmlrpc, test_functools, test_inspect, and
Date User Action Args
2022-04-11 14:57:53adminsetgithub: 63734
2013-12-08 16:17:47serhiy.storchakasetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: - Python 2.7
2013-12-08 16:16:36python-devsetnosy: + python-dev
messages: + msg205578
2013-11-16 19:45:52serhiy.storchakasetmessages: + msg203079
2013-11-16 19:42:04serhiy.storchakasetfiles: + issue19535_3.patch

messages: + msg203078
2013-11-16 18:22:49ezio.melottisetdependencies: + test_email and Lib/email/ failures with -OO
messages: + msg203073
2013-11-16 18:16:54ezio.melottisetfiles: + issue19535_statistics.diff
nosy: + r.david.murray, ezio.melotti
messages: + msg203071

2013-11-16 17:47:22serhiy.storchakasetfiles: + issue19535_2.patch

messages: + msg203067
2013-11-16 10:51:35serhiy.storchakasetfiles: + issue19535.patch
messages: + msg203021

assignee: serhiy.storchaka
keywords: + patch
stage: patch review
2013-11-16 00:37:17terry.reedysetnosy: + terry.reedy
messages: + msg202995
2013-11-09 09:25:42serhiy.storchakasetmessages: + msg202477
2013-11-09 09:21:22serhiy.storchakacreate