@@ -222,38 +222,6 @@ def _get_default_randomize_ordering_seed() -> int:
222222flags .DEFINE_string ('xml_output_file' , '' , 'File to store XML test results' )
223223
224224
225- # We might need to monkey-patch TestResult so that it stops considering an
226- # unexpected pass as a "successful result". For details, see
227- # http://bugs.python.org/issue20165
228- def _monkey_patch_test_result_for_unexpected_passes () -> None :
229- """Workaround for <http://bugs.python.org/issue20165>."""
230-
231- def wasSuccessful (self ) -> bool :
232- """Tells whether or not this result was a success.
233-
234- Any unexpected pass is to be counted as a non-success.
235-
236- Args:
237- self: The TestResult instance.
238-
239- Returns:
240- Whether or not this result was a success.
241- """
242- return (len (self .failures ) == len (self .errors ) ==
243- len (self .unexpectedSuccesses ) == 0 )
244-
245- test_result = unittest .TestResult ()
246- test_result .addUnexpectedSuccess (unittest .FunctionTestCase (lambda : None ))
247- if test_result .wasSuccessful (): # The bug is present.
248- unittest .TestResult .wasSuccessful = wasSuccessful # type: ignore[method-assign]
249- if test_result .wasSuccessful (): # Warn the user if our hot-fix failed.
250- sys .stderr .write ('unittest.result.TestResult monkey patch to report'
251- ' unexpected passes as failures did not work.\n ' )
252-
253-
254- _monkey_patch_test_result_for_unexpected_passes ()
255-
256-
257225def _open (
258226 filepath : str , mode : str , _open_func : Callable [..., IO [AnyStr ]] = open
259227) -> IO [AnyStr ]:
0 commit comments