Add comments to tests
This commit is contained in:
parent
e9cef87154
commit
f3917c6e4d
@ -20,24 +20,24 @@ settings_cases = [
|
||||
group="tst",
|
||||
exclusive=False,
|
||||
),
|
||||
),
|
||||
), # Equivalent to Setting("--test", group="tst")
|
||||
{
|
||||
"action": None,
|
||||
"choices": None,
|
||||
"cmdline": True,
|
||||
"const": None,
|
||||
"default": None,
|
||||
"dest": "test",
|
||||
"dest": "test", # dest is calculated by Setting and is not used by argparse
|
||||
"exclusive": False,
|
||||
"file": True,
|
||||
"group": "tst",
|
||||
"help": None,
|
||||
"internal_name": "tst_test",
|
||||
"metavar": "TEST",
|
||||
"internal_name": "tst_test", # Should almost always be "{group}_{dest}"
|
||||
"metavar": "TEST", # Set manually so argparse doesn't use TST_TEST
|
||||
"nargs": None,
|
||||
"required": None,
|
||||
"type": None,
|
||||
"argparse_args": ("--test",),
|
||||
"argparse_args": ("--test",), # *args actually sent to argparse
|
||||
"argparse_kwargs": {
|
||||
"action": None,
|
||||
"choices": None,
|
||||
@ -49,7 +49,7 @@ settings_cases = [
|
||||
"nargs": None,
|
||||
"required": None,
|
||||
"type": None,
|
||||
},
|
||||
}, # Non-None **kwargs sent to argparse
|
||||
},
|
||||
),
|
||||
(
|
||||
@ -74,7 +74,7 @@ settings_cases = [
|
||||
group="tst",
|
||||
exclusive=False,
|
||||
),
|
||||
),
|
||||
), # Equivalent to Setting("-t", "--test", group="tst")
|
||||
{
|
||||
"action": None,
|
||||
"choices": None,
|
||||
@ -94,7 +94,7 @@ settings_cases = [
|
||||
"argparse_args": (
|
||||
"-t",
|
||||
"--test",
|
||||
),
|
||||
), # Only difference with above is here
|
||||
"argparse_kwargs": {
|
||||
"action": None,
|
||||
"choices": None,
|
||||
@ -128,7 +128,7 @@ settings_cases = [
|
||||
group="tst",
|
||||
exclusive=False,
|
||||
),
|
||||
),
|
||||
), # Equivalent to Setting("test", group="tst")
|
||||
{
|
||||
"action": None,
|
||||
"choices": None,
|
||||
@ -151,7 +151,7 @@ settings_cases = [
|
||||
"choices": None,
|
||||
"const": None,
|
||||
"default": None,
|
||||
"dest": None,
|
||||
"dest": None, # Only difference with #1 is here, argparse sets dest based on the *args passed to it
|
||||
"help": None,
|
||||
"metavar": "TEST",
|
||||
"nargs": None,
|
||||
@ -179,7 +179,7 @@ settings_cases = [
|
||||
group="",
|
||||
exclusive=False,
|
||||
),
|
||||
),
|
||||
), # Equivalent to Setting("test")
|
||||
{
|
||||
"action": None,
|
||||
"choices": None,
|
||||
@ -191,7 +191,7 @@ settings_cases = [
|
||||
"file": True,
|
||||
"group": "",
|
||||
"help": None,
|
||||
"internal_name": "test",
|
||||
"internal_name": "test", # No group, leading _ is stripped
|
||||
"metavar": "TEST",
|
||||
"nargs": None,
|
||||
"required": None,
|
||||
|
@ -54,17 +54,19 @@ def test_cmdline_only(settings_manager):
|
||||
|
||||
file_normalized = settings_manager.normalize_options({}, file=True)
|
||||
cmdline_normalized = settings_manager.normalize_options({}, cmdline=True)
|
||||
assert "test" not in file_normalized["tst"]
|
||||
|
||||
assert "test" in cmdline_normalized["tst"]
|
||||
assert "test2" in file_normalized["tst2"]
|
||||
assert "test2" not in cmdline_normalized["tst2"]
|
||||
|
||||
assert "test" not in file_normalized["tst"]
|
||||
assert "test2" in file_normalized["tst2"]
|
||||
|
||||
|
||||
def test_normalize(settings_manager):
|
||||
settings_manager.add_group("tst", lambda parser: parser.add_setting("--test", default="hello"))
|
||||
|
||||
defaults = settings_manager.defaults()
|
||||
defaults["test"] = "fail"
|
||||
defaults["test"] = "fail" # Not defined in settings_manager
|
||||
|
||||
defaults_namespace = settings_manager.get_namespace(defaults)
|
||||
defaults_namespace.test = "fail"
|
||||
@ -86,6 +88,7 @@ def test_normalize(settings_manager):
|
||||
"raw, raw2, expected",
|
||||
[
|
||||
({"tst": {"test": "fail"}}, argparse.Namespace(tst_test="success"), "success"),
|
||||
# hello is default so is not used in raw_options_2
|
||||
({"tst": {"test": "success"}}, argparse.Namespace(tst_test="hello"), "success"),
|
||||
(argparse.Namespace(tst_test="fail"), {"tst": {"test": "success"}}, "success"),
|
||||
(argparse.Namespace(tst_test="success"), {"tst": {"test": "hello"}}, "success"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user