Try to install the rewrite hook, raise SystemError if it fails.
(config: Config)
| 127 | |
| 128 | |
| 129 | def install_importhook(config: Config) -> rewrite.AssertionRewritingHook: |
| 130 | class="st">""class="st">"Try to install the rewrite hook, raise SystemError if it fails."class="st">"" |
| 131 | config.stash[assertstate_key] = AssertionState(config, class="st">"rewrite") |
| 132 | config.stash[assertstate_key].hook = hook = rewrite.AssertionRewritingHook(config) |
| 133 | sys.meta_path.insert(0, hook) |
| 134 | config.stash[assertstate_key].trace(class="st">"installed rewrite import hook") |
| 135 | |
| 136 | def undo() -> None: |
| 137 | hook = config.stash[assertstate_key].hook |
| 138 | if hook is not None and hook in sys.meta_path: |
| 139 | sys.meta_path.remove(hook) |
| 140 | |
| 141 | config.add_cleanup(undo) |
| 142 | return hook |
| 143 | |
| 144 | |
| 145 | def pytest_collection(session: Session) -> None: |
nothing calls this directly
no test coverage detected