fune/third_party/python/pytest/testing/test_helpconfig.py
Dave Hunt a631fc714d Bug 1472201 - Vendor pytest 3.6.2 and dependencies; r=ahal
MozReview-Commit-ID: 5qfK6OygVMH

--HG--
rename : third_party/python/pytest/_pytest/vendored_packages/pluggy-0.4.0.dist-info/LICENSE.txt => third_party/python/pluggy/LICENSE
rename : third_party/python/pytest/doc/en/example/costlysetup/sub1/__init__.py => third_party/python/pytest/doc/en/example/costlysetup/sub_a/__init__.py
rename : third_party/python/pytest/doc/en/example/costlysetup/sub1/__init__.py => third_party/python/pytest/doc/en/example/costlysetup/sub_b/__init__.py
rename : third_party/python/pytest/_pytest/_code/__init__.py => third_party/python/pytest/src/_pytest/_code/__init__.py
extra : rebase_source : d80873f2b1899decefbddddfc2f69ae045925b81
2018-06-29 15:37:31 +01:00

72 lines
2 KiB
Python

from __future__ import absolute_import, division, print_function
from _pytest.main import EXIT_NOTESTSCOLLECTED
import pytest
def test_version(testdir, pytestconfig):
result = testdir.runpytest("--version")
assert result.ret == 0
# p = py.path.local(py.__file__).dirpath()
result.stderr.fnmatch_lines(["*pytest*%s*imported from*" % (pytest.__version__,)])
if pytestconfig.pluginmanager.list_plugin_distinfo():
result.stderr.fnmatch_lines(["*setuptools registered plugins:", "*at*"])
def test_help(testdir):
result = testdir.runpytest("--help")
assert result.ret == 0
result.stdout.fnmatch_lines(
"""
*-v*verbose*
*setup.cfg*
*minversion*
*to see*markers*pytest --markers*
*to see*fixtures*pytest --fixtures*
"""
)
def test_hookvalidation_unknown(testdir):
testdir.makeconftest(
"""
def pytest_hello(xyz):
pass
"""
)
result = testdir.runpytest()
assert result.ret != 0
result.stdout.fnmatch_lines(["*unknown hook*pytest_hello*"])
def test_hookvalidation_optional(testdir):
testdir.makeconftest(
"""
import pytest
@pytest.hookimpl(optionalhook=True)
def pytest_hello(xyz):
pass
"""
)
result = testdir.runpytest()
assert result.ret == EXIT_NOTESTSCOLLECTED
def test_traceconfig(testdir):
result = testdir.runpytest("--traceconfig")
result.stdout.fnmatch_lines(["*using*pytest*py*", "*active plugins*"])
def test_debug(testdir, monkeypatch):
result = testdir.runpytest_subprocess("--debug")
assert result.ret == EXIT_NOTESTSCOLLECTED
p = testdir.tmpdir.join("pytestdebug.log")
assert "pytest_sessionstart" in p.read()
def test_PYTEST_DEBUG(testdir, monkeypatch):
monkeypatch.setenv("PYTEST_DEBUG", "1")
result = testdir.runpytest_subprocess()
assert result.ret == EXIT_NOTESTSCOLLECTED
result.stderr.fnmatch_lines(
["*pytest_plugin_registered*", "*manager*PluginManager*"]
)