diff options
| author | Hai Shi <shihai1992@gmail.com> | 2020-08-03 16:49:18 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-03 16:49:18 (GMT) |
| commit | 4660597b51b3d14ce6269d0ed865ab7e22c6ae1f (patch) | |
| tree | 00ab23106abb1d0023e261685dc4f2077002aabd /Lib/test/test_optparse.py | |
| parent | bb0424b122e3d222a558bd4177ce37befd3e0347 (diff) | |
| download | cpython-4660597b51b3d14ce6269d0ed865ab7e22c6ae1f.zip cpython-4660597b51b3d14ce6269d0ed865ab7e22c6ae1f.tar.gz cpython-4660597b51b3d14ce6269d0ed865ab7e22c6ae1f.tar.bz2 | |
bpo-40275: Use new test.support helper submodules in tests (GH-21448)
Diffstat (limited to 'Lib/test/test_optparse.py')
| -rw-r--r-- | Lib/test/test_optparse.py | 29 |
1 files changed, 15 insertions, 14 deletions
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 @@ import unittest from io import StringIO from test import support +from test.support import os_helper import optparse @@ -1021,10 +1022,10 @@ class TestExtendAddTypes(BaseTest): 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 @@ class TestExtendAddTypes(BaseTest): 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 @@ class TestHelp(BaseTest): # 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 @@ class TestHelp(BaseTest): 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) |
