Beispiel #1
0
 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)
Beispiel #2
0
    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")
Beispiel #3
0
 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)
Beispiel #4
0
 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)
Beispiel #5
0
 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)
Beispiel #6
0
    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')
Beispiel #7
0
    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')
Beispiel #8
0
 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)
Beispiel #9
0
    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)
Beispiel #10
0
    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)
Beispiel #11
0
    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
Beispiel #12
0
    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
Beispiel #13
0
    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
Beispiel #14
0
    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
Beispiel #15
0
    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')
Beispiel #16
0
    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')
Beispiel #17
0
    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')
Beispiel #18
0
    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')
Beispiel #19
0
    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')
Beispiel #20
0
    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')
Beispiel #21
0
    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)
Beispiel #22
0
    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)
Beispiel #23
0
    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)
Beispiel #24
0
 def execute(self, command):
     '''Execute a command'''
     execute(command, verbose=self.verbose)
Beispiel #25
0
 def test_execute_dry(self, check_call, check_output):
     execute('some command', dryrun=True)
     self.assertFalse(check_call.called)
     self.assertFalse(check_output.called)
Beispiel #26
0
 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)
Beispiel #27
0
 def test_execute_quoted(self, check_call, check_output):
     execute('some command "with quote"')
     check_output.assert_called_with(['some', 'command', 'with quote'])
Beispiel #28
0
 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
Beispiel #29
0
 def test_execute_format_array(self, check_output):
     execute(["some", "command", "{key}"], replacements={"key": "value"})
     check_output.assert_called_with(["some", "command", "value"])
Beispiel #30
0
 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
Beispiel #31
0
 def test_execute_array(self, check_call, check_output):
     execute(["some", "command"])
     check_output.assert_called_with(["some", "command"])
     assert not check_call.called
Beispiel #32
0
    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)
Beispiel #33
0
 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)
Beispiel #34
0
 def execute(self, command):
     '''Execute a command'''
     execute(command, verbose=self.verbose)
Beispiel #35
0
 def test_execute_quoted(self, check_output):
     execute('some command "with quote"')
     check_output.assert_called_with(['some', 'command', 'with quote'])
Beispiel #36
0
 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'])
Beispiel #37
0
 def test_execute_dry(self, check_call, check_output):
     execute('some command', dryrun=True)
     assert not check_call.called
     assert not check_output.called
Beispiel #38
0
 def test_execute_array(self, check_call, check_output):
     execute(['some', 'command'])
     check_output.assert_called_with(['some', 'command'])
     assert not check_call.called
Beispiel #39
0
 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
Beispiel #40
0
 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
Beispiel #41
0
 def test_execute_dry(self, check_call, check_output):
     execute('some command', dryrun=True)
     assert not check_call.called
     assert not check_output.called
Beispiel #42
0
 def test_execute_array(self, check_call, check_output):
     execute(['some', 'command'])
     check_output.assert_called_with(['some', 'command'])
     assert not check_call.called
Beispiel #43
0
 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)
Beispiel #44
0
 def test_execute_format_array(self, check_output):
     execute(['some', 'command', '{key}'], replacements={'key': 'value'})
     check_output.assert_called_with(['some', 'command', 'value'])
Beispiel #45
0
 def test_execute_dry(self, check_call, check_output):
     execute('some command', dryrun=True)
     self.assertFalse(check_call.called)
     self.assertFalse(check_output.called)
Beispiel #46
0
 def test_execute_quoted(self, check_output):
     execute('some command "with quote"')
     check_output.assert_called_with(["some", "command", "with quote"])
Beispiel #47
0
 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
Beispiel #48
0
    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)
Beispiel #49
0
 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