There could be several reasons why pytest monkeypatch is not working on an imported function:
The module containing the function may have already been imported before the pytest session started. In this case, the function's original implementation may have already been loaded into memory, and the monkeypatched version will not have any effect.
The function may be defined in a way that is not compatible with pytest monkeypatch. For example, if the function relies on global state or executes external code, monkeypatching may not be able to modify its behavior.
The code importing the function may not be designed to allow monkeypatching. Some libraries or frameworks may not support monkeypatching, or may require additional configuration to enable it.
To diagnose the issue, it may be helpful to inspect the function's implementation and the code importing it, as well as any relevant documentation or example code for the library or framework in use. It may also be useful to try alternative monkeypatching techniques or to use a different testing approach altogether.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-06-25 10:54:39 +0000
Seen: 13 times
Last updated: Jun 25 '23
What is the process of using the Multmerge() function in r to combine files in a directory?
Is it possible for two distinct useState functions to trigger changes simultaneously?
How can one use node to change an ogg file into an mp3 file?
How can a function pointer be transferred between different files in CUDA?
What does the error message "TypeError: e.endsWith is not a function" mean in Redoc?
What is the expected outcome of the math.floor function in terms of the return value?