[Zope-dev] Re: Unit Test Failures
Tres Seaver
tseaver at palladion.com
Mon Dec 19 10:55:14 EST 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Philipp von Weitershausen wrote:
> Tres Seaver wrote:
>
>>Benji York wrote:
>>
>>>The Zope2 unit tests have been failing for some time on
>>>buildbot.zope.com. Looks like a Five-related problem:
>>>http://buildbot.zope.org/Zope%20trunk%202.4%20Linux%20zc-buildbot/builds/109/test/0
>>
>>The failing test is a functional test, not a unit test; I don't run
>>them by default when I check in.
>
> Actually, I put this particular test (functional.txt) on level=2 because it would fail
> when run together with other Five tests. It passes fine when run by itself. This test
> exists identically in Five 1.2 (based on Zope 2.8) where it passes just fine when run
> together with other tests and by itself. During the hot phase of making the deadline on
> November 1st, I decided that this wasn't a big issue and could be resolved during the
> beta phase (after all, the test passes by itself). I obviously forgot to look into it
> again, but then again, I still don't know what the heck is wrong with this.
>
>> I see a couple of problem points: the biggest is the use in the
>> output of 'checkSiteManager.html' of a repr'ed dict, which might
>> render differently between different machines (or even the same
>> machine across Python versions).
>
> Well, if you look closer you find that it uses pprint.pformat which always outputs the
> same on all machines (because it provides output sorted by the dictionary key).
I see that in the implementation; it isn't documented as part of
pprint's contract, however.
>> This is a classic case where the "doctest" does *not* provide
>> clarity over a "traditional" 'unittest' style test, IMNSHO.
>
> Comparing dictionaries is not trivial in classic javiotic tests, either. Using pprint is
> actually quite an elegant way, I think.
But the dictionary here is an *artifact* -- what you are really trying
to do would be expressed as individual assertions in a classic unit test:
self.failUnless(IFiveUtilityRegistry.providedBy(utility_service))
self.failIf(zapi.getSiteManager() is zapi.getGlobalSiteManager())
etc. If you really want to test equality of dictionaries, then
'self.assertEqual' does the trick just fine.
>>I'm not sure what it is testing, either;
>
> It's testing how local site managers get found during traversal and how that affects
> component lookup of e.g. views (depending on which site is traversed, you would find
> local components or not).
OK, thanks!
Tres.
- --
===================================================================
Tres Seaver +1 202-558-7113 tseaver at palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFDptfi+gerLs4ltQ4RAtfkAKCiJLa+s+8GaNxew9DcIPWrbw7qXgCeNaSj
csBJ641nurB0xPwBu6xLByY=
=juKw
-----END PGP SIGNATURE-----
More information about the Zope-Dev
mailing list