Skip to content

Error: fixture 'grpc_channel' not found #16

@mipnw

Description

@mipnw

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions