def bump(self, replacements): if self.config.bump: replacements = dict( version=self.releaser.version, date=self.releaser.timestamp, **self.releaser.version.__dict__ ) execute(self.config.bump, replacements=replacements, verbose=self.verbose, dryrun=self.dryrun)
def test_execute_error_quiet(self, check_output, mocker): error = CalledProcessError(1, "cmd") error.output = "some output" check_output.side_effect = error with pytest.raises(BumprError): mocker.patch("builtins.print") execute("some failed command")
def prepare(self, replacements): if self.config.prepare: replacements = dict( version=self.releaser.next_version, date=self.releaser.timestamp, **self.releaser.next_version.__dict__ ) execute(self.config.prepare, replacements=replacements, verbose=self.verbose, dryrun=self.dryrun)
def bump(self, replacements): if self.config.bump: replacements = dict(version=self.releaser.version, date=self.releaser.timestamp, **self.releaser.version.__dict__) execute(self.config.bump, replacements=replacements, verbose=self.verbose, dryrun=self.dryrun)
def prepare(self, replacements): if self.config.prepare: replacements = dict(version=self.releaser.next_version, date=self.releaser.timestamp, **self.releaser.next_version.__dict__) execute(self.config.prepare, replacements=replacements, verbose=self.verbose, dryrun=self.dryrun)
def test_execute_error_quiet(self, check_call, check_output): error = CalledProcessError(1, 'cmd') error.output = 'some output' check_output.side_effect = error with pytest.raises(BumprError): to_patch = '{0}.print'.format('builtins' if IS_PY3 else '__builtin__') with patch(to_patch): execute('some failed command')
def test_execute_error_quiet(self, check_output, mocker): error = CalledProcessError(1, 'cmd') error.output = 'some output' check_output.side_effect = error with pytest.raises(BumprError): to_patch = '{0}.print'.format( 'builtins' if IS_PY3 else '__builtin__') mocker.patch(to_patch) execute('some failed command')
def execute(self, command, version=None, verbose=None): version = version or self.version verbose = verbose or self.config.verbose replacements = dict(version=version, date=self.timestamp, **version.__dict__) execute(command, replacements=replacements, dryrun=self.config.dryrun, verbose=verbose)
def test_execute_multiple_array(self, check_call, check_output): execute(( ['some', 'command'], ['another', 'command'], )) expected = ( call(['some', 'command']), call(['another', 'command']), ) self.assertSequenceEqual(check_output.call_args_list, expected)
def test_execute_multiple_array(self, check_call, check_output): execute(( ['some', 'command'], ['another', 'command'], )) expected = ( call(['some', 'command']), call(['another', 'command']), ) for executed, expected in zip(check_output.call_args_list, expected): assert executed == expected
def test_execute_multiple(self, check_output, mocker): execute(''' some command another command ''') expected = ( mocker.call(['some', 'command']), mocker.call(['another', 'command']), ) for executed, expected in zip(check_output.call_args_list, expected): assert executed == expected
def test_execute_multiple_array(self, check_output, mocker): execute(( ['some', 'command'], ['another', 'command'], )) expected = ( mocker.call(['some', 'command']), mocker.call(['another', 'command']), ) for executed, expected in zip(check_output.call_args_list, expected): assert executed == expected
def test_execute_multiple(self, check_output, mocker): execute( """ some command another command """ ) expected = ( mocker.call(["some", "command"]), mocker.call(["another", "command"]), ) for executed, expected in zip(check_output.call_args_list, expected): assert executed == expected
def validate(self): if not isdir('.hg'): raise BumprError('Current directory is not a mercurial repopsitory') for line in execute('hg status -mard', verbose=False).splitlines(): if not line.startswith('??'): raise BumprError('The current repository contains modified files')
def validate(self): if not isdir('.git'): raise BumprError('Current directory is not a git repopsitory') for line in execute('git status --porcelain', verbose=False).splitlines(): if not line.startswith('??'): raise BumprError('The current repository contains modified files')
def validate(self): if not isdir('.bzr'): raise BumprError('Current directory is not a bazaar repopsitory') for line in execute('bzr status --short', verbose=False).splitlines(): if not line.startswith('?'): raise BumprError('The current repository contains modified files')
def validate(self): if not isdir('.bzr'): raise BumprError('Current directory is not a bazaar repopsitory') for line in execute('bzr status --short', verbose=False).splitlines(): if not line.startswith('?'): raise BumprError( 'The current repository contains modified files')
def validate(self): if not isdir('.hg'): raise BumprError( 'Current directory is not a mercurial repopsitory') for line in execute('hg status -mard', verbose=False).splitlines(): if not line.startswith('??'): raise BumprError( 'The current repository contains modified files')
def validate(self): if not isdir('.git'): raise BumprError('Current directory is not a git repopsitory') for line in execute('git status --porcelain', verbose=False).splitlines(): if not line.startswith('??'): raise BumprError( 'The current repository contains modified files')
def validate(self, dryrun=False): if not isdir('.bzr'): raise BumprError('Current directory is not a bazaar repopsitory') for line in execute('bzr status --short', verbose=False).splitlines(): if not line.startswith('?'): if dryrun: log.warning(MSG) break else: raise BumprError(MSG)
def validate(self, dryrun=False): if not isdir('.hg'): raise BumprError('Current directory is not a mercurial repopsitory') for line in execute('hg status -mard', verbose=False).splitlines(): if not line.startswith('??'): if dryrun: log.warning(MSG) break else: raise BumprError(MSG)
def validate(self, dryrun=False): if not isdir('.git'): raise BumprError('Current directory is not a git repopsitory') for line in execute('git status --porcelain', verbose=False).splitlines(): if not line.startswith('??'): if dryrun: log.warning(MSG) break else: raise BumprError(MSG)
def execute(self, command): '''Execute a command''' execute(command, verbose=self.verbose)
def test_execute_dry(self, check_call, check_output): execute('some command', dryrun=True) self.assertFalse(check_call.called) self.assertFalse(check_output.called)
def test_execute_quoted(self, check_call, check_output): execute('some command "with quote"') check_output.assert_called_with(['some', 'command', 'with quote'])
def test_execute_verbose(self, check_call, check_output): execute('some command', verbose=True) check_call.assert_called_with(['some', 'command']) assert not check_output.called
def test_execute_format_array(self, check_output): execute(["some", "command", "{key}"], replacements={"key": "value"}) check_output.assert_called_with(["some", "command", "value"])
def test_execute_verbose(self, check_call, check_output): execute("some command", verbose=True) check_call.assert_called_with(["some", "command"]) assert not check_output.called
def test_execute_array(self, check_call, check_output): execute(["some", "command"]) check_output.assert_called_with(["some", "command"]) assert not check_call.called
def test_execute_error_verbose(self, check_call, check_output): check_call.side_effect = CalledProcessError(1, 'cmd') with pytest.raises(BumprError): execute('some failed command', verbose=True)
def test_execute_quiet(self, check_call, check_output): output = 'some output' check_output.return_value = output self.assertEqual(execute('some command'), output) check_output.assert_called_with(['some', 'command']) self.assertFalse(check_call.called)
def test_execute_quoted(self, check_output): execute('some command "with quote"') check_output.assert_called_with(['some', 'command', 'with quote'])
def test_execute_format_array(self, check_call, check_output): execute(['some', 'command', '{key}'], replacements={'key': 'value'}) check_output.assert_called_with(['some', 'command', 'value'])
def test_execute_dry(self, check_call, check_output): execute('some command', dryrun=True) assert not check_call.called assert not check_output.called
def test_execute_array(self, check_call, check_output): execute(['some', 'command']) check_output.assert_called_with(['some', 'command']) assert not check_call.called
def test_execute_quiet(self, check_call, check_output): output = 'some output' check_output.return_value = output assert execute('some command') == output check_output.assert_called_with(['some', 'command']) assert not check_call.called
def test_execute_format_array(self, check_output): execute(['some', 'command', '{key}'], replacements={'key': 'value'}) check_output.assert_called_with(['some', 'command', 'value'])
def test_execute_quoted(self, check_output): execute('some command "with quote"') check_output.assert_called_with(["some", "command", "with quote"])
def test_execute_error_verbose(self, check_call): check_call.side_effect = CalledProcessError(1, 'cmd') with pytest.raises(BumprError): execute('some failed command', verbose=True)
def test_execute_quiet(self, check_call, check_output): output = "some output" check_output.return_value = output assert execute("some command") == output check_output.assert_called_with(["some", "command"]) assert not check_call.called