How to run unit tests stored on host with mpremote?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
MicroRichard
Posts: 15
Joined: Tue Aug 09, 2022 11:32 am

How to run unit tests stored on host with mpremote?

Post by MicroRichard » Thu Aug 25, 2022 12:06 pm

Hi, i like to run unit tests stored on a Windows 10 host pc with mpremote. So basically the Pyboard D should run the unit_tests from this folder. I am not sure if this is possible.
The number of unit tests can quickly increase and until now i have stored them on the Pyboard D device which takes a lot of space.
To create unit tests i use the unittest.TestSuite().
Suppose i store all unit tests in a folder named c:\unit_test on my Windows 10 host pc. How can i run them using a script with mpremote?
Anyone done this before?

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: How to run unit tests stored on host with mpremote?

Post by jimmo » Thu Aug 25, 2022 1:33 pm

MicroRichard wrote:
Thu Aug 25, 2022 12:06 pm
How can i run them using a script with mpremote?
mpremote is based on the pyboard.py tool (available as tools/pyboard.py in https://github.com/micropython/micropython)

pyboard.py is both a standalone tool, but also a library that can be used to script an interaction with a connected micropython device. Despite the name it works on all supported boards.

The documentation is here
https://docs.micropython.org/en/latest/ ... rd.py.html

(Specifically see the very end about how to use it as a library -- you can use pyb.execfile instead of pyb.exec for your use case).

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: How to run unit tests stored on host with mpremote?

Post by jimmo » Fri Aug 26, 2022 2:58 am

I forgot to mention also, this may be relevant: https://github.com/BrianPugh/belay

Post Reply