def test_be(collection, flag):
    (optional, multiple) = SubrecordCollection.parse_flag(flag)
    subc = collection.be(flag)
    assert isinstance(subc, SubrecordCollection)
    assert subc.name == collection.name
    assert subc.items == collection.items
    assert subc.optional == optional
    assert subc.multiple == multiple
def test_from_definition(definition):
    subc = SubrecordCollection.from_definition(*definition)
    assert isinstance(subc, SubrecordCollection)
    assert definition[0].startswith(subc.name)
    assert [item.to_definition() for item in subc.items] == definition[-1]
    if definition[0][-1] in ("*", "+", "?"):
        (optional, multiple) = SubrecordCollection.parse_flag(definition[0][-1])
        assert subc.optional == optional
        assert subc.multiple == multiple
    else:
        assert not subc.optional
        assert not subc.multiple