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:
This is the kind of thing I was suggesting. (It might require more setup than this in your case.)


On Thu, May 7, 2020 at 11:33 AM Brett Cannon <> wrote:
Maybe an initialization/import side-effect bug which is triggered if the module is imported twice?
Python-Dev mailing list --
To unsubscribe send an email to
Message archived at
Code of Conduct: