[Zope3-Users] Add unittest

Florian Lindner mailinglists at xgm.de
Tue Apr 17 14:37:29 EDT 2007


Hello,
I've tried to add a test to my package (I must confess it's my first test.)

I've added an directory "tests", created an empty __init__.py in it and a file 
named test_proxycache.py which contains:

import unittest
from zope.testing.doctestunit import DocTestSuite
 
from zope.app.container.tests.test_icontainer import TestSampleContainer

from ProxyCache.proxycache import ProxyCache
 
class Test(TestSampleContainer):
    def makeTestObject(self):
        return ProxyCache()
     
def test_suite():
    return unittest.TestSuite((
        DocTestSuite("ProxyCache.proxycache"),
        unittest.makeSuite(Test) ))
            
            
if __name__ == "__main__":
     unittest.main(defaultTest="test_suite")

as a first step.

Now I try to run the tests:

florian at horus ~/Zope3 $ python 
test.py -vpu --dir ../Desktop/zope/lib/python/ProxyCache/
Running tests at level 1
Traceback (most recent call last):
  File "test.py", line 61, in ?
    result = testrunner.run(defaults)
  File "/home/florian/Zope3/src/zope/testing/testrunner.py", line 256, in run
    failed = not run_with_options(options)
  File "/home/florian/Zope3/src/zope/testing/testrunner.py", line 365, in 
run_with_options
    tests_by_layer_name = find_tests(options, found_suites)
  File "/home/florian/Zope3/src/zope/testing/testrunner.py", line 1033, in 
find_tests
    for suite in found_suites:
  File "/home/florian/Zope3/src/zope/testing/testrunner.py", line 1072, in 
find_suites
    for fpath, package in find_test_files(options):
  File "/home/florian/Zope3/src/zope/testing/testrunner.py", line 1138, in 
find_test_files
    for f, package in find_test_files_(options):
  File "/home/florian/Zope3/src/zope/testing/testrunner.py", line 1166, in 
find_test_files_
    for (p, package) in test_dirs(options, {}):
  File "/home/florian/Zope3/src/zope/testing/testrunner.py", line 1220, in 
test_dirs
    p = import_name(p)
  File "/home/florian/Zope3/src/zope/testing/testrunner.py", line 1236, in 
import_name
    __import__(name)
ValueError: Empty module name


tried also some variations but the error does not change.

What's wrong there?

Thanks,

Florian


More information about the Zope3-users mailing list