Permalink
Browse files

tests/thread: Improve modthread.c test coverage.

  • Loading branch information...
1 parent c15ebf7 commit f397e1fdf0519a6770336c04904c4f0495e75496 @flowergrass flowergrass committed with dpgeorge Dec 29, 2016
Showing with 23 additions and 1 deletion.
  1. +1 −1 tests/run-tests
  2. +10 −0 tests/thread/thread_exc2.py
  3. +5 −0 tests/thread/thread_exc2.py.exp
  4. +7 −0 tests/thread/thread_start2.py
View
@@ -51,7 +51,7 @@ def convert_regex_escapes(line):
def run_micropython(pyb, args, test_file):
- special_tests = ('micropython/meminfo.py', 'basics/bytes_compare3.py')
+ special_tests = ('micropython/meminfo.py', 'basics/bytes_compare3.py', 'thread/thread_exc2.py')
is_special = False
if pyb is None:
# run on PC
@@ -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')
@@ -0,0 +1,5 @@
+Unhandled exception in thread started by <function thread_entry at 0x\[0-9a-f\]\+>
+Traceback (most recent call last):
+ File "thread/thread_exc2.py", line 6, in thread_entry
+ValueError:
+done
@@ -16,4 +16,11 @@ def thread_entry(a0, a1, a2, a3):
# 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')

0 comments on commit f397e1f

Please sign in to comment.