예제 #1
0
 def test_options_not_allowed(self):
     with self.assertRaises(CmdLineInputError) as cm:
         prepare_options_allowed(["d=1", "a=2", "c=3", "b=4"], ["a", "b"])
     self.assertEqual(
         str(cm.exception),
         "Unknown options 'c', 'd'"
     )
예제 #2
0
 def test_options_not_allowed(self):
     with self.assertRaises(CmdLineInputError) as cm:
         prepare_options_allowed(["d=1", "a=2", "c=3", "b=4"], ["a", "b"])
     self.assertEqual(
         str(cm.exception),
         "Unknown options 'c', 'd'"
     )
예제 #3
0
 def test_option_not_allowed(self):
     with self.assertRaises(CmdLineInputError) as cm:
         prepare_options_allowed(["a=1"], [])
     self.assertEqual(
         str(cm.exception),
         "Unknown option 'a'"
     )
예제 #4
0
 def test_option_not_allowed(self):
     with self.assertRaises(CmdLineInputError) as cm:
         prepare_options_allowed(["a=1"], [])
     self.assertEqual(
         str(cm.exception),
         "Unknown option 'a'"
     )
예제 #5
0
 def test_allow_repeatable(self):
     self.assertEqual(
         {"a": ["1", "2"]},
         prepare_options_allowed(
             ["a=1", "a=2"], ["a"], allowed_repeatable_options=("a")
         ),
     )
예제 #6
0
 def test_prepare_option_dict_form_args(self):
     self.assertEqual(
         {
             "a": "b",
             "c": "d"
         },
         prepare_options_allowed(["a=b", "c=d"], ["a", "c"]),
     )
예제 #7
0
 def test_allow_repeatable(self):
     self.assertEqual(
         {'a': ['1', '2']},
         prepare_options_allowed(
             ["a=1", "a=2"],
             ["a"],
             allowed_repeatable_options=("a")
         )
     )
예제 #8
0
 def test_allow_repeatable(self):
     self.assertEqual(
         {'a': ['1', '2']},
         prepare_options_allowed(
             ["a=1", "a=2"],
             ["a"],
             allowed_repeatable_options=("a")
         )
     )
예제 #9
0
 def test_prepare_option_dict_with_empty_value(self):
     self.assertEqual({"a": ""}, prepare_options_allowed(["a="], "a"))
예제 #10
0
 def test_accept_options_with_same_key_and_same_value(self):
     self.assertEqual(
         {'a': '1'},
         prepare_options_allowed(["a=1", "a=1"], ["a"]))
예제 #11
0
 def test_refuse_options_with_same_key_and_differend_value(self):
     self.assertRaises(
         CmdLineInputError,
         lambda: prepare_options_allowed(['a=a', "a=b"], ["a"]))
예제 #12
0
 def test_prepare_option_dict_with_empty_value(self):
     self.assertEqual({'a': ''}, prepare_options_allowed(['a='], "a"))
예제 #13
0
 def test_prepare_option_dict_form_args(self):
     self.assertEqual(
         {'a': 'b', 'c': 'd'},
         prepare_options_allowed(['a=b', 'c=d'], ["a", "c"]))
예제 #14
0
 def test_refuse_option_without_value(self):
     self.assertRaises(
         CmdLineInputError, lambda: prepare_options_allowed(['abc'], ["abc"])
     )
예제 #15
0
 def test_refuse_option_without_value(self):
     self.assertRaises(CmdLineInputError,
                       lambda: prepare_options_allowed(['abc'], ["abc"]))
예제 #16
0
 def test_prepare_option_dict_form_args(self):
     self.assertEqual({
         'a': 'b',
         'c': 'd'
     }, prepare_options_allowed(['a=b', 'c=d'], ["a", "c"]))
예제 #17
0
 def test_prepare_option_dict_with_empty_value(self):
     self.assertEqual({'a': ''}, prepare_options_allowed(['a='], "a"))
예제 #18
0
 def test_refuse_option_without_key(self):
     self.assertRaises(CmdLineInputError,
                       lambda: prepare_options_allowed(['=a'], ["a"]))
예제 #19
0
 def test_refuse_option_without_key(self):
     self.assertRaises(
         CmdLineInputError, lambda: prepare_options_allowed(['=a'], ["a"])
     )
예제 #20
0
 def test_accept_options_with_same_key_and_same_value(self):
     self.assertEqual({'a': '1'},
                      prepare_options_allowed(["a=1", "a=1"], ["a"]))
예제 #21
0
 def test_refuse_options_with_same_key_and_differend_value(self):
     self.assertRaises(
         CmdLineInputError,
         lambda: prepare_options_allowed(['a=a', "a=b"], ["a"])
     )