-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
topic: rewriterelated to the assertion rewrite mechanismrelated to the assertion rewrite mechanismtype: bugproblem that needs to be addressedproblem that needs to be addressed
Description
Importing a module with assertion rewrite enabled, changing the code and then reloading the module (with reload or imp.reload) does not pick up the changes.
A fix was done in 2.7.0 but AFAIK it is wrong:
https://docs.pytest.org/en/latest/changelog.html#id456
In _pytest/assertion/rewrite.py, load_module should indeed use the module from sys.modules, but it should also load the code again (overwriting the module dict):
https://docs.python.org/3/library/importlib.html#importlib.abc.Loader.load_module
I wrote a testcase and a possible fix here (but I'm not that familiar with the code):
iwanb@c78569b
I can do a pull request if it looks ok to you.
Metadata
Metadata
Assignees
Labels
topic: rewriterelated to the assertion rewrite mechanismrelated to the assertion rewrite mechanismtype: bugproblem that needs to be addressedproblem that needs to be addressed