Package: gocept.pytestlayer
The gocept.pytestlayer distributionIntegration of zope.testrunner-style test layers into thepytestframeworkThis package is compatible with Python versions 3.7 - 3.10 including
PyPy3.Quick startMake sure your test files follow theconventions of pytest’s test
discoveryIn particular, a file namedtests.pywill not be recognised.Add a buildout section to create thepytestrunner:[buildout]
parts += pytest

[pytest]
recipe = zc.recipe.egg
eggs = gocept.pytestlayer
       pytest
       <YOUR PACKAGE HERE>gocept.pytestlayerregisters itself as apytestplugin. This way, nothing
more is needed to run an existing Zope or Plone test suite.Advanced usageVersion 2.1 reintroducedfixture.create()to be able to define the name of the generated to pytest fixtures. So it is possible to use them in function style tests.Example (Code has to be incontest.py!):from .testing import FUNCTIONAL_LAYER
import gocept.pytestlayer.fixture

globals().update(gocept.pytestlayer.fixture.create(
    FUNCTIONAL_LAYER,
    session_fixture_name='functional_session',
    class_fixture_name='functional_class',
    function_fixture_name='functional'))This creates three fixtures with the given names and the scopes in the argument name. The session and class fixtures runsetUp()andtearDown()of the layer if it has not been run before while the function fixture runstestSetUp()andtestTearDown()of the layer. The function fixture depends on the session one. The fixtures return the instance of the layer. So you can use thefunctionalfixture like this:def test_mymodule__my_function__1(functional):
    assert functional['app'] is not NoneNot supported use casesInheriting from a base class while changing the layer. See commitf879f9e.Mixing classes inheritingunittest.TestCaseand atest_suite()function (e. g. to create aDocTestSuiteor aDocFileSuite) in a single module (aka file).This is a limitation of thepytesttest discovery which ignores the doctests in this case.Solution: Put the classes andtest_suite()into different modules.Adoctest.DocFileSuitewhich does not have alayeris silently skipped. Use the built-in doctest abilities of pytest to run those tests.Developing gocept.pytestlayerAuthor:gocept<mail@gocept.com>,
Godefroid Chapelle <gotcha@bubblenet.be>PyPI page:http://pypi.python.org/pypi/gocept.pytestlayer/Issues:https://github.com/gocept/gocept.pytestlayer/issuesSource code:https://github.com/gocept/gocept.pytestlayerCurrent change log:https://raw.githubusercontent.com/gocept/gocept.pytestlayer/master/CHANGES.rstChange log for gocept.pytestlayer8.1 (2022-09-05)Ensure compatibility with pytest >= 7.1.3..layered.LayeredTestCaseInstancenow has to inherit from_pytest.unittest.UnitTestCase.8.0 (2021-12-13)Use GitHub actions as CI.Add support for Python 3.9 and 3.10.Drop support for Python 3.6.Add a workaround for#4: Usegcoept.pytestlayer.doctest.DocTestSuiteinstead ofdoctest.DocTestSuiteto circumvent the issue.7.0 (2020-08-03)Backwards imcompatible changesDrop support for Python 2.7 and 3.5 andpytest < 5.0. (#8)FeaturesSupportpytest >= 6.0. (#8)6.3 (2020-05-15)Ensure compatibility with pytest > 5.4.2. We need a_explicit_tearDownon ourLayeredTestCaseFunctionnow.6.2 (2020-03-20)Ensure compatibility with pytest > 5.4. We need a_needs_explicit_tearDownon ourLayeredTestCaseFunctionnow.6.1 (2020-02-20)Fix tests to run withpytest >= 4.2.0.Migrate to Github.Do not break when rerunning a doctest usingpytest-rerunfailures.Add support for Python 3.8.6.0 (2018-10-24)Add support for Python 3.6, 3.7 and PyPy3.Drop support for Python 3.4.Fix tests to run withpytest >= 3.9.1.Release also as universal wheel.Update to new pytest fixture API to avoid DeprecationWarnings. (#10)5.1 (2016-12-02)Make installation process compatible withsetuptools >= 30.0.5.0 (2016-08-23)Fix tests to pass ifpytest >= 3.0is used for testing.4.0 (2016-04-27)Support Python 3.4, 3.5 and PyPy.Use tox as testrunner.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-introducegocept.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]Addplone.testing.layeredtest suites support.
[gotcha]Made tests a bit more robust.
[icemac]1.0 (2013-08-28)Initial release.
[tlotze, icemac, gotcha]