Example #1
0
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"})
Example #2
0
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
Example #3
0
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
Example #4
0
def test_config_update_context_converts_list():
    import math
    config = konch.Config()
    config.update({'context': [math]})
    assert config['context'] == {'math': math}
Example #5
0
def test_config_set_context_converts_list():
    import math
    config = konch.Config()
    config['context'] = [math]
    assert config['context'] == {'math': math}
Example #6
0
def test_config_converts_list_context():
    import math
    config = konch.Config(context=[math])
    assert config['context'] == {'math': math}
Example #7
0
def test_reset_config():
    assert konch._cfg == konch.Config()
    konch.config({'banner': 'Foo bar'})
    konch.reset_config()
    assert konch._cfg == konch.Config()
Example #8
0
def test_config():
    assert konch._cfg == konch.Config()
    konch.config({'banner': 'Foo bar'})
    assert konch._cfg['banner'] == 'Foo bar'
Example #9
0
def test_config_update_context_converts_list():
    import math

    config = konch.Config()
    config.update({"context": [math]})
    assert config["context"] == {"math": math}
Example #10
0
def test_config_set_context_converts_list():
    import math

    config = konch.Config()
    config["context"] = [math]
    assert config["context"] == {"math": math}
Example #11
0
def test_config_converts_list_context():
    import math

    config = konch.Config(context=[math])
    assert config["context"] == {"math": math}
Example #12
0
def test_reset_config():
    assert konch._cfg == konch.Config()
    konch.config({"banner": "Foo bar"})
    konch.reset_config()
    assert konch._cfg == konch.Config()
Example #13
0
def test_config():
    assert konch._cfg == konch.Config()
    konch.config({"banner": "Foo bar"})
    assert konch._cfg["banner"] == "Foo bar"