-
Tim Peters authored
Reworked the way some of the ZEO tests use threads, so that unittest is more likely to notice the real cause of a failure (which usually occurs in a thread), and less likely to latch on to spurious problems resulting from the real failure. Detail: The TestThread class got the (unittest) test case as an argument, and remembered it. If the run() method saw the thread die with an exception, it called testcase.fail() with the formatted exception. But this can't work as apparently intended: unittest's fail() raises an AssertionError then, and the piece of unittest running the test expects to catch that exception and append the message to the result object's list of failures. But the piece of unittest running the test isn't on *this* thread's call stack! It's on the main thread's call stack. So unittest simply raised an exception that wasn't noticed by anything, and the thread died then, leaving a traceback somewhere in the middle of the output. unittest didn't know anything about that, and sometimes thought the test passed despite the thread failure. Alas, when a thread dies like this it's also got a decent chance of leaving things in a state where the test's final checking code can't succeed, but the checking code doesn't know the thread died either, and spurious unittest failures and errors could get reported then. Reworked things so that only the main thread ever tries to tell unittest that a test failed. A TestThread remembers an exception- death now, but doesn't report it until the main thread tries to join it. This way unittest knows the test failed; records and reports the true cause of failure; and, because tests generally join all their threads before doing their final checking, unittest stops the test before final checking if a thread death occurred, and so there's less chance of seeing reports of spurious errors and failures.
adb8ff42