[Zope3-Users] Re: ftesting.zcml in zopeproject

Philipp von Weitershausen philipp at weitershausen.de
Wed Sep 26 00:54:38 EDT 2007


roymathew at bellsouth.net wrote:
> When I use zopeproject to create a project, the project name and the
> package name are the same... ie: $HOME/py24/MYPROJ/src/MYPROJ/...

Not quite. By default, the project name will be used as the directory 
name for the sandbox and as the name of the egg (in setup.py). The lower 
case of the project name will be used for the package name.

> Can I override this to get a package name that is different than the
> project name?

* The name of the directory containing the sandbox is completely 
irrelevant. You can completely move it around, so long as you run 
bin/buildout afterwards.

* The name of the package is completely arbitrary as well. You may 
rename it if you wish. Just make sure you update every occurrence of 
that name in the Python code and ZCML as well.

* The name of the egg is defined in setup.py::

     setup(name='...',

You may change it any time, as long as you also update buildout.cfg 
(where the egg name is mentioned a couple of times) and then run 
bin/buildout.

Thanks for bringing up this question. I will add this to zopeproject's 
README.txt file.

> Also, when I run bin/test, I get:
>   bin/test
>   Running tests at level 1 
>   Running zope.app.testing.functional.Functional tests:
>     Set up zope.app.testing.functional.Functional Traceback (most recent call  last):
>     ...
>     File "$HOME/py24/eggs/tmp1w5hah/zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/xmlconfig.py", line 539, in include
>     File "$HOME/py24/eggs/tmp1w5hah/zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/xmlconfig.py", line 427, in openInOrPlain
>   IOError: [Errno 2] No such file or directory: '$HOME/py24/MYPROJ/parts/test/ftesting.zcml'
> 
> However, I find that there is such an ftesting.zcml file - just not
> in the "right" place. Symlinking/copying it solves the problem:
> 
> ln -s $HOME/py24/MYPROJ/src/MYPROJ/ftesting.zcml
> $HOME/py24/MYPROJ/parts/test/ftesting.zcml
> 
> What gives?

It seems you're using the old default functional test layer from 
zope.app.testing.functional. In Zope 3 instances there used to be a 
global ftesting.zcml that this layer would look for and load. In a 
buildout, that'd be the parts/test directory.

Nowadays we define package-specific functional test layers. Your 
zopeproject-generated code does that too. It comes with a custom 
ftesting.zcml (which you found already) and defines a FunctionalLayer in 
pkg.testing based on that file. You should apply this layer to your 
functional test suites.

For your convenience, the pkg.testing module also defines 
FunctionalDocFileSuite, FunctionalDocTestSuite and a FunctionalTestCase 
variants with that layer applied already. So if you import them for 
pkg.testing rather than zope.app.testing.functional, you won't have to 
do this symlinking.

This is documented already, by the way: 
http://pypi.python.org/pypi/zopeproject#writing-functional-tests


-- 
http://worldcookery.com -- Professional Zope documentation and training



More information about the Zope3-users mailing list