Beispiel #1
0
 def test_subsequent_calls_to_setup_do_nothing(self):
     assert bd.cfg._prv['done_setup'] is False
     cfg = bd.setup()
     assert bd.cfg._prv['done_setup'] is True
     cfg = bd.setup()
     assert bd.cfg._prv['done_setup'] is True
     assert cfg is bd.cfg
Beispiel #2
0
    def test_can_not_set_global_config_module_if_imported_as_global(self):
        from util.imported_cfg import my_bd_cfg_is_same_as_given

        cfg = bd.setup()
        other = bd.config.config.Config()
        assert my_bd_cfg_is_same_as_given(cfg)
        assert not my_bd_cfg_is_same_as_given(other)
        bd.cfg = other
        assert not my_bd_cfg_is_same_as_given(other)
Beispiel #3
0
 def test_can_create_other_config_objects(self):
     cfg = bd.setup()
     other = bd.config.config.Config()
     assert cfg is not other
Beispiel #4
0
 def test_can_call_setup_and_setup_returns_self(self):
     assert bd.cfg._prv['done_setup'] is False
     cfg = bd.setup()
     assert bd.cfg._prv['done_setup'] is True
     assert cfg is bd.cfg
Beispiel #5
0
 def test_calling_setup_with_wrong_sysargv_raises_error(self):
     sys.argv = sys.argv + ['bonkers']
     with pytest.raises(SystemExit):
         bd.setup()
Beispiel #6
0
 def test_non_existing_cfg_file_raises_error(self):
     simple_cfg_file = os.path.join(_ASSETS_DIR, 'does_not_exist.bd')
     sys.argv = sys.argv + [simple_cfg_file]
     bd.cfg.add_argument(flag='--foo', default=42, help='Foo')
     with pytest.raises(SystemExit):
         bd.setup()
Beispiel #7
0
 def test_only_supported_extensions_work(self):
     f_cfg_1 = create_asset("foo 3", '.bdx')
     sys.argv = sys.argv + [f_cfg_1]
     with pytest.raises(SystemExit):
         bd.setup()
Beispiel #8
0
 def test_using_empty_argument_list_resets_previously_added_ones(self):
     bd.cfg.add_argument(flag='--foo', default=42, help='Foo')
     bd.cfg.empty_argument_list()
     sys.argv = sys.argv + ['--foo', '3']
     with pytest.raises(SystemExit):
         bd.setup()
Beispiel #9
0
 def test_use_boardom_arguments_does_not_reset_previously_added_ones(self):
     bd.cfg.add_argument(flag='--foo', default=42, help='Foo')
     bd.cfg.use_boardom_arguments()
     bd.cfg.use_boardom_arguments()
     sys.argv = sys.argv + ['--foo', '3']
     bd.setup()
Beispiel #10
0
 def test_can_pass_list_to_setup_for_replacing_sysargv(self):
     sys.argv = sys.argv + ['--foo', '3']
     bd.cfg.add_argument(flag='--foo', default=42, help='Foo')
     bd.setup(use_sysargv=False, extra=['--foo', '5'])
     assert bd.cfg.foo == '5'
Beispiel #11
0
 def test_calling_without_sysargv_ignores_sysargv_values(self):
     sys.argv = sys.argv + ['--foo', '3']
     bd.cfg.add_argument(flag='--foo', default=42, help='Foo')
     bd.setup(use_sysargv=False)
     assert bd.cfg.foo == 42
Beispiel #12
0
 def test_can_call_setup_without_sysargv(self):
     sys.argv = sys.argv + ['bonkers']
     bd.cfg.add_argument(flag='--foo', default=42, help='Foo')
     bd.setup(use_sysargv=False)
Beispiel #13
0
 def test_can_not_add_arguments_after_setup(self):
     bd.cfg.add_argument(flag='--foo', default=42, help='Foo')
     bd.setup()
     with pytest.raises(RuntimeError) as e:
         bd.cfg.add_argument(flag='--bar', default=1, help='Bar')
     assert 'Attempted to add argument after setup' in str(e)
Beispiel #14
0
    def test_only_uses_automatic_arguments_by_default_when_imported(self):
        from boardom.config.common import AUTOMATIC_ARGS

        assert len(bd.cfg) == 0
        bd.setup()
        assert len(bd.cfg) == len(AUTOMATIC_ARGS)