zopefoundation / zope.schema

http://zopeschema.readthedocs.io
Other
7 stars 22 forks source link

Problem with doctests using zope.schema vocabulary #120

Open tflorac opened 1 year ago

tflorac commented 1 year ago

I'm actually building a package using zope.schema, actually in release 6.2.1. My development and Gitlab CI environments are both built using zc.buildout in virtual environments from the same configuration file. I have a doctest which is checking for a missing vocabulary, but:

What could explain this difference while zope.schema is always in the same version? The only difference, as far as I can see, is that packages are installed using PIP in my development environment, but installed using eggs in Gitlab CI...

P. S.: previous example displays outputs from Python 3.7 and Python 3.11, but the behavior is the same whatever Python version is used!

mgedmin commented 1 year ago

Ah, vocabularies. My "favourite" Zope 3 gotcha, although I cannot say for sure that this is the same thing I remember.

The vocabulary registry is pluggable. There's a default implementation using in-memory dictionaries, and there's an alternative implementation that uses zope.component's utility registry for IVocabularyFactory utilities IIRC. And there's some zope.something module somewhere that switches the registries as an import-time side effect.

So, what Python modules are imported during test discovery may affect the behavior of the tests.

I'm sorry for not being able to provide more precise details, but maybe the gist of the thing will be helpful in your debugging efforts.

tflorac commented 1 year ago

Hi Marius, Thank you for your kind reply! I'll try to have an inner look at the vocabulary registry used in my tests! The first step will probably be to create another development environment using the same tools as those used in Gitlab CI, and to see if I get the same behavior...

Best regards, Thierry