Skip to content

Commit 3ddfa71

Browse files
author
heliang
committed
Fix: Correct ImportError and NameError in test_warnings
1 parent 20c4390 commit 3ddfa71

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Lib/test/test_warnings/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
from test.support import import_helper
1515
from test.support import os_helper
1616
from test.support import warnings_helper
17+
from test.support import script_helper
18+
from _pyrepl.completing_reader import stripcolor as strip_ansi
1719
from test.support import force_not_colorized
1820
from test.support.script_helper import assert_python_ok, assert_python_failure
1921

@@ -771,8 +773,8 @@ def test_improper_input(self):
771773
self.assertRaises(UserWarning, self.module.warn, 'convert to error')
772774

773775
def test_import_from_module(self):
774-
with support.temp_dir() as script_dir:
775-
script = support.script_helper.make_script(script_dir,
776+
with os_helper.temp_dir() as script_dir:
777+
script = script_helper.make_script(script_dir,
776778
'test_warnings_importer',
777779
'import test.test_warnings.data.import_warning')
778780
rc, out, err = assert_python_ok(script)
@@ -788,15 +790,15 @@ def func(self):
788790
""")
789791
# The name of the script is 'test_sw'
790792
with os_helper.temp_dir() as script_dir:
791-
script_name = support.script_helper.make_script(script_dir, 'test_sw', code)
793+
script_name = script_helper.make_script(script_dir, 'test_sw', code)
792794
# We want to check that the warning filter for 'test_sw' module works.
793795
rc, out, err = assert_python_failure("-W", "error::SyntaxWarning:test_sw",
794796
script_name)
795797
self.assertEqual(rc, 1)
796798
self.assertEqual(out, b'')
797799
# Check that we got a SyntaxError.
798800
err = err.decode()
799-
err = support.strip_ansi(err)
801+
err = strip_ansi(err)
800802
self.assertIn("""SyntaxError: "is" with 'int' literal. Did you mean "=="?""", err)
801803
# Check that the filename in the traceback is correct.
802804
self.assertIn(os.path.basename(script_name), err)

0 commit comments

Comments
 (0)