Closed Bug 770891 Opened 13 years ago Closed 13 years ago

mozhttpd proxy test needs to uninstall url openers after use

Categories

(Testing :: Mozbase, defect)

x86_64
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: wlach, Assigned: wlach)

Details

Attachments

(1 file, 2 obsolete files)

The mozhttpd api proxy test installs a custom url opener for urllib2 globally, but doesn't reset it to default after it's finished. This causes problems if another test uses urllib2 to open a url later.
Comment on attachment 639096 [details] [diff] [review] Patch to reset global url opener to default in mozhttpd proxy api test after finished Cool, though if this test asserts the old opener won't be reinstalled. Do you think it's worth putting it into its own class with setUp() and tearDown() methods to handler the openers (the latter being called regardless of whether the test passes or fails)?
Attachment #639096 - Flags: review?(mcote) → review+
Also, I think urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler()) should really be urllib2.install_opener(urllib2.build_opener()) This is what urllib2.urlopen() does if there is no opener. Or really, maybe it should just be urllib2.install_opener(None) which would make the next call to urlopen install the default opener. I'm sure this is unlikely to change in Python 2, but it seems safer.
Updated patch, carrying over r+
Attachment #639096 - Attachment is obsolete: true
Attachment #639339 - Flags: review+
Oops, screwed up my diff. Here's the right patch.
Attachment #639339 - Attachment is obsolete: true
Attachment #639341 - Flags: review+
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: