Skip to content

Fix title formatting when fixture fails setup (fixes #873) - #939

Open
udayraj1238 wants to merge 1 commit into
allure-framework:masterfrom
udayraj1238:fix-pytest-title-formatting-failed-fixture
Open

udayraj1238 wants to merge 1 commit into
allure-framework:masterfrom
udayraj1238:fix-pytest-title-formatting-failed-fixture

Conversation

@udayraj1238

Copy link
Copy Markdown

Context

Fixes #873

When a parametrized fixture fails or is skipped during test setup, pytest retains the raw parameter in item.callspec.params (e.g. primitive 1), but item.funcargs is not populated with the fixture instance. When @allure.title formats a field accessing fixture attributes (e.g. {fix.attribute}), SafeFormatter().format() in allure_name() attempted attribute access on the raw parameter and raised AttributeError: 'int' object has no attribute 'attribute'.

This escaped allure_name() during pytest_runtest_setup, raising an unhandled exception that broke test execution and shadowed the actual fixture error or skip.

Changes

  • Safely catch (AttributeError, IndexError, TypeError) during title string formatting in allure_name(), returning the title template string instead of aborting test setup.
  • Add acceptance regression test test_failed_parametrized_fixture_attribute_in_display_name in tests/allure_pytest/acceptance/display_name/display_name_test.py verifying that skipped or failed parametrized fixtures with attribute access in @allure.title retain the expected title without crashing test setup.

Checklist

…p fails (fixes allure-framework#873)

Signed-off-by: udayraj1238 <rajuday6002@gmail.com>
@CLAassistant

CLAassistant commented Nov 22, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Attribute error in @allure.title when using @pytest.fixture(params=[...]

2 participants