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