threadverify package¶
Functions¶
-
crl.threadverify.verify_no_new_threads_at_end()[source]¶ Contexmanager which verify that there is no new active threads after start. Prints to stdout information of still active threads:
- Thread stack which lead starting of the new thread.
- Robot Framework backtrace in case listener
ThreadListeneris used when robot.run_cli() is started. - Bcktrace dump of the current threads state.
Raises: ThreadVerificationFailed– Raised if there is any new active threads at exit of the context.Example:
>>> import threading >>> import time >>> from crl.threadverify import verify_no_new_threads_at_end >>> >>> def work_forever(): ... while(True): ... time.sleep(1) ... >>> thread = threading.Thread(target=work_forever) >>> >>> with verify_no_new_threads_at_end(): ... thread.start() ... Still running thread: Thread-1 Thread-1 start traceback (most recently started thread last): Thread-1 started by MainThread at 11:48:14.471 ================================================= Traceback (most recent call last): File: "<stdin>", line 2, in <module> local variables: ... raise ThreadVerificationFailed() crl.threadverify.threadverify.ThreadVerificationFailed
Robot Framework Listeners¶
-
class
crl.threadverify.ThreadListener[source]¶ Robot Framework listener class to be used with
threadverify.verify_no_new_threads_at_end().Example:
>>> from robot import run_cli >>> from crl.threadverify import verify_no_new_threads_at_end >>> with verify_no_new_threads_at_end(): ... run_cli(['--listener', 'crl.threadverify.ThreadListener', ... 'robottests/newthreads.robot']) ... =================================================================== Newthreads =================================================================== New Threads | PASS | ------------------------------------------------------------------- Newthreads | PASS | 1 critical test, 1 passed, 0 failed 1 test total, 1 passed, 0 failed =================================================================== Output: /home/pehuovin/crl-threadverify/tests/output.xml Log: /home/pehuovin/crl-threadverify/tests/log.html Report: /home/pehuovin/crl-threadverify/tests/report.html Still running thread: Thread-1 Thread-1 start traceback (most recently started thread last): Thread-1 started by MainThread at 12:34:30.614 Robot Framework Traceback (most recent call last): file: robottests/newthreads.robot, suite: Newthreads file: robottests/newthreads.robot, testcase: New Threads resource: CreateThread, keyword: CreateThread.Create Thread ================================================= Traceback (most recent call last): File: "<stdin>", line 3, in <module> ... raise ThreadVerificationFailed() crl.threadverify.threadverify.ThreadVerificationFailed