Workflow for testing when using VS Code?

Hello everyone,

I am wondering if anyone has a good workflow for doing Unit-Tests on Python modules which are used by GHPython components when I am creating those modules in VS Code or similar external IDE?


For example:

I can create components in Grasshopper which import and use my custom modules - that all works great:

and I can write those modules outside Rhino/GH (I’m using VS Code at the moment) and that is all working fine as well. Though I am not able to make the ‘stubs’ work unfortunately, so I am still not getting any autocomplete. But that’s not the end of the world, and when I run everything in Grasshopper it all works just fine.


So the only issue I run into is if I try and create any Unit-Tests which import my custom module(s). If my module includes Rhino / Grasshopper module imports (which they almost all do), I get an error when I try and run the tests:

So I wonder if there is good workflow / process that I should be using for something like this? I can do UnitTests for the functions inside Grasshopper using the process outlined here, so that is helpful, but I’d like to be able to integrate more testing into my modules as well? Do I need to setup VS Code in some particular fashion to allow my to access those Rhino/GH modules somehow? Is there some other preferred method I should be using to do tests on GHPython modules?

any advice or recommendations are much appreciated!
thanks so much.
@ed.p.may