zc.recipe.testrunner


Namezc.recipe.testrunner JSON
Version 3.1 PyPI version JSON
download
home_pagehttps://github.com/zopefoundation/zc.recipe.testrunner
SummaryZC Buildout recipe for creating test runners
upload_time2024-09-27 07:16:08
maintainerNone
docs_urlNone
authorJim Fulton
requires_python>=3.8
licenseZPL 2.1
keywords development build testing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ******************
Test-Runner Recipe
******************

.. image:: https://github.com/zopefoundation/zc.recipe.testrunner/actions/workflows/tests.yml/badge.svg
        :target: https://github.com/zopefoundation/zc.recipe.testrunner/actions/workflows/tests.yml

.. image:: https://coveralls.io/repos/github/zopefoundation/zc.recipe.testrunner/badge.svg?branch=master
        :target: https://coveralls.io/github/zopefoundation/zc.recipe.testrunner?branch=master

.. image:: https://img.shields.io/pypi/v/zc.recipe.testrunner.svg
        :target: https://pypi.org/project/zc.recipe.testrunner/
        :alt: Current version on PyPI

.. image:: https://img.shields.io/pypi/pyversions/zc.recipe.testrunner.svg
        :target: https://pypi.org/project/zc.recipe.testrunner/
        :alt: Supported Python versions

.. contents::

This recipe generates zope.testing test-runner scripts for testing a
collection of eggs.

Example usage in ``buildout.cfg``::

    [buildout]
    parts = test

    [test]
    recipe = zc.recipe.testrunner
    eggs = <eggs to test>


Change History
**************

3.1 (2024-09-27)
================

- Add support for Python 3.12.

- Drop support for Python 3.7.

- Fix tests to run successfully against newer ``setuptools`` versions.


3.0 (2023-02-08)
================

- Add support for Python 3.10, 3.11.

- Drop support for Python 2.7, 3.5, 3.6.


2.2 (2020-11-30)
================

- Add support for Python 3.9, PyPy2 and PyPy3.


2.1 (2019-05-14)
================

- Add support for Python 3.5 up to 3.8a3.


2.0.0 (2013-02-10)
==================

Work with buildout 2.

This was accomplised by starting from 1.3.0 then:

- Merge fixes from 1.2.1
  (svn://svn.zope.org/repos/main/zc.recipe.testrunner/tags/1.2.1)
  Excluding nailing zope.testing version. That fixes a bunch of
  windows issues

1.4.0 (2010-08-27)
==================

- Update to using zc.buildout 1.5.0 script generation.  This adds the
  following options: include-site-packages, allowed-eggs-from-site-packages,
  extends, and exec-sitecustomize.

- Merge fixes from 1.2.1
  (svn://svn.zope.org/repos/main/zc.recipe.testrunner/tags/1.2.1)
  Excluding nailing zope.testing version. That fixes a bunch of
  windows issues

1.3.0 (2010-06-09)
==================

- Updated tests to run with the last versions of all modules.

- Removed the usage of the deprecated zope.testing.doctest, therby also
  dropping Python 2.3 support.

- Started using zope.testrunner instead of zope.testing.testrunner.

1.2.1 (2010-08-24)
==================

- Fixed a lot of windows issues
- Nailed versions to ZTK 1.0a2 (oh well, we have to have at least some stability)
- Fixed some other test failures that seemed to come from other packages

1.2.0 (2009-03-23)
==================

- Added a relative-paths option to use egg, test, and
  working-directory paths relative to the test script.


1.1.0 (2008-08-25)
==================

- Requiring at least zope.testing 3.6.0.

- Fixed a bug: Parallel runs of layers failed when using
  working-directory parameter.


1.0.0 (2007-11-04)
==================

- Preparing stable release.


1.0.0b8 (2007-07-17)
====================

- Added the ability to use `initialization` option that will be inserted into
  the bin/test after the environment is set up.

1.0.0b7 (2007-04-26)
====================

Feature Changes
---------------

- Added optional option `environment` that allows defining a section in your
  buildout.cfg to specify environment variables that should be set before
  running the tests.

1.0.0b6 (2007-02-25)
====================

Feature Changes
---------------

- If the working directory is not specified, or specified as the empty
  string, an empty part directory is created for the tests to run in.

1.0.0b5 (2007-01-24)
====================

Bugs fixed
----------

- When:

  + the working-directory option was used,
  + and the test runner needed to restart itself
  + and the test runner was run with a relative path (e.g. bin/test)

  then the testrunner could not restart itself successfully because the
  relative path in sys.argv[0] was no-longer valid.

  Now we convert sys.argv[0] to an absolute path.

1.0.0b4 (2006-10-24)
====================

Feature Changes
---------------

- Added a working-directoy option to specify a working directory for
  the generated script.


1.0.0b3 (2006-10-16)
====================

Updated to work with (not get a warning from) zc.buildout 1.0.0b10.

1.0.0b2
=======

Added a defaults option to specify testrunner default options.

1.0.0b1
=======

Updated to work with zc.buildout 1.0.0b5.

1.0.0a3
=======

Added a defaults option that lets you specify test-runner default
options.


1.0.0a2
=======

Now provide a extra-paths option for including extra paths in test
scripts. This is useful when eggs depend on Python packages not
packaged as eggs.


1.0.0a1
=======

Initial public version

Detailed Documentation
**********************

Test-Runner Recipe
==================

The test-runner recipe, zc.recipe.testrunner, creates a test runner
for a project.

The test-runner recipe has several options:

eggs
    The eggs option specified a list of eggs to test given as one ore
    more setuptools requirement strings.  Each string must be given on
    a separate line.

script
    The script option gives the name of the script to generate, in the
    buildout bin directory.  Of the option isn't used, the part name
    will be used.

extra-paths
    One or more extra paths to include in the generated test script.

defaults
    The defaults option lets you specify testrunner default
    options. These are specified as Python source for an expression
    yielding a list, typically a list literal.

working-directory
    The working-directory option lets to specify a directory where the
    tests will run. The testrunner will change to this directory when
    run. If the working directory is the empty string or not specified
    at all, the recipe will create a working directory among the parts.

environment
    A set of environment variables that should be exported before
    starting the tests.

initialization
    Provide initialization code to run before running tests.

relative-paths
    Use egg, test, and working-directory paths relative to the test script.

(Note that, at this time, due to limitations in the Zope test runner, the
distributions cannot be zip files. TODO: Fix the test runner!)

To illustrate this, we'll create a pair of projects in our sample
buildout:

    >>> mkdir(sample_buildout, 'demo')
    >>> mkdir(sample_buildout, 'demo', 'demo')
    >>> write(sample_buildout, 'demo', 'demo', '__init__.py', '')
    >>> write(sample_buildout, 'demo', 'demo', 'tests.py',
    ... '''
    ... import unittest
    ...
    ... class TestDemo(unittest.TestCase):
    ...    def test(self):
    ...        pass
    ...
    ... def test_suite():
    ...     loader = unittest.TestLoader()
    ...     return loader.loadTestsFromTestCase(TestDemo)
    ... ''')

    >>> write(sample_buildout, 'demo', 'setup.py',
    ... """
    ... from setuptools import setup
    ...
    ... setup(name = "demo")
    ... """)

    >>> write(sample_buildout, 'demo', 'README.txt', '')

    >>> mkdir(sample_buildout, 'demo2')
    >>> mkdir(sample_buildout, 'demo2', 'demo2')
    >>> write(sample_buildout, 'demo2', 'demo2', '__init__.py', '')
    >>> write(sample_buildout, 'demo2', 'demo2', 'tests.py',
    ... '''
    ... import unittest
    ...
    ... class Demo2Tests(unittest.TestCase):
    ...    def test2(self):
    ...        pass
    ...
    ... def test_suite():
    ...     loader = unittest.TestLoader()
    ...     return loader.loadTestsFromTestCase(Demo2Tests)
    ... ''')

    >>> write(sample_buildout, 'demo2', 'setup.py',
    ... """
    ... from setuptools import setup
    ...
    ... setup(name = "demo2", install_requires= ['demoneeded'])
    ... """)

    >>> write(sample_buildout, 'demo2', 'README.txt', '')

Demo 2 depends on demoneeded:

    >>> mkdir(sample_buildout, 'demoneeded')
    >>> mkdir(sample_buildout, 'demoneeded', 'demoneeded')
    >>> write(sample_buildout, 'demoneeded', 'demoneeded', '__init__.py', '')
    >>> write(sample_buildout, 'demoneeded', 'demoneeded', 'tests.py',
    ... '''
    ... import unittest
    ...
    ... class TestNeeded(unittest.TestCase):
    ...    def test_needed(self):
    ...        pass
    ...
    ... def test_suite():
    ...     loader = unittest.TestLoader()
    ...     return loader.loadTestsFromTestCase(TestNeeded)
    ... ''')

    >>> write(sample_buildout, 'demoneeded', 'setup.py',
    ... """
    ... from setuptools import setup
    ...
    ... setup(name = "demoneeded")
    ... """)

    >>> write(sample_buildout, 'demoneeded', 'README.txt', '')

We'll update our buildout to install the demo project as a
develop egg and to create the test script:

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... develop = demo demoneeded demo2
    ... parts = testdemo
    ... offline = true
    ...
    ... [testdemo]
    ... recipe = zc.recipe.testrunner
    ... eggs =
    ...    demo
    ...    demo2
    ... script = test
    ... """)

Note that we specified both demo and demo2 in the eggs
option and that we put them on separate lines.

We also specified the offline option to run the buildout in offline mode.

Now when we run the buildout:

    >>> import os
    >>> os.chdir(sample_buildout)
    >>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),
    ...        end='')

We get a test script installed in our bin directory:

    >>> ls(sample_buildout, 'bin')
    -  buildout
    -  test

We also get a part directory for the tests to run in:

    >>> ls(sample_buildout, 'parts')
    d  testdemo


And updating leaves its contents intact:

    >>> _ = system(os.path.join(sample_buildout, 'bin', 'test') +
    ...            ' -q --coverage=coverage')
    >>> ls(sample_buildout, 'parts', 'testdemo')
    d  coverage
    >>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),
    ...        end='')
    >>> ls(sample_buildout, 'parts', 'testdemo')
    d  coverage

We can run the test script to run our demo test:

    >>> print_(system(os.path.join(sample_buildout, 'bin', 'test') + ' -vv'),
    ...        end='')
    Running tests at level 1
    Running zope.testrunner.layer.UnitTests tests:
      Set up zope.testrunner.layer.UnitTests in 0.001 seconds.
      Running:
     test (demo.tests.TestDemo...)
     test2 (demo2.tests.Demo2Tests...)
      Ran 2 tests with 0 failures, 0 errors and 0 skipped in 0.001 seconds.
    Tearing down left over layers:
      Tear down zope.testrunner.layer.UnitTests in 0.001 seconds.

Note that we didn't run the demoneeded tests.  Tests are only run for
the eggs listed, not for their dependencies.

If we leave the script option out of the configuration, then the test
script will get it's name from the part:

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... develop = demo
    ... parts = testdemo
    ... offline = true
    ...
    ... [testdemo]
    ... recipe = zc.recipe.testrunner
    ... eggs = demo
    ... """)

    >>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),
    ...        end='')

    >>> ls(sample_buildout, 'bin')
    -  buildout
    -  testdemo

