Commits

Anonymous committed a51a9c0 Draft

Added tests (passing, thankfully) for store_true and store_false (special cases
of store_const).

  • Participants
  • Parent commits 3108fea

Comments (0)

Files changed (1)

File argparse_config.src/argparse_config/tests/__init__.py

         self.assertEqual(parsed_args.value_ignored_flag, 'used', "Not what is in the config file")
         self.assertEqual(parsed_args.no_value_flag, True, "Indeed, no value in the config file is actually needed")
 
+    @with_config_file()
+    def test_store_true_false(self, config_parser):
+        """
+        [default]
+        flag:
+        flag_false:
+        """
+        arg_parser = ArgumentParser()
+        arg_parser.add_argument('--flag', action='store_true')
+        arg_parser.add_argument('--flag-false', action='store_false')
+
+        set_defaults(arg_parser, config_parser)
+
+        parsed_args = arg_parser.parse_args([])
+
+        self.assertIsNotNone(parsed_args.flag)
+        self.assertIs(parsed_args.flag, True)
+        self.assertIsNotNone(parsed_args.flag_false)
+        self.assertIs(parsed_args.flag_false, False)
+
     def test_file_shortcut(self):
         arg_parser = ArgumentParser()
         arg_parser.add_argument('--verbose', action='store_const', const=True)