Errors in setUp can lead to misleading error messaging
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Python Fixtures |
Fix Released
|
Low
|
Robert Collins |
Bug Description
It is possible to create a fixture that is hard to debug by overriding Fixture.setUp and not calling it *first* in the subclass' setUp implementation. The fixture instance is not in a usable state until after the parent setUp is called so any errors that happen before that are lost.
Example code:
class MyFixture(
def setUp(self):
# do stuff that would raise an exception
raise Exception
Error message:
===
ERROR: test_test.
---
_StringExce
File "/tmp/testit/
File "/usr/local/
File "/usr/local/
result = dict(self._details)
AttributeError: 'MyFixture' object has no attribute '_details'
I didn't see this explicitly documented so it took me a little while to find the source of my errors. I think this would either be documented or possibly have Fixture.
This is a pure documentation issue IMO - doing it in __init__ would prevent fixture reuse.