pytest-forked


Namepytest-forked JSON
Version 1.4.0 PyPI version JSON
download
home_pagehttps://github.com/pytest-dev/pytest-forked
Summaryrun tests in isolated forked subprocesses
upload_time2021-12-10 15:43:19
maintainer
docs_urlNone
authorpytest-dev
requires_python>=3.6
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            pytest-forked: run each test in a forked subprocess
====================================================


.. warning::

	this is a extraction of the xdist --forked module,
	future maintenance beyond the bare minimum is not planned until a new maintainer is found.


This plugin **does not work on Windows** because there's no ``fork`` support.


* ``--forked``: run each test in a forked
  subprocess to survive ``SEGFAULTS`` or otherwise dying processes.

|python| |version| |ci| |pre-commit| |black|

.. |version| image:: http://img.shields.io/pypi/v/pytest-forked.svg
  :target: https://pypi.python.org/pypi/pytest-forked

.. |ci| image:: https://github.com/pytest-dev/pytest-forked/workflows/build/badge.svg
  :target: https://github.com/pytest-dev/pytest-forked/actions

.. |python| image:: https://img.shields.io/pypi/pyversions/pytest-forked.svg
  :target: https://pypi.python.org/pypi/pytest-forked/

.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
  :target: https://github.com/ambv/black

.. |pre-commit| image:: https://results.pre-commit.ci/badge/github/pytest-dev/pytest-forked/master.svg
   :target: https://results.pre-commit.ci/latest/github/pytest-dev/pytest-forked/master

Installation
-----------------------

Install the plugin with::

    pip install pytest-forked

or use the package in develope/in-place mode with
a checkout of the `pytest-forked repository`_ ::

   pip install -e .


Usage examples
---------------------

If you have tests involving C or C++ libraries you might have to deal
with tests crashing the process.  For this case you may use the boxing
options::

    pytest --forked

which will run each test in a subprocess and will report if a test
crashed the process.  You can also combine this option with
running multiple processes via pytest-xdist to speed up the test run
and use your CPU cores::

    pytest -n3 --forked

this would run 3 testing subprocesses in parallel which each
create new forked subprocesses for each test.


You can also fork for individual tests::

    @pytest.mark.forked
    def test_with_leaky_state():
        run_some_monkey_patches()


This test will be unconditionally boxed, regardless of CLI flag.


.. _`pytest-forked repository`: https://github.com/pytest-dev/pytest-forked



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pytest-dev/pytest-forked",
    "name": "pytest-forked",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "pytest-dev",
    "author_email": "pytest-dev@python.org",
    "download_url": "https://files.pythonhosted.org/packages/f1/bc/0121a2e386b261b69f4f5aa48e5304c947451dce70d68628cb28d5cd0d28/pytest-forked-1.4.0.tar.gz",
    "platform": "linux",
    "description": "pytest-forked: run each test in a forked subprocess\n====================================================\n\n\n.. warning::\n\n\tthis is a extraction of the xdist --forked module,\n\tfuture maintenance beyond the bare minimum is not planned until a new maintainer is found.\n\n\nThis plugin **does not work on Windows** because there's no ``fork`` support.\n\n\n* ``--forked``: run each test in a forked\n  subprocess to survive ``SEGFAULTS`` or otherwise dying processes.\n\n|python| |version| |ci| |pre-commit| |black|\n\n.. |version| image:: http://img.shields.io/pypi/v/pytest-forked.svg\n  :target: https://pypi.python.org/pypi/pytest-forked\n\n.. |ci| image:: https://github.com/pytest-dev/pytest-forked/workflows/build/badge.svg\n  :target: https://github.com/pytest-dev/pytest-forked/actions\n\n.. |python| image:: https://img.shields.io/pypi/pyversions/pytest-forked.svg\n  :target: https://pypi.python.org/pypi/pytest-forked/\n\n.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg\n  :target: https://github.com/ambv/black\n\n.. |pre-commit| image:: https://results.pre-commit.ci/badge/github/pytest-dev/pytest-forked/master.svg\n   :target: https://results.pre-commit.ci/latest/github/pytest-dev/pytest-forked/master\n\nInstallation\n-----------------------\n\nInstall the plugin with::\n\n    pip install pytest-forked\n\nor use the package in develope/in-place mode with\na checkout of the `pytest-forked repository`_ ::\n\n   pip install -e .\n\n\nUsage examples\n---------------------\n\nIf you have tests involving C or C++ libraries you might have to deal\nwith tests crashing the process.  For this case you may use the boxing\noptions::\n\n    pytest --forked\n\nwhich will run each test in a subprocess and will report if a test\ncrashed the process.  You can also combine this option with\nrunning multiple processes via pytest-xdist to speed up the test run\nand use your CPU cores::\n\n    pytest -n3 --forked\n\nthis would run 3 testing subprocesses in parallel which each\ncreate new forked subprocesses for each test.\n\n\nYou can also fork for individual tests::\n\n    @pytest.mark.forked\n    def test_with_leaky_state():\n        run_some_monkey_patches()\n\n\nThis test will be unconditionally boxed, regardless of CLI flag.\n\n\n.. _`pytest-forked repository`: https://github.com/pytest-dev/pytest-forked\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "run tests in isolated forked subprocesses",
    "version": "1.4.0",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "bf0249039fb39cb7d6af60f09957e61d",
                "sha256": "bbbb6717efc886b9d64537b41fb1497cfaf3c9601276be8da2cccfea5a3c8ad8"
            },
            "downloads": -1,
            "filename": "pytest_forked-1.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bf0249039fb39cb7d6af60f09957e61d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 4885,
            "upload_time": "2021-12-10T15:43:18",
            "upload_time_iso_8601": "2021-12-10T15:43:18.903487Z",
            "url": "https://files.pythonhosted.org/packages/0c/36/c56ef2aea73912190cdbcc39aaa860db8c07c1a5ce8566994ec9425453db/pytest_forked-1.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "fc2d4bb78f3a5e7c082173527d5009d3",
                "sha256": "8b67587c8f98cbbadfdd804539ed5455b6ed03802203485dd2f53c1422d7440e"
            },
            "downloads": -1,
            "filename": "pytest-forked-1.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "fc2d4bb78f3a5e7c082173527d5009d3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 10197,
            "upload_time": "2021-12-10T15:43:19",
            "upload_time_iso_8601": "2021-12-10T15:43:19.979635Z",
            "url": "https://files.pythonhosted.org/packages/f1/bc/0121a2e386b261b69f4f5aa48e5304c947451dce70d68628cb28d5cd0d28/pytest-forked-1.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-12-10 15:43:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "pytest-dev",
    "github_project": "pytest-forked",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "pytest-forked"
}
        
Elapsed time: 0.02020s