Anonymous committed 3c3d171 Draft

Added failing test for flags without colon.

Comments (0)

Files changed (1)


         def wrapper(self):
             config_file = textwrap.dedent(f.__doc__.lstrip('\n'))
-            config_parser = SafeConfigParser()
+            config_parser = SafeConfigParser(allow_no_value=True)
             return f(self, config_parser)
         return wrapper
         inverted_flag: 1
         value_ignored_flag: ignored
+        no_value_flag_without_colon
         arg_parser = ArgumentParser()
         arg_parser.add_argument('--flag', action='store_const', const=True, default=False)
         arg_parser.add_argument('--unused-flag', action='store_const', const=True, default=False)
         arg_parser.add_argument('--value-ignored-flag', action='store_const', const='used', default=None)
         arg_parser.add_argument('--no-value-flag', action='store_const', const=True, default=False)
+        arg_parser.add_argument('--no-value-flag-without-colon', action='store_true')
         set_defaults(arg_parser, config_parser)
         parsed_args = arg_parser.parse_args([])
         self.assertEqual(parsed_args.flag, True)
-        self.assertEqual(parsed_args.inverted_flag, False, "Effect should be the same as commandline")
+        self.assertIs(parsed_args.inverted_flag, False, "Effect should be the same as commandline")
         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")
+        self.assertIs(parsed_args.no_value_flag_without_colon, True)
     def test_store_true_false(self, config_parser):
         arg_parser.add_argument('--verbose', action='store_const', const=True)
         file_contents = textwrap.dedent("""
-        verbose:
+        verbose
         temp_file = tempfile.NamedTemporaryFile()
         with temp_file.file as f:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.