Skip to content

Smoke tests for assorted plugins #7721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Sep 19, 2020
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:

"docs",
"doctesting",
"plugins",
]

include:
Expand Down Expand Up @@ -111,6 +112,11 @@ jobs:
tox_env: "py38-xdist"
use_coverage: true

- name: "plugins"
python: "3.7"
os: ubuntu-latest
tox_env: "plugins"

- name: "docs"
python: "3.7"
os: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ write_to = "src/_pytest/_version.py"
[tool.pytest.ini_options]
minversion = "2.0"
addopts = "-rfEX -p pytester --strict-markers"
python_files = ["test_*.py", "*_test.py", "testing/*/*.py"]
python_files = ["test_*.py", "*_test.py", "testing/python/*.py"]
python_classes = ["Test", "Acceptance"]
python_functions = ["test"]
# NOTE: "doc" is not included here, but gets tested explicitly via "doctesting".
Expand Down
4 changes: 4 additions & 0 deletions src/_pytest/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,10 @@ def _preparse(self, args: List[str], addopts: bool = True) -> None:
self.pluginmanager.load_setuptools_entrypoints("pytest11")
self.pluginmanager.consider_env()

self.known_args_namespace = self._parser.parse_known_args(
args, namespace=copy.copy(self.known_args_namespace)
)

self._validate_plugins()
self._warn_about_skipped_plugins()

Expand Down
2 changes: 2 additions & 0 deletions testing/plugins_integration/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.html
assets/
1 change: 1 addition & 0 deletions testing/plugins_integration/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This folder contains tests and support files for smoke testing popular plugins against the current pytest version.
1 change: 1 addition & 0 deletions testing/plugins_integration/django_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SECRET_KEY = "mysecret"
4 changes: 4 additions & 0 deletions testing/plugins_integration/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[pytest]
addopts = --strict-markers
filterwarnings =
error::pytest.PytestWarning
8 changes: 8 additions & 0 deletions testing/plugins_integration/pytest_asyncio_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import asyncio

import pytest


@pytest.mark.asyncio
async def test_sleep():
await asyncio.sleep(0)
2 changes: 2 additions & 0 deletions testing/plugins_integration/pytest_mock_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def test_mocker(mocker):
mocker.MagicMock()
8 changes: 8 additions & 0 deletions testing/plugins_integration/pytest_trio_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import trio

import pytest


@pytest.mark.trio
async def test_sleep():
await trio.sleep(0)
10 changes: 10 additions & 0 deletions testing/plugins_integration/simple_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import pytest


def test_foo():
assert True


@pytest.mark.parametrize("i", range(3))
def test_bar(i):
assert True
19 changes: 19 additions & 0 deletions testing/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,25 @@ def my_dists():
else:
testdir.parseconfig()

def test_early_config_cmdline(self, testdir, monkeypatch):
"""early_config contains options registered by third-party plugins.

This is a regression involving pytest-cov (and possibly others) introduced in #7700.
"""
testdir.makepyfile(
myplugin="""
def pytest_addoption(parser):
parser.addoption('--foo', default=None, dest='foo')

def pytest_load_initial_conftests(early_config, parser, args):
assert early_config.known_args_namespace.foo == "1"
"""
)
monkeypatch.setenv("PYTEST_PLUGINS", "myplugin")
testdir.syspathinsert()
result = testdir.runpytest("--foo=1")
result.stdout.fnmatch_lines("* no tests ran in *")


class TestConfigCmdlineParsing:
def test_parsing_again_fails(self, testdir):
Expand Down
23 changes: 23 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ envlist =
pypy3
py37-{pexpect,xdist,unittestextras,numpy,pluggymaster}
doctesting
plugins
py37-freeze
docs
docs-checklinks
Expand Down Expand Up @@ -114,6 +115,28 @@ commands =
rm -rf {envdir}/.pytest_cache
make regen

[testenv:plugins]
changedir = testing/plugins_integration
deps =
django
pytest-asyncio
pytest-cov
pytest-django
pytest-html
pytest-mock
pytest-sugar
pytest-trio
setenv =
PYTHONPATH=.
commands =
pytest pytest_asyncio_integration.py
pytest --cov=. simple_integration.py
pytest --ds=django_settings simple_integration.py
pytest --html=simple.html simple_integration.py
pytest pytest_mock_integration.py
pytest simple_integration.py --force-sugar
pytest pytest_trio_integration.py

[testenv:py37-freeze]
changedir = testing/freeze
deps =
Expand Down