with os_helper.temp_dir() as work_dir:
script_name = _make_test_script(work_dir, 'script.py', script)
with open(script_name, "r") as fp:
- p = spawn_python(f"/dev/fd/{fp.fileno()}", close_fds=False, pass_fds=(0,1,2,fp.fileno()))
+ p = spawn_python(f"/dev/fd/{fp.fileno()}", close_fds=True, pass_fds=(0,1,2,fp.fileno()))
out, err = p.communicate()
self.assertEqual(out, b"12345678912345678912345\n")
with self.module.catch_warnings(
module=self.module, action="error", category=FutureWarning
):
- self.module.warn("Other types of warnings are not errors")
- self.assertRaises(FutureWarning,
- self.module.warn, FutureWarning("msg"))
+ with support.captured_stderr() as stderr:
+ error_msg = "Other types of warnings are not errors"
+ self.module.warn(error_msg)
+ self.assertRaises(FutureWarning,
+ self.module.warn, FutureWarning("msg"))
+ stderr = stderr.getvalue()
+ self.assertIn(error_msg, stderr)
class CFilterTests(FilterTests, unittest.TestCase):
module = c_warnings