def test_rm(self, cask, debug, verbose, formulas): brew = Brew(cask, debug, verbose) args = self.__cmd(cask) + ["zap" if cask else "rm"] + formulas args += self.__flags(debug, verbose) brew.rm(*formulas) sh.spawn.assert_called_with(args, debug=debug, check_output=False, env=brew.env)
def test_ls(self, cask, debug, verbose): brew = Brew(cask, debug, verbose) old_return, sh.spawn.return_value = sh.spawn.return_value, "" args = self.__cmd(cask) + ["ls", "-1"] brew.ls() sh.spawn.assert_called_with(args, debug=debug, check_output=True, env=brew.env) sh.spawn.return_value = old_return
def test_untap(self, cask, debug, verbose, tap): with pytest.raises(AssertionError) if cask else empty(): brew = Brew(cask, debug, verbose) args = self.__cmd() + ["untap", tap] args += self.__flags(debug, verbose) brew.untap(tap) sh.spawn.assert_called_with(args, debug=debug, check_output=False, env=brew.env)
def test_install(self, cask, debug, verbose, formulas, force): brew = Brew(cask, debug, verbose) args = self.__cmd(cask) args += ["install"] + formulas + (["--force"] if force else []) args += self.__flags(debug, verbose) brew.install(*formulas, force=force) sh.spawn.assert_called_with(args, debug=debug, check_output=False, env=brew.env)
def test_tap(self, cask, debug, verbose, tap, use_tap): with pytest.raises(AssertionError) if cask else empty(): brew = Brew(cask, debug, verbose) tap = tap if use_tap else None args = self.__cmd() + ["tap"] + ([tap] if tap is not None else []) args += self.__flags(debug, verbose) brew.tap(tap) sh.spawn.assert_called_with(args, debug=debug, check_output=not use_tap, env=brew.env)
def test_uses(self, cask, debug, verbose, formula): brew = Brew(cask, debug, verbose) old_return, sh.spawn.return_value = sh.spawn.return_value, "" args = self.__cmd(cask) args += ["uses", "--installed", "--recursive", formula] args += self.__flags(debug, verbose) brew.uses(formula) sh.spawn.assert_called_with(args, debug=debug, check_output=True, env=brew.env) sh.spawn.return_value = old_return
def test_safe_install(self, cask, debug, verbose, formula): brew = Brew(cask, debug, verbose) old_side_effect = sh.spawn.side_effect args = self.__cmd(cask) + ["install", formula] args += self.__flags(debug, verbose) sh.spawn.side_effect = CalledProcessError(42, " ".join(args)) brew.safe_install(formula) sh.spawn.assert_called_with(args, debug=debug, check_output=False, env=brew.env) sh.spawn.side_effect = old_side_effect