-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mocking script methods when testing with pytest-console-scripts #44
Comments
Yes, you are exactly right. When the script is called as a subprocess we can't mock, because the script is a separate process and the test doesn't have access to its namespaces.
Here you are right again, but there are ways around it. They are not perfect, but it's something. I replied to you on stackoverflow. |
Great, you made my day! Actually, I can't see anything else at the moment that would allow mocking function for a python script. You should def. emphasize it in your Readme/doc |
Yeah, I think you are right that ability to mock things inside of scripts is an important feature. I will merge the PR that adds this to the README. Let me know if you see a better way to describe it. Thanks for the proposal and for kind words. |
Hi,
i've started using your package to test some legacy code I need to refactor.
Took me a while to figure out an essential part: how to mock functions called by the script.
I think you should write a comment on this part in the Readme, as this appear to be a common use case for your PCS.
So far, tell me if I'm wrong, it's possible to mock function when the script is called as
"inprocess". If it's called as subprocess, it's not possible to mock, afaics.
The problem I'm facing right now is that I can't find a way to mock calls to functions internal to the script. Maybe it's just not possible in python.
FYI https://stackoverflow.com/questions/66676962/how-to-mock-a-function-within-a-python-script-tested-with-pytest-console-scripts
The text was updated successfully, but these errors were encountered: