Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

Integration of zope.testrunner-style test layers into py.test framework

Project description

The gocept.pytestlayer distribution

Integration of zope.testrunner-style test layers into the py.test framework

This package is compatible with Python versions 2.6 and 2.7. (To run its tests successfully you should use at least Python 2.7.4 because of a bug in earlier Python 2.7 versions.)

Quick start

  • Make sure your test files follow the conventions of py.test’s test discovery

    In particular, a file named will not be recognised.

  • Add a buildout section to create the py.test runner:

    parts += pytest
    recipe = zc.recipe.egg
    eggs = gocept.pytestlayer
           <YOUR PACKAGE HERE>

gocept.pytestlayer registers itself as a py.test plugin. This way, nothing more is needed to run an existing Zope or Plone test suite.

Not supported use cases

  • Inheriting from a base class while changing the layer. See issue #5
  • Mixing classes inheriting unittest.TestCase and a test_suite() function (e. g. to create a DocTestSuite or a DocFileSuite) in a single module (aka file).
    • This is a limitation of the py.test test discovery which ignores the doctests in this case.
    • Solution: Put the classes and test_suite() into different modules.
  • A doctest.DocFileSuite which does not have a layer is silently skipped. Use the built-in doctest abilities of py.test to run those tests.

Change log for gocept.pytestlayer

3.0 (2016-04-14)

  • Claim compatibility with py.test 2.9.x.
  • Drop Python 2.6 support.

2.1 (2014-10-22)

  • Update handling of keywords and doctest testnames for py.test-2.5. [wosc]
  • Re-introduce gocept.pytestlayer.fixture.create() method, to allow giving created fixtures a non-random name, so other fixtures can depend on them. [tlotze, wosc]
  • Generate session-scoped fixtures from layers in addition to class-scoped ones, if a session-scoped one is required somewhere, the class-scoped ones are simply ignored. [tlotze, wosc]

2.0 (2013-09-19)

  • Remove need to explicitely create fixtures. [gotcha]
  • Add plone.testing.layered test suites support. [gotcha]
  • Made tests a bit more robust. [icemac]

1.0 (2013-08-28)

  • Initial release. [tlotze, icemac, gotcha]

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
gocept.pytestlayer-3.0.tar.gz (21.3 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page