示例#1
0
def test_mapping_with_mappings():
    input_ = {
        'foo': {
            'bar': 'error-a',
            'baz': 'error-b',
        },
        'bar': {
            'baz': 'error-c',
            'foo': 'error-d',
        }
    }
    expected = [
        "'foo':",
        "    - 'bar': 'error-a'",
        "    - 'baz': 'error-b'",
        "'bar':",
        "    - 'baz': 'error-c'",
        "    - 'foo': 'error-d'",
    ]
    actual = list(map(
        operator.methodcaller('replace', "u'", "'"),
        format_errors(input_),
    ))

    assert set(actual) == set(expected)
示例#2
0
def test_string():
    messages = list(map(
        operator.methodcaller('replace', "u'", "'"),
        format_errors("error"),
    ))

    assert messages == ["'error'"]
示例#3
0
def test_mapping_with_mappings():
    input_ = {
        'foo': {
            'bar': 'error-a',
            'baz': 'error-b',
        },
        'bar': {
            'baz': 'error-c',
            'foo': 'error-d',
        }
    }
    expected = [
        "'foo':",
        "    - 'bar': 'error-a'",
        "    - 'baz': 'error-b'",
        "'bar':",
        "    - 'baz': 'error-c'",
        "    - 'foo': 'error-d'",
    ]
    actual = list(
        map(
            operator.methodcaller('replace', "u'", "'"),
            format_errors(input_),
        ))

    assert set(actual) == set(expected)
示例#4
0
def test_string():
    messages = list(
        map(
            operator.methodcaller('replace', "u'", "'"),
            format_errors("error"),
        ))

    assert messages == ["'error'"]
示例#5
0
def test_short_iterable():
    input_ = ["error-a", "error-b"]
    expected = [
        "0. 'error-a'",
        "1. 'error-b'",
    ]
    actual = list(format_errors(input_))

    assert set(actual) == set(expected)
示例#6
0
def test_short_iterable():
    input_ = ["error-a", "error-b"]
    expected = [
        "0. 'error-a'",
        "1. 'error-b'",
    ]
    actual = list(map(
        operator.methodcaller('replace', "u'", "'"),
        format_errors(input_),
    ))

    assert set(actual) == set(expected)
示例#7
0
def test_mapping_with_string_values():
    input_ = {
        'foo': 'bar',
        'bar': 'baz',
    }
    expected = [
        "'foo': 'bar'",
        "'bar': 'baz'",
    ]
    actual = list(format_errors(input_))

    assert set(actual) == set(expected)
示例#8
0
def test_short_iterable():
    input_ = ["error-a", "error-b"]
    expected = [
        "0. 'error-a'",
        "1. 'error-b'",
    ]
    actual = list(
        map(
            operator.methodcaller('replace', "u'", "'"),
            format_errors(input_),
        ))

    assert set(actual) == set(expected)
示例#9
0
def test_iterable_of_mappings():
    input_ = [
        {'foo': 'bar'},
        {'bar': ['baz', 'foo']},
    ]
    expected = [
        "0. 'foo': 'bar'",
        "1. 'bar':",
        "    0. 'baz'",
        "    1. 'foo'",
    ]
    actual = list(format_errors(input_))

    assert set(actual) == set(expected)
示例#10
0
def test_mapping_with_string_values():
    input_ = {
        'foo': 'bar',
        'bar': 'baz',
    }
    expected = [
        "'foo': 'bar'",
        "'bar': 'baz'",
    ]
    actual = list(map(
        operator.methodcaller('replace', "u'", "'"),
        format_errors(input_),
    ))

    assert set(actual) == set(expected)
示例#11
0
def test_mapping_with_string_values():
    input_ = {
        'foo': 'bar',
        'bar': 'baz',
    }
    expected = [
        "'foo': 'bar'",
        "'bar': 'baz'",
    ]
    actual = list(
        map(
            operator.methodcaller('replace', "u'", "'"),
            format_errors(input_),
        ))

    assert set(actual) == set(expected)
示例#12
0
def test_mapping_with_iterables():
    input_ = {
        'foo': ['bar', 'baz'],
        'bar': ['baz', 'foo'],
    }
    expected = [
        "'foo':",
        "    0. 'bar'",
        "    1. 'baz'",
        "'bar':",
        "    0. 'baz'",
        "    1. 'foo'",
    ]
    actual = list(format_errors(input_))

    assert set(actual) == set(expected)
示例#13
0
def test_iterable_of_mappings():
    input_ = [
        {'foo': 'bar'},
        {'bar': ['baz', 'foo']},
    ]
    expected = [
        "0. 'foo': 'bar'",
        "1. 'bar':",
        "    0. 'baz'",
        "    1. 'foo'",
    ]
    actual = list(map(
        operator.methodcaller('replace', "u'", "'"),
        format_errors(input_),
    ))

    assert set(actual) == set(expected)
示例#14
0
def test_mapping_with_iterables():
    input_ = {
        'foo': ['bar', 'baz'],
        'bar': ['baz', 'foo'],
    }
    expected = [
        "'foo':",
        "    0. 'bar'",
        "    1. 'baz'",
        "'bar':",
        "    0. 'baz'",
        "    1. 'foo'",
    ]
    actual = list(map(
        operator.methodcaller('replace', "u'", "'"),
        format_errors(input_),
    ))

    assert set(actual) == set(expected)
示例#15
0
def test_mapping_with_iterables():
    input_ = {
        'foo': ['bar', 'baz'],
        'bar': ['baz', 'foo'],
    }
    expected = [
        "'foo':",
        "    0. 'bar'",
        "    1. 'baz'",
        "'bar':",
        "    0. 'baz'",
        "    1. 'foo'",
    ]
    actual = list(
        map(
            operator.methodcaller('replace', "u'", "'"),
            format_errors(input_),
        ))

    assert set(actual) == set(expected)
示例#16
0
def test_mapping_with_mappings():
    input_ = {
        'foo': {
            'bar': 'error-a',
            'baz': 'error-b',
        },
        'bar': {
            'baz': 'error-c',
            'foo': 'error-d',
        }
    }
    expected = [
        "'foo':",
        "    - 'bar': 'error-a'",
        "    - 'baz': 'error-b'",
        "'bar':",
        "    - 'baz': 'error-c'",
        "    - 'foo': 'error-d'",
    ]
    actual = list(format_errors(input_))

    assert set(actual) == set(expected)
示例#17
0
def test_iterable_of_mappings():
    input_ = [
        {
            'foo': 'bar'
        },
        {
            'bar': ['baz', 'foo']
        },
    ]
    expected = [
        "0. 'foo': 'bar'",
        "1. 'bar':",
        "    0. 'baz'",
        "    1. 'foo'",
    ]
    actual = list(
        map(
            operator.methodcaller('replace', "u'", "'"),
            format_errors(input_),
        ))

    assert set(actual) == set(expected)
示例#18
0
def test_string():
    messages = list(format_errors("error"))

    assert messages == ["'error'"]