Beispiel #1
0
def test_bag_find():
    name, *aliases = ['Name', 'UPPER ALIAS', 'lower alias']
    bag = Bag({Item(name, *aliases)})

    assert bag.find('name')
    assert bag.find('Name')
    assert bag.find('NAME')
    assert bag.find('upper alias')
    assert bag.find('LOWER ALIAS')
    assert not bag.find('other')
def test_bag_find():
    """We can find items in a bag by name, case insensitively."""
    name, *aliases = ['Name', 'UPPER ALIAS', 'lower alias']
    bag = Bag({Item(name, *aliases)})

    assert bag.find('name')
    assert bag.find('Name')
    assert bag.find('NAME')
    assert bag.find('upper alias')
    assert bag.find('LOWER ALIAS')
    assert not bag.find('other')
def test_bag_find():
    """We can find items in a bag by name, case insensitively."""
    name, *aliases = ['Name', 'UPPER ALIAS', 'lower alias']
    named_item = Item(name, *aliases)
    appellative_item = Item('appellation', *aliases)
    nameless_item = Item('noname', 'none at all')
    bag = Bag({named_item, appellative_item, nameless_item})

    assert bag.find('name') is named_item
    assert bag.find('Name') is named_item
    assert bag.find('NAME') is named_item
    assert bag.find('appellation') is appellative_item
    assert bag.find('upper alias') in {named_item, appellative_item}
    assert bag.find('LOWER ALIAS') in {named_item, appellative_item}
    assert not bag.find('other')