Skip to content

Commit f397e1f

Browse files
flowergrassdpgeorge
authored andcommitted
tests/thread: Improve modthread.c test coverage.
1 parent c15ebf7 commit f397e1f

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

tests/run-tests

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def convert_regex_escapes(line):
5151

5252

5353
def run_micropython(pyb, args, test_file):
54-
special_tests = ('micropython/meminfo.py', 'basics/bytes_compare3.py')
54+
special_tests = ('micropython/meminfo.py', 'basics/bytes_compare3.py', 'thread/thread_exc2.py')
5555
is_special = False
5656
if pyb is None:
5757
# run on PC

tests/thread/thread_exc2.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# test raising exception within thread which is not caught
2+
import utime
3+
import _thread
4+
5+
def thread_entry():
6+
raise ValueError
7+
8+
_thread.start_new_thread(thread_entry, ())
9+
utime.sleep(1)
10+
print('done')

tests/thread/thread_exc2.py.exp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Unhandled exception in thread started by <function thread_entry at 0x\[0-9a-f\]\+>
2+
Traceback (most recent call last):
3+
File "thread/thread_exc2.py", line 6, in thread_entry
4+
ValueError:
5+
done

tests/thread/thread_start2.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,11 @@ def thread_entry(a0, a1, a2, a3):
1616

1717
# wait for thread to finish
1818
time.sleep(1)
19+
20+
# incorrect argument where dictionary is needed for keyword args
21+
try:
22+
_thread.start_new_thread(thread_entry, (), ())
23+
except TypeError:
24+
print('TypeError')
25+
1926
print('done')

0 commit comments

Comments
 (0)