A pytest plugin to skip `@pytest.mark.slow` tests by default.

Overview

pytest-skip-slow

A pytest plugin to skip @pytest.mark.slow tests by default. Include the slow tests with --slow.

Installation

$ pip install pytest-skip-slow

Usage

Example test_slow.py:

import pytest

def test_normal():
    pass

@pytest.mark.slow
def test_slow():
    pass

Normal pytest sessions skip slow tests:

(venv) $ pytest -v test_slow.py
========================= test session starts ==========================
collected 2 items                                                      

test_slow.py::test_normal PASSED                                 [ 50%]
test_slow.py::test_slow SKIPPED (need --slow option to run)      [100%]

===================== 1 passed, 1 skipped in 0.00s =====================

Include the slow tests with --slow.

(venv) $ pytest -v --slow test_slow.py
========================= test session starts ==========================
collected 2 items                                                      

test_slow.py::test_normal PASSED                                 [ 50%]
test_slow.py::test_slow PASSED                                   [100%]

========================== 2 passed in 0.00s ===========================
You might also like...
Pytest-rich - Pytest + rich integration (proof of concept)
Pytest-rich - Pytest + rich integration (proof of concept)

pytest-rich Leverage rich for richer test session output. This plugin is not pub

A Django plugin for pytest.

Welcome to pytest-django! pytest-django allows you to test your Django project/applications with the pytest testing tool. Quick start / tutorial Chang

A command-line tool and Python library and Pytest plugin for automated testing of RESTful APIs, with a simple, concise and flexible YAML-based syntax

1.0 Release See here for details about breaking changes with the upcoming 1.0 release: https://github.com/taverntesting/tavern/issues/495 Easier API t

Coverage plugin for pytest.

Overview docs tests package This plugin produces coverage reports. Compared to just using coverage run this plugin does some extras: Subprocess suppor

pytest plugin for distributed testing and loop-on-failures testing modes.

xdist: pytest distributed testing plugin The pytest-xdist plugin extends pytest with some unique test execution modes: test run parallelization: if yo

Plugin for generating HTML reports for pytest results
Plugin for generating HTML reports for pytest results

pytest-html pytest-html is a plugin for pytest that generates a HTML report for test results. Resources Documentation Release Notes Issue Tracker Code

Mypy static type checker plugin for Pytest

pytest-mypy Mypy static type checker plugin for pytest Features Runs the mypy static type checker on your source files as part of your pytest test run

A rewrite of Python's builtin doctest module (with pytest plugin integration) but without all the weirdness
A rewrite of Python's builtin doctest module (with pytest plugin integration) but without all the weirdness

The xdoctest package is a re-write of Python's builtin doctest module. It replaces the old regex-based parser with a new abstract-syntax-tree based pa

pytest plugin for manipulating test data directories and files

pytest-datadir pytest plugin for manipulating test data directories and files. Usage pytest-datadir will look up for a directory with the name of your

