-
Notifications
You must be signed in to change notification settings - Fork 23
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
tests: centralize FakeKojiSession definition #145
Comments
I don't think I want to do this anymore. Instead I would probably focus on making the canonical Koji Hub code more reusable somehow. |
After developing more koji-ansible features, which required writing even more improvements to As we add more advanced features, the pytest suite also become more advanced. Here are my recent thoughts: The simplest way to unit test new code is to pass in simple When Problems I've seen with
|
Every unit test has its own
FakeKojiSession
class, and its own "session" pytest fixture method. Each unit test file'sFakeKojiSession
class implements just enough of the Koji Hub API to pass the tests, but there is quite a bit of copy-and-paste here.I think we've reached the point where we could centralize this into
tests/conftest.py
. We could define a singleFakeKojiSession
class and implement all the Koji Hub logic that we need into that class. A single "session" pytest fixture method could just return an instance of this class, and then all the unit test files can use this central fixture.This would make our FakeKojiSession more complex, but we're at the point where there is considerable complexity already when we have to re-implement so much of the Hub's logic anyway. I think it would make it easier to get to full test coverage if we had a single large fixture. (I also wonder if we could extract this fixture into a completely standalone pytest plugin, for other Python projects that might want to fake calls to Koji).
The text was updated successfully, but these errors were encountered: