Exemple #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)
Exemple #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")
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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')
Exemple #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')
Exemple #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)
    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)
Exemple #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)
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #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')
Exemple #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')
Exemple #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')
Exemple #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')
Exemple #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')
Exemple #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')
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #24
0
 def execute(self, command):
     '''Execute a command'''
     execute(command, verbose=self.verbose)
Exemple #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)
Exemple #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)
Exemple #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'])
Exemple #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
Exemple #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"])
Exemple #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
Exemple #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
Exemple #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)
Exemple #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)
Exemple #34
0
 def execute(self, command):
     '''Execute a command'''
     execute(command, verbose=self.verbose)
Exemple #35
0
 def test_execute_quoted(self, check_output):
     execute('some command "with quote"')
     check_output.assert_called_with(['some', 'command', 'with quote'])
Exemple #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'])
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #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
 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)
Exemple #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'])
 def test_execute_dry(self, check_call, check_output):
     execute('some command', dryrun=True)
     self.assertFalse(check_call.called)
     self.assertFalse(check_output.called)
Exemple #46
0
 def test_execute_quoted(self, check_output):
     execute('some command "with quote"')
     check_output.assert_called_with(["some", "command", "with quote"])
Exemple #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
Exemple #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)
Exemple #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