Sto cercando un modo per eseguire tutti i miei test di unità in PyTest, anche se alcuni di essi falliscono. So che ci deve essere un modo semplice per farlo. Ho controllato le opzioni CLi e ho guardato attraverso questo sito per domande/risposte simili ma non ho visto nulla. Scusate se è già stata data una risposta.Come eseguire tutti i test PyTest anche se alcuni di essi falliscono?
Ad esempio, si consideri il seguente frammento di codice, con il codice di PyTest accanto ad esso:
def parrot(i):
return i
def test_parrot():
assert parrot(0) == 0
assert parrot(1) == 1
assert parrot(2) == 1
assert parrot(2) == 2
Per impostazione predefinita, l'esecuzione si ferma al primo fallimento:
$ python -m pytest fail_me.py
=================== test session starts ===================
platform linux2 -- Python 2.7.10, pytest-2.9.1, py-1.4.31, pluggy-0.3.1
rootdir: /home/npsrt/Documents/repo/codewars, inifile:
collected 1 items
fail_me.py F
=================== FAILURES ===================
___________________ test_parrot ___________________
def test_parrot():
assert parrot(0) == 0
assert parrot(1) == 1
> assert parrot(2) == 1
E assert 2 == 1
E + where 2 = parrot(2)
fail_me.py:7: AssertionError
=================== 1 failed in 0.05 seconds ===================
Quello che vorrei fare è che il codice continui ad essere eseguito anche dopo che PyTest riscontra il primo errore.
Vedi anche [questa domanda] (https://stackoverflow.com/q/4732827/102441) per 'unittest', che è collegato a un gruppo di domande molto simili – Eric