Ejemplo n.º 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)
Ejemplo n.º 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")
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 24
0
 def execute(self, command):
     '''Execute a command'''
     execute(command, verbose=self.verbose)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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'])
Ejemplo n.º 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
Ejemplo n.º 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"])
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 34
0
 def execute(self, command):
     '''Execute a command'''
     execute(command, verbose=self.verbose)
Ejemplo n.º 35
0
 def test_execute_quoted(self, check_output):
     execute('some command "with quote"')
     check_output.assert_called_with(['some', 'command', 'with quote'])
Ejemplo n.º 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'])
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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'])
Ejemplo n.º 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)
Ejemplo n.º 46
0
 def test_execute_quoted(self, check_output):
     execute('some command "with quote"')
     check_output.assert_called_with(["some", "command", "with quote"])
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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