def test_version_flag(self, mock_version, capsys): mock_version.__str__.return_value = '1.2.3' with pytest.raises(SystemExit): parse_args(['--version']) out, _ = capsys.readouterr() assert out.strip() == "Current version: 1.2.3"
def test_no_color_flag_disables_crayons(self, mock_crayons): parse_args(['--no-color']) assert mock_crayons.disable.called_once
def test_parses_message(self): args = parse_args(['--message', 'new version {}']) assert args.message == 'new version {}'
def test_parses_files(self): args = parse_args(['--files', 'setup.py', 'README.rst']) assert all(isinstance(x, TextIOWrapper) for x in args.files) assert len(args.files) == 2
def test_provides_default_message(self): args = parse_args([]) assert args.message == 'version {}'
def test_calls_system_exit_on_invalid_args(self, capsys): with pytest.raises(SystemExit): parse_args(['--no-tag']) out, err = capsys.readouterr() msg = err.strip().split("\n").pop() assert match(".* --files are required when --no-tag is set", msg)