-
Making an egg with your own tests
last modified May 6 by maikroeder
Include Funittest in your buildout
Funittest is packaged as regular python eggs, so it's quite easy to add them to your buildout. You can add a part called funittest for instance:
[buildout] parts = funittest ...
[funittest] recipe = zc.recipe.egg eggs = funittest funittest.plone
This going to install Funittest, and tests for Plone as well. You may want to include selenium in your buildout (required to run tests):
[buildout]
parts = funittest
seleniumrc
...
[seleniumrc]
recipe = collective.recipe.seleniumrc
Use Funittest without buildout
You can use Funittest without buildout. Here you will have to install it using easy_install:
$ easy_install-2.4 https://svn.plone.org/svn/collective/funittest/funittest/trunk#egg=funittest
And in the same way you can install Plone tests:
$ easy_install-2.4 https://svn.plone.org/svn/collective/funittest/funittest.plone/trunk#egg=funittest.plone
You will have to install selenium by your own.
Use paster to create your egg structure
You may have different versions of Python installed, and just in case you run into trouble further ahead, here is some sanity checking of the Python version these scripts are actually using:
$ which easy_install /Library/Frameworks/Python.framework/Versions/Current/bin/easy_install $ head -n1 /Library/Frameworks/Python.framework/Versions/Current/bin/easy_install #!/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python $ which paster /Library/Frameworks/Python.framework/Versions/Current/bin/paster $ head -n1 /Library/Frameworks/Python.framework/Versions/Current/bin/paster #!/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python
You can use paster to create the egg structure. There is a branch of ZopeSkel which contains for the moment the required template:
easy_install 'https://svn.plone.org/svn/collective/ZopeSkel/branches/funittest-templates#egg=name'
After, for instance, in the src folder of your buildout tree, you can use paster:
$ cd buildout/src $ paster create -t funittest_test Selected and implied templates: ZopeSkel#funittest_test A simple egg to write Funittest tests Enter project name: funittest.myapp Variables: egg: funittest.myapp package: funittestmyapp project: funittest.myapp Enter application (The tested application) ['myapp']: myapp Enter version (Version) ['0.1']: Enter description (One-line description of the test) ['']: Functional test for myapp Enter long_description (Multi-line description (in reST)) ['']: Functional test for myapp, using Funittest Enter author (Author name) ['']: Sylvain Viollon Enter author_email (Author email) ['']: sylvain@infrae.com Enter license_name (License name) ['GPL']: Creating template funittest_test ...
If you use buildout, you have to add your new egg to your buildout configuration file:
[buildout]
develop = src/funittest.myapp
other develop eggs
[funittest]
eggs = funittest
funittest.myapp
others dependant funittest eggs
Note: if you use the buildout of Funittest (the one in SVN), don't add src/ to your develop eggs, it's already specified with the develop-dir buildout option.
Dependency on other Funittest eggs
If your egg depends on other funittest eggs, you have to mention them in your buildout configuration, and you have to edit the setup.py file of your egg to include them in the install_requires section.