We can run the test script to run our demo test:

    >>> print_(system(os.path.join(sample_buildout, 'bin', 'testdemo') + ' -q'),
    ...        end='')
    Running zope.testrunner.layer.UnitTests tests:
      Set up zope.testrunner.layer.UnitTests in 0.001 seconds.
      Ran 1 tests with 0 failures, 0 errors and 0 skipped in 0.001 seconds.
    Tearing down left over layers:
      Tear down zope.testrunner.layer.UnitTests in 0.001 seconds.

If we need to include other paths in our test script, we can use the
extra-paths option to specify them:

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... develop = demo
    ... parts = testdemo
    ... offline = true
    ...
    ... [testdemo]
    ... recipe = zc.recipe.testrunner
    ... eggs = demo
    ... extra-paths = /usr/local/zope/lib/python
    ... """)

    >>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),
    ...        end='')

    >>> cat(sample_buildout, 'bin', 'testdemo')  # doctest: +ELLIPSIS
    #!/usr/local/bin/python2.4
    <BLANKLINE>
    import sys
    sys.path[0:0] = [
      ...
      ]
    <BLANKLINE>
    import os
    sys.argv[0] = os.path.abspath(sys.argv[0])
    os.chdir('/sample-buildout/parts/testdemo')
    <BLANKLINE>
    <BLANKLINE>
    import zope.testrunner
    <BLANKLINE>
    if __name__ == '__main__':
        sys.exit(zope.testrunner.run([
            '--test-path', '/sample-buildout/demo',
            ]))

We can use the working-directory option to specify a working
directory:

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... develop = demo
    ... parts = testdemo
    ... offline = true
    ...
    ... [testdemo]
    ... recipe = zc.recipe.testrunner
    ... eggs = demo
    ... extra-paths = /usr/local/zope/lib/python
    ... working-directory = /foo/bar
    ... """)

    >>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),
    ...        end='')

    >>> cat(sample_buildout, 'bin', 'testdemo')  # doctest: +ELLIPSIS
    #!/usr/local/bin/python2.4
    <BLANKLINE>
    import sys
    sys.path[0:0] = [
      ...
      ]
    <BLANKLINE>
    import os
    sys.argv[0] = os.path.abspath(sys.argv[0])
    os.chdir('/foo/bar')
    <BLANKLINE>
    <BLANKLINE>
    import zope.testrunner
    <BLANKLINE>
    if __name__ == '__main__':
        sys.exit(zope.testrunner.run([
            '--test-path', '/sample-buildout/demo',
            ]))

