Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from subprocess import Popen, PIPE
- class foo(object):
- def __init__(self):
- self.process = None
- self.command = 'some command'
- def _start_process(self, duration):
- self.process = Popen([self.command, '-d'], stdout=PIPE)
- def _terminate_process(self):
- self.process.terminate()
- import pytest
- from _pytest.monkeypatch import MonkeyPatch
- from mock import MagicMock, patch
- monkeypatch = MonkeyPatch()
- import file.foo
- def bar():
- test_object = file.foo()
- monkeypatch.setattr('subprocess.Popen', MagicMock())
- test_object._start_process()
Add Comment
Please, Sign In to add comment