Attribute error in @allure.title when using @pytest.fixture(params=[...]
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Inizia dal percorso di formattazione di @allure.title e da allure_commons.utils.SafeFormatter.get_field mostrati nel traceback; confrontali con il comportamento descritto in #670. Riproduci i casi di skip ed errore di una fixture parametrizzata, quindi verifica che venga segnalato lo skip originale di pytest o ValueError invece di AttributeError.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
@allure.title decorator doesn't correctly formats a title string when using a parametrized fixture and having that fixture skip a test or raise an error:
import pytest
import allure
class TestClass:
@pytest.fixture(params=[1, 2]) # <-- causes AttributeError: 'int' object has no attribute 'one'
# @pytest.fixture()
def params(self):
# will cause AttributeError in allure.title
# if this fixture is skipping tests
pytest.skip('skip')
# or raising an error
raise ValueError('aa')
class _Params:
"""some params every test needs"""
one = 1
two = 2
# but no error if it returns a value
return _Params()
@allure.title('should display "1" {params.one}')
def test_func(self, params): # <-- causes AttributeError: 'int' object has no attribute 'one'
assert params.one == 1
self = <allure_commons.utils.SafeFormatter object at 0x7f1851ab19d0>, field_name = 'params.one', args = (), kwargs = {'param_id': '2', 'params': 2}
def get_field(self, field_name, args, kwargs):
first, rest = _string.formatter_field_name_split(field_name)
obj = self.get_value(first, args, kwargs)
# loop through the rest of the field_name, doing
# getattr or getitem as needed
for is_attr, i in rest:
if is_attr:
> obj = getattr(obj, i)
^^^^^^^^^^^^^^^
E AttributeError: 'int' object has no attribute 'one'
/usr/lib64/python3.12/string.py:305: AttributeError
=================================================================== short test summary info ====================================================================
ERROR p.py::TestClass::test_func[1] - AttributeError: 'int' object has no attribute 'one'
ERROR p.py::TestClass::test_func[2] - AttributeError: 'int' object has no attribute 'one'
====================================================================== 2 errors in 0.14s =======================================================================
This is shadowing the real error or skip in the fixture and is similar to #670
allure-pytest==2.15.0
pytest==8.4.1
- Lingua principale
- Python
- Stelle
- 817
- Fork
- 262
- 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
-
[allure-behave] Steps from tag-excluded scenarios bleed into the next matching scenario's result when hide_excluded=trueForse già presa @liuyaohui666 l’ha presa 46 giorni fa. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
-
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 50 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 155 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 83/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
FuRongJun-1999/dsh-memory#65 ·
I maintainer di solito rispondono entro 1 giorno
-
ci needs-ac
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Ikalus1988/MisakaNet#2930 ·
I maintainer di solito rispondono entro 1 giorno
-
`FakeBackendV2.run` fails with `NoiseError` on circuits with delays on qubits where T2 > 2·T1Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Qiskit/qiskit-aer#2466 ·
-
area/cli
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100