@@ -219,6 +219,7 @@ def add_cli_argument_group(group: argparse._ArgumentGroup) -> None:
219219 group .add_argument ("--o2" , type = str , default = "a" )
220220 group .add_argument ("--o3" , dest = "arg_name" , type = int )
221221 group .add_argument ("--override-toml" )
222+ group .add_argument ("--dont-override-toml" , action = "store_const" , const = True )
222223
223224
224225def test_cli_options_group (monkeypatch , tmp_path ):
@@ -236,6 +237,7 @@ def test_cli_options_group(monkeypatch, tmp_path):
236237 [plugin.table]
237238override_toml = 'failed'
238239toml_only = true
240+ dont_override_toml = 'dont override this with None if CLI opt not given'
239241"""
240242 )
241243
@@ -259,11 +261,16 @@ def test_cli_options_group(monkeypatch, tmp_path):
259261 posargs = call_ [0 ]
260262 # Options is the second positional arg of MDRender.render
261263 opts = posargs [1 ]
262- assert opts ["mdformat" ]["plugin" ]["table" ]["o1" ] == "other"
263- assert opts ["mdformat" ]["plugin" ]["table" ]["o2" ] == "a"
264- assert opts ["mdformat" ]["plugin" ]["table" ]["arg_name" ] == 4
265- assert opts ["mdformat" ]["plugin" ]["table" ]["override_toml" ] == "success"
266- assert opts ["mdformat" ]["plugin" ]["table" ]["toml_only" ] is True
264+ table_opts = opts ["mdformat" ]["plugin" ]["table" ]
265+ assert table_opts ["o1" ] == "other"
266+ assert table_opts ["o2" ] == "a"
267+ assert table_opts ["arg_name" ] == 4
268+ assert table_opts ["override_toml" ] == "success"
269+ assert table_opts ["toml_only" ] is True
270+ assert (
271+ table_opts ["dont_override_toml" ]
272+ == "dont override this with None if CLI opt not given"
273+ )
267274
268275
269276def test_cli_options_group__no_toml (monkeypatch , tmp_path ):
0 commit comments