diff --git a/tests/run-tests b/tests/run-tests
index 2866a6c487c13ba6c5c7c8d46cf22b5e3ec4c973..33409832ba23b588a1dbb0fbbb22759f2995d9c2 100755
--- a/tests/run-tests
+++ b/tests/run-tests
@@ -46,14 +46,21 @@ for test_file in tests:
         output_expected = b'CPYTHON3 CRASH'
 
     # run Micro Python
-    try:
-        if test_on_pyboard:
-            pyb.enter_raw_repl()
-            output_mupy = pyb.execfile(test_file).replace(b'\r\n', b'\n')
-        else:
+    if test_on_pyboard:
+        pyb.enter_raw_repl()
+        try:
+            if test_file == 'basics/math-fun.py':
+                # this test crashes the pyboard
+                output_mupy = b'CRASH'
+            else:
+                output_mupy = pyb.execfile(test_file).replace(b'\r\n', b'\n')
+        except pyboard.PyboardError:
+            output_mupy = b'CRASH\n' + output_mupy
+    else:
+        try:
             output_mupy = subprocess.check_output([MP_PY, '-X', 'emit=bytecode', test_file])
-    except subprocess.CalledProcessError:
-        output_mupy = b'CRASH'
+        except subprocess.CalledProcessError:
+            output_mupy = b'CRASH'
 
     testcase_count += len(output_expected.splitlines())
 
diff --git a/tools/pyboard.py b/tools/pyboard.py
index 1c5c84f304397a97fc773bffad46774ac5388428..902a93c15a4d49a8eafb7b0d1c76b2f5d96c9dca 100644
--- a/tools/pyboard.py
+++ b/tools/pyboard.py
@@ -22,6 +22,9 @@ To run a script from the local machine on the board and print out the results:
 import time
 import serial
 
+class PyboardError(BaseException):
+    pass
+
 class Pyboard:
     def __init__(self, serial_device):
         self.serial = serial.Serial(serial_device)
@@ -38,7 +41,7 @@ class Pyboard:
             time.sleep(0.1)
         if not data.endswith(b'raw REPL; CTRL-B to exit\r\n>'):
             print(data)
-            raise Exception('could not enter raw repl')
+            raise PyboardError('could not enter raw repl')
 
     def exit_raw_repl(self):
         self.serial.write(b'\r\x02') # ctrl-B: enter friendly REPL
@@ -56,7 +59,7 @@ class Pyboard:
         self.serial.write(b'\x04')
         data = self.serial.read(2)
         if data != b'OK':
-            raise Exception('could not exec command')
+            raise PyboardError('could not exec command')
         data = self.serial.read(2)
         timeout = 0
         while True:
@@ -72,10 +75,10 @@ class Pyboard:
                 time.sleep(0.1)
         if not data.endswith(b'\x04>'):
             print(data)
-            raise Exception('timeout waiting for EOF reception')
+            raise PyboardError('timeout waiting for EOF reception')
         if data.startswith(b'Traceback') or data.startswith(b'  File '):
             print(data)
-            raise Exception('command failed')
+            raise PyboardError('command failed')
         return data[:-2]
 
     def execfile(self, filename):