Exemplo n.º 1
0
def test_rename_strict():

    table = (('foo', 'bar'),
             ('M', 12),
             ('F', 34),
             ('-', 56))

    result = rename(table, 'baz', 'quux')
    try:
        fieldnames(result)
    except FieldSelectionError:
        pass
    else:
        assert False, 'exception expected'

    result = rename(table, 2, 'quux')
    try:
        fieldnames(result)
    except FieldSelectionError:
        pass
    else:
        assert False, 'exception expected'

    result = rename(table, 'baz', 'quux', strict=False)
    assert fieldnames(result) == ('foo', 'bar')
    result = rename(table, 2, 'quux', strict=False)
    assert fieldnames(result) == ('foo', 'bar')
Exemplo n.º 2
0
def test_rename():

    table = (("foo", "bar"), ("M", 12), ("F", 34), ("-", 56))

    result = rename(table, "foo", "foofoo")
    assert fieldnames(result) == ["foofoo", "bar"]

    result = rename(table, 0, "foofoo")
    assert fieldnames(result) == ["foofoo", "bar"]

    result = rename(table, {"foo": "foofoo", "bar": "barbar"})
    assert fieldnames(result) == ["foofoo", "barbar"]

    result = rename(table)
    result["foo"] = "spong"
    assert fieldnames(result) == ["spong", "bar"]
Exemplo n.º 3
0
def test_rename():

    table = (('foo', 'bar'), ('M', 12), ('F', 34), ('-', 56))

    result = rename(table, 'foo', 'foofoo')
    assert fieldnames(result) == ('foofoo', 'bar')

    result = rename(table, 0, 'foofoo')
    assert fieldnames(result) == ('foofoo', 'bar')

    result = rename(table, {'foo': 'foofoo', 'bar': 'barbar'})
    assert fieldnames(result) == ('foofoo', 'barbar')

    result = rename(table)
    result['foo'] = 'spong'
    assert fieldnames(result) == ('spong', 'bar')
Exemplo n.º 4
0
def test_rename():

    table = (('foo', 'bar'),
             ('M', 12),
             ('F', 34),
             ('-', 56))

    result = rename(table, 'foo', 'foofoo')
    assert fieldnames(result) == ('foofoo', 'bar')

    result = rename(table, 0, 'foofoo')
    assert fieldnames(result) == ('foofoo', 'bar')

    result = rename(table, {'foo': 'foofoo', 'bar': 'barbar'})
    assert fieldnames(result) == ('foofoo', 'barbar')

    result = rename(table)
    result['foo'] = 'spong'
    assert fieldnames(result) == ('spong', 'bar')
Exemplo n.º 5
0
def test_rename_strict():

    table = (('foo', 'bar'), ('M', 12), ('F', 34), ('-', 56))

    result = rename(table, 'baz', 'quux')
    try:
        fieldnames(result)
    except FieldSelectionError:
        pass
    else:
        assert False, 'exception expected'

    result = rename(table, 2, 'quux')
    try:
        fieldnames(result)
    except FieldSelectionError:
        pass
    else:
        assert False, 'exception expected'

    result = rename(table, 'baz', 'quux', strict=False)
    assert fieldnames(result) == ('foo', 'bar')
    result = rename(table, 2, 'quux', strict=False)
    assert fieldnames(result) == ('foo', 'bar')
Exemplo n.º 6
0
def test_rename_empty():
    table = (('foo', 'bar'),)
    expect = (('foofoo', 'bar'),)
    actual = rename(table, 'foo', 'foofoo')
    ieq(expect, actual)
Exemplo n.º 7
0
def test_rename_empty():
    table = (('foo', 'bar'), )
    expect = (('foofoo', 'bar'), )
    actual = rename(table, 'foo', 'foofoo')
    ieq(expect, actual)
Exemplo n.º 8
0
def test_rename_empty():
    table = (("foo", "bar"),)
    expect = (("foofoo", "bar"),)
    actual = rename(table, "foo", "foofoo")
    ieq(expect, actual)