Description
pytest fixtures have a fairly specific use case, and it isn't clear to me that we are using them as intended.
The two main cases as I understand them are a) constructing something that is somewhat expensive and you would like to reuse, as you would with setup_class
and b) lists of test cases that you want to write in one place instead of many. Am I missing anything major here?
Many of our fixtures don't fall into these categories: datetime_tz_utc
is a singleton used exactly once, tdser
just returns pd.Series(['59 Days', '59 Days', 'NaT'], dtype='timedelta64[ns]')
, float_frame
just returns DataFrame(tm.getSeriesData())
, ...
The cost of overusing fixtures includes
- lock-in
- transparency: I can't look at a test and know what's being tested without looking at conftest
- inability to run tests as stand-alone code when troubleshooting
I think at the very least we should avoid singleton fixtures, and many others can just be invoked directly from pd.util.testing instead of through fixtures.
Thoughts?