zope.pytestlayer


Namezope.pytestlayer JSON
Version 8.2 PyPI version JSON
download
home_pagehttps://github.com/zopefoundation/zope.pytestlayer/
SummaryIntegration of zope.testrunner-style test layers into pytest framework
upload_time2024-05-15 15:17:57
maintainerNone
docs_urlNone
authorgocept
requires_python>=3.7
licenseZPL 2.1
keywords pytest zope.testrunner layer fixture
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            =================================
The zope.pytestlayer distribution
=================================

.. image:: https://img.shields.io/pypi/v/zope.pytestlayer.svg
    :target: https://pypi.org/project/zope.pytestlayer/

.. image:: https://img.shields.io/pypi/pyversions/zope.pytestlayer.svg
    :target: https://pypi.org/project/zope.pytestlayer/

.. image:: https://github.com/zopefoundation/zope.pytestlayer/actions/workflows/tests.yml/badge.svg
    :target: https://github.com/zopefoundation/zope.pytestlayer/actions?query=tests

.. image:: https://coveralls.io/repos/github/zope/zope.pytestlayer/badge.svg?branch=master
    :target: https://coveralls.io/github/zope/zope.pytestlayer?branch=master


Integration of zope.testrunner-style test layers into the `pytest`_
framework

This package is compatible with Python versions 3.7 - 3.12 including
PyPy3.

It was formerly known as ``gocept.pytestlayer``.

.. _`pytest` : http://pytest.org

Quick start
===========

* Make sure your test files follow the `conventions of pytest's test
  discovery`_

  .. _`conventions of pytest's test discovery`:
     http://pytest.org/latest/goodpractises.html#python-test-discovery

  In particular, a file named ``tests.py`` will not be recognized.

* Add a buildout section to create the `pytest` runner::

    [buildout]
    parts += pytest

    [pytest]
    recipe = zc.recipe.egg
    eggs = zope.pytestlayer
           pytest
           <YOUR PACKAGE HERE>

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

Advanced usage
==============

Version 2.1 reintroduced `fixture.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 in `contest.py`!)::

    from .testing import FUNCTIONAL_LAYER
    import zope.pytestlayer.fixture

    globals().update(zope.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 run `setUp()` and `tearDown()` of the
layer if it has not been run before while the function fixture runs
`testSetUp()` and `testTearDown()` of the layer. The function fixture depends
on the session one. The fixtures return the instance of the layer. So you can
use the `functional` fixture like this::

    def test_mymodule__my_function__1(functional):
        assert functional['app'] is not None

Not supported use cases
=======================

* Inheriting from a base class while changing the layer. See commit `f879f9e
  <https://github.com/zope/zope.pytestlayer/commit/f879f9eb21cbd41a843b5021bc1264e9462fb505>`_.

* 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 `pytest` 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 pytest to run those tests.


===========================
Developing zope.pytestlayer
===========================

:Author:
    gocept,
    Godefroid Chapelle <gotcha@bubblenet.be>

:PyPI page:
    https://pypi.org/project/zope.pytestlayer/

:Issues:
    https://github.com/zopefoundation/zope.pytestlayer/issues

:Source code:
    https://github.com/zopefoundation/zope.pytestlayer

:Current change log:
    https://raw.githubusercontent.com/zopefoundation/zope.pytestlayer/master/CHANGES.rst


=================================
Change log for zope.pytestlayer
=================================

8.2 (2024-05-15)
================

- Make tests compatible with pytest >= 7.3. (Caution: We do not yet support
  pytest >= 8)

- Add support for Python 3.11.

- Add support for Python 3.12.

- Rename from ``gocept.pytestlayer`` to ``zope.pytestlayer``.


8.1 (2022-09-05)
================

- Ensure compatibility with pytest >= 7.1.3.
  ``.layered.LayeredTestCaseInstance`` now 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 <https://github.com/gocept/gocept.pytestlayer/issues/4>`_: Use
  ``gcoept.pytestlayer.doctest.DocTestSuite`` instead of
  ``doctest.DocTestSuite`` to circumvent the issue.