Comments
  • Rename `plugin.py` module to something less generic?

    Rename `plugin.py` module to something less generic?

    Currently plugin.py is installed into site-packages, but the name is a bit too generic.

    Perhaps this should be named pytest_skip_slow.py to prevent potential collisions?

    $ cd $(poetry env info --path)/lib/python3.9/site-packages
    $ cat pytest_skip_slow-0.0.2.dist-info/RECORD 
    __pycache__/plugin.cpython-39.pyc,,
    plugin.py,sha256=Th3PGYyl5btnJc33wkHHkZJaOu0Jl2TSWZIwqAnSOls,707
    pytest_skip_slow-0.0.2.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
    pytest_skip_slow-0.0.2.dist-info/LICENSE,sha256=J1khrtIr9XsJdHt3m6r5a8yuoOlLNuDA4HCxgjvfc_s,1078
    pytest_skip_slow-0.0.2.dist-info/METADATA,sha256=HVRDa6rFoN2QHM9cGy1QTGHbL0uAqo4RhHgNXn8oKNw,1674
    pytest_skip_slow-0.0.2.dist-info/RECORD,,
    pytest_skip_slow-0.0.2.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
    pytest_skip_slow-0.0.2.dist-info/WHEEL,sha256=VUbF57hf4yRZWWrOOjp25Fr4BQX9EtnVSbnP2vNxHDM,81
    pytest_skip_slow-0.0.2.dist-info/direct_url.json,sha256=YwJGmeOrMisuKK26zj6VsIFK8eEdB8fjyXLgTZjfPnA,182
    pytest_skip_slow-0.0.2.dist-info/entry_points.txt,sha256=HngPZjwZt9tMbHFw9qOgMJReTF6tf3hdo5BPJZjkv4k,26
    
    enhancement 
    opened by ngnpope 2
  • Does not work with --looponfail

    Does not work with --looponfail

    In my repo, we have 243 tests:

    > pytest --collect-only
    <snip>
    ======================================================= 243 tests collected in 2.48s ========================================================
    

    A run in parallel shows 185/243 as running:

    > pytest -n5
    ============================================================ test session starts ============================================================
    platform linux -- Python 3.9.7, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
    Using --randomly-seed=2570972701
    <snip>
    plugins: randomly-3.10.1, forked-1.3.0, instafail-0.4.2, skip-slow-0.0.2, hypothesis-6.24.0, xdist-2.4.0, anyio-3.3.4
    gw0 [243] / gw1 [243] / gw2 [243] / gw3 [243] / gw4 [243]
    ......s........s..............s.....ssssssssssssssssssssssssssss...........................................sssssss.................ss [ 54%]
    ss.......ssssssssss........s.s......s........sss..............................................................                        [100%]
    ========================================================== short test summary info ==========================================================
    SKIPPED [1] <snip>: need --slow option to run
    <snip>
    SKIPPED [1] <snip>: need --slow option to run
    ===================================================== 185 passed, 58 skipped in 59.58s ======================================================
    

    A run in parallel with --slow works as expected:

    > pytest -n5 --slow
    ============================================================ test session starts ============================================================
    platform linux -- Python 3.9.7, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
    Using --randomly-seed=483316960
    <snip}
    plugins: randomly-3.10.1, forked-1.3.0, instafail-0.4.2, skip-slow-0.0.2, hypothesis-6.24.0, xdist-2.4.0, anyio-3.3.4
    gw0 [243] / gw1 [243] / gw2 [243] / gw3 [243] / gw4 [243]
    ..................................................................................................................................... [ 54%]
    ..............................................................................................................                        [100%]
    ====================================================== 243 passed in 315.03s (0:05:15) ======================================================
    

    However, a run in parallel with --slow and --looponfail does not:

    > pytest -f -n5 --slow
    ============================= test session starts ==============================
    platform linux -- Python 3.9.7, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
    Using --randomly-seed=1986922651
    <snip>
    plugins: randomly-3.10.1, forked-1.3.0, instafail-0.4.2, skip-slow-0.0.2, hypothesis-6.24.0, xdist-2.4.0, anyio-3.3.4
    gw0 I / gw1 I / gw2 I / gw3 I / gw4 I
    gw0 [243] / gw1 [243] / gw2 [243] / gw3 [243] / gw4 [243]
    
    ..........................s............................................. [ 29%]
    ........s.......s.............ssssssssssssssssssssssssssss.............. [ 59%]
    s.........s.......................sssss...ssssssss..ssssssssss.......s.s [ 88%]
    ...........................                                              [100%]
    =========================== short test summary info ============================
    SKIPPED [1] <snip>: need --slow option to run
    <snip>
    SKIPPED [1] <snip>: need --slow option to run
    ================= 185 passed, 58 skipped in 163.80s (0:02:43) ==================
    ############################################################ waiting for changes ############################################################
    

    My src/tests/conftest.py has some hypothesis settings, no pytest ones.

    My pyproject.toml has some packages and options:

    pytest = "^6.2.5"
    pytest-instafail = "^0.4.2"
    pytest-randomly = "^3.10.1"
    pytest-skip-slow = "^0.0.2"
    pytest-xdist = "^2.4.0"
    
    [tool.pytest.ini_options]
    addopts = ["-rsxX", "--strict-markers"]
    filterwarnings = [
      "ignore:`np.bool` is a deprecated alias for the builtin `bool`:DeprecationWarning",
      "ignore:`np.int` is a deprecated alias for the builtin `int`:DeprecationWarning",
      "ignore:`np.long` is a deprecated alias for `np.compat.long`:DeprecationWarning",
      "ignore:elementwise comparison failed:DeprecationWarning",
      "ignore:Solution may be inaccurate:UserWarning",
      "ignore:Use of `disable_window_seconds` has been deprecated:DeprecationWarning",
      "ignore:You are solving a parameterized problem that is not DPP:UserWarning",
    ]
    looponfailroots = ["src"]
    minversion = 6.0
    testpaths = ["src/tests"]
    xfail_strict = true
    
    question 
    opened by dycw 2
  • Add option to run slow tests only?

    Add option to run slow tests only?

    It might be useful to provide an option, e.g. --slow-only, or provide some other mechanism to enable running only those tests marked as slow and skipping others? This could be useful in CI where normal tests run as usual, but there can be an optional job to run only the slow tests without re-running all of the non-slow tests.

    opened by ngnpope 1
