Bases: unittest.case.TestCase
derived classes need to implement a request_handler
Bases: BaseHTTPServer.HTTPServer
Bases: threading.Thread
Call this to enable Qt Signal debugging. This will trap all connect, and disconnect calls.
Bases: unittest2.case.TestCase
Extends standard unittest.TestCase with several PyQt4 testing features useful for asynchronous testing.
Asserts if given signal was emited. Waits 1 second by default, before asserts signal emission.
If callable_ is given, it should be a function which takes two arguments: args and kwargs. It will be called after blocking operation or when assertion about signal emission is made and signal was emited.
When timeout is not False, method call is blocking, and ends after timeout seconds. After that time, it validates wether signal was emited.
When timeout is False, method is non blocking, and test should wait for signals afterwards. Otherwise, at the end of the test, all signal emissions are checked if appeared.
Function returns context, which yields to list of parameters given to signal. It can be useful for testing given parameters. Following code:
- with self.assertEmited(widget.signal) as (args, kwargs):
- self.assertEqual(1, len(args)) self.assertEqual(“Hello World!”, args[0])
will wait 1 second and test for correct parameters, is signal was emtied.
Note that code:
- with self.assertEmited(widget.signal, timeout=False) as (a, k):
- # Will not be invoked
will always fail since signal cannot be emited in the time of its connection - code inside the context will not be invoked at all.
Waits given amount of time, and fails the test if succeed(bool) is not called - in most common case, succeed(bool) should be called asynchronously (in signal handler):
self.widget.signal.connect(lambda: self.succeed()) self.failAfter(1, “signal not emited?”)
After invocation, test is no longer consider as succeeded.
Waits given amount of time and executes the context.
If callable_ is given, executes it, instead of context.
Marks test as suceeded for next failAfter() invocation.
Waits given amount of time.
self.widget.loadImage(url) self.waitFor(seconds=10)
becase it’s oh so meta
Bases: unittest2.case.TestCase, leap.testing.test_basetest._TestCaseRunner