Now that out tests use a specified working directory, their designated
part directory is gone:

    >>> ls(sample_buildout, 'parts')

If we need to specify default options, we can use the defaults
option. For example, Zope 3 applications typically define test suites
in modules named ftests or tests.  The default test runner behaviour
is to look in modules named tests.  To specify that we want to look in
tests and ftests module, we'd supply a default for the --tests-pattern
option.  If we like dots, we could also request more verbose output
using the -v option:

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... develop = demo
    ... parts = testdemo
    ... offline = true
    ...
    ... [testdemo]
    ... recipe = zc.recipe.testrunner
    ... eggs = demo
    ... extra-paths = /usr/local/zope/lib/python
    ... defaults = ['--tests-pattern', '^f?tests$',
    ...             '-v'
    ...            ]
    ... """)

    >>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),
    ...        end='')

    >>> cat(sample_buildout, 'bin', 'testdemo')  # doctest: +ELLIPSIS
    #!/usr/local/bin/python2.4
    <BLANKLINE>
    import sys
    sys.path[0:0] = [
      ...
      ]
    <BLANKLINE>
    import os
    sys.argv[0] = os.path.abspath(sys.argv[0])
    os.chdir('/sample-buildout/parts/testdemo')
    <BLANKLINE>
    <BLANKLINE>
    import zope.testrunner
    <BLANKLINE>
    if __name__ == '__main__':
        sys.exit(zope.testrunner.run((['--tests-pattern', '^f?tests$',
    '-v'
    ]) + [
            '--test-path', '/sample-buildout/demo',
            ]))

Some things to note from this example:

- Parentheses are placed around the given expression.

- Leading whitespace is removed.


To demonstrate the ``environment`` option, we first update the tests to
include a check for an environment variable:

    >>> write(sample_buildout, 'demo', 'demo', 'tests.py',
    ... '''
    ... import unittest
    ... import os
    ...
    ... class DemoTests(unittest.TestCase):
    ...    def test(self):
    ...        self.assertEqual('42', os.environ.get('zc.recipe.testrunner', '23'))
    ...
    ... def test_suite():
    ...     loader = unittest.TestLoader()
    ...     return loader.loadTestsFromTestCase(DemoTests)
    ... ''')

Running them with the current buildout will produce a failure:

    >>> print_(system(os.path.join(sample_buildout, 'bin', 'testdemo')
    ...               + ' -vv'),
    ...        end='') # doctest: +ELLIPSIS
    Running tests at level 1
    Running zope.testrunner.layer.UnitTests tests:
      Set up zope.testrunner.layer.UnitTests in 0.001 seconds.
      Running:
     test (demo.tests.DemoTests...) (... s)
    <BLANKLINE>
    <BLANKLINE>
    Failure in test test (demo.tests.DemoTests...)
    Traceback (most recent call last):
      ...
    AssertionError: '42' != '23'
    ...
      Ran 1 tests with 1 failures, 0 errors and 0 skipped in 0.001 seconds.
    Tearing down left over layers:
      Tear down zope.testrunner.layer.UnitTests in 0.001 seconds.
    <BLANKLINE>
    Tests with failures:
       test (demo.tests.DemoTests...)


Let's update the buildout to specify the environment variable for the test
runner:

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... develop = demo
    ... parts = testdemo
    ... offline = true
    ...
    ... [testdemo]
    ... recipe = zc.recipe.testrunner
    ... eggs = demo
    ... environment = testenv
    ...
    ... [testenv]
    ... zc.recipe.testrunner = 42
    ... """)

We run buildout and see that the test runner script now includes setting up
the environment variable. Also, the tests pass again:

    >>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),
    ...        end='')

    >>> cat(sample_buildout, 'bin', 'testdemo')  # doctest: +ELLIPSIS
    #!/usr/local/bin/python2.4
    <BLANKLINE>
    import sys
    sys.path[0:0] = [
      ...
      ]
    <BLANKLINE>
    import os
    sys.argv[0] = os.path.abspath(sys.argv[0])
    os.chdir('/sample-buildout/parts/testdemo')
    os.environ['zc.recipe.testrunner'] = '42'
    <BLANKLINE>
    <BLANKLINE>
    import zope.testrunner
    <BLANKLINE>
    if __name__ == '__main__':
        sys.exit(zope.testrunner.run([
            '--test-path', '/sample-buildout/demo',
            ]))

    >>> print_(system(os.path.join(sample_buildout, 'bin', 'testdemo')+' -vv'),
    ...        end='')
    Running tests at level 1
    Running zope.testrunner.layer.UnitTests tests:
      Set up zope.testrunner.layer.UnitTests in 0.001 seconds.
      Running:
     test (demo.tests.DemoTests...)
      Ran 1 tests with 0 failures, 0 errors and 0 skipped in 0.001 seconds.
    Tearing down left over layers:
      Tear down zope.testrunner.layer.UnitTests in 0.001 seconds.

One can add initialization steps in the buildout.  These will be added to the
end of the script:

    >>> write(sample_buildout, 'buildout.cfg',
    ... r"""
    ... [buildout]
    ... develop = demo
    ... parts = testdemo
    ... offline = true
    ...
    ... [testdemo]
    ... recipe = zc.recipe.testrunner
    ... eggs = demo
    ... extra-paths = /usr/local/zope/lib/python
    ... defaults = ['--tests-pattern', '^f?tests$',
    ...             '-v'
    ...            ]
    ... initialization = sys.stdout.write('Hello all you egg-laying pythons!\n')
    ... """)

    >>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),
    ...        end='')

    >>> cat(sample_buildout, 'bin', 'testdemo')  # doctest: +ELLIPSIS
    #!/usr/local/bin/python2.4
    <BLANKLINE>
    import sys
    sys.path[0:0] = [
      ...
      ]
    <BLANKLINE>
    import os
    sys.argv[0] = os.path.abspath(sys.argv[0])
    os.chdir('/sample-buildout/parts/testdemo')
    sys.stdout.write('Hello all you egg-laying pythons!\n')
    <BLANKLINE>
    import zope.testrunner
    <BLANKLINE>
    if __name__ == '__main__':
        sys.exit(zope.testrunner.run((['--tests-pattern', '^f?tests$',
    '-v'
    ]) + [
            '--test-path', '/sample-buildout/demo',
            ]))

