import tempfile class MockSubprocess(): def __init__(self): self.last_call = None def call(self, args): self.last_call = args def last_call_args(self): return self.last_call def write_tempfile(text): tempdir = tempfile.mkdtemp() path = tempdir + "/test-file.txt" with open(path, "w") as f: f.write(text) f.close() return path