For an application I'm testing I'd like to create an autouse=True
fixture which monkeypatches smtplib.SMTP.connect
to fail tests if they try to send an email unexpectedly.
However, in cases where I do expect tests to send emails, I want to use a different fixture logging those emails instead (most likely by using the smtpserver
fixture from pytest-localserver
and monkeypatching the connect
method to use the host/port returned by that fixture)
Of course that can only work if the autouse fixture is executed before the other fixture (loaded as funcarg). Is there any specific order in which fixtures are executed and/or is there a way to guarantee the execution order?
question from:
https://stackoverflow.com/questions/25660064/in-which-order-are-pytest-fixtures-executed 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…