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
Fix issue with mro in zodb #19
Conversation
Layers don't have to be classes. They're objects with a
|
I fear it must be both classes and mro |
I have reviewed code and docs a bit more. zope.testrunner keeps it simple for itself. |
zope.testrunner's documentation says "Layers are generally implemented as classes using class methods" (emphasis mine), which can be read to imply that they don't have to be. Martin Aspeli describes some downsides of using classes themselves as test layers in this email from 2010. Some market research:
In short, I don't think zope.testrunner can afford to drop support of object instances as test layers (or require that everyone go implement a I suggest that reimplementing the MRO algorithm inside zope.testrunner to compute the MRO from |
Just for the record, I volunteered too. For reverting 4.4.5... |
Oh my, this is a can of worms. I'm now worrying about the implications of zope.testrunner not using the C3 MRO algorithm when running layer setup. (AFAICS the optimal layer ordering solution that minimizes the total number of layer setUp/tearDown calls is NP-hard.) |
#20 is my attempt to fix this by moving forwards rather than backwards. Review would be appreciated! |
Fixed by #20. |
Commit 3a68ee9 improved layer sorting but accidentally dropped support for instance-based layers. These turn out to be rather widely used (in ZODB, in zope.app.testing, in plone.testing etc). This change fixes the above problem in a different way from PR #6: it replacing inspect.getmro(layer) with a recursive sort key computation that traverses layer.__bases__. It doesn't actually use the C3 algorithm for MRO computation. I tried to find an example where that would matter and couldn't. This commit also adds tests to prevent this from regressing in the future.
@mgedmin Thanks for point me to the failing zodb tests.
I am not happy with this solution, but checking for the mro attribute failed, probably because of the python trick to make __ private, and isinstance(layer, type) also failed, maybe because of old style layer classes.
I was also wondering, if it is legal to have an object as a layer, but the docs don't say.
I manually tests zodb with 3.4 and this change, and my tests then ran through