testing Package

basetest Module

class leap.testing.basetest.BaseLeapTest(methodName='runTest')

Bases: unittest2.case.TestCase

chmod600(filepath)
get_groupname()
get_tempfile(filename)
get_username()
setUp()
classmethod setUpClass()
tearDown()
classmethod tearDownClass()
touch(filepath)

https_server Module

class leap.testing.https_server.BaseHTTPSServerTestCase(methodName='runTest')

Bases: unittest.case.TestCase

derived classes need to implement a request_handler

get_server()
setUp()
tearDown()
class leap.testing.https_server.HTTPSServer(server_address, RequestHandlerClass, bind_and_activate=True)

Bases: BaseHTTPServer.HTTPServer

server_bind()
class leap.testing.https_server.TestServerThread(test_object, request_handler)

Bases: threading.Thread

run()
stop()
leap.testing.https_server.where(filename)

pyqt Module

leap.testing.pyqt.enableSignalDebugging(**kwargs)

Call this to enable Qt Signal debugging. This will trap all connect, and disconnect calls.

qunittest Module

class leap.testing.qunittest.TestCase(*args, **kwargs)

Bases: unittest2.case.TestCase

Extends standard unittest.TestCase with several PyQt4 testing features useful for asynchronous testing.

assertEmited(signal, callable_=None, timeout=1)

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.

failAfter(seconds, message=None)

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.

invokeAfter(*args, **kwds)

Waits given amount of time and executes the context.

If callable_ is given, executes it, instead of context.

succeed(bool_=True)

Marks test as suceeded for next failAfter() invocation.

waitFor(seconds)

Waits given amount of time.

self.widget.loadImage(url) self.waitFor(seconds=10)

leap.testing.qunittest.main(*args, **kwargs)

test_basetest Module

becase it’s oh so meta

class leap.testing.test_basetest.TestAbstractBaseLeapTest(methodName='runTest')

Bases: unittest2.case.TestCase, leap.testing.test_basetest._TestCaseRunner

test_abstract_base_class()
class leap.testing.test_basetest.TestCleanedBaseLeapTest(methodName='runTest')

Bases: unittest2.case.TestCase, leap.testing.test_basetest._TestCaseRunner

test_tempdir_is_cleaned_after_tests()
class leap.testing.test_basetest.TestInitBaseLeapTest(methodName='runTest')

Bases: leap.testing.basetest.BaseLeapTest

setUp()
tearDown()
test_old_path_is_saved()
test_path_is_changed()

Table Of Contents

Previous topic

tests Package

Next topic

util Package

This Page