Checks that sys.warnoptions and sys._xoptions can be set before the runtime is initialized (otherwise they won't be effective).
(self)
| 333 | self.assertEqual(err, '') |
| 334 | |
| 335 | def test_pre_initialization_sys_options(self): |
| 336 | """ |
| 337 | Checks that sys.warnoptions and sys._xoptions can be set before the |
| 338 | runtime is initialized (otherwise they won't be effective). |
| 339 | """ |
| 340 | env = remove_python_envvars() |
| 341 | env['PYTHONPATH'] = os.pathsep.join(sys.path) |
| 342 | out, err = self.run_embedded_interpreter( |
| 343 | "test_pre_initialization_sys_options", env=env) |
| 344 | if support.verbose > 1: |
| 345 | print() |
| 346 | print(out) |
| 347 | print(err) |
| 348 | expected_output = ( |
| 349 | "sys.warnoptions: ['once', 'module', 'default']\n" |
| 350 | "sys._xoptions: {'not_an_option': '1', 'also_not_an_option': '2'}\n" |
| 351 | "warnings.filters[:3]: ['default', 'module', 'once']\n" |
| 352 | ) |
| 353 | self.assertIn(expected_output, out) |
| 354 | self.assertEqual(err, '') |
| 355 | |
| 356 | def test_bpo20891(self): |
| 357 | """ |
nothing calls this directly
no test coverage detected