7.0 (2020-08-03)
================

Backwards imcompatible changes
------------------------------

- Drop support for Python 2.7 and 3.5 and ``pytest < 5.0``. (#8)

Features
--------

- Support ``pytest >= 6.0``. (#8)


6.3 (2020-05-15)
================

- Ensure compatibility with pytest > 5.4.2. We need a
  ``_explicit_tearDown`` on our ``LayeredTestCaseFunction`` now.


6.2 (2020-03-20)
================

- Ensure compatibility with pytest > 5.4. We need a
  ``_needs_explicit_tearDown`` on our ``LayeredTestCaseFunction`` now.


6.1 (2020-02-20)
================

- Fix tests to run with `pytest >= 4.2.0`.

- Migrate to Github.

- Do not break when rerunning a doctest using `pytest-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 with `pytest >= 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 with `setuptools >= 30.0`.


5.0 (2016-08-23)
================

- Fix tests to pass if `pytest >= 3.0` is 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-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]

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/zopefoundation/zope.pytestlayer/",
    "name": "zope.pytestlayer",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "pytest zope.testrunner layer fixture",
    "author": "gocept",
    "author_email": "zope-dev@zope.dev",
    "download_url": "https://files.pythonhosted.org/packages/cb/99/ecc0b4aeb9072edde6e2ccf5c1b9498d16e86d1e456191c9bd828598a1d0/zope.pytestlayer-8.2.tar.gz",
    "platform": null,
    "description": "=================================\nThe zope.pytestlayer distribution\n=================================\n\n.. image:: https://img.shields.io/pypi/v/zope.pytestlayer.svg\n    :target: https://pypi.org/project/zope.pytestlayer/\n\n.. image:: https://img.shields.io/pypi/pyversions/zope.pytestlayer.svg\n    :target: https://pypi.org/project/zope.pytestlayer/\n\n.. image:: https://github.com/zopefoundation/zope.pytestlayer/actions/workflows/tests.yml/badge.svg\n    :target: https://github.com/zopefoundation/zope.pytestlayer/actions?query=tests\n\n.. image:: https://coveralls.io/repos/github/zope/zope.pytestlayer/badge.svg?branch=master\n    :target: https://coveralls.io/github/zope/zope.pytestlayer?branch=master\n\n\nIntegration of zope.testrunner-style test layers into the `pytest`_\nframework\n\nThis package is compatible with Python versions 3.7 - 3.12 including\nPyPy3.\n\nIt was formerly known as ``gocept.pytestlayer``.\n\n.. _`pytest` : http://pytest.org\n\nQuick start\n===========\n\n* Make sure your test files follow the `conventions of pytest's test\n  discovery`_\n\n  .. _`conventions of pytest's test discovery`:\n     http://pytest.org/latest/goodpractises.html#python-test-discovery\n\n  In particular, a file named ``tests.py`` will not be recognized.\n\n* Add a buildout section to create the `pytest` runner::\n\n    [buildout]\n    parts += pytest\n\n    [pytest]\n    recipe = zc.recipe.egg\n    eggs = zope.pytestlayer\n           pytest\n           <YOUR PACKAGE HERE>\n\n``zope.pytestlayer`` registers itself as a ``pytest`` plugin. This way, nothing\nmore is needed to run an existing Zope or Plone test suite.\n\nAdvanced usage\n==============\n\nVersion 2.1 reintroduced `fixture.create()` to be able to define the name of\nthe generated to pytest fixtures. So it is possible to use them in function\nstyle tests.\n\nExample (Code has to be in `contest.py`!)::\n\n    from .testing import FUNCTIONAL_LAYER\n    import zope.pytestlayer.fixture\n\n    globals().update(zope.pytestlayer.fixture.create(\n        FUNCTIONAL_LAYER,\n        session_fixture_name='functional_session',\n        class_fixture_name='functional_class',\n        function_fixture_name='functional'))\n\nThis creates three fixtures with the given names and the scopes in the argument\nname. The session and class fixtures run `setUp()` and `tearDown()` of the\nlayer if it has not been run before while the function fixture runs\n`testSetUp()` and `testTearDown()` of the layer. The function fixture depends\non the session one. The fixtures return the instance of the layer. So you can\nuse the `functional` fixture like this::\n\n    def test_mymodule__my_function__1(functional):\n        assert functional['app'] is not None\n\nNot supported use cases\n=======================\n\n* Inheriting from a base class while changing the layer. See commit `f879f9e\n  <https://github.com/zope/zope.pytestlayer/commit/f879f9eb21cbd41a843b5021bc1264e9462fb505>`_.\n\n* Mixing classes inheriting ``unittest.TestCase`` and a ``test_suite()``\n  function (e. g. to create a ``DocTestSuite`` or a ``DocFileSuite``) in a\n  single module (aka file).\n\n  * This is a limitation of the `pytest` test discovery which ignores the\n    doctests in this case.\n\n  * Solution: Put the classes and ``test_suite()`` into different modules.\n\n* A ``doctest.DocFileSuite`` which does not have a ``layer`` is silently\n  skipped. Use the built-in doctest abilities of pytest to run those tests.\n\n\n===========================\nDeveloping zope.pytestlayer\n===========================\n\n:Author:\n    gocept,\n    Godefroid Chapelle <gotcha@bubblenet.be>\n\n:PyPI page:\n    https://pypi.org/project/zope.pytestlayer/\n\n:Issues:\n    https://github.com/zopefoundation/zope.pytestlayer/issues\n\n:Source code:\n    https://github.com/zopefoundation/zope.pytestlayer\n\n:Current change log:\n    https://raw.githubusercontent.com/zopefoundation/zope.pytestlayer/master/CHANGES.rst\n\n\n=================================\nChange log for zope.pytestlayer\n=================================\n\n8.2 (2024-05-15)\n================\n\n- Make tests compatible with pytest >= 7.3. (Caution: We do not yet support\n  pytest >= 8)\n\n- Add support for Python 3.11.\n\n- Add support for Python 3.12.\n\n- Rename from ``gocept.pytestlayer`` to ``zope.pytestlayer``.\n\n\n8.1 (2022-09-05)\n================\n\n- Ensure compatibility with pytest >= 7.1.3.\n  ``.layered.LayeredTestCaseInstance`` now has to inherit from\n  ``_pytest.unittest.UnitTestCase``.\n\n\n8.0 (2021-12-13)\n================\n\n- Use GitHub actions as CI.\n\n- Add support for Python 3.9 and 3.10.\n\n- Drop support for Python 3.6.\n\n- Add a workaround for\n  `#4 <https://github.com/gocept/gocept.pytestlayer/issues/4>`_: Use\n  ``gcoept.pytestlayer.doctest.DocTestSuite`` instead of\n  ``doctest.DocTestSuite`` to circumvent the issue.\n\n\n7.0 (2020-08-03)\n================\n\nBackwards imcompatible changes\n------------------------------\n\n- Drop support for Python 2.7 and 3.5 and ``pytest < 5.0``. (#8)\n\nFeatures\n--------\n\n- Support ``pytest >= 6.0``. (#8)\n\n\n6.3 (2020-05-15)\n================\n\n- Ensure compatibility with pytest > 5.4.2. We need a\n  ``_explicit_tearDown`` on our ``LayeredTestCaseFunction`` now.\n\n\n6.2 (2020-03-20)\n================\n\n- Ensure compatibility with pytest > 5.4. We need a\n  ``_needs_explicit_tearDown`` on our ``LayeredTestCaseFunction`` now.\n\n\n6.1 (2020-02-20)\n================\n\n- Fix tests to run with `pytest >= 4.2.0`.\n\n- Migrate to Github.\n\n- Do not break when rerunning a doctest using `pytest-rerunfailures`.\n\n- Add support for Python 3.8.\n\n\n6.0 (2018-10-24)\n================\n\n- Add support for Python 3.6, 3.7 and PyPy3.\n\n- Drop support for Python 3.4.\n\n- Fix tests to run with `pytest >= 3.9.1`.\n\n- Release also as universal wheel.\n\n- Update to new pytest fixture API to avoid DeprecationWarnings. (#10)\n\n\n5.1 (2016-12-02)\n================\n\n- Make installation process compatible with `setuptools >= 30.0`.\n\n\n5.0 (2016-08-23)\n================\n\n- Fix tests to pass if `pytest >= 3.0` is used for testing.\n\n\n4.0 (2016-04-27)\n================\n\n- Support Python 3.4, 3.5 and PyPy.\n\n- Use tox as testrunner.\n\n\n3.0 (2016-04-14)\n================\n\n- Claim compatibility with py.test 2.9.x.\n\n- Drop Python 2.6 support.\n\n2.1 (2014-10-22)\n================\n\n- Update handling of keywords and doctest testnames for py.test-2.5.\n  [wosc]\n\n- Re-introduce ``gocept.pytestlayer.fixture.create()`` method, to allow giving\n  created fixtures a non-random name, so other fixtures can depend on them.\n  [tlotze, wosc]\n\n- Generate session-scoped fixtures from layers in addition to class-scoped\n  ones, if a session-scoped one is required somewhere, the class-scoped ones\n  are simply ignored. [tlotze, wosc]\n\n\n2.0 (2013-09-19)\n================\n\n- Remove need to explicitely create fixtures.\n  [gotcha]\n\n- Add ``plone.testing.layered`` test suites support.\n  [gotcha]\n\n- Made tests a bit more robust.\n  [icemac]\n\n\n1.0 (2013-08-28)\n================\n\n- Initial release.\n  [tlotze, icemac, gotcha]\n",
    "bugtrack_url": null,
    "license": "ZPL 2.1",
    "summary": "Integration of zope.testrunner-style test layers into pytest framework",
    "version": "8.2",
    "project_urls": {
        "Homepage": "https://github.com/zopefoundation/zope.pytestlayer/"
    },
    "split_keywords": [
        "pytest",
        "zope.testrunner",
        "layer",
        "fixture"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f49451b0032b171e82e3d1019a95f32a97e7381a3d5b0aafc85e915ec7413413",
                "md5": "38be24080697d1aa63c0ae67307cb29d",
                "sha256": "c0e6e26811fd909fa1fa9dddbae0842663b6fb1a4dd6b814abac4639b1cde7c1"
            },
            "downloads": -1,
            "filename": "zope.pytestlayer-8.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "38be24080697d1aa63c0ae67307cb29d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 37661,
            "upload_time": "2024-05-15T15:17:55",
            "upload_time_iso_8601": "2024-05-15T15:17:55.237246Z",
            "url": "https://files.pythonhosted.org/packages/f4/94/51b0032b171e82e3d1019a95f32a97e7381a3d5b0aafc85e915ec7413413/zope.pytestlayer-8.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cb99ecc0b4aeb9072edde6e2ccf5c1b9498d16e86d1e456191c9bd828598a1d0",
                "md5": "029fd49a53103a2bb337f0f64d49afe5",
                "sha256": "15b5a862f595cc3844dec506a52968c60b572b3d0cfa320d7caf9bad97d5eb54"
            },
            "downloads": -1,
            "filename": "zope.pytestlayer-8.2.tar.gz",
            "has_sig": false,
            "md5_digest": "029fd49a53103a2bb337f0f64d49afe5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 25506,
            "upload_time": "2024-05-15T15:17:57",
            "upload_time_iso_8601": "2024-05-15T15:17:57.659467Z",
            "url": "https://files.pythonhosted.org/packages/cb/99/ecc0b4aeb9072edde6e2ccf5c1b9498d16e86d1e456191c9bd828598a1d0/zope.pytestlayer-8.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-15 15:17:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "zopefoundation",
    "github_project": "zope.pytestlayer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "zope.pytestlayer"
}
        
Elapsed time: 0.24530s