Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: fixture 'grpc_channel' not found #16

Open
mipnw opened this issue Oct 30, 2020 · 1 comment
Open

Error: fixture 'grpc_channel' not found #16

mipnw opened this issue Oct 30, 2020 · 1 comment

Comments

@mipnw
Copy link

mipnw commented Oct 30, 2020

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.

@BJK
Copy link

BJK commented Nov 19, 2020

Did you install the plugin? It's strangely not mentioned in the readme.

pip install pytest-grpc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants