[allure-behave] Steps from tag-excluded scenarios bleed into the next matching scenario's result when hide_excluded=true
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Idoneità per principianti
- 84/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Tranquilla
- Stack tecnologico
- python
- Ambito
- testing-qa
Direzione di ricerca
Inizia in listener.py, in AllureListener.stop_scenario(), dove gli scenari esclusi vengono scartati, e riproduci il problema con il comando behave fornito usando hide_excluded=true. Ispeziona i file allure-results/*-result.json generati; il lavoro è completato quando il risultato di uno scenario corrispondente contiene solo i propri step, senza step provenienti da scenari precedenti esclusi dai tag.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Environment
- allure-behave: 2.15.3
- allure-commons: (run
pip show allure-commons) - behave: 1.3.3
- Python: 3.12
Describe the Bug
When running behave with a tag filter (e.g. -t ETS-TC-372) and
-D AllureFormatter.hide_excluded=true, the Allure result JSON for the
matching scenario accumulates steps from all tag-excluded scenarios that
appeared before it in the same feature file.
For example: if Sample.feature has 12 scenarios before ETS-TC-372, and
those 12 scenarios collectively have 179 steps, the result JSON for ETS-TC-372
shows 227 steps (179 orphaned + 48 real) instead of 48.
Root Cause
Behave calls formatter.step(step) for every scenario — including
tag-excluded ones — because show_skipped=True by default
(run_scenario or show_skipped in Scenario.run()).
This schedules excluded scenario steps into AllureListener.self.steps (a
deque).
In stop_scenario(), excluded scenarios hit the should_drop_excluded=True
branch and call self.logger.drop_test(uuid) immediately, without ever
calling flush_steps() or clearing the deque. All accumulated steps remain
in the deque.
When the first matching scenario runs, its steps are appended to the
already-populated deque. match_step() pops from the front (FIFO), consuming
the orphaned steps and stamping them into the matching scenario's TestResult.
Reproduction Steps
- Create a feature file with 5+ scenarios where only the last one has
@target-tag. - Run:
behave -t target-tag my.feature \ --format allure_behave.formatter:AllureFormatter \ --outfile allure-results \ -D AllureFormatter.hide_excluded=true - Inspect allure-results/*-result.json — the step count will be
(sum of all excluded scenario steps) + (target scenario steps).
Expected Behaviour
The result JSON for the matching scenario should contain only its own
steps.
Fix
In AllureListener.stop_scenario(), clear the deque before dropping the
test so orphaned steps do not leak into the next scenario:
listener.py — stop_scenario()
if should_drop_skipped_by_option or should_drop_excluded:
self.steps.clear() # ← add this line
self.logger.drop_test(self.current_scenario_uuid)
This one-line fix prevents accumulated steps from tag-excluded scenarios
bleeding into any subsequent scenario's result.
- Lingua principale
- Python
- Stelle
- 819
- Fork
- 261
- Merge medio
- 3h 20m
- PR unite (30g)
- 3
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di allure-framework/allure-python
-
theme:pytest
Difficoltà 3/5 1-2 giorni Idoneità per principianti 64/100
allure-framework/allure-python#929 · 1 reazione ·
-
Added CategoriesAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
-
Phantom <lambda> teardown entries with unknown status when using pytest 9.1+Forse già presa @Mohanad49 l’ha presa 52 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
allure-framework/allure-python#918 · 1 reazione ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
allure-framework/allure-python#903 · 1 commento ·
-
Allure step placeholder fails when accessing dataclass attribute `data.name`Forse già presa @golikovichev l’ha presa 157 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
Tutte le issue di allure-framework/allure-python
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
rpm-software-management/mock#1824 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
jpata/particleflow#520 ·
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue hacktoberfest
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
gridhead/gi-loadouts#699 ·
I maintainer di solito rispondono entro 13 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
FinanceFlash/unvibecode#206 ·
I maintainer di solito rispondono entro 1 giorno