From bd40d35a43bfa6e1e4c1654fe63c38a54bc8a268 Mon Sep 17 00:00:00 2001 From: joncrall <jon.crall@kitware.com> Date: Tue, 14 May 2024 15:39:48 -0400 Subject: [PATCH] tests for special options --- tests/test_special_options.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/test_special_options.py diff --git a/tests/test_special_options.py b/tests/test_special_options.py new file mode 100644 index 0000000..32c466e --- /dev/null +++ b/tests/test_special_options.py @@ -0,0 +1,22 @@ +def test_without_special_options(): + """ + The "special options" of "config", "dump", and "dumps" are useful but they + prevent the user from being able to use them as official config args. + """ + import scriptconfig as scfg + class MyConfig(scfg.DataConfig): + config = None + + # Without using the ``cli`` classmethod there should be no issue with using + # these "special options". + config = MyConfig() + assert config.config is None + + # But, if special options are enabled we cannot have options that conflict + import pytest + with pytest.raises(Exception): + config = MyConfig.cli(argv=['--config=foo'], special_options=True) + + # But setting special_options=False will allow for this + config = MyConfig.cli(argv=['--config=foo'], special_options=False) + assert config.config == 'foo' -- GitLab