Skip to content

Commit

Permalink
tests: improve plugin option merge test
Browse files Browse the repository at this point in the history
  • Loading branch information
hukkin committed Dec 19, 2024
1 parent e3b4c33 commit 52f3c06
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ def add_cli_argument_group(group: argparse._ArgumentGroup) -> None:
group.add_argument("--o2", type=str, default="a")
group.add_argument("--o3", dest="arg_name", type=int)
group.add_argument("--override-toml")
group.add_argument("--dont-override-toml", action="store_const", const=True)


def test_cli_options_group(monkeypatch, tmp_path):
Expand All @@ -236,6 +237,7 @@ def test_cli_options_group(monkeypatch, tmp_path):
[plugin.table]
override_toml = 'failed'
toml_only = true
dont_override_toml = 'dont override this with None if CLI opt not given'
"""
)

Expand All @@ -259,11 +261,16 @@ def test_cli_options_group(monkeypatch, tmp_path):
posargs = call_[0]
# Options is the second positional arg of MDRender.render
opts = posargs[1]
assert opts["mdformat"]["plugin"]["table"]["o1"] == "other"
assert opts["mdformat"]["plugin"]["table"]["o2"] == "a"
assert opts["mdformat"]["plugin"]["table"]["arg_name"] == 4
assert opts["mdformat"]["plugin"]["table"]["override_toml"] == "success"
assert opts["mdformat"]["plugin"]["table"]["toml_only"] is True
table_opts = opts["mdformat"]["plugin"]["table"]
assert table_opts["o1"] == "other"
assert table_opts["o2"] == "a"
assert table_opts["arg_name"] == 4
assert table_opts["override_toml"] == "success"
assert table_opts["toml_only"] is True
assert (
table_opts["dont_override_toml"]
== "dont override this with None if CLI opt not given"
)


def test_cli_options_group__no_toml(monkeypatch, tmp_path):
Expand Down

0 comments on commit 52f3c06

Please sign in to comment.