diff --git a/ports/unix/mpconfigport.h b/ports/unix/mpconfigport.h
index b557f3d448861e51ab95ec705049e0830c9a80f2..50b979279aeeeb88a82302613f38f0c7df935e27 100644
--- a/ports/unix/mpconfigport.h
+++ b/ports/unix/mpconfigport.h
@@ -145,8 +145,11 @@
 // names in exception messages (may require more RAM).
 #define MICROPY_ERROR_REPORTING     (MICROPY_ERROR_REPORTING_DETAILED)
 #define MICROPY_WARNINGS            (1)
+#define MICROPY_ERROR_PRINTER       (&mp_stderr_print)
 #define MICROPY_PY_STR_BYTES_CMP_WARN (1)
 
+extern const struct _mp_print_t mp_stderr_print;
+
 // Define to 1 to use undertested inefficient GC helper implementation
 // (if more efficient arch-specific one is not available).
 #ifndef MICROPY_GCREGS_SETJMP
diff --git a/py/modthread.c b/py/modthread.c
index bf74128e81621b3af0b453e5ad1c8f3039d54b11..cb071d0f86fae3ce5527b04ca049f8379cb48731 100644
--- a/py/modthread.c
+++ b/py/modthread.c
@@ -192,10 +192,10 @@ STATIC void *thread_entry(void *args_in) {
             // swallow exception silently
         } else {
             // print exception out
-            mp_printf(&mp_plat_print, "Unhandled exception in thread started by ");
-            mp_obj_print_helper(&mp_plat_print, args->fun, PRINT_REPR);
-            mp_printf(&mp_plat_print, "\n");
-            mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(exc));
+            mp_printf(MICROPY_ERROR_PRINTER, "Unhandled exception in thread started by ");
+            mp_obj_print_helper(MICROPY_ERROR_PRINTER, args->fun, PRINT_REPR);
+            mp_printf(MICROPY_ERROR_PRINTER, "\n");
+            mp_obj_print_exception(MICROPY_ERROR_PRINTER, MP_OBJ_FROM_PTR(exc));
         }
     }
 
diff --git a/py/mpconfig.h b/py/mpconfig.h
index b93f851d6c44938230d1973ccde21b1ef8010dd1..44de3beebeb3cabe6472382655d6bcb97a865976 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -533,6 +533,11 @@ typedef long long mp_longint_impl_t;
 #define MICROPY_WARNINGS (0)
 #endif
 
+// This macro is used when printing runtime warnings and errors
+#ifndef MICROPY_ERROR_PRINTER
+#define MICROPY_ERROR_PRINTER (&mp_plat_print)
+#endif
+
 // Float and complex implementation
 #define MICROPY_FLOAT_IMPL_NONE (0)
 #define MICROPY_FLOAT_IMPL_FLOAT (1)
diff --git a/py/warning.c b/py/warning.c
index 46b31ecca7a5fb5d7fd353dfea7c1a33e3534499..12d0f9c99b03262b2f74f0db5938671e51036801 100644
--- a/py/warning.c
+++ b/py/warning.c
@@ -35,9 +35,9 @@
 void mp_warning(const char *msg, ...) {
     va_list args;
     va_start(args, msg);
-    mp_print_str(&mp_plat_print, "Warning: ");
-    mp_vprintf(&mp_plat_print, msg, args);
-    mp_print_str(&mp_plat_print, "\n");
+    mp_print_str(MICROPY_ERROR_PRINTER, "Warning: ");
+    mp_vprintf(MICROPY_ERROR_PRINTER, msg, args);
+    mp_print_str(MICROPY_ERROR_PRINTER, "\n");
     va_end(args);
 }
 
diff --git a/tests/run-tests b/tests/run-tests
index 568d99f8e80dc745a96f31d488e1bd09f9655add..23fc3d9102a9a0ee3248136ee1706de10351a54e 100755
--- a/tests/run-tests
+++ b/tests/run-tests
@@ -103,7 +103,7 @@ def run_micropython(pyb, args, test_file, is_special=False):
                         os.close(master)
                         os.close(slave)
                 else:
-                    output_mupy = subprocess.check_output(args + [test_file])
+                    output_mupy = subprocess.check_output(args + [test_file], stderr=subprocess.STDOUT)
             except subprocess.CalledProcessError:
                 return b'CRASH'
 
@@ -124,7 +124,7 @@ def run_micropython(pyb, args, test_file, is_special=False):
 
             # run the actual test
             try:
-                output_mupy = subprocess.check_output(cmdlist)
+                output_mupy = subprocess.check_output(cmdlist, stderr=subprocess.STDOUT)
             except subprocess.CalledProcessError:
                 output_mupy = b'CRASH'