You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

conftest.py 630 B

1234567891011121314151617
  1. import pytest
  2. def pytest_addoption(parser):
  3. parser.addoption(
  4. "--grpc", action="store_true", default=False, help="run grpc tests"
  5. )
  6. def pytest_collection_modifyitems(config, items):
  7. grpc_option_passed = config.getoption("--grpc")
  8. skip_grpc = pytest.mark.skip(reason="Need --grpc option to run")
  9. skip_non_grpc = pytest.mark.skip(reason="Skipped since --grpc passed")
  10. for item in items:
  11. if "grpc" in item.keywords and not grpc_option_passed:
  12. item.add_marker(skip_grpc)
  13. elif "grpc" not in item.keywords and grpc_option_passed:
  14. item.add_marker(skip_non_grpc)