You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the expectations are checked that they are all used upon destruction of the mocked object. However, pytest will ignore any exception thrown by a destructor. This leaves a traceback in the pytest output about "Ignored exception" when some exceptions were not used.
Possible solutions
let unused expectations go unchecked
pros
cons
The done() method can be called from the test code
This may cause a deviation from expected behavior
assert that done() is called upon destruction
pros
cons
This serves as reminder to update the test code
This seems to have poor behavior with the monkey_patch_sys_paths fixture because it is set to autouse=True (see also move pytest fixture into submodule #9 )
Additional context
Because pytest manages setup and tear-down as an internal implementation detail, this is destructor approach is rather undesirable.
Currently, the expectations are checked that they are all used upon destruction of the mocked object. However, pytest will ignore any exception thrown by a destructor. This leaves a traceback in the pytest output about "Ignored exception" when some exceptions were not used.
Possible solutions
let unused expectations go unchecked
done()method can be called from the test codeassert that
done()is called upon destructionmonkey_patch_sys_pathsfixture because it is set toautouse=True(see also move pytest fixture into submodule #9 )Additional context
Because pytest manages setup and tear-down as an internal implementation detail, this is destructor approach is rather undesirable.