-def force_reimport(module):\r
- """Force the module under test to be re-imported.\r
-\r
- Because pytest runs all tests within the same scope (this makes me cry)\r
- we have to do some manual housekeeping to avoid tests polluting each other.\r
-\r
- Since conftest.py already does some sys.modules mangling I see no reason not to\r
- do the same thing here.\r
- """\r
- if "." in module:\r
- steps = module.split(".")\r
- else:\r
- steps = [module]\r
- \r
- for i in range(len(steps)):\r
- module = ".".join(steps[0:i + 1])\r
- try:\r
- del sys.modules[module]\r
- except KeyError:\r
- pass\r
-\r
-\r