TBH I'm honestly not sure what the problem was before, or why this fixes it. But what I can tell from debugging is that under Py3, `sortMethodsUsing` is treated as a class attribute, but it was being accessed as `self.sortMethodsUsing`. What the full implications of this are I don't quite know, but the symptom here was that the value we were assigning to it -- the global lambda `cmp_` -- was being treated as a bound method instead of a global method. So it was expecting to be called with a `self` argument, and I got an exception saying the method expected 3 arguments but received 2. Why exactly this happens in Python 3, and why exactly this *doesn't* happen in Python 2, even though the syntax was identical in both cases are not clear to me.
Details
Details
Diff Detail
Diff Detail
Event Timeline
Comment Actions
Derp, seems I uploaded this review twice. Now we have split threads. Anyway, there were a couple issues. The issue that was blocking me was related to the instance attributes. Specifically we were writing this:
testMethodPrefix = 'test' suiteClass = suite.TestSuite sortTestMethodsUsing = cmp_ _top_level_dir = None
instead of this:
def __init__(self): self.testMethodPrefix = 'test' self.sortTestMethodsUsing = cmp_ self.testMethodPrefix = 'test' self._top_level_dir = None
But we were still accessing the variables as self.sortTestMethodsUsing. I'm not sure how this works in 2.7, but for whatever reason, it doesn't work in 3.x. sortTestMethodsUsing is treated as a bound method here (i.e. instance method), so it expects a self argument.
Comment Actions
The other issues with reversed_cmp_ were still valid issues that I just fixed at the same time since they were related, but the main one was the instance / class attribute incompatibility.