bpo-40275: Use new test.support helper submodules in tests (GH-21314)

This commit is contained in:
Hai Shi 2020-07-06 17:12:49 +08:00 committed by GitHub
parent 9ce8132e1f
commit 883bc63833
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 225 additions and 194 deletions

View file

@ -6,6 +6,7 @@ import unittest
import subprocess
from test import support
from test.support import os_helper
from test.support.script_helper import assert_python_ok
@ -91,7 +92,7 @@ class TestTool(unittest.TestCase):
self.assertEqual(process.stderr, '')
def _create_infile(self, data=None):
infile = support.TESTFN
infile = os_helper.TESTFN
with open(infile, "w", encoding="utf-8") as fp:
self.addCleanup(os.remove, infile)
fp.write(data or self.data)
@ -121,7 +122,7 @@ class TestTool(unittest.TestCase):
def test_infile_outfile(self):
infile = self._create_infile()
outfile = support.TESTFN + '.out'
outfile = os_helper.TESTFN + '.out'
rc, out, err = assert_python_ok('-m', 'json.tool', infile, outfile)
self.addCleanup(os.remove, outfile)
with open(outfile, "r") as fp:
@ -189,7 +190,7 @@ class TestTool(unittest.TestCase):
def test_no_ensure_ascii_flag(self):
infile = self._create_infile('{"key":"💩"}')
outfile = support.TESTFN + '.out'
outfile = os_helper.TESTFN + '.out'
self.addCleanup(os.remove, outfile)
assert_python_ok('-m', 'json.tool', '--no-ensure-ascii', infile, outfile)
with open(outfile, "rb") as f:
@ -200,7 +201,7 @@ class TestTool(unittest.TestCase):
def test_ensure_ascii_default(self):
infile = self._create_infile('{"key":"💩"}')
outfile = support.TESTFN + '.out'
outfile = os_helper.TESTFN + '.out'
self.addCleanup(os.remove, outfile)
assert_python_ok('-m', 'json.tool', infile, outfile)
with open(outfile, "rb") as f: