]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-27973 - Use test.support.temp_dir instead of NamedTemporaryFile for the (#17774)
authorSenthil Kumaran <senthil@uthcode.com>
Sat, 4 Jan 2020 02:14:18 +0000 (18:14 -0800)
committerGitHub <noreply@github.com>
Sat, 4 Jan 2020 02:14:18 +0000 (18:14 -0800)
desired behavior under windows platform.

Suggestion by David Bolen

Lib/test/test_urllibnet.py

index df118dc75d1b3f3b6b55f3fc38b6104d777fbf60..ef33e3a0ea6173310bd19a309e14731dfee058c4 100644 (file)
@@ -1,4 +1,3 @@
-import tempfile
 import unittest
 from test import test_support
 from test.test_urllib2net import skip_ftp_test_on_travis
@@ -224,9 +223,10 @@ class urlopen_FTPTest(unittest.TestCase):
 
         with test_support.transient_internet(self.FTP_TEST_FILE):
             try:
-                for _ in range(self.NUM_FTP_RETRIEVES):
-                    with tempfile.NamedTemporaryFile() as fp:
-                        urllib.FancyURLopener().retrieve(self.FTP_TEST_FILE, fp.name)
+                for file_num in range(self.NUM_FTP_RETRIEVES):
+                    with test_support.temp_dir() as td:
+                        urllib.FancyURLopener().retrieve(self.FTP_TEST_FILE,
+                                                         os.path.join(td, str(file_num)))
             except IOError as e:
                 self.fail("Failed FTP retrieve while accessing ftp url "
                           "multiple times.\n Error message was : %s" % e)