MashaTelyatnikova / protobuf-socket-rpc

Automatically exported from code.google.com/p/protobuf-socket-rpc
MIT License
0 stars 0 forks source link

Python unit tests fail with protobuf 2.4.0's C++ backend #19

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
2. python setup.py develop
3. python setup.py test

What is the expected output? What do you see instead?

I expect the same output as with the python backend but get:

{{running test
running egg_info
writing src/protobuf.socketrpc.egg-info/PKG-INFO
writing top-level names to src/protobuf.socketrpc.egg-info/top_level.txt
writing dependency_links to src/protobuf.socketrpc.egg-info/dependency_links.txt
reading manifest file 'src/protobuf.socketrpc.egg-info/SOURCES.txt'
writing manifest file 'src/protobuf.socketrpc.egg-info/SOURCES.txt'
running build_ext
libprotobuf ERROR google/protobuf/descriptor.cc:2237] Invalid proto descriptor 
for file "test.proto":
libprotobuf ERROR google/protobuf/descriptor.cc:2240]   
protobuf.socketrpc.Request: "protobuf.socketrpc.Request" is already defined in 
file "rpc.proto".
libprotobuf ERROR google/protobuf/descriptor.cc:2240]   
protobuf.socketrpc.Response: "protobuf.socketrpc.Response" is already defined 
in file "rpc.proto".
libprotobuf ERROR google/protobuf/descriptor.cc:2240]   
protobuf.socketrpc.TestService.TestMethod: "protobuf.socketrpc.Request" seems 
to be defined in "rpc.proto", which is not imported by "test.proto".  To use it 
here, please add the necessary import.
libprotobuf ERROR google/protobuf/descriptor.cc:2240]   
protobuf.socketrpc.TestService.TestMethod: "protobuf.socketrpc.Response" seems 
to be defined in "rpc.proto", which is not imported by "test.proto".  To use it 
here, please add the necessary import.
Traceback (most recent call last):
  File "setup.py", line 53, in <module>
    test_suite='protobuf.socketrpc.tests',
  File "/usr/lib/python2.6/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/usr/lib/python2.6/distutils/dist.py", line 975, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.6/distutils/dist.py", line 995, in run_command
    cmd_obj.run()
  File "/usr/lib/python2.6/dist-packages/setuptools/command/test.py", line 137, in run
    self.with_project_on_sys_path(self.run_tests)
  File "/usr/lib/python2.6/dist-packages/setuptools/command/test.py", line 117, in with_project_on_sys_path
    func()
  File "/usr/lib/python2.6/dist-packages/setuptools/command/test.py", line 146, in run_tests
    testLoader = loader_class()
  File "/usr/lib/python2.6/unittest.py", line 816, in __init__
    self.parseArgs(argv)
  File "/usr/lib/python2.6/unittest.py", line 843, in parseArgs
    self.createTests()
  File "/usr/lib/python2.6/unittest.py", line 849, in createTests
    self.module)
  File "/usr/lib/python2.6/unittest.py", line 613, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python2.6/unittest.py", line 587, in loadTestsFromName
    return self.loadTestsFromModule(obj)
  File "/usr/lib/python2.6/dist-packages/setuptools/command/test.py", line 34, in loadTestsFromModule
    tests.append(self.loadTestsFromName(submodule))
  File "/usr/lib/python2.6/unittest.py", line 576, in loadTestsFromName
    module = __import__('.'.join(parts_copy))
  File "/home/jan/src/debian-stuff/build-area/python-protobuf.socketrpc-1.3.2/src/protobuf/socketrpc/tests/service_test.py", line 45, in <module>
    import fake
  File "/home/jan/src/debian-stuff/build-area/python-protobuf.socketrpc-1.3.2/src/protobuf/socketrpc/tests/fake.py", line 39, in <module>
    import test_pb2
  File "/home/jan/src/debian-stuff/build-area/python-protobuf.socketrpc-1.3.2/src/protobuf/socketrpc/tests/test_pb2.py", line 15, in <module>
    serialized_pb='\n\ntest.proto\x12\x12protobuf.socketrpc\"\x1b\n\x07Request\x12\x10\n\x08str_data\x18\x01 \x02(\t\".\n\x08Response\x12\x10\n\x08str_data\x18\x01 \x02(\t\x12\x10\n\x08int_data\x18\x02 \x01(\x05\x32V\n\x0bTestService\x12G\n\nTestMethod\x12\x1b.protobuf.socketrpc.Request\x1a\x1c.protobuf.socketrpc.Response')
  File "/usr/lib/pymodules/python2.6/google/protobuf/descriptor.py", line 580, in __init__
    cpp_message.BuildFile(self.serialized_pb)
  File "/usr/lib/pymodules/python2.6/google/protobuf/internal/cpp_message.py", line 63, in BuildFile
    _net_proto2___python.BuildFile(content)
TypeError: Couldn't build proto file into descriptor pool!}}

The problem seems to be that test.proto defines types that are already defined 
in rpc.proto and the C++ backend handles this differently.

As the C++ backend will be promoted to default according to 
http://code.google.com/intl/de-DE/apis/protocolbuffers/docs/reference/python-gen
erated.html#cpp_impl this should be fixed.

Maybe it should be evaluated whether the socket-rpc implementation should be 
switched to a protoc plugin as suggested at 
http://code.google.com/intl/de-DE/apis/protocolbuffers/docs/reference/python-gen
erated.html#service

Original issue reported on code.google.com by jan.ditt...@gmail.com on 22 Feb 2011 at 9:03