This will also work with a multi-line initialization section:

    >>> write(sample_buildout, 'buildout.cfg',
    ... r"""
    ... [buildout]
    ... develop = demo
    ... parts = testdemo
    ... offline = true
    ...
    ... [testdemo]
    ... recipe = zc.recipe.testrunner
    ... eggs = demo
    ... extra-paths = /usr/local/zope/lib/python
    ... defaults = ['--tests-pattern', '^f?tests$',
    ...             '-v'
    ...            ]
    ... initialization = sys.stdout.write('Hello all you egg-laying pythons!\n')
    ...               sys.stdout.write('I thought pythons were live bearers?\n')
    ... """)

    >>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),
    ...        end='')

    >>> cat(sample_buildout, 'bin', 'testdemo')  # doctest: +ELLIPSIS
    #!/usr/local/bin/python2.4
    <BLANKLINE>
    import sys
    sys.path[0:0] = [
      ...
      ]
    <BLANKLINE>
    import os
    sys.argv[0] = os.path.abspath(sys.argv[0])
    os.chdir('/sample-buildout/parts/testdemo')
    sys.stdout.write('Hello all you egg-laying pythons!\n')
    sys.stdout.write('I thought pythons were live bearers?\n')
    <BLANKLINE>
    import zope.testrunner
    <BLANKLINE>
    if __name__ == '__main__':
        sys.exit(zope.testrunner.run((['--tests-pattern', '^f?tests$',
    '-v'
    ]) + [
            '--test-path', '/sample-buildout/demo',
            ]))

If the relative-paths option is used, egg (and extra) paths are
generated relative to the test script.

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... develop = demo
    ... parts = testdemo
    ... offline = true
    ...
    ... [testdemo]
    ... recipe = zc.recipe.testrunner
    ... eggs = demo
    ... extra-paths = /usr/local/zope/lib/python
    ...               ${buildout:directory}/sources
    ... relative-paths = true
    ... """)

    >>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),
    ...        end='')

    >>> cat(sample_buildout, 'bin', 'testdemo')  # doctest: +ELLIPSIS
    #!/usr/local/bin/python2.4
    <BLANKLINE>
    import os
    <BLANKLINE>
    join = os.path.join
    base = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
    base = os.path.dirname(base)
    <BLANKLINE>
    import sys
    sys.path[0:0] = [
      join(base, 'demo'),
      ...
      '/usr/local/zope/lib/python',
      join(base, 'sources'),
      ]
    <BLANKLINE>
    import os
    sys.argv[0] = os.path.abspath(sys.argv[0])
    os.chdir(join(base, 'parts/testdemo'))
    <BLANKLINE>
    <BLANKLINE>
    import zope.testrunner
    <BLANKLINE>
    if __name__ == '__main__':
        sys.exit(zope.testrunner.run([
            '--test-path', join(base, 'demo'),
            ]))

The relative-paths option can be specified at the buildout level:

    >>> write(sample_buildout, 'buildout.cfg',
    ... """
    ... [buildout]
    ... develop = demo
    ... parts = testdemo
    ... offline = true
    ... relative-paths = true
    ...
    ... [testdemo]
    ... recipe = zc.recipe.testrunner
    ... eggs = demo
    ... extra-paths = /usr/local/zope/lib/python
    ...               ${buildout:directory}/sources
    ... """)

    >>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),
    ...        end='')

    >>> cat(sample_buildout, 'bin', 'testdemo')  # doctest: +ELLIPSIS
    #!/usr/local/bin/python2.4
    <BLANKLINE>
    import os
    <BLANKLINE>
    join = os.path.join
    base = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
    base = os.path.dirname(base)
    <BLANKLINE>
    import sys
    sys.path[0:0] = [
      join(base, 'demo'),
      ...
      '/usr/local/zope/lib/python',
      join(base, 'sources'),
      ]
    <BLANKLINE>
    import os
    sys.argv[0] = os.path.abspath(sys.argv[0])
    os.chdir(join(base, 'parts/testdemo'))
    <BLANKLINE>
    <BLANKLINE>
    import zope.testrunner
    <BLANKLINE>
    if __name__ == '__main__':
        sys.exit(zope.testrunner.run([
            '--test-path', join(base, 'demo'),
            ]))

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/zopefoundation/zc.recipe.testrunner",
    "name": "zc.recipe.testrunner",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "development build testing",
    "author": "Jim Fulton",
    "author_email": "jim@zope.com",
    "download_url": "https://files.pythonhosted.org/packages/36/4d/3f76e6a0abe183415fe914dc3b616ef379238937c695aebb1c0c531ab109/zc.recipe.testrunner-3.1.tar.gz",
    "platform": null,
    "description": "******************\nTest-Runner Recipe\n******************\n\n.. image:: https://github.com/zopefoundation/zc.recipe.testrunner/actions/workflows/tests.yml/badge.svg\n        :target: https://github.com/zopefoundation/zc.recipe.testrunner/actions/workflows/tests.yml\n\n.. image:: https://coveralls.io/repos/github/zopefoundation/zc.recipe.testrunner/badge.svg?branch=master\n        :target: https://coveralls.io/github/zopefoundation/zc.recipe.testrunner?branch=master\n\n.. image:: https://img.shields.io/pypi/v/zc.recipe.testrunner.svg\n        :target: https://pypi.org/project/zc.recipe.testrunner/\n        :alt: Current version on PyPI\n\n.. image:: https://img.shields.io/pypi/pyversions/zc.recipe.testrunner.svg\n        :target: https://pypi.org/project/zc.recipe.testrunner/\n        :alt: Supported Python versions\n\n.. contents::\n\nThis recipe generates zope.testing test-runner scripts for testing a\ncollection of eggs.\n\nExample usage in ``buildout.cfg``::\n\n    [buildout]\n    parts = test\n\n    [test]\n    recipe = zc.recipe.testrunner\n    eggs = <eggs to test>\n\n\nChange History\n**************\n\n3.1 (2024-09-27)\n================\n\n- Add support for Python 3.12.\n\n- Drop support for Python 3.7.\n\n- Fix tests to run successfully against newer ``setuptools`` versions.\n\n\n3.0 (2023-02-08)\n================\n\n- Add support for Python 3.10, 3.11.\n\n- Drop support for Python 2.7, 3.5, 3.6.\n\n\n2.2 (2020-11-30)\n================\n\n- Add support for Python 3.9, PyPy2 and PyPy3.\n\n\n2.1 (2019-05-14)\n================\n\n- Add support for Python 3.5 up to 3.8a3.\n\n\n2.0.0 (2013-02-10)\n==================\n\nWork with buildout 2.\n\nThis was accomplised by starting from 1.3.0 then:\n\n- Merge fixes from 1.2.1\n  (svn://svn.zope.org/repos/main/zc.recipe.testrunner/tags/1.2.1)\n  Excluding nailing zope.testing version. That fixes a bunch of\n  windows issues\n\n1.4.0 (2010-08-27)\n==================\n\n- Update to using zc.buildout 1.5.0 script generation.  This adds the\n  following options: include-site-packages, allowed-eggs-from-site-packages,\n  extends, and exec-sitecustomize.\n\n- Merge fixes from 1.2.1\n  (svn://svn.zope.org/repos/main/zc.recipe.testrunner/tags/1.2.1)\n  Excluding nailing zope.testing version. That fixes a bunch of\n  windows issues\n\n1.3.0 (2010-06-09)\n==================\n\n- Updated tests to run with the last versions of all modules.\n\n- Removed the usage of the deprecated zope.testing.doctest, therby also\n  dropping Python 2.3 support.\n\n- Started using zope.testrunner instead of zope.testing.testrunner.\n\n1.2.1 (2010-08-24)\n==================\n\n- Fixed a lot of windows issues\n- Nailed versions to ZTK 1.0a2 (oh well, we have to have at least some stability)\n- Fixed some other test failures that seemed to come from other packages\n\n1.2.0 (2009-03-23)\n==================\n\n- Added a relative-paths option to use egg, test, and\n  working-directory paths relative to the test script.\n\n\n1.1.0 (2008-08-25)\n==================\n\n- Requiring at least zope.testing 3.6.0.\n\n- Fixed a bug: Parallel runs of layers failed when using\n  working-directory parameter.\n\n\n1.0.0 (2007-11-04)\n==================\n\n- Preparing stable release.\n\n\n1.0.0b8 (2007-07-17)\n====================\n\n- Added the ability to use `initialization` option that will be inserted into\n  the bin/test after the environment is set up.\n\n1.0.0b7 (2007-04-26)\n====================\n\nFeature Changes\n---------------\n\n- Added optional option `environment` that allows defining a section in your\n  buildout.cfg to specify environment variables that should be set before\n  running the tests.\n\n1.0.0b6 (2007-02-25)\n====================\n\nFeature Changes\n---------------\n\n- If the working directory is not specified, or specified as the empty\n  string, an empty part directory is created for the tests to run in.\n\n1.0.0b5 (2007-01-24)\n====================\n\nBugs fixed\n----------\n\n- When:\n\n  + the working-directory option was used,\n  + and the test runner needed to restart itself\n  + and the test runner was run with a relative path (e.g. bin/test)\n\n  then the testrunner could not restart itself successfully because the\n  relative path in sys.argv[0] was no-longer valid.\n\n  Now we convert sys.argv[0] to an absolute path.\n\n1.0.0b4 (2006-10-24)\n====================\n\nFeature Changes\n---------------\n\n- Added a working-directoy option to specify a working directory for\n  the generated script.\n\n\n1.0.0b3 (2006-10-16)\n====================\n\nUpdated to work with (not get a warning from) zc.buildout 1.0.0b10.\n\n1.0.0b2\n=======\n\nAdded a defaults option to specify testrunner default options.\n\n1.0.0b1\n=======\n\nUpdated to work with zc.buildout 1.0.0b5.\n\n1.0.0a3\n=======\n\nAdded a defaults option that lets you specify test-runner default\noptions.\n\n\n1.0.0a2\n=======\n\nNow provide a extra-paths option for including extra paths in test\nscripts. This is useful when eggs depend on Python packages not\npackaged as eggs.\n\n\n1.0.0a1\n=======\n\nInitial public version\n\nDetailed Documentation\n**********************\n\nTest-Runner Recipe\n==================\n\nThe test-runner recipe, zc.recipe.testrunner, creates a test runner\nfor a project.\n\nThe test-runner recipe has several options:\n\neggs\n    The eggs option specified a list of eggs to test given as one ore\n    more setuptools requirement strings.  Each string must be given on\n    a separate line.\n\nscript\n    The script option gives the name of the script to generate, in the\n    buildout bin directory.  Of the option isn't used, the part name\n    will be used.\n\nextra-paths\n    One or more extra paths to include in the generated test script.\n\ndefaults\n    The defaults option lets you specify testrunner default\n    options. These are specified as Python source for an expression\n    yielding a list, typically a list literal.\n\nworking-directory\n    The working-directory option lets to specify a directory where the\n    tests will run. The testrunner will change to this directory when\n    run. If the working directory is the empty string or not specified\n    at all, the recipe will create a working directory among the parts.\n\nenvironment\n    A set of environment variables that should be exported before\n    starting the tests.\n\ninitialization\n    Provide initialization code to run before running tests.\n\nrelative-paths\n    Use egg, test, and working-directory paths relative to the test script.\n\n(Note that, at this time, due to limitations in the Zope test runner, the\ndistributions cannot be zip files. TODO: Fix the test runner!)\n\nTo illustrate this, we'll create a pair of projects in our sample\nbuildout:\n\n    >>> mkdir(sample_buildout, 'demo')\n    >>> mkdir(sample_buildout, 'demo', 'demo')\n    >>> write(sample_buildout, 'demo', 'demo', '__init__.py', '')\n    >>> write(sample_buildout, 'demo', 'demo', 'tests.py',\n    ... '''\n    ... import unittest\n    ...\n    ... class TestDemo(unittest.TestCase):\n    ...    def test(self):\n    ...        pass\n    ...\n    ... def test_suite():\n    ...     loader = unittest.TestLoader()\n    ...     return loader.loadTestsFromTestCase(TestDemo)\n    ... ''')\n\n    >>> write(sample_buildout, 'demo', 'setup.py',\n    ... \"\"\"\n    ... from setuptools import setup\n    ...\n    ... setup(name = \"demo\")\n    ... \"\"\")\n\n    >>> write(sample_buildout, 'demo', 'README.txt', '')\n\n    >>> mkdir(sample_buildout, 'demo2')\n    >>> mkdir(sample_buildout, 'demo2', 'demo2')\n    >>> write(sample_buildout, 'demo2', 'demo2', '__init__.py', '')\n    >>> write(sample_buildout, 'demo2', 'demo2', 'tests.py',\n    ... '''\n    ... import unittest\n    ...\n    ... class Demo2Tests(unittest.TestCase):\n    ...    def test2(self):\n    ...        pass\n    ...\n    ... def test_suite():\n    ...     loader = unittest.TestLoader()\n    ...     return loader.loadTestsFromTestCase(Demo2Tests)\n    ... ''')\n\n    >>> write(sample_buildout, 'demo2', 'setup.py',\n    ... \"\"\"\n    ... from setuptools import setup\n    ...\n    ... setup(name = \"demo2\", install_requires= ['demoneeded'])\n    ... \"\"\")\n\n    >>> write(sample_buildout, 'demo2', 'README.txt', '')\n\nDemo 2 depends on demoneeded:\n\n    >>> mkdir(sample_buildout, 'demoneeded')\n    >>> mkdir(sample_buildout, 'demoneeded', 'demoneeded')\n    >>> write(sample_buildout, 'demoneeded', 'demoneeded', '__init__.py', '')\n    >>> write(sample_buildout, 'demoneeded', 'demoneeded', 'tests.py',\n    ... '''\n    ... import unittest\n    ...\n    ... class TestNeeded(unittest.TestCase):\n    ...    def test_needed(self):\n    ...        pass\n    ...\n    ... def test_suite():\n    ...     loader = unittest.TestLoader()\n    ...     return loader.loadTestsFromTestCase(TestNeeded)\n    ... ''')\n\n    >>> write(sample_buildout, 'demoneeded', 'setup.py',\n    ... \"\"\"\n    ... from setuptools import setup\n    ...\n    ... setup(name = \"demoneeded\")\n    ... \"\"\")\n\n    >>> write(sample_buildout, 'demoneeded', 'README.txt', '')\n\nWe'll update our buildout to install the demo project as a\ndevelop egg and to create the test script:\n\n    >>> write(sample_buildout, 'buildout.cfg',\n    ... \"\"\"\n    ... [buildout]\n    ... develop = demo demoneeded demo2\n    ... parts = testdemo\n    ... offline = true\n    ...\n    ... [testdemo]\n    ... recipe = zc.recipe.testrunner\n    ... eggs =\n    ...    demo\n    ...    demo2\n    ... script = test\n    ... \"\"\")\n\nNote that we specified both demo and demo2 in the eggs\noption and that we put them on separate lines.\n\nWe also specified the offline option to run the buildout in offline mode.\n\nNow when we run the buildout:\n\n    >>> import os\n    >>> os.chdir(sample_buildout)\n    >>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),\n    ...        end='')\n\nWe get a test script installed in our bin directory:\n\n    >>> ls(sample_buildout, 'bin')\n    -  buildout\n    -  test\n\nWe also get a part directory for the tests to run in:\n\n    >>> ls(sample_buildout, 'parts')\n    d  testdemo\n\n\nAnd updating leaves its contents intact:\n\n    >>> _ = system(os.path.join(sample_buildout, 'bin', 'test') +\n    ...            ' -q --coverage=coverage')\n    >>> ls(sample_buildout, 'parts', 'testdemo')\n    d  coverage\n    >>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),\n    ...        end='')\n    >>> ls(sample_buildout, 'parts', 'testdemo')\n    d  coverage\n\nWe can run the test script to run our demo test:\n\n    >>> print_(system(os.path.join(sample_buildout, 'bin', 'test') + ' -vv'),\n    ...        end='')\n    Running tests at level 1\n    Running zope.testrunner.layer.UnitTests tests:\n      Set up zope.testrunner.layer.UnitTests in 0.001 seconds.\n      Running:\n     test (demo.tests.TestDemo...)\n     test2 (demo2.tests.Demo2Tests...)\n      Ran 2 tests with 0 failures, 0 errors and 0 skipped in 0.001 seconds.\n    Tearing down left over layers:\n      Tear down zope.testrunner.layer.UnitTests in 0.001 seconds.\n\nNote that we didn't run the demoneeded tests.  Tests are only run for\nthe eggs listed, not for their dependencies.\n\nIf we leave the script option out of the configuration, then the test\nscript will get it's name from the part:\n\n    >>> write(sample_buildout, 'buildout.cfg',\n    ... \"\"\"\n    ... [buildout]\n    ... develop = demo\n    ... parts = testdemo\n    ... offline = true\n    ...\n    ... [testdemo]\n    ... recipe = zc.recipe.testrunner\n    ... eggs = demo\n    ... \"\"\")\n\n    >>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),\n    ...        end='')\n\n    >>> ls(sample_buildout, 'bin')\n    -  buildout\n    -  testdemo\n\nWe can run the test script to run our demo test:\n\n    >>> print_(system(os.path.join(sample_buildout, 'bin', 'testdemo') + ' -q'),\n    ...        end='')\n    Running zope.testrunner.layer.UnitTests tests:\n      Set up zope.testrunner.layer.UnitTests in 0.001 seconds.\n      Ran 1 tests with 0 failures, 0 errors and 0 skipped in 0.001 seconds.\n    Tearing down left over layers:\n      Tear down zope.testrunner.layer.UnitTests in 0.001 seconds.\n\nIf we need to include other paths in our test script, we can use the\nextra-paths option to specify them:\n\n    >>> write(sample_buildout, 'buildout.cfg',\n    ... \"\"\"\n    ... [buildout]\n    ... develop = demo\n    ... parts = testdemo\n    ... offline = true\n    ...\n    ... [testdemo]\n    ... recipe = zc.recipe.testrunner\n    ... eggs = demo\n    ... extra-paths = /usr/local/zope/lib/python\n    ... \"\"\")\n\n    >>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),\n    ...        end='')\n\n    >>> cat(sample_buildout, 'bin', 'testdemo')  # doctest: +ELLIPSIS\n    #!/usr/local/bin/python2.4\n    <BLANKLINE>\n    import sys\n    sys.path[0:0] = [\n      ...\n      ]\n    <BLANKLINE>\n    import os\n    sys.argv[0] = os.path.abspath(sys.argv[0])\n    os.chdir('/sample-buildout/parts/testdemo')\n    <BLANKLINE>\n    <BLANKLINE>\n    import zope.testrunner\n    <BLANKLINE>\n    if __name__ == '__main__':\n        sys.exit(zope.testrunner.run([\n            '--test-path', '/sample-buildout/demo',\n            ]))\n\nWe can use the working-directory option to specify a working\ndirectory:\n\n    >>> write(sample_buildout, 'buildout.cfg',\n    ... \"\"\"\n    ... [buildout]\n    ... develop = demo\n    ... parts = testdemo\n    ... offline = true\n    ...\n    ... [testdemo]\n    ... recipe = zc.recipe.testrunner\n    ... eggs = demo\n    ... extra-paths = /usr/local/zope/lib/python\n    ... working-directory = /foo/bar\n    ... \"\"\")\n\n    >>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),\n    ...        end='')\n\n    >>> cat(sample_buildout, 'bin', 'testdemo')  # doctest: +ELLIPSIS\n    #!/usr/local/bin/python2.4\n    <BLANKLINE>\n    import sys\n    sys.path[0:0] = [\n      ...\n      ]\n    <BLANKLINE>\n    import os\n    sys.argv[0] = os.path.abspath(sys.argv[0])\n    os.chdir('/foo/bar')\n    <BLANKLINE>\n    <BLANKLINE>\n    import zope.testrunner\n    <BLANKLINE>\n    if __name__ == '__main__':\n        sys.exit(zope.testrunner.run([\n            '--test-path', '/sample-buildout/demo',\n            ]))\n\nNow that out tests use a specified working directory, their designated\npart directory is gone:\n\n    >>> ls(sample_buildout, 'parts')\n\nIf we need to specify default options, we can use the defaults\noption. For example, Zope 3 applications typically define test suites\nin modules named ftests or tests.  The default test runner behaviour\nis to look in modules named tests.  To specify that we want to look in\ntests and ftests module, we'd supply a default for the --tests-pattern\noption.  If we like dots, we could also request more verbose output\nusing the -v option:\n\n    >>> write(sample_buildout, 'buildout.cfg',\n    ... \"\"\"\n    ... [buildout]\n    ... develop = demo\n    ... parts = testdemo\n    ... offline = true\n    ...\n    ... [testdemo]\n    ... recipe = zc.recipe.testrunner\n    ... eggs = demo\n    ... extra-paths = /usr/local/zope/lib/python\n    ... defaults = ['--tests-pattern', '^f?tests$',\n    ...             '-v'\n    ...            ]\n    ... \"\"\")\n\n    >>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),\n    ...        end='')\n\n    >>> cat(sample_buildout, 'bin', 'testdemo')  # doctest: +ELLIPSIS\n    #!/usr/local/bin/python2.4\n    <BLANKLINE>\n    import sys\n    sys.path[0:0] = [\n      ...\n      ]\n    <BLANKLINE>\n    import os\n    sys.argv[0] = os.path.abspath(sys.argv[0])\n    os.chdir('/sample-buildout/parts/testdemo')\n    <BLANKLINE>\n    <BLANKLINE>\n    import zope.testrunner\n    <BLANKLINE>\n    if __name__ == '__main__':\n        sys.exit(zope.testrunner.run((['--tests-pattern', '^f?tests$',\n    '-v'\n    ]) + [\n            '--test-path', '/sample-buildout/demo',\n            ]))\n\nSome things to note from this example:\n\n- Parentheses are placed around the given expression.\n\n- Leading whitespace is removed.\n\n\nTo demonstrate the ``environment`` option, we first update the tests to\ninclude a check for an environment variable:\n\n    >>> write(sample_buildout, 'demo', 'demo', 'tests.py',\n    ... '''\n    ... import unittest\n    ... import os\n    ...\n    ... class DemoTests(unittest.TestCase):\n    ...    def test(self):\n    ...        self.assertEqual('42', os.environ.get('zc.recipe.testrunner', '23'))\n    ...\n    ... def test_suite():\n    ...     loader = unittest.TestLoader()\n    ...     return loader.loadTestsFromTestCase(DemoTests)\n    ... ''')\n\nRunning them with the current buildout will produce a failure:\n\n    >>> print_(system(os.path.join(sample_buildout, 'bin', 'testdemo')\n    ...               + ' -vv'),\n    ...        end='') # doctest: +ELLIPSIS\n    Running tests at level 1\n    Running zope.testrunner.layer.UnitTests tests:\n      Set up zope.testrunner.layer.UnitTests in 0.001 seconds.\n      Running:\n     test (demo.tests.DemoTests...) (... s)\n    <BLANKLINE>\n    <BLANKLINE>\n    Failure in test test (demo.tests.DemoTests...)\n    Traceback (most recent call last):\n      ...\n    AssertionError: '42' != '23'\n    ...\n      Ran 1 tests with 1 failures, 0 errors and 0 skipped in 0.001 seconds.\n    Tearing down left over layers:\n      Tear down zope.testrunner.layer.UnitTests in 0.001 seconds.\n    <BLANKLINE>\n    Tests with failures:\n       test (demo.tests.DemoTests...)\n\n\nLet's update the buildout to specify the environment variable for the test\nrunner:\n\n    >>> write(sample_buildout, 'buildout.cfg',\n    ... \"\"\"\n    ... [buildout]\n    ... develop = demo\n    ... parts = testdemo\n    ... offline = true\n    ...\n    ... [testdemo]\n    ... recipe = zc.recipe.testrunner\n    ... eggs = demo\n    ... environment = testenv\n    ...\n    ... [testenv]\n    ... zc.recipe.testrunner = 42\n    ... \"\"\")\n\nWe run buildout and see that the test runner script now includes setting up\nthe environment variable. Also, the tests pass again:\n\n    >>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),\n    ...        end='')\n\n    >>> cat(sample_buildout, 'bin', 'testdemo')  # doctest: +ELLIPSIS\n    #!/usr/local/bin/python2.4\n    <BLANKLINE>\n    import sys\n    sys.path[0:0] = [\n      ...\n      ]\n    <BLANKLINE>\n    import os\n    sys.argv[0] = os.path.abspath(sys.argv[0])\n    os.chdir('/sample-buildout/parts/testdemo')\n    os.environ['zc.recipe.testrunner'] = '42'\n    <BLANKLINE>\n    <BLANKLINE>\n    import zope.testrunner\n    <BLANKLINE>\n    if __name__ == '__main__':\n        sys.exit(zope.testrunner.run([\n            '--test-path', '/sample-buildout/demo',\n            ]))\n\n    >>> print_(system(os.path.join(sample_buildout, 'bin', 'testdemo')+' -vv'),\n    ...        end='')\n    Running tests at level 1\n    Running zope.testrunner.layer.UnitTests tests:\n      Set up zope.testrunner.layer.UnitTests in 0.001 seconds.\n      Running:\n     test (demo.tests.DemoTests...)\n      Ran 1 tests with 0 failures, 0 errors and 0 skipped in 0.001 seconds.\n    Tearing down left over layers:\n      Tear down zope.testrunner.layer.UnitTests in 0.001 seconds.\n\nOne can add initialization steps in the buildout.  These will be added to the\nend of the script:\n\n    >>> write(sample_buildout, 'buildout.cfg',\n    ... r\"\"\"\n    ... [buildout]\n    ... develop = demo\n    ... parts = testdemo\n    ... offline = true\n    ...\n    ... [testdemo]\n    ... recipe = zc.recipe.testrunner\n    ... eggs = demo\n    ... extra-paths = /usr/local/zope/lib/python\n    ... defaults = ['--tests-pattern', '^f?tests$',\n    ...             '-v'\n    ...            ]\n    ... initialization = sys.stdout.write('Hello all you egg-laying pythons!\\n')\n    ... \"\"\")\n\n    >>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),\n    ...        end='')\n\n    >>> cat(sample_buildout, 'bin', 'testdemo')  # doctest: +ELLIPSIS\n    #!/usr/local/bin/python2.4\n    <BLANKLINE>\n    import sys\n    sys.path[0:0] = [\n      ...\n      ]\n    <BLANKLINE>\n    import os\n    sys.argv[0] = os.path.abspath(sys.argv[0])\n    os.chdir('/sample-buildout/parts/testdemo')\n    sys.stdout.write('Hello all you egg-laying pythons!\\n')\n    <BLANKLINE>\n    import zope.testrunner\n    <BLANKLINE>\n    if __name__ == '__main__':\n        sys.exit(zope.testrunner.run((['--tests-pattern', '^f?tests$',\n    '-v'\n    ]) + [\n            '--test-path', '/sample-buildout/demo',\n            ]))\n\nThis will also work with a multi-line initialization section:\n\n    >>> write(sample_buildout, 'buildout.cfg',\n    ... r\"\"\"\n    ... [buildout]\n    ... develop = demo\n    ... parts = testdemo\n    ... offline = true\n    ...\n    ... [testdemo]\n    ... recipe = zc.recipe.testrunner\n    ... eggs = demo\n    ... extra-paths = /usr/local/zope/lib/python\n    ... defaults = ['--tests-pattern', '^f?tests$',\n    ...             '-v'\n    ...            ]\n    ... initialization = sys.stdout.write('Hello all you egg-laying pythons!\\n')\n    ...               sys.stdout.write('I thought pythons were live bearers?\\n')\n    ... \"\"\")\n\n    >>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),\n    ...        end='')\n\n    >>> cat(sample_buildout, 'bin', 'testdemo')  # doctest: +ELLIPSIS\n    #!/usr/local/bin/python2.4\n    <BLANKLINE>\n    import sys\n    sys.path[0:0] = [\n      ...\n      ]\n    <BLANKLINE>\n    import os\n    sys.argv[0] = os.path.abspath(sys.argv[0])\n    os.chdir('/sample-buildout/parts/testdemo')\n    sys.stdout.write('Hello all you egg-laying pythons!\\n')\n    sys.stdout.write('I thought pythons were live bearers?\\n')\n    <BLANKLINE>\n    import zope.testrunner\n    <BLANKLINE>\n    if __name__ == '__main__':\n        sys.exit(zope.testrunner.run((['--tests-pattern', '^f?tests$',\n    '-v'\n    ]) + [\n            '--test-path', '/sample-buildout/demo',\n            ]))\n\nIf the relative-paths option is used, egg (and extra) paths are\ngenerated relative to the test script.\n\n    >>> write(sample_buildout, 'buildout.cfg',\n    ... \"\"\"\n    ... [buildout]\n    ... develop = demo\n    ... parts = testdemo\n    ... offline = true\n    ...\n    ... [testdemo]\n    ... recipe = zc.recipe.testrunner\n    ... eggs = demo\n    ... extra-paths = /usr/local/zope/lib/python\n    ...               ${buildout:directory}/sources\n    ... relative-paths = true\n    ... \"\"\")\n\n    >>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),\n    ...        end='')\n\n    >>> cat(sample_buildout, 'bin', 'testdemo')  # doctest: +ELLIPSIS\n    #!/usr/local/bin/python2.4\n    <BLANKLINE>\n    import os\n    <BLANKLINE>\n    join = os.path.join\n    base = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))\n    base = os.path.dirname(base)\n    <BLANKLINE>\n    import sys\n    sys.path[0:0] = [\n      join(base, 'demo'),\n      ...\n      '/usr/local/zope/lib/python',\n      join(base, 'sources'),\n      ]\n    <BLANKLINE>\n    import os\n    sys.argv[0] = os.path.abspath(sys.argv[0])\n    os.chdir(join(base, 'parts/testdemo'))\n    <BLANKLINE>\n    <BLANKLINE>\n    import zope.testrunner\n    <BLANKLINE>\n    if __name__ == '__main__':\n        sys.exit(zope.testrunner.run([\n            '--test-path', join(base, 'demo'),\n            ]))\n\nThe relative-paths option can be specified at the buildout level:\n\n    >>> write(sample_buildout, 'buildout.cfg',\n    ... \"\"\"\n    ... [buildout]\n    ... develop = demo\n    ... parts = testdemo\n    ... offline = true\n    ... relative-paths = true\n    ...\n    ... [testdemo]\n    ... recipe = zc.recipe.testrunner\n    ... eggs = demo\n    ... extra-paths = /usr/local/zope/lib/python\n    ...               ${buildout:directory}/sources\n    ... \"\"\")\n\n    >>> print_(system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),\n    ...        end='')\n\n    >>> cat(sample_buildout, 'bin', 'testdemo')  # doctest: +ELLIPSIS\n    #!/usr/local/bin/python2.4\n    <BLANKLINE>\n    import os\n    <BLANKLINE>\n    join = os.path.join\n    base = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))\n    base = os.path.dirname(base)\n    <BLANKLINE>\n    import sys\n    sys.path[0:0] = [\n      join(base, 'demo'),\n      ...\n      '/usr/local/zope/lib/python',\n      join(base, 'sources'),\n      ]\n    <BLANKLINE>\n    import os\n    sys.argv[0] = os.path.abspath(sys.argv[0])\n    os.chdir(join(base, 'parts/testdemo'))\n    <BLANKLINE>\n    <BLANKLINE>\n    import zope.testrunner\n    <BLANKLINE>\n    if __name__ == '__main__':\n        sys.exit(zope.testrunner.run([\n            '--test-path', join(base, 'demo'),\n            ]))\n",
    "bugtrack_url": null,
    "license": "ZPL 2.1",
    "summary": "ZC Buildout recipe for creating test runners",
    "version": "3.1",
    "project_urls": {
        "Homepage": "https://github.com/zopefoundation/zc.recipe.testrunner"
    },
    "split_keywords": [
        "development",
        "build",
        "testing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5cc7e1a43fc55910d05111d98985f5a34046f288505db4b9f63c9cdd8c01f859",
                "md5": "642518d29a4fab921fc682aa7271bdaf",
                "sha256": "3136328f393f3041b7cee43f92dff0962f4fbfa9941f9bc6d82eb818a3760131"
            },
            "downloads": -1,
            "filename": "zc.recipe.testrunner-3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "642518d29a4fab921fc682aa7271bdaf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 15767,
            "upload_time": "2024-09-27T07:16:06",
            "upload_time_iso_8601": "2024-09-27T07:16:06.286880Z",
            "url": "https://files.pythonhosted.org/packages/5c/c7/e1a43fc55910d05111d98985f5a34046f288505db4b9f63c9cdd8c01f859/zc.recipe.testrunner-3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "364d3f76e6a0abe183415fe914dc3b616ef379238937c695aebb1c0c531ab109",
                "md5": "460d3f3d8681bbceabc1be844a9e5848",
                "sha256": "bbffa7197fb915245345bc443656fac5018a58f54f93d3613fac5120e307f4a9"
            },
            "downloads": -1,
            "filename": "zc.recipe.testrunner-3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "460d3f3d8681bbceabc1be844a9e5848",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 20350,
            "upload_time": "2024-09-27T07:16:08",
            "upload_time_iso_8601": "2024-09-27T07:16:08.464077Z",
            "url": "https://files.pythonhosted.org/packages/36/4d/3f76e6a0abe183415fe914dc3b616ef379238937c695aebb1c0c531ab109/zc.recipe.testrunner-3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-27 07:16:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "zopefoundation",
    "github_project": "zc.recipe.testrunner",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "zc.recipe.testrunner"
}
        
Elapsed time: 0.50347s