[z3-five] pythonproducts monkey patches
yuppie
y.2006_ at wcm-solutions.de
Thu Jul 20 11:05:28 CEST 2006
Hi Philipp!
Philipp von Weitershausen wrote:
> yuppie wrote:
>> The monkey patching code used in Five 1.4 is not very robust.
>
> We accept patches :). Seriously, we do, though this is Rocky's code so I
> hope he'll have something to say about this.
I know ;) But I usually don't fix bugs myself if they have a low
priority for me or if someone else checked in the broken code recently.
>> The unit tests actually depend on the fact that test_externalmethods is
>> usually run before test_registerPackage. If you change their order
>> (AFAICS they are run in alphabetical order) you can see the problem.
>
> No idea in what order tests are run. I think it might also change with
> the endinanness of your platform, the size of your screen and the colour
> of your underpants.
All I wanted to say is this:
- tests should never rely on the order in which they are called
- apparently this bug was never noticed because in all environments in
which these tests were run so far test_externalmethods was called before
test_registerPackage
- renaming 'test_registerPackage' to 'test_a' did work for me to enforce
a different order
>> I stumbled over this issue because I did run the Five tests together
>> with tests that initialize Five.
>
> Well, you're actually not supposed to do that. Five tests will clean up
> after them nicely. Stuff that does installProduct('Five') will not.
> These two collide.
Sometimes I run tests I didn't write myself ;)
So far the only issue was that installProduct('Five') doesn't make sure
the ZCML is loaded because it might have been cleaned up by other tests.
If you are aware of that they don't collide. setupPythonProducts is
initialized with initialize(), not with ZCML.
> The monkey patches, when tested, should clean up after themselves. ALL
> code that operates on global registries or does monkey patching should
> clean up after itself. If pythonproducts doesn't do that, it's a bug.
That's one part of the solution. AFAICS other parts of Five make also
sure they don't apply monkey patches twice. Either using __five_method__
or using some other bookkeeping. That makes things more robust.
Cheers,
Yuppie
More information about the z3-five
mailing list