diff -r 5163fb8dc61f Lib/test/_test_multiprocessing.py --- a/Lib/test/_test_multiprocessing.py Tue Mar 10 14:47:41 2015 +0200 +++ b/Lib/test/_test_multiprocessing.py Tue Mar 10 12:18:17 2015 -0500 @@ -423,6 +423,19 @@ self.parent_conn.close() self.child_conn.close() +def is_error_on_warning_set(): + """Returns True when tests are run with -Werror, False otherwise. When + the equivalent of 'warnings.simplefilter("error", Warning)' has been set, + any warnings will trigger output sent to stderr but some of the tests + in this module examine what appears on stderr when exiting a Process. + This utility helps such tests adjust accordingly. + """ + import warnings + gen_action_category = ((action, category) \ + for action, _pattern, category, *_extras in warnings.filters) + error_on_warning = ("error", Warning) in gen_action_category + return error_on_warning + class _TestSubclassingProcess(BaseTestCase): ALLOWED_TYPES = ('processes',) @@ -480,7 +493,12 @@ self.assertEqual(p.exitcode, code) with open(testfn, 'r') as f: - self.assertEqual(f.read().rstrip(), str(reason)) + if is_error_on_warning_set(): + # Ignore any spurious warnings (via -Werror) sent to stderr + contents = f.read().splitlines() + self.assertEqual(contents[0], str(reason)) + else: + self.assertEqual(f.read().rstrip(), str(reason)) for reason in (True, False, 8): p = self.Process(target=sys.exit, args=(reason,))