def test_func_decorators(): @core.provides('ls') def fake(): raise RuntimeError() fake() @core.provides('some-unknown-command') def fake2(): return True ok(fake2()) == True @core.provides_pkg('coreutils') def fake3(): raise RuntimeError() fake3() @core.provides_pkg('some-unknown-pkg') def fake4(): return True ok(fake4()) == True @core.ensure_pkg('coreutils') def fake5(): pass with mock.patch('fablib.core.install', lambda x : 1 / 0): # no system call should be made fake5() pkg_name = 'mp3blaster' if core.check_pkg(pkg_name): core.uninstall(pkg_name) @core.ensure_pkg(pkg_name) def fake5(): ok(core.check_pkg(pkg_name)) == True core.uninstall(pkg_name) fake5()
def test_pkg(): cmd_name = 'mp3blaster' pkg_name = 'mp3blaster' if core.check_pkg(pkg_name): core.uninstall(pkg_name) ok(core.pkg()) != None ok(core.check_pkg(pkg_name)) == False ok(core.check_cmd(cmd_name)) == False core.install(pkg_name) ok(core.check_pkg(pkg_name)) == True ok(core.check_cmd(cmd_name)) == True core.uninstall(pkg_name) ok(core.check_pkg(pkg_name)) == False ok(core.check_cmd(cmd_name)) == False
def fake5(): ok(core.check_pkg(pkg_name)) == True core.uninstall(pkg_name)