Metadata-Version: 2.1
Name: gocept.pytestlayer
Version: 6.3
Summary: Integration of zope.testrunner-style test layers into py.test framework
Home-page: https://github.com/gocept/gocept.pytestlayer/
Author: gocept <mail@gocept.com>
Author-email: mail@gocept.com
License: ZPL 2.1
Keywords: pytest py.test zope.testrunner layer fixture
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Framework :: Plone
Classifier: Framework :: Zope2
Classifier: Framework :: Zope3
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved
Classifier: License :: OSI Approved :: Zope Public License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: Implementation
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*
Requires-Dist: pytest
Requires-Dist: setuptools
Requires-Dist: six
Requires-Dist: zope.dottedname
Provides-Extra: test
Requires-Dist: plone.testing ; extra == 'test'

===================================
The gocept.pytestlayer distribution
===================================

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

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

.. image:: https://travis-ci.com/gocept/gocept.pytestlayer.svg?branch=master
    :target: https://travis-ci.com/gocept/gocept.pytestlayer

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


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

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

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

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

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

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

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

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

    [buildout]
    parts += pytest

    [pytest]
    recipe = zc.recipe.egg
    eggs = gocept.pytestlayer
           pytest
           <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.

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

Version 2.1 reintroduced `fixture.create()` to be able to define the name of the generated to py.test 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 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 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/gocept/gocept.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 `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.

.. _`issue #5` : https://bitbucket.org/gocept/gocept.pytestlayer/issues/5


=============================
Developing gocept.pytestlayer
=============================

:Author:
    `gocept <http://gocept.com/>`_ <mail@gocept.com>,
    Godefroid Chapelle <gotcha@bubblenet.be>

:PyPI page:
    http://pypi.python.org/pypi/gocept.pytestlayer/

:Issues:
    https://github.com/gocept/gocept.pytestlayer/issues

:Source code:
    https://github.com/gocept/gocept.pytestlayer

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


=================================
Change log for gocept.pytestlayer
=================================

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]


