bpo-40275: Use new test.support helper submodules in tests (GH-21448)
diff --git a/Lib/test/test_optparse.py b/Lib/test/test_optparse.py
index 437fdd2..ed65b77 100644
--- a/Lib/test/test_optparse.py
+++ b/Lib/test/test_optparse.py
@@ -14,6 +14,7 @@
from io import StringIO
from test import support
+from test.support import os_helper
import optparse
@@ -1021,10 +1022,10 @@
self.parser.add_option("-f", "--file", type="file", dest="file")
def tearDown(self):
- if os.path.isdir(support.TESTFN):
- os.rmdir(support.TESTFN)
- elif os.path.isfile(support.TESTFN):
- os.unlink(support.TESTFN)
+ if os.path.isdir(os_helper.TESTFN):
+ os.rmdir(os_helper.TESTFN)
+ elif os.path.isfile(os_helper.TESTFN):
+ os.unlink(os_helper.TESTFN)
class MyOption (Option):
def check_file(option, opt, value):
@@ -1039,21 +1040,21 @@
TYPE_CHECKER["file"] = check_file
def test_filetype_ok(self):
- support.create_empty_file(support.TESTFN)
- self.assertParseOK(["--file", support.TESTFN, "-afoo"],
- {'file': support.TESTFN, 'a': 'foo'},
+ os_helper.create_empty_file(os_helper.TESTFN)
+ self.assertParseOK(["--file", os_helper.TESTFN, "-afoo"],
+ {'file': os_helper.TESTFN, 'a': 'foo'},
[])
def test_filetype_noexist(self):
- self.assertParseFail(["--file", support.TESTFN, "-afoo"],
+ self.assertParseFail(["--file", os_helper.TESTFN, "-afoo"],
"%s: file does not exist" %
- support.TESTFN)
+ os_helper.TESTFN)
def test_filetype_notfile(self):
- os.mkdir(support.TESTFN)
- self.assertParseFail(["--file", support.TESTFN, "-afoo"],
+ os.mkdir(os_helper.TESTFN)
+ self.assertParseFail(["--file", os_helper.TESTFN, "-afoo"],
"%s: not a regular file" %
- support.TESTFN)
+ os_helper.TESTFN)
class TestExtendAddActions(BaseTest):
@@ -1497,7 +1498,7 @@
# we must restore its original value -- otherwise, this test
# screws things up for other tests when it's part of the Python
# test suite.
- with support.EnvironmentVarGuard() as env:
+ with os_helper.EnvironmentVarGuard() as env:
env['COLUMNS'] = str(columns)
return InterceptingOptionParser(option_list=options)
@@ -1522,7 +1523,7 @@
self.assertHelpEquals(_expected_help_long_opts_first)
def test_help_title_formatter(self):
- with support.EnvironmentVarGuard() as env:
+ with os_helper.EnvironmentVarGuard() as env:
env["COLUMNS"] = "80"
self.parser.formatter = TitledHelpFormatter()
self.assertHelpEquals(_expected_help_title_formatter)