Setting up tests in packages __init__.py
----------------------------------------

We can also setup tests in packages' __init__ modules. We defined such
a test setup in the cave package::

    >>> import os
    >>> import z3c.testsetup
    >>> pkgpath = os.path.dirname(z3c.testsetup.__file__)
    >>> cavepath = os.path.join(pkgpath, 'tests', 'cave')

The setup looks like this::

    >>> setupfile = os.path.join(cavepath, 'tests', '__init__.py')
    >>> print open(setupfile).read()
    # this is a package that contains a testsetup.
    #
    # To let it be found by the testrunner, you must call the testrunner
    # with the approriate options set.
    import z3c.testsetup
    test_suite = z3c.testsetup.register_all_tests('z3c.testsetup.tests.cave')

Now we run this test, requiring `__init__` as the test-file-pattern
for the testrunner::

    >>> import sys
    >>> defaults = [
    ...     '--path', cavepath,
    ...     '--tests-pattern', '^tests$',
    ...     '--test-file-pattern', '__init__',
    ...     ]
    >>> sys.argv = [sys.argv[0]]
    >>> from z3c.testsetup import testrunner
    >>> testrunner.run(defaults)
    Running z3c.testsetup.functional.doctesting.FunctionalLayer tests:
      Set up z3c.testsetup.functional.doctesting.FunctionalLayer in 0.040 seconds.
      Ran 2 tests with 0 failures and 0 errors in 0.004 seconds.
    Running zope...testrunner.layer.UnitTests tests:
      Tear down z3c.testsetup.functional.doctesting.FunctionalLayer ...
      Running in a subprocess.
      Set up zope...testrunner.layer.UnitTests in 0.000 seconds.
      Ran 2 tests with 0 failures and 0 errors in 0.003 seconds.
      Tear down zope...testrunner.layer.UnitTests in 0.000 seconds.
    Total: 4 tests, 0 failures, 0 errors in 1.854 seconds.
    False
