Title: allure-behave: extend scenario_history_id to use optional environment variable · Issue #880 · allure-framework/allure-python · GitHub
Open Graph Title: allure-behave: extend scenario_history_id to use optional environment variable · Issue #880 · allure-framework/allure-python
X Title: allure-behave: extend scenario_history_id to use optional environment variable · Issue #880 · allure-framework/allure-python
Description: Context allure-behave: extend scenario_history_id to use optional environment variable We have a problem where we want to run the same test-suite in different environments. For example: Execute Test-Suite for Different Browser: Firefox, ...
Open Graph Description: Context allure-behave: extend scenario_history_id to use optional environment variable We have a problem where we want to run the same test-suite in different environments. For example: Execute Tes...
X Description: Context allure-behave: extend scenario_history_id to use optional environment variable We have a problem where we want to run the same test-suite in different environments. For example: Execute Tes...
Opengraph URL: https://github.com/allure-framework/allure-python/issues/880
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"allure-behave: extend scenario_history_id to use optional environment variable","articleBody":"\u003c!---\nThank you so much for sending us a pull request! \n\nMake sure you have a clear name for your pull request. \nThe name should start with a capital letter and no dot is required in the end of the sentence.\nTo link the request with issues use the following notation: (fixes #123, fixes #321\\)\n\nAn example of good pull request names:\n* Add Cucumber integration (fixes #123\\)\n* Add an ability to disable default plugins\n* Support emoji in test descriptions\n--\u003e\n\n### Context\n\u003c!---\nDescribe the problem or feature in addition to a link to the issues\n--\u003e\n\n# allure-behave: extend scenario_history_id to use optional environment variable\n\nWe have a problem where we want to run the same test-suite in different environments. For example:\n\n1. **Execute Test-Suite for Different Browser:** Firefox, Chrome, ... (i.e. 'BROWSER=firefox behave' 'BROWSER=chromium behave' etc.)\n2. **Execute Test-Suite for Different Systems:** Linux armx64, Linux amd64, Win amd64, ...\n\nIf we collect all JSON allure-results and generate an allure report we only see **one** result for each test-scenario. Other executions are shown only in the \"retries\" section. We need to change the history ID so that each execution appears as a separate test. \n\nWe want to solve this by adding additional information into the historyId. It would have been nice to use additional user-modifiable information from the Scenario object, but this is not possible since scenario_history_id() is called before the before_scenario() hook (environment.py). Therefore not action in the before_scenario hook function (like changing scenario name or adding other information, can impact the historyId. \n\nThus, we designed a solution that uses an environment variable to pass this information. Our proposal is to the set an environment variable in `environment.py` that is used to influence the `historyId`.\n\nIn `allure-python/allure-behave/src/utils.py`:\n\n```python\ndef scenario_history_id(scenario) -\u003e str:\n \"\"\"\n Create a historyId for a scenario.\n - Always based on feature name and scenario name\n - Optional: can append a value from an environment variable\n \"\"\"\n parts = [scenario.feature.name, scenario.name]\n\n if hasattr(scenario, \"_row\") and scenario._row:\n row = scenario._row\n parts.extend([f\"{name}={value}\" for name, value in zip(row.headings, row.cells)])\n\n # Optional: append environment variable to differentiate runs\n history_id = os.getenv(\"ALLURE_HISTORY_ID\")\n if history_id:\n parts.append(history_id)\n\n return md5(*parts)\n```\n\nTo use this feature, add the environment variable in `environment.py`:\n\n```python\nfrom enum import Enum\nimport os\n\nclass Option(str, Enum):\n OPTION_A = \"Option A\"\n OPTION_B = \"Option B\"\n\ndef before_all(context):\n os.environ[\"ALLURE_HISTORY_ID\"] = Option.OPTION_B.name\n```\n\nPull Request: #879 ","author":{"url":"https://github.com/Monstertoaster","@type":"Person","name":"Monstertoaster"},"datePublished":"2025-10-08T13:47:46.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/880/allure-python/issues/880"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3a0cfd86-3cf5-8cea-eb10-7712b5c139e0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DC1C:2A1D2C:E40B1C:1319D66:6970256D |
| html-safe-nonce | 0d276612d2149bc3c893fca822b606a0fe630977985ce32a7a5556709c19bca9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQzFDOjJBMUQyQzpFNDBCMUM6MTMxOUQ2Njo2OTcwMjU2RCIsInZpc2l0b3JfaWQiOiI1MzE5ODcwMzY1NzQ2MzQxMjMwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 669061bd5fac633eb548c403ed61cc8b38d91f464fa0c2e1b745156a4d7ce0a9 |
| hovercard-subject-tag | issue:3495527934 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/allure-framework/allure-python/880/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4d10f84824f7787f99e24001d5729a36f8b43a95f0f52425f2b63dd537724ada/allure-framework/allure-python/issues/880 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4d10f84824f7787f99e24001d5729a36f8b43a95f0f52425f2b63dd537724ada/allure-framework/allure-python/issues/880 |
| og:image:alt | Context allure-behave: extend scenario_history_id to use optional environment variable We have a problem where we want to run the same test-suite in different environments. For example: Execute Tes... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Monstertoaster |
| hostname | github.com |
| expected-hostname | github.com |
| None | 26d344b5c41e8171f05f1b33de4ed89a222e01250099adfcd988bb0e02fd1cbb |
| turbo-cache-control | no-preview |
| go-import | github.com/allure-framework/allure-python git https://github.com/allure-framework/allure-python.git |
| octolytics-dimension-user_id | 5879127 |
| octolytics-dimension-user_login | allure-framework |
| octolytics-dimension-repository_id | 79346720 |
| octolytics-dimension-repository_nwo | allure-framework/allure-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 79346720 |
| octolytics-dimension-repository_network_root_nwo | allure-framework/allure-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9f0c240136b4f91bdb92e57a88ba5dc425cbdb12 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width