def test_config_shallow_merges_context(): config = konch.Config() config.update({"context": {"foo": 42}, "banner": "bar"}) config.update({"context": {"baz": 24}, "banner": "qux"}) assert config["context"] == {"foo": 42, "baz": 24} assert config["banner"] == "qux" config = konch.Config() config.update({"context": {"foo": 42}}) config.update({"context": {"foo": 24}}) assert config["context"] == {"foo": 24} config = konch.Config() config.update({"context": {"foo": {"inner": 42}}}) config.update({"context": {"foo": {"inner2": 24}}}) assert config["context"] == {"foo": {"inner2": 24}} config = konch.Config() def bar(): pass config.update({"context": {"foo": 42}, "banner": "bar"}) config.update({"context": [bar], "banner": "bar"})
def test_config_list(): assert konch._cfg == konch.Config() def my_func(): return konch.config({'context': [my_func]}) assert konch._cfg['context']['my_func'] == my_func
def test_config_list(): assert konch._cfg == konch.Config() def my_func(): return konch.config({"context": [my_func]}) assert konch._cfg["context"]["my_func"] == my_func
def test_config_update_context_converts_list(): import math config = konch.Config() config.update({'context': [math]}) assert config['context'] == {'math': math}
def test_config_set_context_converts_list(): import math config = konch.Config() config['context'] = [math] assert config['context'] == {'math': math}
def test_config_converts_list_context(): import math config = konch.Config(context=[math]) assert config['context'] == {'math': math}
def test_reset_config(): assert konch._cfg == konch.Config() konch.config({'banner': 'Foo bar'}) konch.reset_config() assert konch._cfg == konch.Config()
def test_config(): assert konch._cfg == konch.Config() konch.config({'banner': 'Foo bar'}) assert konch._cfg['banner'] == 'Foo bar'
def test_config_update_context_converts_list(): import math config = konch.Config() config.update({"context": [math]}) assert config["context"] == {"math": math}
def test_config_set_context_converts_list(): import math config = konch.Config() config["context"] = [math] assert config["context"] == {"math": math}
def test_config_converts_list_context(): import math config = konch.Config(context=[math]) assert config["context"] == {"math": math}
def test_reset_config(): assert konch._cfg == konch.Config() konch.config({"banner": "Foo bar"}) konch.reset_config() assert konch._cfg == konch.Config()
def test_config(): assert konch._cfg == konch.Config() konch.config({"banner": "Foo bar"}) assert konch._cfg["banner"] == "Foo bar"