def sudo(self): mc = MockContext(sudo={"foo": Result("bar")}) assert mc.sudo("foo").stdout == "bar" mc.set_result_for("sudo", "foo", Result("biz")) assert mc.sudo("foo").stdout == "biz"
def sudo(self): mc = MockContext(sudo=[Result("foo")]) with raises(TypeError): mc.set_result_for("sudo", "whatever", Result("bar"))
def run(self): mc = MockContext(run={"foo": Result("bar")}) assert mc.run("foo").stdout == "bar" mc.set_result_for("run", "foo", Result("biz")) assert mc.run("foo").stdout == "biz"
def run(self): mc = MockContext(run=[Result("foo")]) with raises(TypeError): mc.set_result_for("run", "whatever", Result("bar"))