Skip to content

Commit 20c4390

Browse files
author
heliang
committed
Fix test_warnings failures in CI
1 parent 423fae3 commit 20c4390

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Lib/test/test_warnings/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -771,9 +771,11 @@ def test_improper_input(self):
771771
self.assertRaises(UserWarning, self.module.warn, 'convert to error')
772772

773773
def test_import_from_module(self):
774-
script = support.script_helper.make_script('test_warnings_importer',
775-
'import test.test_warnings.data.import_warning')
776-
rc, out, err = assert_python_ok(script)
774+
with support.temp_dir() as script_dir:
775+
script = support.script_helper.make_script(script_dir,
776+
'test_warnings_importer',
777+
'import test.test_warnings.data.import_warning')
778+
rc, out, err = assert_python_ok(script)
777779
self.assertNotIn(b'UserWarning', err)
778780

779781
def test_syntax_warning_for_compiler(self):
@@ -794,6 +796,7 @@ def func(self):
794796
self.assertEqual(out, b'')
795797
# Check that we got a SyntaxError.
796798
err = err.decode()
799+
err = support.strip_ansi(err)
797800
self.assertIn("""SyntaxError: "is" with 'int' literal. Did you mean "=="?""", err)
798801
# Check that the filename in the traceback is correct.
799802
self.assertIn(os.path.basename(script_name), err)

0 commit comments

Comments
 (0)