Skip to content Skip to sidebar Skip to footer

How To Fake Popen In Test?

I've successfully Faked other module with my own Fake implementation or using monkeypatch. But in this case using both fake implementation or monkeypatch failed for subprocess.Pope

Solution 1:

You're patching subprocess.Popen, but in your function under test you're using Popen directly. You're changing the wrong symbol table.

If your function is in foo.py, you want to patch foo.Popen or change your function to use subprocess.Popen.

Post a Comment for "How To Fake Popen In Test?"