Owner
Brian Okken
Host of Test & Code Podcast, testandcode.com. Co-Host of Python Bytes Podcast, pythonbytes.fm. Author of "Python Testing with pytest", pytestbook.com.
Brian Okken
It helps to use fixtures in pytest.mark.parametrize

pytest-lazy-fixture Use your fixtures in @pytest.mark.parametrize. Installation pip install pytest-lazy-fixture Usage import pytest @pytest.fixture(p

Marsel Zaripov 299 Dec 24, 2022
:game_die: Pytest plugin to randomly order tests and control random.seed

pytest-randomly Pytest plugin to randomly order tests and control random.seed. Features All of these features are on by default but can be disabled wi

pytest-dev 471 Dec 30, 2022
pytest plugin providing a function to check if pytest is running.

pytest-is-running pytest plugin providing a function to check if pytest is running. Installation Install with: python -m pip install pytest-is-running

Adam Johnson 21 Nov 1, 2022
Pytest-typechecker - Pytest plugin to test how type checkers respond to code

pytest-typechecker this is a plugin for pytest that allows you to create tests t

vivax 2 Aug 20, 2022
pytest splinter and selenium integration for anyone interested in browser interaction in tests

Splinter plugin for the pytest runner Install pytest-splinter pip install pytest-splinter Features The plugin provides a set of fixtures to use splin

pytest-dev 238 Nov 14, 2022
The pytest framework makes it easy to write small tests, yet scales to support complex functional testing

The pytest framework makes it easy to write small tests, yet scales to support complex functional testing for applications and libraries. An example o

pytest-dev 9.6k Jan 2, 2023
Selects tests affected by changed files. Continous test runner when used with pytest-watch.

This is a pytest plug-in which automatically selects and re-executes only tests affected by recent changes. How is this possible in dynamic language l

Tibor Arpas 614 Dec 30, 2022
a wrapper around pytest for executing tests to look for test flakiness and runtime regression

bubblewrap a wrapper around pytest for assessing flakiness and runtime regressions a cs implementations practice project How to Run: First, install de

Anna Nagy 1 Aug 5, 2021
ApiPy was created for api testing with Python pytest framework which has also requests, assertpy and pytest-html-reporter libraries.

ApiPy was created for api testing with Python pytest framework which has also requests, assertpy and pytest-html-reporter libraries. With this f

Mustafa 1 Jul 11, 2022
Playwright Python tool practice pytest pytest-bdd screen-play page-object allure cucumber-report

pytest-ui-automatic Playwright Python tool practice pytest pytest-bdd screen-play page-object allure cucumber-report How to run Run tests execute_test

moyu6027 11 Nov 8, 2022