ikostia / surrogate

A Python micro-lib to create stubs for non-existing modules.
28 stars 4 forks source link

Create a function that imports or stubs a module, at the module level #3

Open cristi-zz opened 3 years ago

cristi-zz commented 3 years ago

Hi! I use this library on embedded/hardware testing scenarios where various hardware libs are not available on regular computers.

I created something similar to https://docs.pytest.org/en/6.2.x/reference.html#pytest-importorskip but instead of skipping the whole test suite, just create a surrogate.

It is a syntax sugaring, getting rid of all the @surrogate before each test case.

Hope it helps!