-
Notifications
You must be signed in to change notification settings - Fork 1.5k
TST: Set up reusable pytest fixtures #3604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Thanks for the PR. Please discuss such changes first, instead of starting with a PR directly. For me, it is not obvious what the advantage of pytest fixtures is over moving the directory logic to |
|
some advantages:
i didn't push it too far here because i didn't know if you guys would be interested in this change, but tbh it feels like these fixtures would be the least of your problems if you wanted to use a tool other than but if you're not interested in the change feel free to close the PR. |
|
Having utility functions in
I currently do not have any plans to change this, but apart from the fact that fixtures do not require explicit imports, I do not really see any benefits of fixtures over an universal centralized regular Python solution. |
the advantages are not huge but they are real. in general pytest likes it when you use fixtures so there are some nice things you can do. for instance
there's more stuff than that, but those are things i have found particularly useful in other contexts. either way test suites are usually neglected and i'm offering to help bring some order to the chaos, but if you're ideologically opposed to doing reusable test data the way pytest is designed to do reusable test data, then i'm sure someone else will be happy to do the test suite in the nonstandard/bespoke way you describe. |
I noticed that every test file was redefining path variables and a lot of the tests were working with the same sample PDFs so I did something to make the tests more in line with how
pytestis designed to work. (I looked around in the issues and documentation to see if there was some reason things weren't done this way and didn't see anything).Also theoretically with clever use of
scope=in the@pytest.fixture()calls you could theoretically speed up the tests a tiny bit because there would be less object creation though I didn't attempt to do that because a) gains are likely to be small (how much time does it take to setup aPdfReader?) and b) it's a bit fraught as far as the state of the fixture objects.