{"id":21379596,"url":"https://github.com/yugokato/pytest-smoke","last_synced_at":"2025-07-01T12:38:38.771Z","repository":{"id":261144622,"uuid":"883418401","full_name":"yugokato/pytest-smoke","owner":"yugokato","description":"pytest plugin for supporting smoke testing","archived":false,"fork":false,"pushed_at":"2024-11-14T03:23:25.000Z","size":20,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-14T04:23:11.436Z","etag":null,"topics":["pytest-plugin","python","smoke-testing"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/pytest-smoke/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yugokato.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-04T23:41:16.000Z","updated_at":"2024-11-14T03:23:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"e48a76c0-e06f-41c6-a043-bb848ffedf63","html_url":"https://github.com/yugokato/pytest-smoke","commit_stats":null,"previous_names":["yugokato/pytest-smoke"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yugokato%2Fpytest-smoke","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yugokato%2Fpytest-smoke/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yugokato%2Fpytest-smoke/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yugokato%2Fpytest-smoke/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yugokato","download_url":"https://codeload.github.com/yugokato/pytest-smoke/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225879598,"owners_count":17538645,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pytest-plugin","python","smoke-testing"],"created_at":"2024-11-22T10:21:31.541Z","updated_at":"2025-07-01T12:38:38.760Z","avatar_url":"https://github.com/yugokato.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"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?branch=main)](https://github.com/yugokato/pytest-smoke/actions/workflows/test.yml?query=branch%3Amain)\n[![Code style ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://docs.astral.sh/ruff/)\n\n`pytest-smoke` is a `pytest` plugin designed to quickly perform smoke testing on large test suites. It allows you to \nscale down test execution by limiting the number of tests run from logical groupings (*smoke scopes*) to a smaller \nsubset defined by `N`. \n\n\n## Installation\n\n```bash\npip install pytest-smoke\n```\n\n\n## Quick Start\n\nFor a quick smoke test with all default options, simply run:\n```bash\npytest --smoke\n```\nThis will run a small subset of tests from your test suite to quickly check basic functionality.\n\n## Usage\n\nThis plugin provides the following command options:\n```\n$ pytest -h\n\n\u003csnip\u003e\n\nSmoke testing:\n  --smoke=[N]           Run only N tests from each smoke scope.\n                        N can be a number (e.g. 5) or a percentage (e.g. 10%).\n                        If not provided, the default value is 1.\n  --smoke-scope=SCOPE   Specify the scope at which the value of N from the above options is applied.\n                        The plugin provides the following predefined scopes, as well as custom user-defined scopes via a hook:\n                        - function: Applies N to each test function\n                        - class: Applies N to each test class\n                        - file: Applies N to each test file\n                        - directory: Applies N to each directory a test file is stored\n                        - all: Applies N to the entire test suite\n                        - auto (default): Dynamically determines an ideal scope per parent node (module or class) based on the presence\n                        of parametrized tests. Uses function scope if any parameterized tests exist under the parent node. Otherwise,\n                        falls back to file scope for test functions or class scope for test methods.\n  --smoke-select-mode=MODE\n                        Specify the mode for selecting tests from each scope.\n                        The plugin provides the following predefined values, as well as custom user-defined values via a hook:\n                        - first: The first N tests (default)\n                        - last: The last N tests\n                        - random: N randomly selected tests\n```\n\n\u003e [!NOTE]\n\u003e - The `--smoke` option is always required to use any `pytest-smoke` plugin functionality\n\u003e - The `--smoke-scope` and `--smoke-select-mode` options also support any custom values, as long as they are handled in the hook. See the \"Hooks\" section below\n\u003e - You can override the plugin's default values for `N`, `SCOPE`, and `MODE` using INI options. See the \"INI Options\" section below\n\u003e - When using the [pytest-xdist](https://pypi.org/project/pytest-xdist/) plugin for parallel testing, you can configure the `pytest-smoke` plugin to replace the default scheduler with a custom distribution algorithm that distributes tests based on the smoke scope\n\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 on subsets of different sizes with the `--smoke` option.  \nHere are some basic examples:\n\n- Run only the first test from each test function\n```\n$ pytest -v --smoke\n======================== test session starts ==========================\n\u003csnip\u003e\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, 28 deselected 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\u003csnip\u003e\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, 24 deselected in 0.02s ===================\n```\n\n- Run 20% of tests from each test function (`N`=20%)\n```\n$ pytest -v --smoke 20%\n======================== test session starts ==========================\n\u003csnip\u003e\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_something3[0] PASSED               [ 57%]\ntests/test_something.py::test_something3[1] PASSED               [ 71%]\ntests/test_something.py::test_something3[2] PASSED               [ 85%]\ntests/test_something.py::test_something3[3] PASSED               [100%]\n\n=================== 7 passed, 24 deselected in 0.02s ===================\n```\n\n\n## Markers\n\n### `@pytest.mark.smoke(*, mustpass=False, runif=True)`\nWhen the feature is explicitly enabled via the `smoke_marked_tests_as_critical` INI option, collected tests marked with \n`@pytest.mark.smoke` are considered \"critical\" smoke tests while ones without this marker are considered \"regular\" \nsmoke tests. Additionally, if the optional `mustpass` keyword argument is set to `True` in the marker, the test is \nconsidered a \"must-pass\" critical smoke test.   \n\nThe plugin will apply the following behavior:\n- All collected critical tests with `runif=True` are automatically included, in addition to the regular tests selected as part of `N` (Ones with `runif=False` will be deselected)\n- Execute critical smoke tests first, before any regular smoke tests\n- If any \"must-pass\" test fails, all subsequent regular smoke tests will be skipped\n\n\u003e [!NOTE]\n\u003e - The marker will have no effect on the plugin until the feature has been enabled\n\u003e - When enabled, the plugin assumes that tests will run sequentially. It will not work when running tests in parallel using a plugin like `pytest-xdist`\n\n\n## Hooks\n\nThe plugin provides the following hooks to customize or extend the plugin's capabilities: \n\n### `pytest_smoke_generate_group_id(item, scope)`\nThis hook allows you to implement your own custom scopes for the `--smoke-scope` option, or override the logic of the \npredefined scopes. Items with the same group ID are grouped together and are considered to be in the same scope, \nat which `N` is applied.  \nAny custom values passed to the  `--smoke-scope` option must be handled in this hook.\n\n### `pytest_smoke_include(item, scope)`\nReturn `True` for tests that should be included as \"additional\" tests. These tests will not be counted towards the \ncalculation of `N`.\n\n### `pytest_smoke_exclude(item, scope)`\nReturn `True` for tests that should not be selected. These items will not be included in the total number of tests to \nwhich `N`% is applied. An example use case is to prevent tests that are marked with `skip` and/or `xfail` from being \nselected.  \nNote that this hook takes precedence over any other options provided by the plugin.\n\n### `pytest_smoke_sort_by_select_mode(items, scope, select_mode)`\nThis hook allows you to implement your own custom select modes for the `--smoke-select-mode` option. Return sorted items \nto implement a test selection logic for the custom select mode. The plugin will pick `N` tests from each scope group \nbased on the sorted items, meaning that an item appearing earlier in the same scope group has a higher chance of being \nselected.  \nAny custom values passed to the `--smoke-select-mode` option must be handled in this hook.  \nNote that the hook does not affect the test execution order.\n\n\n## INI Options\n\nYou can override the plugin's default values by setting the following options in a configuration \nfile (pytest.ini, pyproject.toml, etc.).  \n\n### `smoke_default_n`\nThe default `N` value to be applied when not provided to the `--smoke` option.  \nPlugin default: `1`\n\n### `smoke_default_scope`\nThe default smoke scope to be applied when not explicitly specified with the `--smoke-scope` option.  \nPlugin default: `auto`\n\n### `smoke_default_select_mode`\nThe default smoke select mode to be applied when not explicitly specified with the `--smoke-select-mode` \noption.  \nPlugin default: `first`\n\n### `smoke_default_xdist_dist_by_scope`\nWhen using the [pytest-xdist](https://pypi.org/project/pytest-xdist/) plugin (\u003e=2.3.0) for parallel testing, this \noption replaces the default scheduler with a custom distribution algorithm that distributes tests based on the smoke \nscope. When enabled, the custom scheduler will be automatically used when the `-n`/`--numprocesses` option is used \nwithout a dist option (`--dist` or `-d`).  \nPlugin default: `false`\n\n### `smoke_marked_tests_as_critical`\nTreat tests marked with `@pytest.mark.smoke` as \"critical\" smoke tests.    \nPlugin default: `false`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyugokato%2Fpytest-smoke","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyugokato%2Fpytest-smoke","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyugokato%2Fpytest-smoke/lists"}