diff options
author | Sorin Sbarnea <ssbarnea@users.noreply.github.com> | 2020-09-19 19:56:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-19 15:56:52 -0300 |
commit | b031a7cecfe66367b0767300f454669b6234508f (patch) | |
tree | 0974c3189246ae8b7e5e71a9ffb30609ddb5728f /testing/plugins_integration | |
parent | 9f164b72278c9057da4e09239687533aef99c463 (diff) | |
download | pytest-b031a7cecfe66367b0767300f454669b6234508f.tar.gz |
Smoke tests for assorted plugins (#7721)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Co-authored-by: Kyle Altendorf <sda@fstab.net>
Diffstat (limited to 'testing/plugins_integration')
-rw-r--r-- | testing/plugins_integration/.gitignore | 2 | ||||
-rw-r--r-- | testing/plugins_integration/README.rst | 13 | ||||
-rw-r--r-- | testing/plugins_integration/bdd_wallet.feature | 9 | ||||
-rw-r--r-- | testing/plugins_integration/bdd_wallet.py | 39 | ||||
-rw-r--r-- | testing/plugins_integration/django_settings.py | 1 | ||||
-rw-r--r-- | testing/plugins_integration/pytest.ini | 4 | ||||
-rw-r--r-- | testing/plugins_integration/pytest_anyio_integration.py | 8 | ||||
-rw-r--r-- | testing/plugins_integration/pytest_asyncio_integration.py | 8 | ||||
-rw-r--r-- | testing/plugins_integration/pytest_mock_integration.py | 2 | ||||
-rw-r--r-- | testing/plugins_integration/pytest_trio_integration.py | 8 | ||||
-rw-r--r-- | testing/plugins_integration/pytest_twisted_integration.py | 18 | ||||
-rw-r--r-- | testing/plugins_integration/simple_integration.py | 10 |
12 files changed, 122 insertions, 0 deletions
diff --git a/testing/plugins_integration/.gitignore b/testing/plugins_integration/.gitignore new file mode 100644 index 000000000..d934447a0 --- /dev/null +++ b/testing/plugins_integration/.gitignore @@ -0,0 +1,2 @@ +*.html +assets/ diff --git a/testing/plugins_integration/README.rst b/testing/plugins_integration/README.rst new file mode 100644 index 000000000..8f027c3bd --- /dev/null +++ b/testing/plugins_integration/README.rst @@ -0,0 +1,13 @@ +This folder contains tests and support files for smoke testing popular plugins against the current pytest version. + +The objective is to gauge if any intentional or unintentional changes in pytest break plugins. + +As a rule of thumb, we should add plugins here: + +1. That are used at large. This might be subjective in some cases, but if answer is yes to + the question: *if a new release of pytest causes pytest-X to break, will this break a ton of test suites out there?*. +2. That don't have large external dependencies: such as external services. + +Besides adding the plugin as dependency, we should also add a quick test which uses some +minimal part of the plugin, a smoke test. Also consider reusing one of the existing tests if that's +possible. diff --git a/testing/plugins_integration/bdd_wallet.feature b/testing/plugins_integration/bdd_wallet.feature new file mode 100644 index 000000000..e404c4948 --- /dev/null +++ b/testing/plugins_integration/bdd_wallet.feature @@ -0,0 +1,9 @@ +Feature: Buy things with apple + + Scenario: Buy fruits + Given A wallet with 50 + + When I buy some apples for 1 + And I buy some bananas for 2 + + Then I have 47 left diff --git a/testing/plugins_integration/bdd_wallet.py b/testing/plugins_integration/bdd_wallet.py new file mode 100644 index 000000000..35927ea58 --- /dev/null +++ b/testing/plugins_integration/bdd_wallet.py @@ -0,0 +1,39 @@ +from pytest_bdd import given +from pytest_bdd import scenario +from pytest_bdd import then +from pytest_bdd import when + +import pytest + + +@scenario("bdd_wallet.feature", "Buy fruits") +def test_publish(): + pass + + +@pytest.fixture +def wallet(): + class Wallet: + amount = 0 + + return Wallet() + + +@given("A wallet with 50") +def fill_wallet(wallet): + wallet.amount = 50 + + +@when("I buy some apples for 1") +def buy_apples(wallet): + wallet.amount -= 1 + + +@when("I buy some bananas for 2") +def buy_bananas(wallet): + wallet.amount -= 2 + + +@then("I have 47 left") +def check(wallet): + assert wallet.amount == 47 diff --git a/testing/plugins_integration/django_settings.py b/testing/plugins_integration/django_settings.py new file mode 100644 index 000000000..0715f4765 --- /dev/null +++ b/testing/plugins_integration/django_settings.py @@ -0,0 +1 @@ +SECRET_KEY = "mysecret" diff --git a/testing/plugins_integration/pytest.ini b/testing/plugins_integration/pytest.ini new file mode 100644 index 000000000..f6c77b0de --- /dev/null +++ b/testing/plugins_integration/pytest.ini @@ -0,0 +1,4 @@ +[pytest] +addopts = --strict-markers +filterwarnings = + error::pytest.PytestWarning diff --git a/testing/plugins_integration/pytest_anyio_integration.py b/testing/plugins_integration/pytest_anyio_integration.py new file mode 100644 index 000000000..65c2f5936 --- /dev/null +++ b/testing/plugins_integration/pytest_anyio_integration.py @@ -0,0 +1,8 @@ +import anyio + +import pytest + + +@pytest.mark.anyio +async def test_sleep(): + await anyio.sleep(0) diff --git a/testing/plugins_integration/pytest_asyncio_integration.py b/testing/plugins_integration/pytest_asyncio_integration.py new file mode 100644 index 000000000..5d2a3facc --- /dev/null +++ b/testing/plugins_integration/pytest_asyncio_integration.py @@ -0,0 +1,8 @@ +import asyncio + +import pytest + + +@pytest.mark.asyncio +async def test_sleep(): + await asyncio.sleep(0) diff --git a/testing/plugins_integration/pytest_mock_integration.py b/testing/plugins_integration/pytest_mock_integration.py new file mode 100644 index 000000000..740469d00 --- /dev/null +++ b/testing/plugins_integration/pytest_mock_integration.py @@ -0,0 +1,2 @@ +def test_mocker(mocker): + mocker.MagicMock() diff --git a/testing/plugins_integration/pytest_trio_integration.py b/testing/plugins_integration/pytest_trio_integration.py new file mode 100644 index 000000000..199f7850b --- /dev/null +++ b/testing/plugins_integration/pytest_trio_integration.py @@ -0,0 +1,8 @@ +import trio + +import pytest + + +@pytest.mark.trio +async def test_sleep(): + await trio.sleep(0) diff --git a/testing/plugins_integration/pytest_twisted_integration.py b/testing/plugins_integration/pytest_twisted_integration.py new file mode 100644 index 000000000..94748d036 --- /dev/null +++ b/testing/plugins_integration/pytest_twisted_integration.py @@ -0,0 +1,18 @@ +import pytest_twisted +from twisted.internet.task import deferLater + + +def sleep(): + import twisted.internet.reactor + + return deferLater(clock=twisted.internet.reactor, delay=0) + + +@pytest_twisted.inlineCallbacks +def test_inlineCallbacks(): + yield sleep() + + +@pytest_twisted.ensureDeferred +async def test_inlineCallbacks_async(): + await sleep() diff --git a/testing/plugins_integration/simple_integration.py b/testing/plugins_integration/simple_integration.py new file mode 100644 index 000000000..20b2fc4b5 --- /dev/null +++ b/testing/plugins_integration/simple_integration.py @@ -0,0 +1,10 @@ +import pytest + + +def test_foo(): + assert True + + +@pytest.mark.parametrize("i", range(3)) +def test_bar(i): + assert True |