"""Spoof psutil module in order to run and check tests Resulting values of
method calls are set inside `fixtures` module."""

STDOUT = 1
STDERR = 2
STDIN = 3


class FakeProcess:
    args = None
    kwargs = None
    """Kwargs passed to Popen."""
    killed = False
    """kill() have been called."""
    waited = False
    """wait() have been called."""
    polled = False
    """poll() have been called."""
    poll_result = None
    """Result of poll() method."""

    def __init__(self, args=[], kwargs={}):
        self.pid = -13
        self.args = args
        self.kwargs = kwargs

    def kill(self):
        self.killed = True

    def wait(self):
        self.waited = True

    def poll(self):
        self.polled = True
        return self.poll_result


def Popen(args, **kwargs):
    return FakeProcess(args, kwargs)
