-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
I tried to demo this pytest framework by writing a unit test for the RouteGuide service that is part of the python grpc examples.
test_routeguide.py
import pytest
@pytest.fixture(scope='module')
def grpc_add_to_server():
from route_guide_pb2_grpc import add_RouteGuideServicer_to_server
return add_RouteGuideServicer_to_server
@pytest.fixture(scope='module')
def grpc_servicer():
from route_guide_server import RouteGuideServicer
return RouteGuideServicer()
@pytest.fixture(scope='module')
def grpc_stub(grpc_channel):
from route_guide_pb2_grpc import RouteGuideStub
return RouteGuideStub(grpc_channel)
# inspired from guide_list_features() in route_guide_client.py
def test_ListFeatures(grpc_stub):
from route_guide_pb2 import Rectangle, Point
rectangle = Rectangle(
lo=Point(latitude=400000000, longitude=-750000000),
hi=Point(latitude=420000000, longitude=-730000000))
features = grpc_stub.ListFeatures(rectangle)
for feature in features:
print("Feature called %s at %s" % (feature.name, feature.location))
and I get Error: fixture 'grpc_channel' not found when I run pytest.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels