René's URL Explorer Experiment


Title: KeyError in allure_pytest when running pytest.main() from inside a test (nested pytest run) · Issue #881 · allure-framework/allure-python · GitHub

Open Graph Title: KeyError in allure_pytest when running pytest.main() from inside a test (nested pytest run) · Issue #881 · allure-framework/allure-python

X Title: KeyError in allure_pytest when running pytest.main() from inside a test (nested pytest run) · Issue #881 · allure-framework/allure-python

Description: Running a nested pytest session (subsession) from within a test using pytest.main() causes allure to fail during teardown in subsession with a KeyError in allure_commons/reporter.py. The inner test passes, but allure raises an exception,...

Open Graph Description: Running a nested pytest session (subsession) from within a test using pytest.main() causes allure to fail during teardown in subsession with a KeyError in allure_commons/reporter.py. The inner test...

X Description: Running a nested pytest session (subsession) from within a test using pytest.main() causes allure to fail during teardown in subsession with a KeyError in allure_commons/reporter.py. The inner test...

Opengraph URL: https://github.com/allure-framework/allure-python/issues/881

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"KeyError in allure_pytest when running pytest.main() from inside a test (nested pytest run)","articleBody":"Running a nested pytest session (subsession) from within a test using `pytest.main()` causes `allure` to fail during teardown in subsession with a `KeyError` in `allure_commons/reporter.py`.\nThe inner test passes, but `allure` raises an exception, causing the overall main test to fail.\n\nThe issue reproduces **only** when both main and sub sessions use allure (for example, via configuration (`pytest.ini` or `pyproject.toml`) and the subsession runs teardown fixtures.\n\nThe report shows the subtest as broken and duplicates teardown fixtures for it - one fixture has `passed` state, and the duplicate has `unknown` state. \n\n| simple_fixture::0 | Unknown |\n|-|-|\n| simple_fixture::0 | 0s|\n\nOverriding `alluredir` doesn't help - allure report for main session always contains both tests, allure report for subsession - only its test.\n\nSteps to reproduce:\n1. Set pytest ini options (I'm using `pyproject.toml`)\n```toml\n[tool.pytest.ini_options]\naddopts = [\n    \"-v\",\n    \"--alluredir\", \"allure-results\",\n]\n```\n2. Create test file\n\n```python\nfrom pathlib import Path\n\nimport pytest\n\n\ndef test_parent():\n    args: list[str] = [\n        f\"{Path(__file__)}::test_child\",\n    ]\n    result = pytest.main(args)\n    assert not result\n\n\n@pytest.fixture()\ndef simple_fixture():\n    yield 2\n\n\ndef test_child(simple_fixture):\n    assert simple_fixture == 2\n\n```\n3. Run the command\n```bash\npytest test/test_parent.py::test_parent\n```\n\nActual result:\n```log\n❯ poetry run pytest test/test_parent.py::test_parent\n======================================== test session starts =========================================\nplatform darwin -- Python 3.13.5, pytest-8.4.0, pluggy-1.6.0 -- /example_dir/Library/Caches/pypoetry/virtualenvs/tests_repo-CJ2ygyH8-py3.13/bin/python\ncachedir: .pytest_cache\nrootdir: /example_dir/tests_repo\nconfigfile: pyproject.toml\nplugins: allure-pytest-2.14.2, xdist-3.7.0, instafail-0.5.0, anyio-4.9.0, timeout-2.4.0, check-2.5.3, mock-3.14.1, cov-6.1.1\ncollected 1 item\n\ntest/test_parent.py::test_parent FAILED                                                        [100%]\n\n============================================== FAILURES ==============================================\n____________________________________________ test_parent _____________________________________________\n\n    def test_parent():\n        args: list[str] = [\n            \"-s\",\n            f\"{Path(__file__)}::test_child\",\n        ]\n        result = pytest.main(args)\n\u003e       assert not result\nE       assert not \u003cExitCode.TESTS_FAILED: 1\u003e\n\ntest/test_parent.py:12: AssertionError\n---------------------------------------- Captured stdout call ----------------------------------------\n============================= test session starts ==============================\nplatform darwin -- Python 3.13.5, pytest-8.4.0, pluggy-1.6.0 -- /example_dir/Library/Caches/pypoetry/virtualenvs/tests_repo-CJ2ygyH8-py3.13/bin/python\ncachedir: .pytest_cache\nrootdir: /example_dir/tests_repo\nconfigfile: pyproject.toml\nplugins: allure-pytest-2.14.2, xdist-3.7.0, instafail-0.5.0, anyio-4.9.0, timeout-2.4.0, check-2.5.3, mock-3.14.1, cov-6.1.1\ncollecting ... collected 1 item\n\ntest/test_parent.py::test_child PASSED\ntest/test_parent.py::test_child ERROR\n\n==================================== ERRORS ====================================\n_______________________ ERROR at teardown of test_child ________________________\n\nself = \u003callure_commons._allure.fixture object at 0x1027574d0\u003e, args = ()\nkwargs = {}\n\n    def __call__(self, *args, **kwargs):\n        self.parameters = func_parameters(self._fixture_function, *args, **kwargs)\n\n\u003e       with self:\n             ^^^^\n\n../../Library/Caches/pypoetry/virtualenvs/tests_repo-CJ2ygyH8-py3.13/lib/python3.13/site-packages/allure_commons/_allure.py:230:\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\n../../Library/Caches/pypoetry/virtualenvs/tests_repo-CJ2ygyH8-py3.13/lib/python3.13/site-packages/allure_commons/_allure.py:240: in __exit__\n    plugin_manager.hook.stop_fixture(parent_uuid=self._parent_uuid,\n../../Library/Caches/pypoetry/virtualenvs/tests_repo-CJ2ygyH8-py3.13/lib/python3.13/site-packages/allure_pytest/listener.py:66: in stop_fixture\n    self.allure_logger.stop_after_fixture(uuid,\n../../Library/Caches/pypoetry/virtualenvs/tests_repo-CJ2ygyH8-py3.13/lib/python3.13/site-packages/allure_commons/reporter.py:109: in stop_after_fixture\n    self._update_item(uuid, **kwargs)\n../../Library/Caches/pypoetry/virtualenvs/tests_repo-CJ2ygyH8-py3.13/lib/python3.13/site-packages/allure_commons/reporter.py:62: in _update_item\n    item = self._items[uuid] if uuid else self._items[next(reversed(self._items))]\n           ^^^^^^^^^^^^^^^^^\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\n\nself = \u003callure_commons.reporter.ThreadContextItems object at 0x10264b4d0\u003e\nitem = '5073499a-d95d-40a6-a635-36507b26b451'\n\n    def __getitem__(self, item):\n\u003e       return self.thread_context.__getitem__(item)\n               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nE       KeyError: '5073499a-d95d-40a6-a635-36507b26b451'\n\n../../Library/Caches/pypoetry/virtualenvs/tests_repo-CJ2ygyH8-py3.13/lib/python3.13/site-packages/allure_commons/reporter.py:33: KeyError\n=========================== short test summary info ============================\nERROR test/test_parent.py::test_child - KeyError: '5073499a-d95d-40a6-a635-36...\n========================== 1 passed, 1 error in 0.05s ==========================\n====================================== short test summary info =======================================\nFAILED test/test_parent.py::test_parent - assert not \u003cExitCode.TESTS_FAILED: 1\u003e\n========================================= 1 failed in 0.14s ==========================================\n```","author":{"url":"https://github.com/sashko1988","@type":"Person","name":"sashko1988"},"datePublished":"2025-10-09T16:15:30.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/881/allure-python/issues/881"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:6ad319de-6352-62a5-39b4-0a9d0ae2791d
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE0AC:A9627:56C651:792492:696E5AFC
html-safe-nonce2fe2eeb0ec1d3bdb3233d5798624a8f33484590c7cb3d36240f32eb69b7a836d
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMEFDOkE5NjI3OjU2QzY1MTo3OTI0OTI6Njk2RTVBRkMiLCJ2aXNpdG9yX2lkIjoiMjA2NDU3MDI2Mzg5NzI2Njk0MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac29a89bdb7a1fc4bd9fa3ee5fd7f306f56ceb1674c983d5da10e45c44234d25dc
hovercard-subject-tagissue:3499798480
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/allure-framework/allure-python/881/issue_layout
twitter:imagehttps://opengraph.githubassets.com/e9a59b88a1ab3ad8bcc117809238a1ebfd07a7f9814f669c837a3440b6968657/allure-framework/allure-python/issues/881
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/e9a59b88a1ab3ad8bcc117809238a1ebfd07a7f9814f669c837a3440b6968657/allure-framework/allure-python/issues/881
og:image:altRunning a nested pytest session (subsession) from within a test using pytest.main() causes allure to fail during teardown in subsession with a KeyError in allure_commons/reporter.py. The inner test...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesashko1988
hostnamegithub.com
expected-hostnamegithub.com
Nonef68b42d371252b0f236260d6234f4304a806fe5ac43d59faa21fb59d80df103b
turbo-cache-controlno-preview
go-importgithub.com/allure-framework/allure-python git https://github.com/allure-framework/allure-python.git
octolytics-dimension-user_id5879127
octolytics-dimension-user_loginallure-framework
octolytics-dimension-repository_id79346720
octolytics-dimension-repository_nwoallure-framework/allure-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id79346720
octolytics-dimension-repository_network_root_nwoallure-framework/allure-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release6b74bc8dbcd10b5d69fd9ee9d2cfdc8b35e18a4c
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/allure-framework/allure-python/issues/881#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fallure-framework%2Fallure-python%2Fissues%2F881
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fallure-framework%2Fallure-python%2Fissues%2F881
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=allure-framework%2Fallure-python
Reloadhttps://patch-diff.githubusercontent.com/allure-framework/allure-python/issues/881
Reloadhttps://patch-diff.githubusercontent.com/allure-framework/allure-python/issues/881
Reloadhttps://patch-diff.githubusercontent.com/allure-framework/allure-python/issues/881
allure-framework https://patch-diff.githubusercontent.com/allure-framework
allure-pythonhttps://patch-diff.githubusercontent.com/allure-framework/allure-python
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fallure-framework%2Fallure-python
Fork 256 https://patch-diff.githubusercontent.com/login?return_to=%2Fallure-framework%2Fallure-python
Star 789 https://patch-diff.githubusercontent.com/login?return_to=%2Fallure-framework%2Fallure-python
Code https://patch-diff.githubusercontent.com/allure-framework/allure-python
Issues 95 https://patch-diff.githubusercontent.com/allure-framework/allure-python/issues
Pull requests 20 https://patch-diff.githubusercontent.com/allure-framework/allure-python/pulls
Actions https://patch-diff.githubusercontent.com/allure-framework/allure-python/actions
Security Uh oh! There was an error while loading. Please reload this page. https://patch-diff.githubusercontent.com/allure-framework/allure-python/security
Please reload this pagehttps://patch-diff.githubusercontent.com/allure-framework/allure-python/issues/881
Insights https://patch-diff.githubusercontent.com/allure-framework/allure-python/pulse
Code https://patch-diff.githubusercontent.com/allure-framework/allure-python
Issues https://patch-diff.githubusercontent.com/allure-framework/allure-python/issues
Pull requests https://patch-diff.githubusercontent.com/allure-framework/allure-python/pulls
Actions https://patch-diff.githubusercontent.com/allure-framework/allure-python/actions
Security https://patch-diff.githubusercontent.com/allure-framework/allure-python/security
Insights https://patch-diff.githubusercontent.com/allure-framework/allure-python/pulse
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/allure-framework/allure-python/issues/881
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/allure-framework/allure-python/issues/881
KeyError in allure_pytest when running pytest.main() from inside a test (nested pytest run)https://patch-diff.githubusercontent.com/allure-framework/allure-python/issues/881#top
theme:pytesthttps://github.com/allure-framework/allure-python/issues?q=state%3Aopen%20label%3A%22theme%3Apytest%22
https://github.com/sashko1988
https://github.com/sashko1988
sashko1988https://github.com/sashko1988
on Oct 9, 2025https://github.com/allure-framework/allure-python/issues/881#issue-3499798480
theme:pytesthttps://github.com/allure-framework/allure-python/issues?q=state%3Aopen%20label%3A%22theme%3Apytest%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.