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>
This commit is contained in:
committed by
Bruno Oliveira
parent
687146e3f1
commit
5819cb611e
2
testing/plugins_integration/.gitignore
vendored
Normal file
2
testing/plugins_integration/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*.html
|
||||
assets/
|
||||
13
testing/plugins_integration/README.rst
Normal file
13
testing/plugins_integration/README.rst
Normal file
@@ -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.
|
||||
9
testing/plugins_integration/bdd_wallet.feature
Normal file
9
testing/plugins_integration/bdd_wallet.feature
Normal file
@@ -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
|
||||
39
testing/plugins_integration/bdd_wallet.py
Normal file
39
testing/plugins_integration/bdd_wallet.py
Normal file
@@ -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
|
||||
1
testing/plugins_integration/django_settings.py
Normal file
1
testing/plugins_integration/django_settings.py
Normal file
@@ -0,0 +1 @@
|
||||
SECRET_KEY = "mysecret"
|
||||
4
testing/plugins_integration/pytest.ini
Normal file
4
testing/plugins_integration/pytest.ini
Normal file
@@ -0,0 +1,4 @@
|
||||
[pytest]
|
||||
addopts = --strict-markers
|
||||
filterwarnings =
|
||||
error::pytest.PytestWarning
|
||||
8
testing/plugins_integration/pytest_anyio_integration.py
Normal file
8
testing/plugins_integration/pytest_anyio_integration.py
Normal file
@@ -0,0 +1,8 @@
|
||||
import anyio
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_sleep():
|
||||
await anyio.sleep(0)
|
||||
@@ -0,0 +1,8 @@
|
||||
import asyncio
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_sleep():
|
||||
await asyncio.sleep(0)
|
||||
2
testing/plugins_integration/pytest_mock_integration.py
Normal file
2
testing/plugins_integration/pytest_mock_integration.py
Normal file
@@ -0,0 +1,2 @@
|
||||
def test_mocker(mocker):
|
||||
mocker.MagicMock()
|
||||
8
testing/plugins_integration/pytest_trio_integration.py
Normal file
8
testing/plugins_integration/pytest_trio_integration.py
Normal file
@@ -0,0 +1,8 @@
|
||||
import trio
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.trio
|
||||
async def test_sleep():
|
||||
await trio.sleep(0)
|
||||
18
testing/plugins_integration/pytest_twisted_integration.py
Normal file
18
testing/plugins_integration/pytest_twisted_integration.py
Normal file
@@ -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()
|
||||
10
testing/plugins_integration/simple_integration.py
Normal file
10
testing/plugins_integration/simple_integration.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import pytest
|
||||
|
||||
|
||||
def test_foo():
|
||||
assert True
|
||||
|
||||
|
||||
@pytest.mark.parametrize("i", range(3))
|
||||
def test_bar(i):
|
||||
assert True
|
||||
Reference in New Issue
Block a user