>
>
> foo.py:
>
> import os
> def my_mocked_os_system(*args, **kwargs):
> print('a mockery')
> os.system = my_mocked_os_system
>
>
> bar.py:
>
> import os
> os.system("echo bar")
>
> import foo
> os.system("echo foo")
>
>
> Then:
>
> $ PYTHONPATH=. python bar.py
> bar
> a mockery
>
>
I've spent the last 5 hours looking at mock decorators for Python (and
MagicMock and stackoverflow and blogs). I can't get it working on my own -
I'm not experienced enough with Python. Specifically, I can't do it *less*
lines of code and have it the correct Pythonic way. I need help from
someone that's prepared to remote pair on it.
- Paul
Received on 2017-09-16 20:07:13 CEST