示例#1
0
 def test_invalid_command(self):
     """Test if we fail correctly with an invalid command"""
     with capture_stderr():
         self.assertEqual(gbp.scripts.supercommand.supercommand(
                          ['argv0', 'asdf']), 2)
         self.assertEqual(gbp.scripts.supercommand.supercommand(
                          ['argv0', 'asdf', '--verbose']), 2)
 def test_invalid_command(self):
     """Test if we fail correctly with an invalid command"""
     with capture_stderr():
         self.assertEqual(
             gbp.scripts.supercommand.supercommand(['argv0', 'asdf']), 2)
         self.assertEqual(
             gbp.scripts.supercommand.supercommand(
                 ['argv0', 'asdf', '--verbose']), 2)
    def test_invalid_args(self):
        """See that pq-rpm fails gracefully when called with invalid args"""
        GitRepository.create('.')
        # Test empty args
        eq_(mock_pq([]), 1)
        self._check_log(0, 'gbp:error: No action given.')
        self._clear_log()

        # Test invalid command
        eq_(mock_pq(['mycommand']), 1)
        self._check_log(0, "gbp:error: Unknown action 'mycommand'")
        self._clear_log()

        # Test invalid cmdline options
        with assert_raises(SystemExit):
            with capture_stderr():
                mock_pq(['--invalid-arg=123'])
示例#4
0
    def test_invalid_args(self):
        """See that pq-rpm fails gracefully when called with invalid args"""
        GitRepository.create('.')
        # Test empty args
        eq_(mock_pq([]), 1)
        self._check_log(0, 'gbp:error: No action given.')
        self._clear_log()

        # Test invalid command
        eq_(mock_pq(['mycommand']), 1)
        self._check_log(0, "gbp:error: Unknown action 'mycommand'")
        self._clear_log()

        # Test invalid cmdline options
        with assert_raises(SystemExit):
            with capture_stderr():
                mock_pq(['--invalid-arg=123'])
示例#5
0
文件: test_view.py 项目: dmitrvk/smth
 def test_show_error(self):
     message = 'Test message'
     output = testutils.capture_stderr(self.view.show_error, message)
     self.assertEqual(output, f'{message}\n')
示例#6
0
def mock_ch(args):
    """Wrapper for gbp-rpm-ch"""
    with capture_stderr():
        return rpm_ch(['arg0', '--packaging-branch=master',
                       '--spawn-editor=never'] + args)
示例#7
0
def mock_ch(args):
    """Wrapper for gbp-rpm-ch"""
    with capture_stderr():
        return rpm_ch(['arg0', '--packaging-branch=master',
                       '--spawn-editor=never'] + args)
示例#8
0
文件: test_main.py 项目: dmitrvk/smth
 def test_unknown_command(self):
     with mock.patch.object(sys, 'argv', ['__main__.py', 'test']):
         with self.assertRaises(SystemExit):
             testutils.capture_stderr(main.main)
def mock_import(args):
    """Wrapper for import-srpm"""
    # Call import-orig-rpm with added arg0
    with capture_stderr():
        return import_srpm.main(['arg0'] + args)
示例#10
0
def mock_import(args):
    """Wrapper for import-srpm"""
    # Call import-orig-rpm with added arg0
    with capture_stderr():
        return import_srpm.main(['arg0'] + args)