示例#1
0
def test_deep_nesting():
    roots = [pkg_resources.resource_filename(__name__, './resources')]
    test_proto = pkg_resources.resource_filename(
        __name__,
        './resources/deeply_nested_def.proto',
    )
    parser = DefParser(roots)
    parser.parse(test_proto)

    # 10 messages + 7 enums
    defcount = 10 + 7
    actual_defcount = 0
    for k, v in parser.definitions():
        print('def: {} => {}'.format(k, v))
        actual_defcount += 1

    assert defcount == actual_defcount
示例#2
0
def test_iterate_defs():
    roots = [
        pkg_resources.resource_filename(__name__, './resources'),
        pkg_resources.resource_filename(__name__, '.')
    ]
    test_proto = pkg_resources.resource_filename(
        __name__,
        './resources/test_imported_oneof.proto',
    )
    parser = DefParser(roots)
    parser.parse(test_proto)

    passed = False
    for k, v in parser.definitions():
        if k == b'resources.Test.EmbeddedMessage':
            passed = True

    assert passed