From f397e1fdf0519a6770336c04904c4f0495e75496 Mon Sep 17 00:00:00 2001 From: Rami Ali Date: Thu, 29 Dec 2016 13:12:06 +1100 Subject: tests/thread: Improve modthread.c test coverage. --- tests/thread/thread_exc2.py | 10 ++++++++++ tests/thread/thread_exc2.py.exp | 5 +++++ tests/thread/thread_start2.py | 7 +++++++ 3 files changed, 22 insertions(+) create mode 100644 tests/thread/thread_exc2.py create mode 100644 tests/thread/thread_exc2.py.exp (limited to 'tests/thread') diff --git a/tests/thread/thread_exc2.py b/tests/thread/thread_exc2.py new file mode 100644 index 000000000..35cb32441 --- /dev/null +++ b/tests/thread/thread_exc2.py @@ -0,0 +1,10 @@ +# test raising exception within thread which is not caught +import utime +import _thread + +def thread_entry(): + raise ValueError + +_thread.start_new_thread(thread_entry, ()) +utime.sleep(1) +print('done') diff --git a/tests/thread/thread_exc2.py.exp b/tests/thread/thread_exc2.py.exp new file mode 100644 index 000000000..584bfab4d --- /dev/null +++ b/tests/thread/thread_exc2.py.exp @@ -0,0 +1,5 @@ +Unhandled exception in thread started by +Traceback (most recent call last): + File "thread/thread_exc2.py", line 6, in thread_entry +ValueError: +done diff --git a/tests/thread/thread_start2.py b/tests/thread/thread_start2.py index 4efa808eb..d0913e37c 100644 --- a/tests/thread/thread_start2.py +++ b/tests/thread/thread_start2.py @@ -16,4 +16,11 @@ _thread.start_new_thread(thread_entry, (10, 20), {'a2': 0, 'a3': 1}) # wait for thread to finish time.sleep(1) + +# incorrect argument where dictionary is needed for keyword args +try: + _thread.start_new_thread(thread_entry, (), ()) +except TypeError: + print('TypeError') + print('done') -- cgit v1.2.3