issue13287 - Define __all__ for urllib.request and urllib.error and expose only

the relevant module. Other cleanup improvements. Patch by flox.
This commit is contained in:
Senthil Kumaran 2011-11-01 23:20:31 +08:00
parent 712b14fc2a
commit 6c5bd40a3e
4 changed files with 40 additions and 18 deletions

View file

@ -19,6 +19,18 @@ import urllib.error
# parse_keqv_list, parse_http_list, HTTPDigestAuthHandler
class TrivialTests(unittest.TestCase):
def test___all__(self):
# Verify which names are exposed
for module in 'request', 'response', 'parse', 'error', 'robotparser':
context = {}
exec('from urllib.%s import *' % module, context)
del context['__builtins__']
for k, v in context.items():
self.assertEqual(v.__module__, 'urllib.%s' % module,
"%r is exposed in 'urllib.%s' but defined in %r" %
(k, module, v.__module__))
def test_trivial(self):
# A couple trivial tests