Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions allure-pytest/src/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,19 @@ def select_by_labels(items, config):


def select_by_testcase(items):
plan = []
planned_tests = []
file_path = os.environ.get("AS_TESTPLAN_PATH")

if file_path:
with open(file_path, 'r') as plan_file:
plan = json.load(plan_file)
planned_tests = plan.get("tests", [])

return filter(lambda item: any(
[str(planed_item.get("id")) in [str(allure_id) for allure_id in allure_label(item, LabelType.ID)]
or
(planed_item.get("selector") == allure_full_name(item))
for planed_item in plan]), items) if plan else items
for planed_item in planned_tests]), items) if planned_tests else items


def pytest_collection_modifyitems(items, config):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


@pytest.mark.parametrize(
["plan_json", "expected_tests"],
["planned_tests", "expected_tests"],
[
# by ids only
(
Expand Down Expand Up @@ -56,7 +56,7 @@
),
]
)
def test_select_by_testcase_id_test(plan_json, expected_tests, allured_testdir, request):
def test_select_by_testcase_id_test(planned_tests, expected_tests, allured_testdir, request):
"""
>>> import allure

Expand All @@ -82,11 +82,13 @@ def test_select_by_testcase_id_test(plan_json, expected_tests, allured_testdir,
full_name_base_template = "{base}.test_select_by_testcase_id_test".format(
base=test_dir.strip(os.sep).replace(os.sep, "."))

if plan_json:
for item in plan_json:
if planned_tests:
for item in planned_tests:
if "selector" in item:
item["selector"] = "{base}#{name}".format(base=full_name_base_template, name=item["selector"])
py_path = allured_testdir.testdir.makefile(".json", json.dumps(plan_json))

testplan = {"tests": planned_tests}
py_path = allured_testdir.testdir.makefile(".json", json.dumps(testplan))
os.environ["AS_TESTPLAN_PATH"] = py_path.strpath
else:
os.environ.pop("AS_TESTPLAN_PATH", None)
Expand Down