From 65415c420faedcc87276333ee1382002e2e11624 Mon Sep 17 00:00:00 2001 From: Maksim Stepanov <17935127+delatrie@users.noreply.github.com> Date: Mon, 28 Nov 2022 15:19:55 +0700 Subject: [PATCH 1/2] Remove old python2-related code --- .github/workflows/build.yaml | 14 +- .github/workflows/release.yaml | 7 +- allure-behave/features/steps/behave_steps.py | 15 +- allure-behave/features/steps/dummy_steps.py | 38 +++-- allure-behave/features/steps/report_steps.py | 66 ++++----- allure-behave/setup.py | 3 +- allure-behave/src/hooks.py | 2 +- allure-behave/src/listener.py | 10 +- allure-behave/src/utils.py | 10 +- allure-nose2/setup.py | 3 +- allure-nose2/src/listener.py | 2 +- allure-nose2/src/plugin.py | 2 +- allure-nose2/src/utils.py | 4 +- allure-pytest-bdd/setup.py | 10 +- allure-pytest-bdd/src/pytest_bdd_listener.py | 2 +- allure-pytest-bdd/src/utils.py | 14 +- allure-pytest-bdd/test/conftest.py | 4 +- allure-pytest-bdd/test/steps.py | 10 -- allure-pytest/setup.py | 10 +- allure-pytest/src/helper.py | 11 +- allure-pytest/src/listener.py | 21 ++- allure-pytest/src/plugin.py | 18 ++- allure-pytest/src/utils.py | 27 ++-- .../attachment/attachment_class_test.py | 2 +- .../attachment_parametrized_test.py | 2 +- .../acceptance/capture/capture_attach_test.py | 4 +- .../description/description_test.py | 1 - .../display_name/display_name_test.py | 9 +- .../acceptance/duration/duration_time_test.py | 12 +- .../fixture/fixture_finalized_test.py | 12 +- .../test/acceptance/fixture/fixture_test.py | 12 +- .../fixture/parametrized_fixture_test.py | 5 +- .../acceptance/fixture/yield_fixture_test.py | 6 +- .../label/bdd/dynamic_bdd_label_test.py | 4 +- .../acceptance/label/bdd/select_bdd_test.py | 2 +- .../label/suite/default_suite_test.py | 2 +- .../test/acceptance/label/tag/tag_test.py | 8 +- .../test/acceptance/link/dynamic_link_test.py | 4 +- .../parametrization/metafunc_test.py | 5 +- .../parametrization/parametrization_test.py | 12 +- .../status/base_teardown_status_test.py | 12 +- .../status/skip_teardown_status_test.py | 4 +- .../status/xfail_teardown_status_test.py | 4 +- .../test/acceptance/step/step_parameters.py | 3 +- .../unicode_identifier_test.py | 7 - allure-pytest/test/conftest.py | 24 +-- .../select_test_from_testplan_test.py | 7 +- .../pytest_rerunfailures_test.py | 4 +- allure-python-commons-test/setup.py | 3 +- allure-python-commons-test/src/container.py | 7 +- allure-python-commons-test/src/report.py | 10 +- allure-python-commons/setup.py | 9 +- allure-python-commons/src/_allure.py | 8 +- allure-python-commons/src/_compat.py | 80 ---------- allure-python-commons/src/_core.py | 3 +- allure-python-commons/src/_hooks.py | 4 +- allure-python-commons/src/lifecycle.py | 2 +- allure-python-commons/src/logger.py | 14 +- allure-python-commons/src/mapping.py | 2 +- allure-python-commons/src/model2.py | 16 +- allure-python-commons/src/reporter.py | 2 +- allure-python-commons/src/types.py | 2 +- allure-python-commons/src/utils.py | 137 ++++-------------- .../examples/attach/foreign_library.py | 2 +- .../examples/attach/foreign_library_helper.py | 2 +- allure-robotframework/setup.py | 7 +- .../src/listener/allure_listener.py | 8 +- .../src/listener/robot_listener.py | 4 +- allure-robotframework/src/listener/types.py | 6 +- allure-robotframework/src/listener/utils.py | 54 ++++--- .../test/run_robot_library.py | 8 +- 71 files changed, 334 insertions(+), 526 deletions(-) delete mode 100644 allure-python-commons/src/_compat.py diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b63653f9..93ae5b14 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -16,23 +16,23 @@ jobs: id: filter with: filters: | - allure-behave: + allure-behave: - allure-behave/** - allure-python-commons/** - allure-python-commons-test/** - allure-nose2: + allure-nose2: - allure-nose2/** - allure-python-commons/** - allure-python-commons-test/** - allure-pytest: + allure-pytest: - allure-pytest/** - allure-python-commons/** - allure-python-commons-test/** - allure-pytest-bdd: + allure-pytest-bdd: - allure-pytest-bdd/** - allure-python-commons/** - allure-python-commons-test/** - allure-robotframework: + allure-robotframework: - allure-robotframework/** - allure-python-commons/** - allure-python-commons-test/** @@ -72,7 +72,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.11" - name: Get commons from cache id: commons @@ -98,7 +98,7 @@ jobs: strategy: matrix: package: ${{ fromJSON(needs.changes.outputs.packages) }} - python-version: [3.7, 3.8, 3.9, "3.10"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] env: TEST_TMP: /tmp ALLURE_INDENT_OUTPUT: yep diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 725525dd..919cedb5 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -9,9 +9,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - name: Set up Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: python-version: '3.x' @@ -19,7 +20,7 @@ jobs: run: | python -m pip install --upgrade pip pip install setuptools wheel twine - + - name: Build and publish env: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} diff --git a/allure-behave/features/steps/behave_steps.py b/allure-behave/features/steps/behave_steps.py index a7c0bb19..b90f54dc 100644 --- a/allure-behave/features/steps/behave_steps.py +++ b/allure-behave/features/steps/behave_steps.py @@ -11,8 +11,8 @@ from contextlib import contextmanager -@given(u'feature definition') -@given(u'feature definition {lang}') +@given('feature definition') +@given('feature definition {lang}') def feature_definition(context, **kwargs): parser = Parser(language=kwargs.get('lang', None)) feature = parser.parse(context.text) @@ -22,13 +22,13 @@ def feature_definition(context, **kwargs): context.feature_definition = [feature] -@given(u'hooks implementation') +@given('hooks implementation') def hooks_implementations(context): context.globals = {} exec(context.text, context.globals) -@given(u'test plan') +@given('test plan') def test_plan_helper(context): tmp_dir = os.environ.get("TEST_TMP") file, filename = tempfile.mkstemp(suffix=".json", dir=tmp_dir) @@ -38,12 +38,13 @@ def test_plan_helper(context): context.test_plan = filename -@when(u'I run behave with allure formatter') -@when(u'I run behave with allure formatter with options "{args}"') +@when('I run behave with allure formatter') +@when('I run behave with allure formatter with options "{args}"') def run_behave_with_allure(context, **kwargs): with test_context(): cmd_args = '-f allure_behave.formatter:AllureFormatter' - cmd = '{options} {cmd}'.format(cmd=cmd_args, options=kwargs.get('args', '')) + cmd_options = kwargs.get('args', '') + cmd = f'{cmd_options} {cmd_args}' config = Configuration(command_args=cmd) result_tmp_dir = mkdtemp(dir=os.environ.get('TEST_TMP', None)) stream_opener = StreamOpener(filename=result_tmp_dir) diff --git a/allure-behave/features/steps/dummy_steps.py b/allure-behave/features/steps/dummy_steps.py index 1c929e34..e63705ad 100644 --- a/allure-behave/features/steps/dummy_steps.py +++ b/allure-behave/features/steps/dummy_steps.py @@ -1,51 +1,49 @@ -# -*- coding: utf-8 -*- - import allure from behave import given -@given(u'passed step') -@given(u'{what} passed step') -@given(u'passed step {where}') -@given(u'{what} passed step {where}') +@given('passed step') +@given('{what} passed step') +@given('passed step {where}') +@given('{what} passed step {where}') def step_impl(*args, **kwargs): if 'with attachment' in kwargs.values(): allure.attach('Hi there!', name='user attachment', attachment_type=allure.attachment_type.TEXT) pass -@given(u'failed step') -@given(u'{what} failed step') -@given(u'failed step {where}') -@given(u'{what} failed step {where}') +@given('failed step') +@given('{what} failed step') +@given('failed step {where}') +@given('{what} failed step {where}') def step_impl(*args, **kwargs): assert False, 'Assert message' -@given(u'провальный шаг') +@given('провальный шаг') def step_impl(*args, **kwargs): - assert False, u'Фиаско!' + assert False, 'Фиаско!' -@given(u'провальный шаг с ascii') +@given('провальный шаг с ascii') def step_impl(*args, **kwargs): assert False, 'Фиаско!' -@given(u'проходящий шаг') +@given('проходящий шаг') def step_impl(*args, **kwargs): pass -@given(u'broken step') -@given(u'{what} broken step') -@given(u'broken step {where}') -@given(u'{what} broken step {where}') +@given('broken step') +@given('{what} broken step') +@given('broken step {where}') +@given('{what} broken step {where}') def step_impl(*args, **kwargs): raise ZeroDivisionError() -@given(u'всегда будет <это>') -@given(u'всегда буду я') +@given('всегда будет <это>') +@given('всегда буду я') def step_impl(*args, **kwargs): pass diff --git a/allure-behave/features/steps/report_steps.py b/allure-behave/features/steps/report_steps.py index 24f7fa51..ca41d950 100644 --- a/allure-behave/features/steps/report_steps.py +++ b/allure-behave/features/steps/report_steps.py @@ -27,22 +27,22 @@ def match(matcher, *args): return matcher() -@then(u'allure report has a scenario with name "{scenario}"') +@then('allure report has a scenario with name "{scenario}"') def step_scenario(context, scenario): matcher = partial(match, has_test_case, scenario) context.scenario = matcher assert_that(context.allure_report, matcher()) -@then(u'allure report has not a scenario with name "{scenario}"') +@then('allure report has not a scenario with name "{scenario}"') def step_scenario(context, scenario): matcher = partial(match, not_, has_test_case, scenario) context.scenario = matcher assert_that(context.allure_report, matcher()) -@then(u'scenario has before fixture "{fixture}"') -@then(u'this scenario has before fixture "{fixture}"') +@then('scenario has before fixture "{fixture}"') +@then('this scenario has before fixture "{fixture}"') def step_before_fixture(context, fixture): context_matcher = context.scenario matcher = partial(context_matcher, has_container, context.allure_report, has_before, fixture) @@ -50,8 +50,8 @@ def step_before_fixture(context, fixture): assert_that(context.allure_report, matcher()) -@then(u'scenario has after fixture "{fixture}"') -@then(u'this scenario has after fixture "{fixture}"') +@then('scenario has after fixture "{fixture}"') +@then('this scenario has after fixture "{fixture}"') def step_after_fixture(context, fixture): context_matcher = context.scenario matcher = partial(context_matcher, has_container, context.allure_report, has_after, fixture) @@ -59,24 +59,24 @@ def step_after_fixture(context, fixture): assert_that(context.allure_report, matcher()) -@then(u'scenario has not before fixture "{fixture}"') -@then(u'this scenario has not before fixture "{fixture}"') +@then('scenario has not before fixture "{fixture}"') +@then('this scenario has not before fixture "{fixture}"') def step_no_before_fixture(context, fixture): context_matcher = context.scenario matcher = partial(context_matcher, not_, has_container, context.allure_report, has_before, fixture) assert_that(context.allure_report, matcher()) -@then(u'scenario has not after fixture "{fixture}"') -@then(u'this scenario has not after fixture "{fixture}"') +@then('scenario has not after fixture "{fixture}"') +@then('this scenario has not after fixture "{fixture}"') def step_impl(context, fixture): context_matcher = context.scenario matcher = partial(context_matcher, not_, has_container, context.allure_report, has_after, fixture) assert_that(context.allure_report, matcher()) -@then(u'{item} contains step "{step}"') -@then(u'this {item} contains step "{step}"') +@then('{item} contains step "{step}"') +@then('this {item} contains step "{step}"') def step_step(context, item, step): context_matcher = getattr(context, item) matcher = partial(context_matcher, has_step, step) @@ -84,75 +84,75 @@ def step_step(context, item, step): assert_that(context.allure_report, matcher()) -@then(u'{item} has "{status}" status') -@then(u'this {item} has "{status}" status') +@then('{item} has "{status}" status') +@then('this {item} has "{status}" status') def step_status(context, item, status): context_matcher = getattr(context, item) matcher = partial(context_matcher, with_status, status) assert_that(context.allure_report, matcher()) -@then(u'{item} has status details with message "{message}"') -@then(u'this {item} has status details with message "{message}"') +@then('{item} has status details with message "{message}"') +@then('this {item} has status details with message "{message}"') def step_status(context, item, message): context_matcher = getattr(context, item) matcher = partial(context_matcher, has_status_details, with_message_contains, message) assert_that(context.allure_report, matcher()) -@then(u'scenario has "{severity}" severity') -@then(u'this scenario has "{severity}" severity') +@then('scenario has "{severity}" severity') +@then('this scenario has "{severity}" severity') def step_severity(context, severity): context_matcher = context.scenario matcher = partial(context_matcher, has_severity, severity) assert_that(context.allure_report, matcher()) -@then(u'scenario has "{tag}" tag') -@then(u'this scenario has "{tag}" tag') +@then('scenario has "{tag}" tag') +@then('this scenario has "{tag}" tag') def step_tag(context, tag): context_matcher = context.scenario matcher = partial(context_matcher, has_tag, tag) assert_that(context.allure_report, matcher()) -@then(u'scenario has "{url}" link') -@then(u'this scenario has "{url}" link') -@then(u'scenario has "{url}" link with type "{link_type}"') -@then(u'this scenario has "{url}" link with type "{link_type}"') -@then(u'scenario has "{url}" link with type "{link_type}" and name "{name}"') -@then(u'this scenario has "{url}" link with type "{link_type}" and name "{name}"') +@then('scenario has "{url}" link') +@then('this scenario has "{url}" link') +@then('scenario has "{url}" link with type "{link_type}"') +@then('this scenario has "{url}" link with type "{link_type}"') +@then('scenario has "{url}" link with type "{link_type}" and name "{name}"') +@then('this scenario has "{url}" link with type "{link_type}" and name "{name}"') def step_link(context, url, link_type=None, name=None,): context_matcher = context.scenario matcher = partial(context_matcher, has_link, url, link_type, name) assert_that(context.allure_report, matcher()) -@then(u'scenario has "{name}" label with value "{value}"') -@then(u'this scenario has "{name}" label with value "{value}"') +@then('scenario has "{name}" label with value "{value}"') +@then('this scenario has "{name}" label with value "{value}"') def step_label(context, name, value): context_matcher = context.scenario matcher = partial(context_matcher, has_label, name, value) assert_that(context.allure_report, matcher()) -@then(u'{item} has parameter "{name}" with value "{value}"') -@then(u'this {item} has parameter "{name}" with value "{value}"') +@then('{item} has parameter "{name}" with value "{value}"') +@then('this {item} has parameter "{name}" with value "{value}"') def step_parameter(context, item, name, value): context_matcher = getattr(context, item) matcher = partial(context_matcher, has_parameter, name, value) assert_that(context.allure_report, matcher()) -@then(u'{item} has attachment') -@then(u'this {item} has attachment') +@then('{item} has attachment') +@then('this {item} has attachment') def step_attachment(context, item): context_matcher = getattr(context, item) matcher = partial(context_matcher, has_attachment) assert_that(context.allure_report, matcher()) -@then(u'scenario has description "{description}"') +@then('scenario has description "{description}"') def step_description(context, description): context_matcher = context.scenario matcher = partial(context_matcher, has_description, contains_string(description)) diff --git a/allure-behave/setup.py b/allure-behave/setup.py index bd565fea..78e6fbe9 100644 --- a/allure-behave/setup.py +++ b/allure-behave/setup.py @@ -16,6 +16,7 @@ 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', ] setup_requires = [ @@ -31,7 +32,7 @@ def prepare_version(): from setuptools_scm import get_version configuration = {"root": "..", "relative_to": __file__} version = get_version(**configuration) - install_requires.append("allure-python-commons=={version}".format(version=version)) + install_requires.append(f"allure-python-commons=={version}") return configuration diff --git a/allure-behave/src/hooks.py b/allure-behave/src/hooks.py index 0e609e9b..86427523 100644 --- a/allure-behave/src/hooks.py +++ b/allure-behave/src/hooks.py @@ -39,7 +39,7 @@ def allure_report(result_dir="allure_results"): del frame -class AllureHooks(object): +class AllureHooks: def __init__(self, result_dir): self.listener = AllureListener(Configuration()) diff --git a/allure-behave/src/listener.py b/allure-behave/src/listener.py index 619076a0..fbcac3cd 100644 --- a/allure-behave/src/listener.py +++ b/allure-behave/src/listener.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from collections import deque import allure_commons from allure_commons.reporter import AllureReporter @@ -26,7 +24,7 @@ from allure_behave.utils import get_hook_name -class AllureListener(object): +class AllureListener: def __init__(self, behave_config): self.behave_config = behave_config self.issue_pattern = behave_config.userdata.get('AllureFormatter.issue_pattern', None) @@ -132,7 +130,7 @@ def match_step(self, match): def start_behave_step(self, step): self.current_step_uuid = uuid4() - name = u'{keyword} {title}'.format(keyword=step.keyword, title=step.name) + name = f'{step.keyword} {step.name}' allure_step = TestStepResult(name=name, start=now()) self.logger.start_step(None, self.current_step_uuid, allure_step) @@ -191,7 +189,7 @@ def add_description_html(self, test_description_html): def add_link(self, url, link_type, name): test_result = self.logger.get_test(None) if test_result: - pattern = u'{}' + pattern = '{}' if link_type == LinkType.ISSUE and self.issue_pattern: pattern = self.issue_pattern elif link_type == LinkType.LINK and self.link_pattern: @@ -209,7 +207,7 @@ def stop_session(self): self.group_context.exit() -class GroupContext(object): +class GroupContext: def __init__(self, logger): self._logger = logger self._groups = [] diff --git a/allure-behave/src/utils.py b/allure-behave/src/utils.py index 8b129a87..ab768ed2 100644 --- a/allure-behave/src/utils.py +++ b/allure-behave/src/utils.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - from enum import Enum from behave.runner_util import make_undefined_step_snippet from allure_commons.types import Severity, LabelType @@ -30,7 +27,7 @@ def scenario_history_id(scenario): parts = [scenario.feature.name, scenario.name] if scenario._row: row = scenario._row - parts.extend(['{name}={value}'.format(name=name, value=value) for name, value in zip(row.headings, row.cells)]) + parts.extend([f'{name}={value}' for name, value in zip(row.headings, row.cells)]) return md5(*parts) @@ -95,7 +92,7 @@ def get_status(exception): def get_fullname(scenario): name_with_param = scenario_name(scenario) name = name_with_param.rsplit(" -- ")[0] - return "{filename}: {name}".format(filename=scenario.feature.name, name=name) + return f"{scenario.feature.name}: {name}" def get_hook_name(name, parameters): @@ -128,7 +125,8 @@ def step_status_details(result): def step_table(step): table = [','.join(step.table.headings)] - [table.append(','.join(list(row))) for row in step.table.rows] + for row in step.table.rows: + table.append(','.join(list(row))) return '\n'.join(table) diff --git a/allure-nose2/setup.py b/allure-nose2/setup.py index 788dc106..f0741b26 100644 --- a/allure-nose2/setup.py +++ b/allure-nose2/setup.py @@ -15,6 +15,7 @@ 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', ] setup_requires = [ @@ -30,7 +31,7 @@ def prepare_version(): from setuptools_scm import get_version configuration = {"root": "..", "relative_to": __file__} version = get_version(**configuration) - install_requires.append("allure-python-commons=={version}".format(version=version)) + install_requires.append(f"allure-python-commons=={version}") return configuration diff --git a/allure-nose2/src/listener.py b/allure-nose2/src/listener.py index 600605d2..85b4b31a 100644 --- a/allure-nose2/src/listener.py +++ b/allure-nose2/src/listener.py @@ -1,5 +1,5 @@ # ToDo attaches -class AllureListener(object): +class AllureListener: def __init__(self, lifecycle): self.lifecycle = lifecycle diff --git a/allure-nose2/src/plugin.py b/allure-nose2/src/plugin.py index 235d0471..0e5f936f 100644 --- a/allure-nose2/src/plugin.py +++ b/allure-nose2/src/plugin.py @@ -17,7 +17,7 @@ import allure_commons -class DecoratorsHelper(object): +class DecoratorsHelper: @classmethod @allure_commons.hookimpl def decorate_as_label(cls, label_type, labels): diff --git a/allure-nose2/src/utils.py b/allure-nose2/src/utils.py index 9bdcb1a3..97dbd960 100644 --- a/allure-nose2/src/utils.py +++ b/allure-nose2/src/utils.py @@ -68,7 +68,7 @@ def name(event): allure_name = full_name.split(".")[-1] if test_params: params_str = "-".join([p.value for p in test_params]) - return "{name}[{params_str}]".format(name=allure_name, params_str=params_str) + return f"{allure_name}[{params_str}]" return allure_name @@ -76,7 +76,7 @@ def fullname(event): if hasattr(event.test, "_testFunc"): test_module = event.test._testFunc.__module__ test_name = event.test._testFunc.__name__ - return "{module}.{name}".format(module=test_module, name=test_name) + return f"{test_module}.{test_name}" test_id = event.test.id() return test_id.split(":")[0] diff --git a/allure-pytest-bdd/setup.py b/allure-pytest-bdd/setup.py index e5ebe859..bf166279 100644 --- a/allure-pytest-bdd/setup.py +++ b/allure-pytest-bdd/setup.py @@ -12,6 +12,11 @@ 'Topic :: Software Development :: Testing', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', ] setup_requires = [ @@ -20,8 +25,7 @@ install_requires = [ "pytest>=4.5.0", - "pytest-bdd>=3.0.0", - "six>=1.9.0", + "pytest-bdd>=3.0.0" ] @@ -29,7 +33,7 @@ def prepare_version(): from setuptools_scm import get_version configuration = {"root": "..", "relative_to": __file__} version = get_version(**configuration) - install_requires.append("allure-python-commons=={version}".format(version=version)) + install_requires.append(f"allure-python-commons=={version}") return configuration diff --git a/allure-pytest-bdd/src/pytest_bdd_listener.py b/allure-pytest-bdd/src/pytest_bdd_listener.py index 7ec47492..8c02ef08 100644 --- a/allure-pytest-bdd/src/pytest_bdd_listener.py +++ b/allure-pytest-bdd/src/pytest_bdd_listener.py @@ -19,7 +19,7 @@ from .utils import get_full_name, get_name, get_params -class PytestBDDListener(object): +class PytestBDDListener: def __init__(self): self.lifecycle = AllureLifecycle() self.host = host_tag() diff --git a/allure-pytest-bdd/src/utils.py b/allure-pytest-bdd/src/utils.py index c17c1b88..e21f234a 100644 --- a/allure-pytest-bdd/src/utils.py +++ b/allure-pytest-bdd/src/utils.py @@ -8,24 +8,26 @@ def get_step_name(node, step): - name = "{step_keyword} {step_name}".format(step_keyword=step.keyword, step_name=step.name) + name = f"{step.keyword} {step.name}" if hasattr(node, 'callspec'): - for key, value in node.callspec.params.items(): - name = name.replace("<{key}>".format(key=key), "<{{{key}}}>".format(key=key)) - name = name.format(**node.callspec.params) + params = node.callspec.params + for key in params: + name = name.replace(f"<{key}>", f"<{{{key}}}>") + name = name.format(**params) return name def get_name(node, scenario): if hasattr(node, 'callspec'): parts = node.nodeid.rsplit("[") - return "{name} [{params}".format(name=scenario.name, params=parts[-1]) + params = parts[-1] + return f"{scenario.name} [{params}" return scenario.name def get_full_name(feature, scenario): feature_path = os.path.normpath(feature.rel_filename) - return "{feature}:{scenario}".format(feature=feature_path, scenario=scenario.name) + return f"{feature_path}:{scenario.name}" def get_uuid(*args): diff --git a/allure-pytest-bdd/test/conftest.py b/allure-pytest-bdd/test/conftest.py index dc84bb4b..6508c395 100644 --- a/allure-pytest-bdd/test/conftest.py +++ b/allure-pytest-bdd/test/conftest.py @@ -25,7 +25,7 @@ def fake_logger(path, logger): allure_commons.plugin_manager.register(plugin) -class AlluredTestdir(object): +class AlluredTestdir: def __init__(self, testdir, request): self.testdir = testdir self.request = request @@ -35,8 +35,6 @@ def run_with_allure(self): logger = AllureFileLogger(self.testdir.tmpdir.strpath) with fake_logger("allure_pytest_bdd.plugin.AllureFileLogger", logger): self.testdir.runpytest("-s", "-v", "--alluredir", self.testdir.tmpdir) - # print(a.stdout.lines) - # print(a.stderr.lines) self.allure_report = AllureReport(self.testdir.tmpdir.strpath) diff --git a/allure-pytest-bdd/test/steps.py b/allure-pytest-bdd/test/steps.py index db7f162c..eac3cc95 100644 --- a/allure-pytest-bdd/test/steps.py +++ b/allure-pytest-bdd/test/steps.py @@ -2,21 +2,11 @@ from pytest_bdd import parsers from functools import partial from hamcrest import assert_that -# from hamcrest import not_ from allure_commons_test.report import has_test_case from allure_commons_test.result import with_status from allure_commons_test.result import has_step -# from allure_commons_test.result import has_attachment from allure_commons_test.result import has_parameter from allure_commons_test.result import has_history_id -# from allure_commons_test.result import has_status_details -# from allure_commons_test.result import with_message_contains -# from allure_commons_test.result import has_link -# from allure_commons_test.container import has_container -# from allure_commons_test.container import has_before, has_after -# from allure_commons_test.label import has_severity -# from allure_commons_test.label import has_tag -# from allure_commons_test.label import has_label def match(matcher, *args): diff --git a/allure-pytest/setup.py b/allure-pytest/setup.py index b6ea5147..33ea2ade 100644 --- a/allure-pytest/setup.py +++ b/allure-pytest/setup.py @@ -24,6 +24,11 @@ 'Topic :: Software Development :: Testing', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', ] setup_requires = [ @@ -32,8 +37,7 @@ install_requires = [ - "pytest>=4.5.0", - "six>=1.9.0", + "pytest>=4.5.0" ] @@ -41,7 +45,7 @@ def prepare_version(): from setuptools_scm import get_version configuration = {"root": "..", "relative_to": __file__} version = get_version(**configuration) - install_requires.append("allure-python-commons=={version}".format(version=version)) + install_requires.append(f"allure-python-commons=={version}") return configuration diff --git a/allure-pytest/src/helper.py b/allure-pytest/src/helper.py index 5333ddee..e6944ef4 100644 --- a/allure-pytest/src/helper.py +++ b/allure-pytest/src/helper.py @@ -1,13 +1,11 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - import pytest import allure_commons from allure_pytest.utils import ALLURE_DESCRIPTION_MARK, ALLURE_DESCRIPTION_HTML_MARK from allure_pytest.utils import ALLURE_LABEL_MARK, ALLURE_LINK_MARK +from allure_pytest.utils import format_allure_link -class AllureTitleHelper(object): +class AllureTitleHelper: @allure_commons.hookimpl def decorate_as_title(self, test_title): def decorator(func): @@ -22,7 +20,7 @@ def decorator(func): return decorator -class AllureTestHelper(object): +class AllureTestHelper: def __init__(self, config): self.config = config @@ -43,8 +41,7 @@ def decorate_as_label(self, label_type, labels): @allure_commons.hookimpl def decorate_as_link(self, url, link_type, name): - pattern = dict(self.config.option.allure_link_pattern).get(link_type, u'{}') - url = pattern.format(url) + url = format_allure_link(self.config, url, link_type) allure_link = getattr(pytest.mark, ALLURE_LINK_MARK) name = url if name is None else name return allure_link(url, name=name, link_type=link_type) diff --git a/allure-pytest/src/listener.py b/allure-pytest/src/listener.py index 870dee18..74bc3324 100644 --- a/allure-pytest/src/listener.py +++ b/allure-pytest/src/listener.py @@ -1,7 +1,6 @@ import pytest import doctest import allure_commons -from allure_commons.utils import escape_non_unicode_symbols from allure_commons.utils import now from allure_commons.utils import uuid4 from allure_commons.utils import represent @@ -22,10 +21,11 @@ from allure_pytest.utils import get_status, get_status_details from allure_pytest.utils import get_outcome_status, get_outcome_status_details from allure_pytest.utils import get_pytest_report_status +from allure_pytest.utils import format_allure_link from allure_commons.utils import md5 -class AllureListener(object): +class AllureListener: def __init__(self, config): self.config = config @@ -156,8 +156,8 @@ def pytest_fixture_setup(self, fixturedef, request): finalizers = getattr(fixturedef, '_finalizers', []) for index, finalizer in enumerate(finalizers): - name = '{fixture}::{finalizer}'.format(fixture=fixture_name, - finalizer=getattr(finalizer, "__name__", index)) + finalizer_name = getattr(finalizer, "__name__", index) + name = f'{fixture_name}::{finalizer_name}' finalizers[index] = allure_commons.fixture(finalizer, parent_uuid=container_uuid, name=name) @pytest.hookimpl(hookwrapper=True) @@ -178,11 +178,11 @@ def pytest_runtest_makereport(self, item, call): status_details = None if call.excinfo: - message = escape_non_unicode_symbols(call.excinfo.exconly()) + message = call.excinfo.exconly() if hasattr(report, 'wasxfail'): reason = report.wasxfail - message = ('XFAIL {}'.format(reason) if reason else 'XFAIL') + '\n\n' + message - trace = escape_non_unicode_symbols(report.longreprtext) + message = (f'XFAIL {reason}' if reason else 'XFAIL') + '\n\n' + message + trace = report.longreprtext status_details = StatusDetails( message=message, trace=trace) @@ -193,7 +193,7 @@ def pytest_runtest_makereport(self, item, call): if status == Status.PASSED and hasattr(report, 'wasxfail'): reason = report.wasxfail - message = 'XPASS {reason}'.format(reason=reason) if reason else 'XPASS' + message = f'XPASS {reason}' if reason else 'XPASS' status_details = StatusDetails(message=message) if report.when == 'setup': @@ -255,8 +255,7 @@ def add_description_html(self, test_description_html): def add_link(self, url, link_type, name): test_result = self.allure_logger.get_test(None) if test_result: - pattern = dict(self.config.option.allure_link_pattern).get(link_type, u'{}') - link_url = pattern.format(url) + link_url = format_allure_link(self.config, url, link_type) new_link = Link(link_type, link_url, link_url if name is None else name) for link in test_result.links: if link.url == new_link.url: @@ -280,7 +279,7 @@ def add_parameter(self, name, value, excluded, mode: ParameterMode): excluded=excluded or None, mode=mode.value if mode else None)) -class ItemCache(object): +class ItemCache: def __init__(self): self._items = dict() diff --git a/allure-pytest/src/plugin.py b/allure-pytest/src/plugin.py index 8ee60dbb..7ff58f9e 100644 --- a/allure-pytest/src/plugin.py +++ b/allure-pytest/src/plugin.py @@ -46,21 +46,25 @@ def a_label_type(string): if type_name is LabelType.SEVERITY: if not atoms < legal_values: raise argparse.ArgumentTypeError('Illegal {} values: {}, only [{}] are allowed'.format( - type_name, ', '.join(atoms - legal_values), ', '.join(legal_values))) + type_name, + ', '.join(atoms - legal_values), + ', '.join(legal_values) + )) return set((type_name, allure.severity_level(atom)) for atom in atoms) return set((type_name, atom) for atom in atoms) return a_label_type severities = [x.value for x in list(allure.severity_level)] + formatted_severities = ', '.join(severities) parser.getgroup("general").addoption('--allure-severities', action="store", dest="allure_severities", metavar="SEVERITIES_SET", default={}, type=label_type(LabelType.SEVERITY, legal_values=set(severities)), - help="""Comma-separated list of severity names. + help=f"""Comma-separated list of severity names. Tests only with these severities will be run. - Possible values are: %s.""" % ', '.join(severities)) + Possible values are: {formatted_severities}.""") parser.getgroup("general").addoption('--allure-epics', action="store", @@ -150,10 +154,10 @@ def pytest_configure(config): allure_commons.plugin_manager.register(file_logger) config.add_cleanup(cleanup_factory(file_logger)) - config.addinivalue_line("markers", "{mark}: allure label marker".format(mark=ALLURE_LABEL_MARK)) - config.addinivalue_line("markers", "{mark}: allure link marker".format(mark=ALLURE_LINK_MARK)) - config.addinivalue_line("markers", "{mark}: allure description".format(mark=ALLURE_DESCRIPTION_MARK)) - config.addinivalue_line("markers", "{mark}: allure description html".format(mark=ALLURE_DESCRIPTION_HTML_MARK)) + config.addinivalue_line("markers", f"{ALLURE_LABEL_MARK}: allure label marker") + config.addinivalue_line("markers", f"{ALLURE_LINK_MARK}: allure link marker") + config.addinivalue_line("markers", f"{ALLURE_DESCRIPTION_MARK}: allure description") + config.addinivalue_line("markers", f"{ALLURE_DESCRIPTION_HTML_MARK}: allure description html") def select_by_labels(items, config): diff --git a/allure-pytest/src/utils.py b/allure-pytest/src/utils.py index 8e9bda17..4aafa7cf 100644 --- a/allure-pytest/src/utils.py +++ b/allure-pytest/src/utils.py @@ -1,11 +1,7 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -import six import pytest from itertools import chain, islice from allure_commons.utils import represent, SafeFormatter -from allure_commons.utils import format_exception, format_traceback, escape_non_unicode_symbols +from allure_commons.utils import format_exception, format_traceback from allure_commons.model2 import Status from allure_commons.model2 import StatusDetails from allure_commons.types import LabelType @@ -78,6 +74,10 @@ def allure_links(item): yield (mark.kwargs["link_type"], mark.args[0], mark.kwargs["name"]) +def format_allure_link(config, url, link_type): + pattern = dict(config.option.allure_link_pattern).get(link_type, '{}') + return pattern.format(url) + def pytest_markers(item): for keyword in item.keywords.keys(): if any([keyword.startswith('allure_'), keyword == 'parametrize']): @@ -91,14 +91,14 @@ def pytest_markers(item): def mark_to_str(marker): args = [represent(arg) for arg in marker.args] - kwargs = ['{name}={value}'.format(name=key, value=represent(marker.kwargs[key])) for key in marker.kwargs] + kwargs = [f'{key}={represent(value)}' for key, value in marker.kwargs.items()] if marker.name in ('filterwarnings', 'skip', 'skipif', 'xfail', 'usefixtures', 'tryfirst', 'trylast'): - markstr = '@pytest.mark.{name}'.format(name=marker.name) + markstr = f'@pytest.mark.{marker.name}' else: - markstr = '{name}'.format(name=marker.name) + markstr = str(marker.name) if args or kwargs: parameters = ', '.join(args + kwargs) - markstr = '{}({})'.format(markstr, parameters) + markstr = f'{markstr}({parameters})' return markstr @@ -139,11 +139,6 @@ def allure_suite_labels(item): def escape_name(name): - if six.PY2: - try: - name.decode('string_escape').encode('unicode_escape') - except UnicodeDecodeError: - return name.decode('string_escape').decode('utf-8') return name.encode('ascii', 'backslashreplace').decode('unicode_escape') @@ -169,8 +164,8 @@ def get_status(exception): def get_status_details(exception_type, exception, exception_traceback): - message = escape_non_unicode_symbols(format_exception(exception_type, exception)) - trace = escape_non_unicode_symbols(format_traceback(exception_traceback)) + message = format_exception(exception_type, exception) + trace = format_traceback(exception_traceback) return StatusDetails(message=message, trace=trace) if message or trace else None diff --git a/allure-pytest/test/acceptance/attachment/attachment_class_test.py b/allure-pytest/test/acceptance/attachment/attachment_class_test.py index fd03856d..6f229e27 100644 --- a/allure-pytest/test/acceptance/attachment/attachment_class_test.py +++ b/allure-pytest/test/acceptance/attachment/attachment_class_test.py @@ -7,7 +7,7 @@ def test_class_method_attachment(executed_docstring_source): """ >>> import allure - >>> class TestClass(object): + >>> class TestClass: ... def test_class_method_attachment(self): ... allure.attach("text", "failed", allure.attachment_type.TEXT) """ diff --git a/allure-pytest/test/acceptance/attachment/attachment_parametrized_test.py b/allure-pytest/test/acceptance/attachment/attachment_parametrized_test.py index 47d76a73..05a8d4ad 100644 --- a/allure-pytest/test/acceptance/attachment/attachment_parametrized_test.py +++ b/allure-pytest/test/acceptance/attachment/attachment_parametrized_test.py @@ -19,7 +19,7 @@ def test_parametrized_attachment(executed_docstring_source, param): assert_that(executed_docstring_source.allure_report, all_of( - has_test_case("test_parametrized_attachment_example[{param}]".format(param=param)), + has_test_case(f"test_parametrized_attachment_example[{param}]"), has_property("attachments", has_value(contains_string(param)) ) diff --git a/allure-pytest/test/acceptance/capture/capture_attach_test.py b/allure-pytest/test/acceptance/capture/capture_attach_test.py index e4375703..b438eb79 100644 --- a/allure-pytest/test/acceptance/capture/capture_attach_test.py +++ b/allure-pytest/test/acceptance/capture/capture_attach_test.py @@ -25,7 +25,7 @@ def test_capture_stdout(allured_testdir, capture): """ allured_testdir.parse_docstring_source() - allured_testdir.run_with_allure("--capture={capture}".format(capture=capture)) + allured_testdir.run_with_allure(f"--capture={capture}") if_pytest_capture_ = is_not if capture == "no" else is_ @@ -59,7 +59,7 @@ def test_capture_empty_stdout(allured_testdir, capture): """ allured_testdir.parse_docstring_source() - allured_testdir.run_with_allure("--capture={capture}".format(capture=capture)) + allured_testdir.run_with_allure(f"--capture={capture}") assert_that(allured_testdir.allure_report, has_property("attachments", empty()) diff --git a/allure-pytest/test/acceptance/description/description_test.py b/allure-pytest/test/acceptance/description/description_test.py index 81933d44..bec2fbac 100644 --- a/allure-pytest/test/acceptance/description/description_test.py +++ b/allure-pytest/test/acceptance/description/description_test.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ ./examples/description/description.rst """ from hamcrest import assert_that, contains_string diff --git a/allure-pytest/test/acceptance/display_name/display_name_test.py b/allure-pytest/test/acceptance/display_name/display_name_test.py index 370259a9..a3021970 100644 --- a/allure-pytest/test/acceptance/display_name/display_name_test.py +++ b/allure-pytest/test/acceptance/display_name/display_name_test.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ ./examples/display_name/display_name.rst""" from hamcrest import assert_that @@ -27,13 +26,13 @@ def test_unicode_display_name(executed_docstring_source): """ >>> import allure - >>> @allure.title(u"Лунтик") + >>> @allure.title("Лунтик") >>> def test_unicode_display_name_example(): ... pass """ assert_that(executed_docstring_source.allure_report, - has_test_case("test_unicode_display_name_example", has_title(u"Лунтик")) + has_test_case("test_unicode_display_name_example", has_title("Лунтик")) ) @@ -42,7 +41,7 @@ def test_unicode_display_name_template(executed_docstring_source): >>> import allure >>> import pytest - >>> @allure.title(u"Тест с шаблоном и параметром: {param}") + >>> @allure.title("Тест с шаблоном и параметром: {param}") ... @pytest.mark.parametrize("param", [False]) ... def test_unicode_display_name_template_example(param): ... assert param @@ -50,7 +49,7 @@ def test_unicode_display_name_template(executed_docstring_source): assert_that(executed_docstring_source.allure_report, has_test_case("test_unicode_display_name_template_example", - has_title(u"Тест с шаблоном и параметром: False") + has_title("Тест с шаблоном и параметром: False") ) ) diff --git a/allure-pytest/test/acceptance/duration/duration_time_test.py b/allure-pytest/test/acceptance/duration/duration_time_test.py index 6ad8dbd0..e5afc9d0 100644 --- a/allure-pytest/test/acceptance/duration/duration_time_test.py +++ b/allure-pytest/test/acceptance/duration/duration_time_test.py @@ -18,10 +18,10 @@ @pytest.mark.parametrize("snipped", snippets) def test_duration(allured_testdir, snipped): - allured_testdir.testdir.makepyfile(""" + allured_testdir.testdir.makepyfile(f""" def test_duration_example(): {snipped} - """.format(snipped=snipped)) + """) timestamp = now() allured_testdir.run_with_allure() @@ -38,7 +38,7 @@ def test_duration_example(): @allure.issue("244") @pytest.mark.parametrize("snipped", snippets) def test_with_fixture_duration(allured_testdir, snipped): - allured_testdir.testdir.makepyfile(""" + allured_testdir.testdir.makepyfile(f""" import pytest @pytest.fixture @@ -47,7 +47,7 @@ def fixture(): def test_with_fixture_duration_example(fixture): pass - """.format(snipped=snipped)) + """) timestamp = now() allured_testdir.run_with_allure() @@ -64,7 +64,7 @@ def test_with_fixture_duration_example(fixture): @allure.issue("244") @pytest.mark.parametrize("snipped", snippets) def test_with_fixture_finalizer_duration(allured_testdir, snipped): - allured_testdir.testdir.makepyfile(""" + allured_testdir.testdir.makepyfile(f""" import pytest @pytest.fixture @@ -75,7 +75,7 @@ def finalizer(): def test_with_fixture_finalizer_duration(fixture): pass - """.format(snipped=snipped)) + """) timestamp = now() allured_testdir.run_with_allure() diff --git a/allure-pytest/test/acceptance/fixture/fixture_finalized_test.py b/allure-pytest/test/acceptance/fixture/fixture_finalized_test.py index 9ac6f2f0..a5cab436 100644 --- a/allure-pytest/test/acceptance/fixture/fixture_finalized_test.py +++ b/allure-pytest/test/acceptance/fixture/fixture_finalized_test.py @@ -27,9 +27,7 @@ def test_fixture_finalizer(executed_docstring_source): has_test_case("test_fixture_with_finalizer_example", has_container(executed_docstring_source.allure_report, has_before("fixture_with_finalizer"), - has_after("{fixture}::{finalizer}".format(fixture="fixture_with_finalizer", - finalizer="finalizer") - ) + has_after("fixture_with_finalizer::finalizer") ) ) ) @@ -61,12 +59,8 @@ def test_fixture_finalizers(executed_docstring_source): has_test_case("test_fixture_with_finalizers_example", has_container(executed_docstring_source.allure_report, has_before("fixture_with_finalizers"), - has_after("{fixture}::{finalizer}".format(fixture="fixture_with_finalizers", - finalizer="first_finalizer") - ), - has_after("{fixture}::{finalizer}".format(fixture="fixture_with_finalizers", - finalizer="second_finalizer"), - ) + has_after("fixture_with_finalizers::first_finalizer"), + has_after("fixture_with_finalizers::second_finalizer") ) ) ) diff --git a/allure-pytest/test/acceptance/fixture/fixture_test.py b/allure-pytest/test/acceptance/fixture/fixture_test.py index 35aa10fd..0167a308 100644 --- a/allure-pytest/test/acceptance/fixture/fixture_test.py +++ b/allure-pytest/test/acceptance/fixture/fixture_test.py @@ -13,7 +13,7 @@ @pytest.mark.parametrize("first_scope", fixture_scopes) @pytest.mark.parametrize("second_scope", fixture_scopes) def test_fixture(allured_testdir, first_scope, second_scope): - allured_testdir.testdir.makepyfile(""" + allured_testdir.testdir.makepyfile(f""" import pytest @pytest.fixture(scope="{first_scope}") @@ -26,7 +26,7 @@ def second_fixture(): def test_fixture_example(first_fixture, second_fixture): pass - """.format(first_scope=first_scope, second_scope=second_scope)) + """) allured_testdir.run_with_allure() @@ -47,7 +47,7 @@ def test_fixture_example(first_fixture, second_fixture): list(combinations_with_replacement(fixture_scopes, 2)) ) def test_nested_fixture(allured_testdir, parent_scope, child_scope): - allured_testdir.testdir.makepyfile(""" + allured_testdir.testdir.makepyfile(f""" import pytest @pytest.fixture(scope="{parent_scope}") @@ -64,7 +64,7 @@ def test_nested_fixture_example(child_fixture): def test_fixture_used_in_other_fixtures_example(parent_fixture): pass - """.format(parent_scope=parent_scope, child_scope=child_scope)) + """) allured_testdir.run_with_allure() @@ -279,7 +279,7 @@ def test_with_redefined_fixture(my_fixture): list(combinations_with_replacement(fixture_scopes, 2)) ) def test_dynamically_called_fixture(allured_testdir, parent_scope, child_scope): - allured_testdir.testdir.makepyfile(""" + allured_testdir.testdir.makepyfile(f""" import pytest @pytest.fixture(scope="{parent_scope}", autouse=True) @@ -306,7 +306,7 @@ def test_two(request): def test_three(request): request.getfixturevalue('parent_dyn_call_fixture') - """.format(parent_scope=parent_scope, child_scope=child_scope)) + """) allured_testdir.run_with_allure() diff --git a/allure-pytest/test/acceptance/fixture/parametrized_fixture_test.py b/allure-pytest/test/acceptance/fixture/parametrized_fixture_test.py index f0c677a2..048fb86a 100644 --- a/allure-pytest/test/acceptance/fixture/parametrized_fixture_test.py +++ b/allure-pytest/test/acceptance/fixture/parametrized_fixture_test.py @@ -25,7 +25,7 @@ def test_function_scope_parametrized_fixture(param, executed_docstring_source): ... pass """ assert_that(executed_docstring_source.allure_report, - has_test_case("test_function_scope_parametrized_fixture_example[{param}]".format(param=param), + has_test_case(f"test_function_scope_parametrized_fixture_example[{param}]", has_parameter("parametrized_fixture", str(param)), has_container(executed_docstring_source.allure_report, has_before("parametrized_fixture") @@ -47,8 +47,7 @@ def test_function_scope_parametrized_fixture_with_ids(param, executed_docstring_ ... pass """ - test_name = "test_function_scope_parametrized_fixture_with_ids_example[{params_name}]".format( - params_name=params_name(request)) + test_name = f"test_function_scope_parametrized_fixture_with_ids_example[{params_name(request)}]" assert_that(executed_docstring_source.allure_report, has_test_case(test_name, diff --git a/allure-pytest/test/acceptance/fixture/yield_fixture_test.py b/allure-pytest/test/acceptance/fixture/yield_fixture_test.py index 750a5394..e2ac5d92 100644 --- a/allure-pytest/test/acceptance/fixture/yield_fixture_test.py +++ b/allure-pytest/test/acceptance/fixture/yield_fixture_test.py @@ -13,7 +13,7 @@ def test_yield_fixture(executed_docstring_source): >>> @pytest.fixture ... def yield_fixture(): - ... pass + ... yield >>> def test_yield_fixture_example(yield_fixture): ... pass @@ -23,7 +23,7 @@ def test_yield_fixture(executed_docstring_source): has_test_case("test_yield_fixture_example", has_container(executed_docstring_source.allure_report, has_before("yield_fixture") - ), + ) ) ) @@ -58,7 +58,7 @@ def test_opened_step_function(executed_docstring_source): not_(has_step("Body step")) ) ) - ), + ) ) ) ) diff --git a/allure-pytest/test/acceptance/label/bdd/dynamic_bdd_label_test.py b/allure-pytest/test/acceptance/label/bdd/dynamic_bdd_label_test.py index 7a30b09d..cb80f65a 100644 --- a/allure-pytest/test/acceptance/label/bdd/dynamic_bdd_label_test.py +++ b/allure-pytest/test/acceptance/label/bdd/dynamic_bdd_label_test.py @@ -23,9 +23,7 @@ def test_dynamic_labels(executed_docstring_path): ("second feature", "second epic", "second story")]) def test_parametrized_dynamic_labels(executed_docstring_path, feature, epic, story): assert_that(executed_docstring_path.allure_report, - has_test_case("test_parametrized_dynamic_labels[{feature}-{epic}-{story}]".format(feature=feature, - epic=epic, - story=story), + has_test_case(f"test_parametrized_dynamic_labels[{feature}-{epic}-{story}]", has_feature(feature), has_epic(epic), has_story(story), diff --git a/allure-pytest/test/acceptance/label/bdd/select_bdd_test.py b/allure-pytest/test/acceptance/label/bdd/select_bdd_test.py index 1e8d2ef0..fe13c4b2 100644 --- a/allure-pytest/test/acceptance/label/bdd/select_bdd_test.py +++ b/allure-pytest/test/acceptance/label/bdd/select_bdd_test.py @@ -38,7 +38,7 @@ def test_select_by_bdd_label(allured_testdir, options, expected_tests): params = [] for key in options.keys(): - params.append("--allure-{key}".format(key=key)) + params.append(f"--allure-{key}") params.append(",".join(options[key])) allured_testdir.run_with_allure(*params) diff --git a/allure-pytest/test/acceptance/label/suite/default_suite_test.py b/allure-pytest/test/acceptance/label/suite/default_suite_test.py index e971bc4c..daf1d588 100644 --- a/allure-pytest/test/acceptance/label/suite/default_suite_test.py +++ b/allure-pytest/test/acceptance/label/suite/default_suite_test.py @@ -25,7 +25,7 @@ def test_default_suite(executed_docstring_source): @pytest.mark.skip def test_default_class_suite(executed_docstring_source): """ - >>> class TestSuiteClass(object): + >>> class TestSuiteClass: ... def test_default_class_suite_example(self): ... pass diff --git a/allure-pytest/test/acceptance/label/tag/tag_test.py b/allure-pytest/test/acceptance/label/tag/tag_test.py index e029d2b1..a5bc7a47 100644 --- a/allure-pytest/test/acceptance/label/tag/tag_test.py +++ b/allure-pytest/test/acceptance/label/tag/tag_test.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from allure_commons.utils import represent from hamcrest import assert_that, not_ from allure_commons_test.report import has_test_case @@ -107,7 +105,7 @@ def test_pytest_marker_with_kwargs_native_encoding(executed_docstring_source): assert_that(executed_docstring_source.allure_report, has_test_case("test_pytest_marker_with_kwargs_native_encoding_example", - has_tag("marker(stuff=%s)" % represent('я')) + has_tag("marker(stuff='я')") ) ) @@ -116,13 +114,13 @@ def test_pytest_marker_with_kwargs_utf_encoding(executed_docstring_source): """ >>> import pytest - >>> @pytest.mark.marker(stuff=u'я') + >>> @pytest.mark.marker(stuff='я') ... def test_pytest_marker_with_kwargs_utf_encoding_example(): ... pass """ assert_that(executed_docstring_source.allure_report, has_test_case("test_pytest_marker_with_kwargs_utf_encoding_example", - has_tag("marker(stuff=%s)" % represent('я')) + has_tag("marker(stuff='я')") ) ) diff --git a/allure-pytest/test/acceptance/link/dynamic_link_test.py b/allure-pytest/test/acceptance/link/dynamic_link_test.py index 2741b58c..8fe6d610 100644 --- a/allure-pytest/test/acceptance/link/dynamic_link_test.py +++ b/allure-pytest/test/acceptance/link/dynamic_link_test.py @@ -18,7 +18,7 @@ def test_dynamic_link(executed_docstring_path): @pytest.mark.parametrize("link", ["issues/24", "issues/132"]) def test_parametrize_dynamic_link(executed_docstring_path, link): assert_that(executed_docstring_path.allure_report, - has_test_case("test_parametrize_dynamic_link[{link}]".format(link=link), + has_test_case(f"test_parametrize_dynamic_link[{link}]", has_issue_link(link), ) ) @@ -43,4 +43,4 @@ def test_unique_dynamic_links(executed_docstring_source): ... allure.dynamic.link("some/unique/dynamic/link") """ assert_that(executed_docstring_source.allure_report.test_cases[0]['links'], - equal_to([{'url': u'some/unique/dynamic/link', 'type': 'link', 'name': u'some/unique/dynamic/link'}])) + equal_to([{'url': 'some/unique/dynamic/link', 'type': 'link', 'name': 'some/unique/dynamic/link'}])) diff --git a/allure-pytest/test/acceptance/parametrization/metafunc_test.py b/allure-pytest/test/acceptance/parametrization/metafunc_test.py index c71e501e..620f133a 100644 --- a/allure-pytest/test/acceptance/parametrization/metafunc_test.py +++ b/allure-pytest/test/acceptance/parametrization/metafunc_test.py @@ -17,7 +17,7 @@ def test_metafunc_param(executed_docstring_source, param): """ assert_that(executed_docstring_source.allure_report, - has_test_case("test_metafunc_param_example[{param}]".format(param=param), + has_test_case(f"test_metafunc_param_example[{param}]", has_parameter("metafunc_param", str(param)) ) ) @@ -35,8 +35,9 @@ def test_metafunc_param_with_ids(executed_docstring_source, param): ... assert metafunc_param_with_ids """ + param_name = "pass" if param else "fail" assert_that(executed_docstring_source.allure_report, - has_test_case("test_metafunc_param_with_ids_example[{param}]".format(param="pass" if param else "fail"), + has_test_case(f"test_metafunc_param_with_ids_example[{param_name}]", has_parameter("metafunc_param_with_ids", str(param)) ) ) diff --git a/allure-pytest/test/acceptance/parametrization/parametrization_test.py b/allure-pytest/test/acceptance/parametrization/parametrization_test.py index 84d75c3d..d03c14e5 100644 --- a/allure-pytest/test/acceptance/parametrization/parametrization_test.py +++ b/allure-pytest/test/acceptance/parametrization/parametrization_test.py @@ -21,7 +21,7 @@ def test_parametrization(executed_docstring_source, param): """ assert_that(executed_docstring_source.allure_report, - has_test_case("test_parametrization_example[{param}]".format(param=param), + has_test_case(f"test_parametrization_example[{param}]", has_parameter("param", str(param)) ) ) @@ -38,10 +38,11 @@ def test_parametrization_with_ids(executed_docstring_source, param): ... assert param """ + param_name = "pass" if param else "fail" assert_that(executed_docstring_source.allure_report, has_test_case( - "test_parametrization_with_ids_example[{param}]".format(param="pass" if param else "fail"), - has_parameter("pass" if param else "fail", str(param)) + f"test_parametrization_with_ids_example[{param_name}]", + has_parameter(param_name, str(param)) ) ) @@ -58,7 +59,7 @@ def test_parametrization_many_decorators(executed_docstring_source, request, par ... pass """ - test_name = "test_parametrization_many_decorators_example[{params_name}]".format(params_name=params_name(request)) + test_name = f"test_parametrization_many_decorators_example[{params_name(request)}]" assert_that(executed_docstring_source.allure_report, has_test_case(test_name, @@ -82,8 +83,7 @@ def test_parametrization_many_decorators_with_partial_ids(executed_docstring_sou ... pass """ - test_name = "test_parametrization_many_decorators_with_partial_ids_example[{params_name}]".format( - params_name=params_name(request)) + test_name = f"test_parametrization_many_decorators_with_partial_ids_example[{params_name(request)}]" assert_that(executed_docstring_source.allure_report, has_test_case(test_name, diff --git a/allure-pytest/test/acceptance/status/base_teardown_status_test.py b/allure-pytest/test/acceptance/status/base_teardown_status_test.py index 217ecbdb..0ae474da 100644 --- a/allure-pytest/test/acceptance/status/base_teardown_status_test.py +++ b/allure-pytest/test/acceptance/status/base_teardown_status_test.py @@ -29,9 +29,7 @@ def test_failed_finalizer_fixture(executed_docstring_source): with_trace_contains("def fixture_finalizer():") ), has_container(executed_docstring_source.allure_report, - has_after("{fixture}::{finalizer}".format( - fixture="failed_finalizer_fixture", - finalizer="fixture_finalizer"), + has_after("failed_finalizer_fixture::fixture_finalizer", with_status("failed"), has_status_details(with_message_contains("AssertionError"), with_trace_contains("fixture_finalizer") @@ -63,14 +61,12 @@ def test_pytest_failed_finalizer_fixture(executed_docstring_source): with_trace_contains("def fixture_finalizer():") ), has_container(executed_docstring_source.allure_report, - has_after("{fixture}::{finalizer}".format( - fixture="pytest_failed_finalizer_fixture", - finalizer="fixture_finalizer"), + has_after("pytest_failed_finalizer_fixture::fixture_finalizer", with_status("failed"), has_status_details(with_message_contains("Failed"), with_trace_contains("fixture_finalizer") - ), - ), + ) + ) ) ) ) diff --git a/allure-pytest/test/acceptance/status/skip_teardown_status_test.py b/allure-pytest/test/acceptance/status/skip_teardown_status_test.py index 14ea0530..0f8456e4 100644 --- a/allure-pytest/test/acceptance/status/skip_teardown_status_test.py +++ b/allure-pytest/test/acceptance/status/skip_teardown_status_test.py @@ -26,9 +26,7 @@ def test_skip_finalizer_fixture(executed_docstring_source): has_test_case("test_skip_finalizer_fixture_example", with_status("passed"), has_container(executed_docstring_source.allure_report, - has_after("{fixture}::{finalizer}".format( - fixture="skip_finalizer_fixture", - finalizer="fixture_finalizer"), + has_after("skip_finalizer_fixture::fixture_finalizer", with_status("skipped"), has_status_details(with_message_contains("Skipped"), with_trace_contains("fixture_finalizer") diff --git a/allure-pytest/test/acceptance/status/xfail_teardown_status_test.py b/allure-pytest/test/acceptance/status/xfail_teardown_status_test.py index f7a37a37..e76bd282 100644 --- a/allure-pytest/test/acceptance/status/xfail_teardown_status_test.py +++ b/allure-pytest/test/acceptance/status/xfail_teardown_status_test.py @@ -28,9 +28,7 @@ def test_xfail_failed_finalizer_fixture(executed_docstring_source): with_status("passed"), has_status_details(with_message_contains("XPASS")), has_container(executed_docstring_source.allure_report, - has_after("{fixture}::{finalizer}".format( - fixture="failed_finalizer_fixture", - finalizer="fixture_finalizer"), + has_after("failed_finalizer_fixture::fixture_finalizer", with_status("failed"), has_status_details(with_message_contains("AssertionError"), with_trace_contains("fixture_finalizer") diff --git a/allure-pytest/test/acceptance/step/step_parameters.py b/allure-pytest/test/acceptance/step/step_parameters.py index f2647a43..19e3bba8 100644 --- a/allure-pytest/test/acceptance/step/step_parameters.py +++ b/allure-pytest/test/acceptance/step/step_parameters.py @@ -43,8 +43,7 @@ def test_step_parameters(executed_docstring_source, request, args, kwargs): ... step(*args, **kwargs) """ - test_name = "test_args_less_than_placeholders_example[{params_name}]".format( - params_name=params_name(request)) + test_name = f"test_args_less_than_placeholders_example[{params_name(request)}]" assert_that(executed_docstring_source.allure_report, has_test_case(test_name, diff --git a/allure-pytest/test/acceptance/unicode_identifier/unicode_identifier_test.py b/allure-pytest/test/acceptance/unicode_identifier/unicode_identifier_test.py index cb1220d5..abce0b4f 100644 --- a/allure-pytest/test/acceptance/unicode_identifier/unicode_identifier_test.py +++ b/allure-pytest/test/acceptance/unicode_identifier/unicode_identifier_test.py @@ -1,12 +1,7 @@ -# -*- coding: utf-8 -*- - -import pytest -import six from hamcrest import assert_that from allure_commons_test.report import has_test_case -@pytest.mark.skipif(six.PY2, reason="python 2.7") def test_unicode_function_name(executed_docstring_source): """ >>> def test_unicode_func_déjà_vu(): @@ -18,7 +13,6 @@ def test_unicode_function_name(executed_docstring_source): ) -@pytest.mark.skipif(six.PY2, reason="python 2.7") def test_unicode_method_name(executed_docstring_source): """ >>> class TestCase: @@ -31,7 +25,6 @@ def test_unicode_method_name(executed_docstring_source): ) -@pytest.mark.skipif(six.PY2, reason="python 2.7") def test_unicode_class_name(executed_docstring_source): """ >>> class TestCaseПервый: diff --git a/allure-pytest/test/conftest.py b/allure-pytest/test/conftest.py index 35ba9fb8..a5f52417 100644 --- a/allure-pytest/test/conftest.py +++ b/allure-pytest/test/conftest.py @@ -1,5 +1,4 @@ import pytest -import six from allure_commons_test.report import AllureReport from doctest import script_from_examples import mock @@ -31,7 +30,7 @@ def fake_logger(path, logger): allure_commons.plugin_manager.register(plugin) -class AlluredTestdir(object): +class AlluredTestdir: def __init__(self, testdir, request): self.testdir = testdir self.request = request @@ -40,26 +39,15 @@ def __init__(self, testdir, request): def parse_docstring_source(self): docstring = self.request.node.function.__doc__ or self.request.node.module.__doc__ source = script_from_examples(docstring).replace("#\n", "\n") - if six.PY2: - self.testdir.makepyfile("# -*- coding: utf-8 -*-\n%s" % source) - else: - self.testdir.makepyfile(source) + self.testdir.makepyfile(source) def parse_docstring_path(self): doc_file = self.request.node.function.__doc__ or self.request.node.module.__doc__ example_dir = self.request.config.rootdir.join(doc_file.strip()) - - if six.PY2: - with open(str(example_dir)) as f: - content = "# -*- coding: utf-8 -*-\n%s" % f.read() - source = script_from_examples(content) - self.testdir.makepyfile(source) - else: - with open(example_dir, encoding="utf-8") as f: - - content = f.read() - source = script_from_examples(content) - self.testdir.makepyfile(source) + with open(example_dir, encoding="utf-8") as f: + content = f.read() + source = script_from_examples(content) + self.testdir.makepyfile(source) def run_with_allure(self, *args, **kwargs): if self.request.node.get_closest_marker("real_logger"): diff --git a/allure-pytest/test/integration/allure_ee/select_test_from_testplan_test.py b/allure-pytest/test/integration/allure_ee/select_test_from_testplan_test.py index 7c379454..f7dd303c 100644 --- a/allure-pytest/test/integration/allure_ee/select_test_from_testplan_test.py +++ b/allure-pytest/test/integration/allure_ee/select_test_from_testplan_test.py @@ -79,13 +79,14 @@ def test_select_by_testcase_id_test(planned_tests, expected_tests, allured_testd root_dir = request.config.rootdir.strpath test_dir = allured_testdir.testdir.tmpdir.strpath.replace(root_dir, "") - full_name_base_template = "{base}.test_select_by_testcase_id_test".format( - base=test_dir.strip(os.sep).replace(os.sep, ".")) + base_path = test_dir.strip(os.sep).replace(os.sep, ".") + full_name_base_template = f"{base_path}.test_select_by_testcase_id_test" 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"]) + selector = item['selector'] + item["selector"] = f"{full_name_base_template}#{selector}" testplan = {"tests": planned_tests} py_path = allured_testdir.testdir.makefile(".json", json.dumps(testplan)) diff --git a/allure-pytest/test/integration/pytest_rerunfailures/pytest_rerunfailures_test.py b/allure-pytest/test/integration/pytest_rerunfailures/pytest_rerunfailures_test.py index d6be7db1..2f9aea70 100644 --- a/allure-pytest/test/integration/pytest_rerunfailures/pytest_rerunfailures_test.py +++ b/allure-pytest/test/integration/pytest_rerunfailures/pytest_rerunfailures_test.py @@ -9,7 +9,7 @@ @allure.feature("Integration") @pytest.mark.parametrize("countdown", [2, 4]) def test_pytest_rerunfailures(allured_testdir, countdown): - allured_testdir.testdir.makepyfile(""" + allured_testdir.testdir.makepyfile(f""" import threading import pytest @@ -21,7 +21,7 @@ def test_pytest_rerunfailures_example(): back_to_normal.countdown = countdown - 1 assert not countdown > 0 - """.format(countdown=countdown)) + """) allured_testdir.run_with_allure() diff --git a/allure-python-commons-test/setup.py b/allure-python-commons-test/setup.py index 33dcf7c5..7650824c 100644 --- a/allure-python-commons-test/setup.py +++ b/allure-python-commons-test/setup.py @@ -3,8 +3,7 @@ PACKAGE = "allure-python-commons-test" install_requires = [ - "pyhamcrest>=1.9.0", - "six>=1.9.0" + "pyhamcrest>=1.9.0" ] diff --git a/allure-python-commons-test/src/container.py b/allure-python-commons-test/src/container.py index 647f101e..bd66bc0c 100644 --- a/allure-python-commons-test/src/container.py +++ b/allure-python-commons-test/src/container.py @@ -1,4 +1,3 @@ -from six import string_types from hamcrest.core.base_matcher import BaseMatcher from hamcrest import all_of from hamcrest import has_entry, has_item, has_property, equal_to @@ -32,7 +31,7 @@ def has_container(report, *matchers): >>> from allure_commons_test.report import has_test_case - >>> class Report(object): + >>> class Report: ... test_cases = [ ... { ... 'fullName': 'test_case', @@ -78,7 +77,7 @@ def has_container(report, *matchers): class HasSameContainer(BaseMatcher): def __init__(self, *args): - self.test_case_names = [test_case_name for test_case_name in args if isinstance(test_case_name, string_types)] + self.test_case_names = [test_case_name for test_case_name in args if isinstance(test_case_name, str)] self.matchers = args[len(self.test_case_names):] @staticmethod @@ -110,7 +109,7 @@ def has_same_container(*args): """ >>> from hamcrest import assert_that - >>> class Report(object): + >>> class Report: ... test_cases = [ ... { ... 'fullName': 'first_test_case', diff --git a/allure-python-commons-test/src/report.py b/allure-python-commons-test/src/report.py index 16ac9150..cbb2c049 100644 --- a/allure-python-commons-test/src/report.py +++ b/allure-python-commons-test/src/report.py @@ -1,7 +1,7 @@ """ >>> from hamcrest import assert_that ->>> class Report(object): +>>> class Report: ... def __init__(self): ... self.test_cases = [ ... { @@ -66,7 +66,6 @@ """ -import sys import os import json import fnmatch @@ -78,11 +77,8 @@ from hamcrest import only_contains from hamcrest.core.base_matcher import BaseMatcher -if sys.version_info[0] < 3: - from io import open - -class AllureReport(object): +class AllureReport: def __init__(self, result): self.result_dir = result self.test_cases = [json.load(item) for item in self._report_items(result, '*result.json')] @@ -146,7 +142,7 @@ def _matches(self, item): return False def describe_to(self, description): - description.append_text('exactly {} item(s) matching '.format(self.num)).append_text(self.matcher) + description.append_text(f'exactly {self.num} item(s) matching ').append_text(self.matcher) def has_only_n_test_cases(name, num, *matchers): diff --git a/allure-python-commons/setup.py b/allure-python-commons/setup.py index b6710999..cdc55421 100644 --- a/allure-python-commons/setup.py +++ b/allure-python-commons/setup.py @@ -10,13 +10,16 @@ 'Topic :: Software Development :: Testing', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', ] install_requires = [ "attrs>=16.0.0", - "six>=1.9.0", "pluggy>=0.4.0", - "enum34;python_version<'3.4'", ] @@ -36,7 +39,7 @@ def main(): package_dir={"allure_commons": 'src'}, install_requires=install_requires, py_modules=['allure', 'allure_commons'], - python_requires='>=3.5' + python_requires='>=3.6' ) diff --git a/allure-python-commons/src/_allure.py b/allure-python-commons/src/_allure.py index 262b5944..e6dc2cf9 100644 --- a/allure-python-commons/src/_allure.py +++ b/allure-python-commons/src/_allure.py @@ -86,7 +86,7 @@ def testcase(url, name=None): return link(url, link_type=LinkType.TEST_CASE, name=name) -class Dynamic(object): +class Dynamic: @staticmethod def title(test_title): @@ -194,7 +194,7 @@ def impl(*a, **kw): return impl -class Attach(object): +class Attach: def __call__(self, body, name=None, attachment_type=None, extension=None): plugin_manager.hook.attach_data(body=body, name=name, attachment_type=attachment_type, extension=extension) @@ -206,7 +206,7 @@ def file(self, source, name=None, attachment_type=None, extension=None): attach = Attach() -class fixture(object): +class fixture: def __init__(self, fixture_function, parent_uuid=None, name=None): self._fixture_function = fixture_function self._parent_uuid = parent_uuid @@ -235,7 +235,7 @@ def __exit__(self, exc_type, exc_val, exc_tb): exc_tb=exc_tb) -class test(object): +class test: def __init__(self, _test, context): self._test = _test self._uuid = uuid4() diff --git a/allure-python-commons/src/_compat.py b/allure-python-commons/src/_compat.py deleted file mode 100644 index d044edf5..00000000 --- a/allure-python-commons/src/_compat.py +++ /dev/null @@ -1,80 +0,0 @@ -from __future__ import absolute_import, division, print_function -import types - - -def format_exception_only(etype, value): - """Format the exception part of a traceback. - - The arguments are the exception type and value such as given by - sys.last_type and sys.last_value. The return value is a list of - strings, each ending in a newline. - - Normally, the list contains a single string; however, for - SyntaxError exceptions, it contains several lines that (when - printed) display detailed information about where the syntax - error occurred. - - The message indicating which exception occurred is always the last - string in the list. - - """ - - # An instance should not have a meaningful value parameter, but - # sometimes does, particularly for string exceptions, such as - # >>> raise string1, string2 # deprecated - # - # Clear these out first because issubtype(string1, SyntaxError) - # would throw another exception and mask the original problem. - if (isinstance(etype, BaseException) or - isinstance(etype, types.InstanceType) or - etype is None or type(etype) is str): # noqa: E129 - return [_format_final_exc_line(etype, value)] - - stype = etype.__name__ - - if not issubclass(etype, SyntaxError): - return [_format_final_exc_line(stype, value)] - - # It was a syntax error; show exactly where the problem was found. - lines = [] - try: - msg, (filename, lineno, offset, badline) = value.args - except Exception: - pass - else: - filename = filename or "" - lines.append(' File "%s", line %d\n' % (filename, lineno)) - if badline is not None: - lines.append(' %s\n' % badline.strip()) - if offset is not None: - caretspace = badline.rstrip('\n')[:offset].lstrip() - # non-space whitespace (likes tabs) must be kept for alignment - caretspace = ((c.isspace() and c or ' ') for c in caretspace) - # only three spaces to account for offset1 == pos 0 - lines.append(' %s^\n' % ''.join(caretspace)) - value = msg - - lines.append(_format_final_exc_line(stype, value)) - return lines - - -def _format_final_exc_line(etype, value): - """Return a list of a single line -- normal case for format_exception_only""" - valuestr = _some_str(value) - if value is None or not valuestr: - line = "%s\n" % etype - else: - line = "%s: %s\n" % (etype, valuestr) - return line - - -def _some_str(value): - try: - return str(value) - except UnicodeError: - try: - value = unicode(value) # noqa: F821 - return value.encode('utf-8', 'replace') - except Exception: - pass - return '' % type(value).__name__ diff --git a/allure-python-commons/src/_core.py b/allure-python-commons/src/_core.py index 7f79d114..40d9deaf 100644 --- a/allure-python-commons/src/_core.py +++ b/allure-python-commons/src/_core.py @@ -1,4 +1,3 @@ -from six import with_metaclass from pluggy import PluginManager from allure_commons import _hooks @@ -20,5 +19,5 @@ def __getattr__(cls, attr): return getattr(pm, attr) -class plugin_manager(with_metaclass(MetaPluginManager)): +class plugin_manager(metaclass=MetaPluginManager): pass diff --git a/allure-python-commons/src/_hooks.py b/allure-python-commons/src/_hooks.py index 8695c24c..0ff19a27 100644 --- a/allure-python-commons/src/_hooks.py +++ b/allure-python-commons/src/_hooks.py @@ -4,7 +4,7 @@ hookimpl = HookimplMarker("allure") -class AllureUserHooks(object): +class AllureUserHooks: @hookspec def decorate_as_title(self, test_title): @@ -67,7 +67,7 @@ def attach_file(self, source, name, attachment_type, extension): """ attach file """ -class AllureDeveloperHooks(object): +class AllureDeveloperHooks: @hookspec def start_fixture(self, parent_uuid, uuid, name, parameters): diff --git a/allure-python-commons/src/lifecycle.py b/allure-python-commons/src/lifecycle.py index 951de3d2..189ae924 100644 --- a/allure-python-commons/src/lifecycle.py +++ b/allure-python-commons/src/lifecycle.py @@ -13,7 +13,7 @@ from allure_commons.types import AttachmentType -class AllureLifecycle(object): +class AllureLifecycle: def __init__(self): self._items = OrderedDict() diff --git a/allure-python-commons/src/logger.py b/allure-python-commons/src/logger.py index ab326b06..a3906343 100644 --- a/allure-python-commons/src/logger.py +++ b/allure-python-commons/src/logger.py @@ -1,18 +1,16 @@ import errno import io import os -import sys import json import uuid import shutil -from six import text_type from attr import asdict from allure_commons import hookimpl INDENT = 4 -class AllureFileLogger(object): +class AllureFileLogger: def __init__(self, report_dir, clean=False): self._report_dir = report_dir @@ -33,11 +31,7 @@ def _report_item(self, item): filename = item.file_pattern.format(prefix=uuid.uuid4()) data = asdict(item, filter=lambda attr, value: not (type(value) != bool and not bool(value))) with io.open(os.path.join(self._report_dir, filename), 'w', encoding='utf8') as json_file: - if sys.version_info.major < 3: - json_file.write( - unicode(json.dumps(data, indent=indent, ensure_ascii=False, encoding='utf8'))) # noqa: F821 - else: - json.dump(data, json_file, indent=indent, ensure_ascii=False) + json.dump(data, json_file, indent=indent, ensure_ascii=False) @hookimpl def report_result(self, result): @@ -56,13 +50,13 @@ def report_attached_file(self, source, file_name): def report_attached_data(self, body, file_name): destination = os.path.join(self._report_dir, file_name) with open(destination, 'wb') as attached_file: - if isinstance(body, text_type): + if isinstance(body, str): attached_file.write(body.encode('utf-8')) else: attached_file.write(body) -class AllureMemoryLogger(object): +class AllureMemoryLogger: def __init__(self): self.test_cases = [] diff --git a/allure-python-commons/src/mapping.py b/allure-python-commons/src/mapping.py index 311be1a8..6f61c651 100644 --- a/allure-python-commons/src/mapping.py +++ b/allure-python-commons/src/mapping.py @@ -99,7 +99,7 @@ def labels_set(labels): ... ]) [Label(name='epic', value='Epic1'), Label(name='epic', value='Epic2')] """ - class Wl(object): + class Wl: def __init__(self, label): self.label = label diff --git a/allure-python-commons/src/model2.py b/allure-python-commons/src/model2.py index 62f59cab..e8fd330a 100644 --- a/allure-python-commons/src/model2.py +++ b/allure-python-commons/src/model2.py @@ -9,7 +9,7 @@ @attrs -class TestResultContainer(object): +class TestResultContainer: file_pattern = TEST_GROUP_PATTERN uuid = attrib(default=None) @@ -25,7 +25,7 @@ class TestResultContainer(object): @attrs -class ExecutableItem(object): +class ExecutableItem: name = attrib(default=None) status = attrib(default=None) statusDetails = attrib(default=None) @@ -67,7 +67,7 @@ class TestAfterResult(ExecutableItem): @attrs -class Parameter(object): +class Parameter: name = attrib(default=None) value = attrib(default=None) excluded = attrib(default=None) @@ -75,20 +75,20 @@ class Parameter(object): @attrs -class Label(object): +class Label: name = attrib(default=None) value = attrib(default=None) @attrs -class Link(object): +class Link: type = attrib(default=None) url = attrib(default=None) name = attrib(default=None) @attrs -class StatusDetails(object): +class StatusDetails: known = attrib(default=None) flaky = attrib(default=None) message = attrib(default=None) @@ -96,13 +96,13 @@ class StatusDetails(object): @attrs -class Attachment(object): +class Attachment: name = attrib(default=None) source = attrib(default=None) type = attrib(default=None) -class Status(object): +class Status: FAILED = 'failed' BROKEN = 'broken' PASSED = 'passed' diff --git a/allure-python-commons/src/reporter.py b/allure-python-commons/src/reporter.py index 55cf80ac..fe64b982 100644 --- a/allure-python-commons/src/reporter.py +++ b/allure-python-commons/src/reporter.py @@ -53,7 +53,7 @@ def cleanup(self): del self._thread_context[thread] -class AllureReporter(object): +class AllureReporter: def __init__(self): self._items = ThreadContextItems() self._orphan_items = [] diff --git a/allure-python-commons/src/types.py b/allure-python-commons/src/types.py index 56030766..395ac70b 100644 --- a/allure-python-commons/src/types.py +++ b/allure-python-commons/src/types.py @@ -11,7 +11,7 @@ class Severity(str, Enum): TRIVIAL = 'trivial' -class LinkType(object): +class LinkType: LINK = 'link' ISSUE = 'issue' TEST_CASE = 'test_case' diff --git a/allure-python-commons/src/utils.py b/allure-python-commons/src/utils.py index 503a47ec..5ad1b864 100644 --- a/allure-python-commons/src/utils.py +++ b/allure-python-commons/src/utils.py @@ -1,9 +1,6 @@ -# -*- coding: utf-8 -*- - import os import string import sys -import six import time import uuid import json @@ -15,59 +12,7 @@ import traceback import collections -from functools import partial - - -def getargspec(func): - """ - Used because getargspec for python 2.7 does not accept functools.partial - which is the type for pytest fixtures. - - getargspec excerpted from: - - sphinx.util.inspect - ~~~~~~~~~~~~~~~~~~~ - Helpers for inspecting Python modules. - :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS. - :license: BSD, see LICENSE for details. - - Like inspect.getargspec but supports functools.partial as well. - """ - # noqa: E731 type: (Any) -> Any - if inspect.ismethod(func): - func = func.__func__ - parts = 0, () # noqa: E731 type: Tuple[int, Tuple[unicode, ...]] - if type(func) is partial: - keywords = func.keywords - if keywords is None: - keywords = {} - parts = len(func.args), keywords.keys() - func = func.func - if not inspect.isfunction(func): - raise TypeError('%r is not a Python function' % func) - args, varargs, varkw = inspect.getargs(func.__code__) - func_defaults = func.__defaults__ - if func_defaults is None: - func_defaults = [] - else: - func_defaults = list(func_defaults) - if parts[0]: - args = args[parts[0]:] - if parts[1]: - for arg in parts[1]: - i = args.index(arg) - len(args) # type: ignore - del args[i] - try: - del func_defaults[i] - except IndexError: - pass - return inspect.ArgSpec(args, varargs, varkw, func_defaults) # type: ignore - - -if six.PY3: - from traceback import format_exception_only -else: - from _compat import format_exception_only +from traceback import format_exception_only def md5(*args): @@ -87,10 +32,9 @@ def now(): def platform_label(): - major_version, _, __ = platform.python_version_tuple() - implementation = platform.python_implementation() - return '{implementation}{major_version}'.format(implementation=implementation.lower(), - major_version=major_version) + major_version, *_ = platform.python_version_tuple() + implementation = platform.python_implementation().lower() + return f'{implementation}{major_version}' def thread_tag(): @@ -101,20 +45,6 @@ def host_tag(): return socket.gethostname() -def escape_non_unicode_symbols(item): - if not (six.PY2 and isinstance(item, str)): - return item - - def escape_symbol(s): - try: - s.decode(encoding='UTF-8') - return s - except UnicodeDecodeError: - return repr(s)[1:-1] - - return ''.join(map(escape_symbol, item)) - - def represent(item): """ >>> represent(None) @@ -123,26 +53,21 @@ def represent(item): >>> represent(123) '123' - >>> import six - >>> expected = u"'hi'" if six.PY2 else "'hi'" - >>> represent('hi') == expected - True + >>> represent('hi') + "'hi'" - >>> expected = u"'привет'" if six.PY2 else "'привет'" - >>> represent(u'привет') == expected - True + >>> represent('привет') + "'привет'" >>> represent(bytearray([0xd0, 0xbf])) # doctest: +ELLIPSIS "<... 'bytearray'>" >>> from struct import pack - >>> result = "" if six.PY2 else "" - >>> represent(pack('h', 0x89)) == result - True + >>> represent(pack('h', 0x89)) + "" - >>> result = "" if six.PY2 else "" - >>> represent(int) == result - True + >>> represent(int) + "" >>> represent(represent) # doctest: +ELLIPSIS '' @@ -150,21 +75,15 @@ def represent(item): >>> represent([represent]) # doctest: +ELLIPSIS '[]' - >>> class ClassWithName(object): + >>> class ClassWithName: ... pass >>> represent(ClassWithName) "" """ - if six.PY2 and isinstance(item, str): - try: - item = item.decode(encoding='UTF-8') - except UnicodeDecodeError: - pass - - if isinstance(item, six.text_type): - return u'\'%s\'' % item + if isinstance(item, str): + return f"'{item}'" elif isinstance(item, (bytes, bytearray)): return repr(type(item)) else: @@ -278,7 +197,7 @@ def func_parameters(func, *args, **kwargs): >>> args_kwargs_varargs_keywords(1, 2, 4, d=5, e=6) [('a', '1'), ('b', '2'), ('c', '(4,)'), ('d', '5'), ('e', '6')] - >>> class Class(object): + >>> class Class: ... @staticmethod ... @helper ... def static_args(a, b): @@ -306,7 +225,7 @@ def func_parameters(func, *args, **kwargs): """ parameters = {} - arg_spec = getargspec(func) if six.PY2 else inspect.getfullargspec(func) + arg_spec = inspect.getfullargspec(func) arg_order = list(arg_spec.args) args_dict = dict(zip(arg_spec.args, args)) @@ -323,19 +242,25 @@ def func_parameters(func, *args, **kwargs): args_dict.pop(arg_spec.args[0], None) if kwargs: - if sys.version_info < (3, 6): + if sys.version_info < (3, 7): # Sort alphabetically as old python versions does - # not preserve call order for kwargs + # not preserve call order for kwargs. arg_order.extend(sorted(list(kwargs.keys()))) else: - # Keep py3.6 behaviour to preserve kwargs order + # Keep py3.7 behaviour to preserve kwargs order arg_order.extend(list(kwargs.keys())) parameters.update(kwargs) parameters.update(args_dict) - items = parameters.iteritems() if six.PY2 else parameters.items() - sorted_items = sorted(map(lambda kv: (kv[0], represent(kv[1])), items), key=lambda x: arg_order.index(x[0])) + items = parameters.items() + sorted_items = sorted( + map( + lambda kv: (kv[0], represent(kv[1])), + items + ), + key=lambda x: arg_order.index(x[0]) + ) return collections.OrderedDict(sorted_items) @@ -349,7 +274,7 @@ def format_exception(etype, value): >>> import sys >>> try: - ... assert False, u'Привет' + ... assert False, 'Привет' ... except AssertionError: ... etype, e, _ = sys.exc_info() ... format_exception(etype, e) # doctest: +ELLIPSIS @@ -363,7 +288,7 @@ def format_exception(etype, value): 'AssertionError: ...\\n' >>> try: - ... compile("bla u'Привет'", "fake.py", "exec") + ... compile("bla 'Привет'", "fake.py", "exec") ... except SyntaxError: ... etype, e, _ = sys.exc_info() ... format_exception(etype, e) # doctest: +ELLIPSIS @@ -386,7 +311,7 @@ def format_exception(etype, value): "AssertionError: \\nExpected:...but:..." >>> try: - ... assert_that(u'left', equal_to(u'right')) + ... assert_that('left', equal_to('right')) ... except AssertionError: ... etype, e, _ = sys.exc_info() ... format_exception(etype, e) # doctest: +ELLIPSIS diff --git a/allure-robotframework/examples/attach/foreign_library.py b/allure-robotframework/examples/attach/foreign_library.py index e4dc33f2..e1a5d3ef 100644 --- a/allure-robotframework/examples/attach/foreign_library.py +++ b/allure-robotframework/examples/attach/foreign_library.py @@ -2,7 +2,7 @@ from tempfile import mkdtemp -class ForeignLibrary(object): +class ForeignLibrary: def capture_page_screenshot(self): tmp = mkdtemp() diff --git a/allure-robotframework/examples/attach/foreign_library_helper.py b/allure-robotframework/examples/attach/foreign_library_helper.py index c25d86e6..a28146ec 100644 --- a/allure-robotframework/examples/attach/foreign_library_helper.py +++ b/allure-robotframework/examples/attach/foreign_library_helper.py @@ -2,7 +2,7 @@ from robot.libraries.BuiltIn import BuiltIn -class ForeignLibraryHelper(object): +class ForeignLibraryHelper: ROBOT_LIBRARY_SCOPE = "TEST SUITE" ROBOT_LISTENER_API_VERSION = 2 diff --git a/allure-robotframework/setup.py b/allure-robotframework/setup.py index 1925f60c..da2519bb 100644 --- a/allure-robotframework/setup.py +++ b/allure-robotframework/setup.py @@ -13,6 +13,11 @@ 'Topic :: Software Development :: Testing', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', ] setup_requires = [ @@ -27,7 +32,7 @@ def prepare_version(): from setuptools_scm import get_version configuration = {"root": "..", "relative_to": __file__} version = get_version(**configuration) - install_requires.append("allure-python-commons=={version}".format(version=version)) + install_requires.append(f"allure-python-commons=={version}") return configuration diff --git a/allure-robotframework/src/listener/allure_listener.py b/allure-robotframework/src/listener/allure_listener.py index 89fab2c9..a0ee14d3 100644 --- a/allure-robotframework/src/listener/allure_listener.py +++ b/allure-robotframework/src/listener/allure_listener.py @@ -41,8 +41,10 @@ def get_status_details(exc_type, exception, exc_traceback): def pool_id(): pabot_pool_id = BuiltIn().get_variable_value('${PABOTEXECUTIONPOOLID}') pabot_caller_id = BuiltIn().get_variable_value('${CALLER_ID}') - return "{}-{}".format(pabot_pool_id, pabot_caller_id) \ - if all([pabot_pool_id, pabot_caller_id]) else DEFAULT_POOL_ID + return f"{pabot_pool_id}-{pabot_caller_id}" if all([ + pabot_pool_id, + pabot_caller_id + ]) else DEFAULT_POOL_ID def get_message_time(timestamp): @@ -55,7 +57,7 @@ def get_message_time(timestamp): MAX_STEP_MESSAGE_COUNT = int(os.getenv('ALLURE_MAX_STEP_MESSAGE_COUNT', 0)) -class AllureListener(object): +class AllureListener: def __init__(self, lifecycle): self.lifecycle = lifecycle self._platform = platform_label() diff --git a/allure-robotframework/src/listener/robot_listener.py b/allure-robotframework/src/listener/robot_listener.py index 6e6e0519..9dab210e 100644 --- a/allure-robotframework/src/listener/robot_listener.py +++ b/allure-robotframework/src/listener/robot_listener.py @@ -11,7 +11,7 @@ # noinspection PyPep8Naming -class allure_robotframework(object): +class allure_robotframework: ROBOT_LISTENER_API_VERSION = 2 def __init__(self, logger_path=DEFAULT_OUTPUT_PATH): @@ -73,7 +73,7 @@ def close(self): allure_commons.plugin_manager.unregister(name=name) -class Messages(object): +class Messages: def __init__(self): self._stack = [] diff --git a/allure-robotframework/src/listener/types.py b/allure-robotframework/src/listener/types.py index d8719712..84dfb794 100644 --- a/allure-robotframework/src/listener/types.py +++ b/allure-robotframework/src/listener/types.py @@ -1,4 +1,4 @@ -class RobotStatus(object): +class RobotStatus: FAILED = 'FAIL' PASSED = 'PASS' SKIPPED = 'SKIP' @@ -6,7 +6,7 @@ class RobotStatus(object): NOT_SET = 'NOT SET' -class RobotKeywordType(object): +class RobotKeywordType: SETUP = 'SETUP' TEARDOWN = 'TEARDOWN' KEYWORD = 'KEYWORD' @@ -15,7 +15,7 @@ class RobotKeywordType(object): FIXTURES = [SETUP, TEARDOWN] -class RobotLogLevel(object): +class RobotLogLevel: FAIL = 'FAIL' ERROR = 'ERROR' WARNING = 'WARN' diff --git a/allure-robotframework/src/listener/utils.py b/allure-robotframework/src/listener/utils.py index 52dfb824..18e6512a 100644 --- a/allure-robotframework/src/listener/utils.py +++ b/allure-robotframework/src/listener/utils.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from re import search from allure_commons.model2 import Status, Label, Parameter, Link from allure_commons.types import LabelType @@ -16,7 +15,12 @@ def get_allure_status(status): def get_allure_parameters(parameters): - return [Parameter(name="arg{}".format(i + 1), value=param) for i, param in enumerate(parameters)] + return [ + Parameter( + name=f"arg{i}", + value=param + ) for i, param in enumerate(parameters, 1) + ] def get_allure_suites(longname): @@ -53,19 +57,33 @@ def allure_links(attributes, prefix): tags = attributes.get('tags', ()) def is_link(link): - return link.startswith("{link}:".format(link=prefix)) - - def parse_link(link): - lnk_val = link.split(':', 1)[1] or 'unknown' - lnk_label = search(r'\[.+\]', lnk_val) - if lnk_label: - lnk_label = lnk_label.group(0) - lnk_val = lnk_val.strip(lnk_label) - lnk_label = lnk_label.strip('[]') - else: - lnk_label = lnk_val - - return {'name': lnk_label, 'value': lnk_val} - - return [Link(type=prefix, url=parse_link(tag).get('value'), name=parse_link(tag).get('name')) for tag in tags if - is_link(tag)] + return link.startswith(f"{prefix}:") + + return [ + _create_link_from_tag( + prefix, + tag + ) for tag in tags if is_link(tag) + ] + + +def _parse_link(link): + lnk_val = link.split(':', 1)[1] or 'unknown' + lnk_label = search(r'\[.+\]', lnk_val) + if lnk_label: + lnk_label = lnk_label.group(0) + lnk_val = lnk_val.strip(lnk_label) + lnk_label = lnk_label.strip('[]') + else: + lnk_label = lnk_val + + return {'name': lnk_label, 'value': lnk_val} + + +def _create_link_from_tag(prefix, link_tag): + parsed_link = _parse_link(link_tag) + return Link( + type=prefix, + url=parsed_link.get("value"), + name=parsed_link.get("name") + ) diff --git a/allure-robotframework/test/run_robot_library.py b/allure-robotframework/test/run_robot_library.py index 4b9f36f0..b23c3c2a 100644 --- a/allure-robotframework/test/run_robot_library.py +++ b/allure-robotframework/test/run_robot_library.py @@ -21,13 +21,9 @@ def run_robot_with_allure(*args, **kwargs): def run_robot(path, **kw): # ToDo: fix it (_core not works correctly with multiprocessing) - # import six # import allure_commons - # if six.PY2: - # reload(allure_commons._core) - # else: - # import importlib - # importlib.reload(allure_commons._core) + # import importlib + # importlib.reload(allure_commons._core) # # From 61f1197be92d5159f104586ac51031c4c24c81fb Mon Sep 17 00:00:00 2001 From: Maksim Stepanov <17935127+delatrie@users.noreply.github.com> Date: Mon, 28 Nov 2022 16:31:42 +0700 Subject: [PATCH 2/2] Fix styling errors. Remove six from remaining requirements files --- allure-pytest/src/utils.py | 1 + .../test/acceptance/label/tag/tag_test.py | 1 - .../status/base_teardown_status_test.py | 72 +++++++++++-------- .../status/skip_teardown_status_test.py | 29 ++++---- .../status/xfail_teardown_status_test.py | 33 +++++---- allure-python-commons-test/requirements.txt | 1 - allure-robotframework/requirements.txt | 1 - 7 files changed, 80 insertions(+), 58 deletions(-) diff --git a/allure-pytest/src/utils.py b/allure-pytest/src/utils.py index 4aafa7cf..146e37c6 100644 --- a/allure-pytest/src/utils.py +++ b/allure-pytest/src/utils.py @@ -78,6 +78,7 @@ def format_allure_link(config, url, link_type): pattern = dict(config.option.allure_link_pattern).get(link_type, '{}') return pattern.format(url) + def pytest_markers(item): for keyword in item.keywords.keys(): if any([keyword.startswith('allure_'), keyword == 'parametrize']): diff --git a/allure-pytest/test/acceptance/label/tag/tag_test.py b/allure-pytest/test/acceptance/label/tag/tag_test.py index a5bc7a47..0636e5cb 100644 --- a/allure-pytest/test/acceptance/label/tag/tag_test.py +++ b/allure-pytest/test/acceptance/label/tag/tag_test.py @@ -1,4 +1,3 @@ -from allure_commons.utils import represent from hamcrest import assert_that, not_ from allure_commons_test.report import has_test_case from allure_commons_test.label import has_tag diff --git a/allure-pytest/test/acceptance/status/base_teardown_status_test.py b/allure-pytest/test/acceptance/status/base_teardown_status_test.py index 0ae474da..683ff1de 100644 --- a/allure-pytest/test/acceptance/status/base_teardown_status_test.py +++ b/allure-pytest/test/acceptance/status/base_teardown_status_test.py @@ -22,22 +22,28 @@ def test_failed_finalizer_fixture(executed_docstring_source): ... pass """ - assert_that(executed_docstring_source.allure_report, - has_test_case("test_failed_finalizer_fixture_example", - with_status("failed"), - has_status_details(with_message_contains("AssertionError"), - with_trace_contains("def fixture_finalizer():") - ), - has_container(executed_docstring_source.allure_report, - has_after("failed_finalizer_fixture::fixture_finalizer", - with_status("failed"), - has_status_details(with_message_contains("AssertionError"), - with_trace_contains("fixture_finalizer") - ), - ), - ) - ) + assert_that( + executed_docstring_source.allure_report, + has_test_case( + "test_failed_finalizer_fixture_example", + with_status("failed"), + has_status_details( + with_message_contains("AssertionError"), + with_trace_contains("def fixture_finalizer():") + ), + has_container( + executed_docstring_source.allure_report, + has_after( + "failed_finalizer_fixture::fixture_finalizer", + with_status("failed"), + has_status_details( + with_message_contains("AssertionError"), + with_trace_contains("fixture_finalizer") + ) ) + ) + ) + ) def test_pytest_failed_finalizer_fixture(executed_docstring_source): @@ -54,19 +60,25 @@ def test_pytest_failed_finalizer_fixture(executed_docstring_source): ... pass """ - assert_that(executed_docstring_source.allure_report, - has_test_case("test_pytest_failed_finalizer_fixture_example", - with_status("failed"), - has_status_details(with_message_contains("Failed"), - with_trace_contains("def fixture_finalizer():") - ), - has_container(executed_docstring_source.allure_report, - has_after("pytest_failed_finalizer_fixture::fixture_finalizer", - with_status("failed"), - has_status_details(with_message_contains("Failed"), - with_trace_contains("fixture_finalizer") - ) - ) - ) - ) + assert_that( + executed_docstring_source.allure_report, + has_test_case( + "test_pytest_failed_finalizer_fixture_example", + with_status("failed"), + has_status_details( + with_message_contains("Failed"), + with_trace_contains("def fixture_finalizer():") + ), + has_container( + executed_docstring_source.allure_report, + has_after( + "pytest_failed_finalizer_fixture::fixture_finalizer", + with_status("failed"), + has_status_details( + with_message_contains("Failed"), + with_trace_contains("fixture_finalizer") + ) ) + ) + ) + ) diff --git a/allure-pytest/test/acceptance/status/skip_teardown_status_test.py b/allure-pytest/test/acceptance/status/skip_teardown_status_test.py index 0f8456e4..0ec758ce 100644 --- a/allure-pytest/test/acceptance/status/skip_teardown_status_test.py +++ b/allure-pytest/test/acceptance/status/skip_teardown_status_test.py @@ -22,16 +22,21 @@ def test_skip_finalizer_fixture(executed_docstring_source): ... pass """ - assert_that(executed_docstring_source.allure_report, - has_test_case("test_skip_finalizer_fixture_example", - with_status("passed"), - has_container(executed_docstring_source.allure_report, - has_after("skip_finalizer_fixture::fixture_finalizer", - with_status("skipped"), - has_status_details(with_message_contains("Skipped"), - with_trace_contains("fixture_finalizer") - ), - ), - ) - ) + assert_that( + executed_docstring_source.allure_report, + has_test_case( + "test_skip_finalizer_fixture_example", + with_status("passed"), + has_container( + executed_docstring_source.allure_report, + has_after( + "skip_finalizer_fixture::fixture_finalizer", + with_status("skipped"), + has_status_details( + with_message_contains("Skipped"), + with_trace_contains("fixture_finalizer") + ) ) + ) + ) + ) diff --git a/allure-pytest/test/acceptance/status/xfail_teardown_status_test.py b/allure-pytest/test/acceptance/status/xfail_teardown_status_test.py index e76bd282..0b295c06 100644 --- a/allure-pytest/test/acceptance/status/xfail_teardown_status_test.py +++ b/allure-pytest/test/acceptance/status/xfail_teardown_status_test.py @@ -23,17 +23,24 @@ def test_xfail_failed_finalizer_fixture(executed_docstring_source): ... pass """ - assert_that(executed_docstring_source.allure_report, - has_test_case("test_xfail_failed_finalizer_fixture_example", - with_status("passed"), - has_status_details(with_message_contains("XPASS")), - has_container(executed_docstring_source.allure_report, - has_after("failed_finalizer_fixture::fixture_finalizer", - with_status("failed"), - has_status_details(with_message_contains("AssertionError"), - with_trace_contains("fixture_finalizer") - ), - ), - ) - ) + assert_that( + executed_docstring_source.allure_report, + has_test_case( + "test_xfail_failed_finalizer_fixture_example", + with_status("passed"), + has_status_details( + with_message_contains("XPASS") + ), + has_container( + executed_docstring_source.allure_report, + has_after( + "failed_finalizer_fixture::fixture_finalizer", + with_status("failed"), + has_status_details( + with_message_contains("AssertionError"), + with_trace_contains("fixture_finalizer") + ) ) + ) + ) + ) diff --git a/allure-python-commons-test/requirements.txt b/allure-python-commons-test/requirements.txt index cb4a9082..3143fd20 100644 --- a/allure-python-commons-test/requirements.txt +++ b/allure-python-commons-test/requirements.txt @@ -1,6 +1,5 @@ # test requrements pyhamcrest -six poethepoet # linters flake8==5.* diff --git a/allure-robotframework/requirements.txt b/allure-robotframework/requirements.txt index 31a7cf15..b1f04c31 100644 --- a/allure-robotframework/requirements.txt +++ b/allure-robotframework/requirements.txt @@ -2,7 +2,6 @@ robotframework-pabot docutils pyhamcrest -six poethepoet # linters flake8==5.*