pytest-smoke


Namepytest-smoke JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
Summarypytest plugin for supporting smoke testing
upload_time2024-11-07 20:11:37
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT License Copyright (c) 2024 Yugo Kato Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords pytest smoke
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            pytest-smoke
======================

[![PyPI](https://img.shields.io/pypi/v/pytest-smoke)](https://pypi.org/project/pytest-smoke/)
[![Supported Python
versions](https://img.shields.io/pypi/pyversions/pytest-smoke.svg)](https://pypi.org/project/pytest-smoke/)
[![test](https://github.com/yugokato/pytest-smoke/actions/workflows/test.yml/badge.svg)](https://github.com/yugokato/pytest-smoke/actions/workflows/test.yml)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/yugokato/pytest-smoke/main.svg)](https://results.pre-commit.ci/latest/github/yugokato/pytest-smoke/main)
[![Code style ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://docs.astral.sh/ruff/)

A small `pytest` plugin that enables a quick smoke testing against a large test suite by limiting the number of tests 
from each parametrized test function to up to `N`.

## Installation

```
pip install pytest-smoke
```


## Usage

The plugin provides the following options, each accepting an optional positive number `N`:
```
$ pytest -h

<snip>

Smoke testing:
  --smoke=[N]           Run the first N (default=1) tests from each test function
  --smoke-last=[N]      Run the last N (default=1) tests from each test function
  --smoke-random=[N]    Run N (default=1) randomly selected tests from each test function
```
If `N` is not explicitly specified, the default value 1 will be applied.

## Examples

Given you have the following test code:

```python
import pytest


def test_something1():
    pass
    
@pytest.mark.parametrize("p", range(10))
def test_something2(p):
    pass
    
@pytest.mark.parametrize("p", range(20))
def test_something3(p):
    pass
```

You can run smoke tests with either the `--smoke`, `--smoke-last`, or `--smoke-random` option:

### 1. `--smoke` option
- Run only the first test from each test function
```
$ pytest -v --smoke
======================== test session starts =========================
<snip>
collected 31 items / 28 deselected / 3 selected

tests/test_something.py::test_something1 PASSED                 [ 33%]
tests/test_something.py::test_something2[0] PASSED              [ 66%]
tests/test_something.py::test_something3[0] PASSED              [100%]

========================= 3 passed in 0.02s ==========================
```

- Run up to 3 tests from each test function (`N`=3)
```
$ pytest -v --smoke 3
======================== test session starts =========================
<snip>
collected 31 items / 24 deselected / 7 selected

tests/test_something.py::test_something1 PASSED                 [ 14%]
tests/test_something.py::test_something2[0] PASSED              [ 28%]
tests/test_something.py::test_something2[1] PASSED              [ 42%]
tests/test_something.py::test_something2[2] PASSED              [ 57%]
tests/test_something.py::test_something3[0] PASSED              [ 71%]
tests/test_something.py::test_something3[1] PASSED              [ 85%]
tests/test_something.py::test_something3[2] PASSED              [100%]

========================= 7 passed in 0.02s ==========================
```

### 2. `--smoke-last` option
- Run only the last test from each test function
```
$ pytest -v --smoke-last
======================== test session starts =========================
<snip>
collected 31 items / 28 deselected / 3 selected

tests/test_something.py::test_something1 PASSED                 [ 33%]
tests/test_something.py::test_something2[9] PASSED              [ 66%]
tests/test_something.py::test_something3[19] PASSED             [100%]

========================= 3 passed in 0.02s ==========================
```

- Run up to the last 3 tests from each test function (`N`=3)
```
$ pytest -v --smoke-last 3
======================== test session starts =========================
<snip>
collected 31 items / 24 deselected / 7 selected

tests/test_something.py::test_something1 PASSED                 [ 14%]
tests/test_something.py::test_something2[7] PASSED              [ 28%]
tests/test_something.py::test_something2[8] PASSED              [ 42%]
tests/test_something.py::test_something2[9] PASSED              [ 57%]
tests/test_something.py::test_something3[17] PASSED             [ 71%]
tests/test_something.py::test_something3[18] PASSED             [ 85%]
tests/test_something.py::test_something3[19] PASSED             [100%]

========================= 7 passed in 0.02s ==========================
```

### 3. `--smoke-random` option
- Run randomly selected one test from each test function
```
$ pytest -v --smoke-random
======================== test session starts =========================
<snip>
collected 31 items / 28 deselected / 3 selected

tests/test_something.py::test_something1 PASSED                 [ 33%]
tests/test_something.py::test_something2[4] PASSED              [ 66%]
tests/test_something.py::test_something3[8] PASSED              [100%]

========================= 3 passed in 0.02s ==========================
```

- Run up to 3 randomly selected tests from each test function (`N`=3)
```
$ pytest -v --smoke-random 3
======================== test session starts =========================
<snip>
collected 31 items / 24 deselected / 7 selected

tests/test_something.py::test_something1 PASSED                 [ 14%]
tests/test_something.py::test_something2[1] PASSED              [ 28%]
tests/test_something.py::test_something2[3] PASSED              [ 42%]
tests/test_something.py::test_something2[8] PASSED              [ 57%]
tests/test_something.py::test_something3[2] PASSED              [ 71%]
tests/test_something.py::test_something3[4] PASSED              [ 85%]
tests/test_something.py::test_something3[14] PASSED             [100%]

========================= 7 passed in 0.02s ==========================
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pytest-smoke",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "pytest, smoke",
    "author": null,
    "author_email": "Yugo Kato <yugokato.o@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/53/20/4ffabf03f12527814c66705c23f453cab1471015cba7171e6efcfd3c7beb/pytest_smoke-0.2.0.tar.gz",
    "platform": null,
    "description": "pytest-smoke\n======================\n\n[![PyPI](https://img.shields.io/pypi/v/pytest-smoke)](https://pypi.org/project/pytest-smoke/)\n[![Supported Python\nversions](https://img.shields.io/pypi/pyversions/pytest-smoke.svg)](https://pypi.org/project/pytest-smoke/)\n[![test](https://github.com/yugokato/pytest-smoke/actions/workflows/test.yml/badge.svg)](https://github.com/yugokato/pytest-smoke/actions/workflows/test.yml)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/yugokato/pytest-smoke/main.svg)](https://results.pre-commit.ci/latest/github/yugokato/pytest-smoke/main)\n[![Code style ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://docs.astral.sh/ruff/)\n\nA small `pytest` plugin that enables a quick smoke testing against a large test suite by limiting the number of tests \nfrom each parametrized test function to up to `N`.\n\n## Installation\n\n```\npip install pytest-smoke\n```\n\n\n## Usage\n\nThe plugin provides the following options, each accepting an optional positive number `N`:\n```\n$ pytest -h\n\n<snip>\n\nSmoke testing:\n  --smoke=[N]           Run the first N (default=1) tests from each test function\n  --smoke-last=[N]      Run the last N (default=1) tests from each test function\n  --smoke-random=[N]    Run N (default=1) randomly selected tests from each test function\n```\nIf `N` is not explicitly specified, the default value 1 will be applied.\n\n## Examples\n\nGiven you have the following test code:\n\n```python\nimport pytest\n\n\ndef test_something1():\n    pass\n    \n@pytest.mark.parametrize(\"p\", range(10))\ndef test_something2(p):\n    pass\n    \n@pytest.mark.parametrize(\"p\", range(20))\ndef test_something3(p):\n    pass\n```\n\nYou can run smoke tests with either the `--smoke`, `--smoke-last`, or `--smoke-random` option:\n\n### 1. `--smoke` option\n- Run only the first test from each test function\n```\n$ pytest -v --smoke\n======================== test session starts =========================\n<snip>\ncollected 31 items / 28 deselected / 3 selected\n\ntests/test_something.py::test_something1 PASSED                 [ 33%]\ntests/test_something.py::test_something2[0] PASSED              [ 66%]\ntests/test_something.py::test_something3[0] PASSED              [100%]\n\n========================= 3 passed in 0.02s ==========================\n```\n\n- Run up to 3 tests from each test function (`N`=3)\n```\n$ pytest -v --smoke 3\n======================== test session starts =========================\n<snip>\ncollected 31 items / 24 deselected / 7 selected\n\ntests/test_something.py::test_something1 PASSED                 [ 14%]\ntests/test_something.py::test_something2[0] PASSED              [ 28%]\ntests/test_something.py::test_something2[1] PASSED              [ 42%]\ntests/test_something.py::test_something2[2] PASSED              [ 57%]\ntests/test_something.py::test_something3[0] PASSED              [ 71%]\ntests/test_something.py::test_something3[1] PASSED              [ 85%]\ntests/test_something.py::test_something3[2] PASSED              [100%]\n\n========================= 7 passed in 0.02s ==========================\n```\n\n### 2. `--smoke-last` option\n- Run only the last test from each test function\n```\n$ pytest -v --smoke-last\n======================== test session starts =========================\n<snip>\ncollected 31 items / 28 deselected / 3 selected\n\ntests/test_something.py::test_something1 PASSED                 [ 33%]\ntests/test_something.py::test_something2[9] PASSED              [ 66%]\ntests/test_something.py::test_something3[19] PASSED             [100%]\n\n========================= 3 passed in 0.02s ==========================\n```\n\n- Run up to the last 3 tests from each test function (`N`=3)\n```\n$ pytest -v --smoke-last 3\n======================== test session starts =========================\n<snip>\ncollected 31 items / 24 deselected / 7 selected\n\ntests/test_something.py::test_something1 PASSED                 [ 14%]\ntests/test_something.py::test_something2[7] PASSED              [ 28%]\ntests/test_something.py::test_something2[8] PASSED              [ 42%]\ntests/test_something.py::test_something2[9] PASSED              [ 57%]\ntests/test_something.py::test_something3[17] PASSED             [ 71%]\ntests/test_something.py::test_something3[18] PASSED             [ 85%]\ntests/test_something.py::test_something3[19] PASSED             [100%]\n\n========================= 7 passed in 0.02s ==========================\n```\n\n### 3. `--smoke-random` option\n- Run randomly selected one test from each test function\n```\n$ pytest -v --smoke-random\n======================== test session starts =========================\n<snip>\ncollected 31 items / 28 deselected / 3 selected\n\ntests/test_something.py::test_something1 PASSED                 [ 33%]\ntests/test_something.py::test_something2[4] PASSED              [ 66%]\ntests/test_something.py::test_something3[8] PASSED              [100%]\n\n========================= 3 passed in 0.02s ==========================\n```\n\n- Run up to 3 randomly selected tests from each test function (`N`=3)\n```\n$ pytest -v --smoke-random 3\n======================== test session starts =========================\n<snip>\ncollected 31 items / 24 deselected / 7 selected\n\ntests/test_something.py::test_something1 PASSED                 [ 14%]\ntests/test_something.py::test_something2[1] PASSED              [ 28%]\ntests/test_something.py::test_something2[3] PASSED              [ 42%]\ntests/test_something.py::test_something2[8] PASSED              [ 57%]\ntests/test_something.py::test_something3[2] PASSED              [ 71%]\ntests/test_something.py::test_something3[4] PASSED              [ 85%]\ntests/test_something.py::test_something3[14] PASSED             [100%]\n\n========================= 7 passed in 0.02s ==========================\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Yugo Kato  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "pytest plugin for supporting smoke testing",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/yugokato/pytest-smoke"
    },
    "split_keywords": [
        "pytest",
        " smoke"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "440bbc5e87fe5ae91225ee99a74709c0b4a9f0b7beede7e3c25857e15a579e4a",
                "md5": "134f02970ec10d776fbbbc37d1a3e4c8",
                "sha256": "3a4c0252dc4fcb1714639bda97c23f9e0c044cb4f082ebe3f18b7331e7d0f85b"
            },
            "downloads": -1,
            "filename": "pytest_smoke-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "134f02970ec10d776fbbbc37d1a3e4c8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 5447,
            "upload_time": "2024-11-07T20:11:35",
            "upload_time_iso_8601": "2024-11-07T20:11:35.596273Z",
            "url": "https://files.pythonhosted.org/packages/44/0b/bc5e87fe5ae91225ee99a74709c0b4a9f0b7beede7e3c25857e15a579e4a/pytest_smoke-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "53204ffabf03f12527814c66705c23f453cab1471015cba7171e6efcfd3c7beb",
                "md5": "acc4dbc51fdd38021fdf5e479a042c3f",
                "sha256": "66ededa657d2614dc684048c77b51f2b46992a45b7bcff9e34e17c9c74432ccb"
            },
            "downloads": -1,
            "filename": "pytest_smoke-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "acc4dbc51fdd38021fdf5e479a042c3f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 9439,
            "upload_time": "2024-11-07T20:11:37",
            "upload_time_iso_8601": "2024-11-07T20:11:37.462106Z",
            "url": "https://files.pythonhosted.org/packages/53/20/4ffabf03f12527814c66705c23f453cab1471015cba7171e6efcfd3c7beb/pytest_smoke-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-07 20:11:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yugokato",
    "github_project": "pytest-smoke",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "pytest-smoke"
}
        
Elapsed time: 0.97652s