예제 #1
0
 def test_early_version(self, stdout):
     cmd = Command()
     with self.assertRaises(SystemExit):
         cmd.early_version(['--version'])
예제 #2
0
 def test_default_on_usage_error(self):
     cmd = Command()
     cmd.handle_error = Mock()
     exc = Exception()
     cmd.on_usage_error(exc)
     cmd.handle_error.assert_called_with(exc)
예제 #3
0
 def test_run_interface(self):
     with self.assertRaises(NotImplementedError):
         Command().run()
예제 #4
0
 def test_get_options(self):
     cmd = Command()
     cmd.option_list = (1, 2, 3)
     self.assertTupleEqual(cmd.get_options(), (1, 2, 3))
예제 #5
0
 def test_register_callbacks(self):
     c = Command(on_error=8, on_usage_error=9)
     self.assertEqual(c.on_error, 8)
     self.assertEqual(c.on_usage_error, 9)
예제 #6
0
 def test_register_callbacks(self):
     c = Command(on_error=8, on_usage_error=9)
     assert c.on_error == 8
     assert c.on_usage_error == 9
예제 #7
0
 def test_parse_preload_options_shortopt(self):
     cmd = Command()
     cmd.preload_options = (Option('-s', action='store', dest='silent'), )
     acc = cmd.parse_preload_options(['-s', 'yes'])
     self.assertEqual(acc.get('silent'), 'yes')
예제 #8
0
 def test_format_epilog(self):
     assert Command()._format_epilog('hello')
     assert not Command()._format_epilog('')
예제 #9
0
 def test_format_description(self):
     assert Command()._format_description('hello')
예제 #10
0
 def test_early_version(self, stdout):
     cmd = Command()
     with pytest.raises(SystemExit):
         cmd.early_version(['--version'])
예제 #11
0
 def test_get_options(self):
     cmd = Command()
     cmd.option_list = (1, 2, 3)
     assert cmd.get_options() == (1, 2, 3)
예제 #12
0
 def test_run_interface(self):
     with pytest.raises(NotImplementedError):
         Command().run()
예제 #13
0
 def test_run_interface(self):
     self.assertRaises(NotImplementedError, Command().run)
예제 #14
0
    def test_defaults(self):
        cmd1 = Command(defaults=None)
        self.assertTrue(cmd1.defaults)

        cmd2 = Command(defaults=AttributeDict({"foo": "bar"}))
        self.assertTrue(cmd2.defaults)
예제 #15
0
 def test_early_version(self, stdout):
     cmd = Command()
     with self.assertRaises(SystemExit):
         cmd.early_version(['--version'])
     stdout.write.assert_called_with(cmd.version + '\n')
예제 #16
0
 def test_parse_options_version_only(self, stdout):
     cmd = Command()
     with self.assertRaises(SystemExit):
         cmd.parse_options('prog', ['--version'])
     stdout.write.assert_called_with(cmd.version + '\n')