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

add step fail hook #3384

Merged
merged 2 commits into from
Dec 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import json
import os
import pytest
import logging

from tests.common.configs import all_configs
from tests.common.types import SpaceDesc
Expand Down Expand Up @@ -64,6 +65,16 @@ def pytest_addoption(parser):
help="Nebula Graph workspace")


def pytest_bdd_step_error(request, feature, scenario, step, step_func, step_func_args):
Copy link
Contributor

@darionyaphet darionyaphet Dec 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pytest_bdd_step_error not by called? Or how to register the hook?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it registered by pytest automatically.

  1. pytest scan conftest
  2. match the same definition with hook in pytest-bdd.

https://github.com/pytest-dev/pytest-bdd/blob/master/pytest_bdd/plugin.py

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

logging.info("=== more error information ===")
logging.info("feature is {}".format(feature.filename))
logging.info("step line number is {}".format(step.line_number))
logging.info("step name is {}".format(step.name))
if step_func_args.get("graph_spaces") is not None:
graph_spaces = step_func_args.get("graph_spaces")
if graph_spaces.get("space_desc") is not None:
logging.info("error space is {}".format(graph_spaces.get("space_desc")))


def pytest_configure(config):
pytest.cmdline.address = config.getoption("address")
Expand Down