Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_zipimport_support mucks up with modules #54765

Closed
pitrou opened this issue Nov 27, 2010 · 4 comments
Closed

test_zipimport_support mucks up with modules #54765

pitrou opened this issue Nov 27, 2010 · 4 comments
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@pitrou
Copy link
Member

pitrou commented Nov 27, 2010

BPO 10556
Nosy @brettcannon, @ncoghlan, @pitrou

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2011-01-11.14:47:44.616>
created_at = <Date 2010-11-27.23:21:06.192>
labels = ['type-bug', 'tests']
title = 'test_zipimport_support mucks up with modules'
updated_at = <Date 2011-01-11.14:47:44.615>
user = 'https://github.com/pitrou'

bugs.python.org fields:

activity = <Date 2011-01-11.14:47:44.615>
actor = 'ncoghlan'
assignee = 'none'
closed = True
closed_date = <Date 2011-01-11.14:47:44.616>
closer = 'ncoghlan'
components = ['Tests']
creation = <Date 2010-11-27.23:21:06.192>
creator = 'pitrou'
dependencies = []
files = []
hgrepos = []
issue_num = 10556
keywords = []
message_count = 4.0
messages = ['122590', '125988', '125991', '126009']
nosy_count = 3.0
nosy_names = ['brett.cannon', 'ncoghlan', 'pitrou']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue10556'
versions = ['Python 3.1', 'Python 2.7', 'Python 3.2']

@pitrou
Copy link
Member Author

pitrou commented Nov 27, 2010

This test failure is due to test_zipimport_support loading and unloading modules, which leads to them being reloaded. Then the ssl.CertificateError which is checked for by assertRaises isn't the same as the one raised by the module under test (I have printed the type names and ids below):

$ ./python -E -bb -m test.regrtest test_http_cookies test_zipimport_support test_httplib
[1/3] test_http_cookies
[2/3] test_zipimport_support
[3/3] test_httplib
<class 'ssl.CertificateError'> 49243264
<class 'ssl.CertificateError'> 51134640
test test_httplib failed -- Traceback (most recent call last):
  File "/home/antoine/py3k/__svn__/Lib/test/test_httplib.py", line 481, in test_local_bad_hostname
    h.request('GET', '/')
  File "/home/antoine/py3k/__svn__/Lib/http/client.py", line 950, in request
    self._send_request(method, url, body, headers)
  File "/home/antoine/py3k/__svn__/Lib/http/client.py", line 988, in _send_request
    self.endheaders(body)
  File "/home/antoine/py3k/__svn__/Lib/http/client.py", line 946, in endheaders
    self._send_output(message_body)
  File "/home/antoine/py3k/__svn__/Lib/http/client.py", line 791, in _send_output
    self.send(msg)
  File "/home/antoine/py3k/__svn__/Lib/http/client.py", line 737, in send
    self.connect()
  File "/home/antoine/py3k/__svn__/Lib/http/client.py", line 1096, in connect
    ssl.match_hostname(self.sock.getpeercert(), self.host)
  File "/home/antoine/py3k/__svn__/Lib/ssl.py", line 142, in match_hostname
    % (hostname, dnsnames[0]))
ssl.CertificateError: hostname 'localhost' doesn't match 'fakehostname'

(witnessed in http://www.python.org/dev/buildbot/all/builders/AMD64%20Snow%20Leopard%203.x/builds/527/steps/test/logs/stdio )

@pitrou pitrou added tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels Nov 27, 2010
@ncoghlan
Copy link
Contributor

Even more special: put a test_doctest in first and the attempt to clean up sys.modules in test_zipimport_support leaves things alone so the _ssl module doesn't break (test_doctest just leaves sys.modules alone and doesn't even try to remove all the modules it implicitly imports).

I'm actually tempted to remove test.support.modules_setup() and modules_cleanup() and delete the calls from the affected tests. Trying to clear out implicitly imported modules is going to create far more problems than it resolves.

@ncoghlan
Copy link
Contributor

Fixed for 3.2 in r87925. (I simply dropped the attempt to restore sys.modules to its original state from test_zipimport_support)

@ncoghlan
Copy link
Contributor

2.7 and 3.1 don't appear to exhibit the fault, so closing this one.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants