pytest-repeat


Namepytest-repeat JSON
Version 0.9.3 PyPI version JSON
download
home_page
Summarypytest plugin for repeating tests
upload_time2023-10-09 19:24:13
maintainer
docs_urlNone
authorBob Silverberg
requires_python>=3.7
licenseThis Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://www.mozilla.org/en-US/MPL/2.0/.
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            pytest-repeat
===================

pytest-repeat is a plugin for `pytest <https://docs.pytest.org>`_ that makes it
easy to repeat a single test, or multiple tests, a specific number of times.

|license| |python| |version| |anaconda| |ci| |issues|

.. |license| image:: https://img.shields.io/badge/license-MPL%202.0-blue.svg
   :target: https://github.com/pytest-dev/pytest-repeat/blob/master/LICENSE

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

.. |anaconda| image:: https://img.shields.io/conda/vn/conda-forge/pytest-repeat.svg
    :target: https://anaconda.org/conda-forge/pytest-repeat

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

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

.. |issues| image:: https://img.shields.io/github/issues-raw/pytest-dev/pytest-repeat.svg
   :target: https://github.com/pytest-dev/pytest-repeat/issues


Requirements
------------

You will need the following prerequisites in order to use pytest-repeat:

- Python 3.7+ or PyPy3
- pytest 4 or newer

Installation
------------
To install pytest-repeat:

.. code-block:: bash

  $ pip install pytest-repeat

Repeating a test
----------------

Use the :code:`--count` command line option to specify how many times you want
your test, or tests, to be run:

.. code-block:: bash

  $ pytest --count=10 test_file.py

Each test collected by pytest will be run :code:`count` times.

If you want to mark a test in your code to be repeated a number of times, you
can use the :code:`@pytest.mark.repeat(count)` decorator:

.. code-block:: python

   import pytest


   @pytest.mark.repeat(3)
   def test_repeat_decorator():
       pass

If you want to override default tests executions order, you can use :code:`--repeat-scope`
command line option with one of the next values: :code:`session`,  :code:`module`, :code:`class` or :code:`function` (default).
It behaves like a scope of the pytest fixture.

:code:`function` (default) scope repeats each test :code:`count` or :code:`repeat` times before executing next test.
:code:`session` scope repeats whole tests session, i.e. all collected tests executed once, then all such tests executed again and etc.
:code:`class` and :code:`module` behaves similar :code:`session` , but repeating set of tests is a tests from class or module, not all collected tests.

Repeating a test until failure
------------------------------

If you are trying to diagnose an intermittent failure, it can be useful to run the same
test over and over again until it fails. You can use pytest's :code:`-x` option in
conjunction with pytest-repeat to force the test runner to stop at the first failure.
For example:

.. code-block:: bash

  $ pytest --count=1000 -x test_file.py

This will attempt to run test_file.py 1000 times, but will stop as soon as a failure
occurs.

UnitTest Style Tests
--------------------

Unfortunately pytest-repeat is not able to work with unittest.TestCase test classes.
These tests will simply always run once, regardless of :code:`--count`, and show a warning.

Resources
---------

- `Release Notes <https://github.com/pytest-dev/pytest-repeat/blob/master/CHANGES.rst>`_
- `Issue Tracker <https://github.com/pytest-dev/pytest-repeat/issues>`_
- `Code <https://github.com/pytest-dev/pytest-repeat/>`_

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pytest-repeat",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Bob Silverberg",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/86/5e/99365eb229efff0b1bd475886150fc6db9937ab7e1bd21f6f65c1279e0eb/pytest_repeat-0.9.3.tar.gz",
    "platform": null,
    "description": "pytest-repeat\n===================\n\npytest-repeat is a plugin for `pytest <https://docs.pytest.org>`_ that makes it\neasy to repeat a single test, or multiple tests, a specific number of times.\n\n|license| |python| |version| |anaconda| |ci| |issues|\n\n.. |license| image:: https://img.shields.io/badge/license-MPL%202.0-blue.svg\n   :target: https://github.com/pytest-dev/pytest-repeat/blob/master/LICENSE\n\n.. |version| image:: http://img.shields.io/pypi/v/pytest-repeat.svg\n  :target: https://pypi.python.org/pypi/pytest-repeat\n\n.. |anaconda| image:: https://img.shields.io/conda/vn/conda-forge/pytest-repeat.svg\n    :target: https://anaconda.org/conda-forge/pytest-repeat\n\n.. |ci| image:: https://github.com/pytest-dev/pytest-repeat/workflows/test/badge.svg\n  :target: https://github.com/pytest-dev/pytest-repeat/actions\n\n.. |python| image:: https://img.shields.io/pypi/pyversions/pytest-repeat.svg\n  :target: https://pypi.python.org/pypi/pytest-repeat/\n\n.. |issues| image:: https://img.shields.io/github/issues-raw/pytest-dev/pytest-repeat.svg\n   :target: https://github.com/pytest-dev/pytest-repeat/issues\n\n\nRequirements\n------------\n\nYou will need the following prerequisites in order to use pytest-repeat:\n\n- Python 3.7+ or PyPy3\n- pytest 4 or newer\n\nInstallation\n------------\nTo install pytest-repeat:\n\n.. code-block:: bash\n\n  $ pip install pytest-repeat\n\nRepeating a test\n----------------\n\nUse the :code:`--count` command line option to specify how many times you want\nyour test, or tests, to be run:\n\n.. code-block:: bash\n\n  $ pytest --count=10 test_file.py\n\nEach test collected by pytest will be run :code:`count` times.\n\nIf you want to mark a test in your code to be repeated a number of times, you\ncan use the :code:`@pytest.mark.repeat(count)` decorator:\n\n.. code-block:: python\n\n   import pytest\n\n\n   @pytest.mark.repeat(3)\n   def test_repeat_decorator():\n       pass\n\nIf you want to override default tests executions order, you can use :code:`--repeat-scope`\ncommand line option with one of the next values: :code:`session`,  :code:`module`, :code:`class` or :code:`function` (default).\nIt behaves like a scope of the pytest fixture.\n\n:code:`function` (default) scope repeats each test :code:`count` or :code:`repeat` times before executing next test.\n:code:`session` scope repeats whole tests session, i.e. all collected tests executed once, then all such tests executed again and etc.\n:code:`class` and :code:`module` behaves similar :code:`session` , but repeating set of tests is a tests from class or module, not all collected tests.\n\nRepeating a test until failure\n------------------------------\n\nIf you are trying to diagnose an intermittent failure, it can be useful to run the same\ntest over and over again until it fails. You can use pytest's :code:`-x` option in\nconjunction with pytest-repeat to force the test runner to stop at the first failure.\nFor example:\n\n.. code-block:: bash\n\n  $ pytest --count=1000 -x test_file.py\n\nThis will attempt to run test_file.py 1000 times, but will stop as soon as a failure\noccurs.\n\nUnitTest Style Tests\n--------------------\n\nUnfortunately pytest-repeat is not able to work with unittest.TestCase test classes.\nThese tests will simply always run once, regardless of :code:`--count`, and show a warning.\n\nResources\n---------\n\n- `Release Notes <https://github.com/pytest-dev/pytest-repeat/blob/master/CHANGES.rst>`_\n- `Issue Tracker <https://github.com/pytest-dev/pytest-repeat/issues>`_\n- `Code <https://github.com/pytest-dev/pytest-repeat/>`_\n",
    "bugtrack_url": null,
    "license": "This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://www.mozilla.org/en-US/MPL/2.0/.",
    "summary": "pytest plugin for repeating tests",
    "version": "0.9.3",
    "project_urls": {
        "Home": "https://github.com/pytest-dev/pytest-repeat"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "49a80a0aec0c2541b8baf4a0b95af2ba99abce217ee43534adf9cb7c908cf184",
                "md5": "371710dee765b960000802dc40d0fc53",
                "sha256": "26ab2df18226af9d5ce441c858f273121e92ff55f5bb311d25755b8d7abdd8ed"
            },
            "downloads": -1,
            "filename": "pytest_repeat-0.9.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "371710dee765b960000802dc40d0fc53",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 4196,
            "upload_time": "2023-10-09T19:24:12",
            "upload_time_iso_8601": "2023-10-09T19:24:12.315167Z",
            "url": "https://files.pythonhosted.org/packages/49/a8/0a0aec0c2541b8baf4a0b95af2ba99abce217ee43534adf9cb7c908cf184/pytest_repeat-0.9.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "865e99365eb229efff0b1bd475886150fc6db9937ab7e1bd21f6f65c1279e0eb",
                "md5": "f530aa80bdafe1e75344a367e28800a2",
                "sha256": "ffd3836dfcd67bb270bec648b330e20be37d2966448c4148c4092d1e8aba8185"
            },
            "downloads": -1,
            "filename": "pytest_repeat-0.9.3.tar.gz",
            "has_sig": false,
            "md5_digest": "f530aa80bdafe1e75344a367e28800a2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 6272,
            "upload_time": "2023-10-09T19:24:13",
            "upload_time_iso_8601": "2023-10-09T19:24:13.809164Z",
            "url": "https://files.pythonhosted.org/packages/86/5e/99365eb229efff0b1bd475886150fc6db9937ab7e1bd21f6f65c1279e0eb/pytest_repeat-0.9.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-09 19:24:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pytest-dev",
    "github_project": "pytest-repeat",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "pytest-repeat"
}
        
Elapsed time: 1.06010s