Exemplo n.º 1
0
def test_custom_formatter():
    context = {"foo": 42, "bar": 24}

    def my_formatter(ctx):
        return "*".join(sorted(ctx.keys()))

    assert konch.format_context(context, formatter=my_formatter) == "bar*foo"
Exemplo n.º 2
0
def test_custom_formatter():
    context = {'foo': 42, 'bar': 24}

    def my_formatter(ctx):
        return '*'.join(sorted(ctx.keys()))

    assert konch.format_context(context, formatter=my_formatter) == 'bar*foo'
Exemplo n.º 3
0
def test_custom_formatter():
    context = {"foo": 42, "bar": 24}

    def my_formatter(ctx):
        return "*".join(sorted(ctx.keys()))

    assert konch.format_context(context, formatter=my_formatter) == "bar*foo"
Exemplo n.º 4
0
def test_short_formatter():
    class Foo:
        def __repr__(self):
            return "<Foo>"

    context = {"foo": Foo(), "bar": 42}

    assert konch.format_context(context, formatter="short") == "\nContext:\nbar, foo"
Exemplo n.º 5
0
def test_short_formatter():
    class Foo(object):
        def __repr__(self):
            return '<Foo>'

    context = {'foo': Foo(), 'bar': 42}

    assert konch.format_context(context,
                                formatter='short') == '\nContext:\nbar, foo'
Exemplo n.º 6
0
def test_short_formatter():
    class Foo:
        def __repr__(self):
            return "<Foo>"

    context = {"foo": Foo(), "bar": 42}

    assert konch.format_context(context,
                                formatter="short") == "\nContext:\nbar, foo"
Exemplo n.º 7
0
def test_full_formatter():
    class Foo:
        def __repr__(self):
            return "<Foo>"

    context = {"foo": Foo(), "bar": 42}

    assert (konch.format_context(
        context, formatter="full") == "\nContext:\nbar: 42\nfoo: <Foo>")
Exemplo n.º 8
0
def test_format_context():
    context = {
        'my_number': 42,
        'my_func': lambda x: x,
    }
    result = konch.format_context(context)
    assert result == '\n'.join([
        '{0}: {1!r}'.format(key, value)
        for key, value in context.items()
    ])
Exemplo n.º 9
0
def test_full_formatter():
    class Foo:
        def __repr__(self):
            return "<Foo>"

    context = {"foo": Foo(), "bar": 42}

    assert (
        konch.format_context(context, formatter="full")
        == "\nContext:\nbar: 42\nfoo: <Foo>"
    )
Exemplo n.º 10
0
def test_make_banner_hide_context():
    context = {'foo': 42}
    result = konch.make_banner(context=context, hide_context=True)
    assert konch.format_context(context) not in result
Exemplo n.º 11
0
def test_make_banner_with_context():
    context = {'foo': 42}
    result = konch.make_banner(context=context)
    assert konch.format_context(context) in result
Exemplo n.º 12
0
def test_make_banner_hide_context():
    context = {'foo': 42}
    result = konch.make_banner(context=context, context_format='hide')
    assert konch.format_context(context) not in result
Exemplo n.º 13
0
def test_make_banner_includes_full_context_by_default():
    context = {'foo': 42}
    result = konch.make_banner(context=context)
    assert konch.format_context(context, formatter='full') in result
Exemplo n.º 14
0
def test_make_banner_hide_context():
    context = {"foo": 42}
    result = konch.make_banner(context=context, context_format="hide")
    assert konch.format_context(context) not in result
Exemplo n.º 15
0
def test_make_banner_hide_context():
    context = {"foo": 42}
    result = konch.make_banner(context=context, context_format="hide")
    assert konch.format_context(context) not in result
Exemplo n.º 16
0
def test_make_banner_includes_full_context_by_default():
    context = {"foo": 42}
    result = konch.make_banner(context=context)
    assert konch.format_context(context, formatter="full") in result