To expand on my earlier comment about changing the module under test to make your testing easier, asyncio is one library that has lots of tests of different combinations of its C and Python implementations being used together.

As far as I know, it doesn't use import_fresh_module or similar hackery. Instead it exposes a private way of getting at the parallel Python implementation:
https://github.com/python/cpython/blob/b7a78ca74ab539943ab11b5c4c9cfab7f5b7ff5a/Lib/asyncio/futures.py#L271-L272
This is the kind of thing I was suggesting. (It might require more setup than this in your case.)

--Chris


On Thu, May 7, 2020 at 11:33 AM Brett Cannon <brett@python.org> wrote:
Maybe an initialization/import side-effect bug which is triggered if the module is imported twice?
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/25XFYLISP53DRZX2UI7ADYC3JC2V2NVG/
Code of Conduct: http://python.org/psf/codeofconduct/