Пример #1
0
 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"
Пример #2
0
 def sudo(self):
     mc = MockContext(sudo=[Result("foo")])
     with raises(TypeError):
         mc.set_result_for("sudo", "whatever", Result("bar"))
Пример #3
0
 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"
Пример #4
0
 def run(self):
     mc = MockContext(run=[Result("foo")])
     with raises(TypeError):
         mc.set_result_for("run", "whatever", Result("bar"))