testtools-dev team mailing list archive
-
testtools-dev team
-
Mailing list archive
-
Message #00266
[Bug 666345] Re: test_spinner.TestRunInReactor.test_clean_running_threads fails with an extra thread
Failure is completely reliable here, and is unchanged on trunk. Nice
idea on the timeout, and yeah make_timeout should probably be using
multiples of 1.0/60 on windows. Still always hit the race though, which
appears to be in the spinner cleanup code.
Not sure exactly what this test is trying to check, but as background
threads being spawned during the test run would make it fail anyway,
just asserting we have one live thread works:
=== modified file 'testtools/tests/test_spinner.py'
--- testtools/tests/test_spinner.py 2010-10-26 10:42:59 +0000
+++ testtools/tests/test_spinner.py 2010-11-02 17:13:00 +0000
@@ -233,12 +233,11 @@
def test_clean_running_threads(self):
import threading
import time
- current_threads = list(threading.enumerate())
reactor = self.make_reactor()
timeout = self.make_timeout()
spinner = self.make_spinner(reactor)
spinner.run(timeout, reactor.callInThread, time.sleep, timeout / 2.0)
- self.assertThat(list(threading.enumerate()), Equals(current_threads))
+ self.assertThat(sum(t.isAlive() for t in threading.enumerate()), Equals(1))
Alternatively, can add a fudge to lose the race:
=== modified file 'testtools/tests/test_spinner.py'
--- testtools/tests/test_spinner.py 2010-10-26 10:42:59 +0000
+++ testtools/tests/test_spinner.py 2010-11-02 17:23:08 +0000
@@ -237,7 +240,8 @@
reactor = self.make_reactor()
timeout = self.make_timeout()
spinner = self.make_spinner(reactor)
spinner.run(timeout, reactor.callInThread, time.sleep, timeout / 2.0)
+ time.sleep(0)
self.assertThat(list(threading.enumerate()), Equals(current_threads))
def test_leftover_junk_available(self):
** Changed in: testtools
Status: Incomplete => Confirmed
--
test_spinner.TestRunInReactor.test_clean_running_threads fails with an extra thread
https://bugs.launchpad.net/bugs/666345
You received this bug notification because you are a member of testtools
developers, which is subscribed to testtools.
Status in testtools: Confirmed
Bug description:
======================================================================
FAIL: testtools.tests.test_spinner.TestRunInReactor.test_clean_running_threads
----------------------------------------------------------------------
Text attachment: traceback
------------
Traceback (most recent call last):
File "C:\bzr\testtools\testtools\runtest.py", line 143, in _run_user
return fn(*args)
File "C:\bzr\testtools\testtools\testcase.py", line 539, in _run_test_method
return self._get_test_method()()
File "C:\bzr\testtools\testtools\tests\test_spinner.py", line 241, in test_clean_running_threads
self.assertThat(list(threading.enumerate()), Equals(current_threads))
File "C:\bzr\testtools\testtools\testcase.py", line 384, in assertThat
self.fail('Match failed. Matchee: "%s"\nMatcher: %s\nDifference: %s\n'
AssertionError: Match failed. Matchee: "[<_MainThread(MainThread, started)>, <Thread(PoolThread-twisted.internet.reactor-1, stopped)>]"
Matcher: Equals([<_MainThread(MainThread, started)>])
Difference: !=:
reference = [<_MainThread(MainThread, started)>]
actual = [<_MainThread(MainThread, started)>,
<Thread(PoolThread-twisted.internet.reactor-1, stopped)>]
This may be related to my OS, my Python version (2.4) or my twisted version (8.1.0).
References