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:
Sorin Sbarnea
2020-09-19 19:56:52 +01:00
committed by Bruno Oliveira
parent 687146e3f1
commit 5819cb611e
18 changed files with 186 additions and 4 deletions

View File

@@ -0,0 +1,2 @@
*.html
assets/

View 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.

View 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

View 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

View File

@@ -0,0 +1 @@
SECRET_KEY = "mysecret"

View File

@@ -0,0 +1,4 @@
[pytest]
addopts = --strict-markers
filterwarnings =
error::pytest.PytestWarning

View File

@@ -0,0 +1,8 @@
import anyio
import pytest
@pytest.mark.anyio
async def test_sleep():
await anyio.sleep(0)

View File

@@ -0,0 +1,8 @@
import asyncio
import pytest
@pytest.mark.asyncio
async def test_sleep():
await asyncio.sleep(0)

View File

@@ -0,0 +1,2 @@
def test_mocker(mocker):
mocker.MagicMock()

View File

@@ -0,0 +1,8 @@
import trio
import pytest
@pytest.mark.trio
async def test_sleep():
await trio.sleep(0)

View 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()

View File

@@ -0,0 +1,10 @@
import pytest
def test_foo():
assert True
@pytest.mark.parametrize("i", range(3))
def test_bar(i):
assert True