bpo-37421: urllib.request tests call urlcleanup() (GH-14529)

urllib.request tests now call urlcleanup() to remove temporary files
created by urlretrieve() tests and to clear the _opener global
variable set by urlopen() and functions calling indirectly urlopen().

regrtest now checks if urllib.request._url_tempfiles and
urllib.request._opener are changed by tests.
diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py
index d394ced..848ab84 100644
--- a/Lib/test/test_urllibnet.py
+++ b/Lib/test/test_urllibnet.py
@@ -25,6 +25,9 @@
         socket.setdefaulttimeout(None)
 
     def testURLread(self):
+        # clear _opener global variable
+        self.addCleanup(urllib.request.urlcleanup)
+
         domain = urllib.parse.urlparse(support.TEST_HTTP_URL).netloc
         with support.transient_internet(domain):
             f = urllib.request.urlopen(support.TEST_HTTP_URL)
@@ -48,6 +51,10 @@
 
     url = 'http://www.pythontest.net/'
 
+    def setUp(self):
+        # clear _opener global variable
+        self.addCleanup(urllib.request.urlcleanup)
+
     @contextlib.contextmanager
     def urlopen(self, *args, **kwargs):
         resource = args[0]
@@ -144,6 +151,10 @@
 class urlretrieveNetworkTests(unittest.TestCase):
     """Tests urllib.request.urlretrieve using the network."""
 
+    def setUp(self):
+        # remove temporary files created by urlretrieve()
+        self.addCleanup(urllib.request.urlcleanup)
+
     @contextlib.contextmanager
     def urlretrieve(self, *args, **kwargs):
         resource = args[0]