fix up oversights
This commit is contained in:
parent
4d31ea8316
commit
7cdefce656
|
@ -682,9 +682,10 @@ def fail_fixturefunc(fixturefunc, msg):
|
|||
fs, lineno = getfslineno(fixturefunc)
|
||||
location = "%s:%s" % (fs, lineno+1)
|
||||
source = _pytest._code.Source(fixturefunc)
|
||||
pytest.fail(msg + ":\n\n" + str(source.indent()) + "\n" + location,
|
||||
fail(msg + ":\n\n" + str(source.indent()) + "\n" + location,
|
||||
pytrace=False)
|
||||
|
||||
|
||||
def call_fixture_func(fixturefunc, request, kwargs):
|
||||
yieldctx = is_generator(fixturefunc)
|
||||
if yieldctx:
|
||||
|
|
|
@ -1223,8 +1223,8 @@ def raises(expected_exception, *args, **kwargs):
|
|||
return _pytest._code.ExceptionInfo()
|
||||
fail(message)
|
||||
|
||||
raises.Exception = fail.Exception
|
||||
|
||||
raises.Exception = fail.Exception
|
||||
|
||||
|
||||
class RaisesContext(object):
|
||||
|
|
|
@ -7,7 +7,6 @@ import _pytest._code
|
|||
import py
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
from _pytest.fixtures import yield_fixture
|
||||
|
||||
|
||||
|
|
|
@ -204,7 +204,7 @@ def check_xfail_no_run(item):
|
|||
evalxfail = item._evalxfail
|
||||
if evalxfail.istrue():
|
||||
if not evalxfail.get('run', True):
|
||||
pytest.xfail("[NOTRUN] " + evalxfail.getexplanation())
|
||||
xfail("[NOTRUN] " + evalxfail.getexplanation())
|
||||
|
||||
|
||||
def check_strict_xfail(pyfuncitem):
|
||||
|
@ -216,7 +216,7 @@ def check_strict_xfail(pyfuncitem):
|
|||
if is_strict_xfail:
|
||||
del pyfuncitem._evalxfail
|
||||
explanation = evalxfail.getexplanation()
|
||||
pytest.fail('[XPASS(strict)] ' + explanation, pytrace=False)
|
||||
fail('[XPASS(strict)] ' + explanation, pytrace=False)
|
||||
|
||||
|
||||
@hookimpl(hookwrapper=True)
|
||||
|
@ -307,12 +307,14 @@ def pytest_terminal_summary(terminalreporter):
|
|||
for line in lines:
|
||||
tr._tw.line(line)
|
||||
|
||||
|
||||
def show_simple(terminalreporter, lines, stat, format):
|
||||
failed = terminalreporter.stats.get(stat)
|
||||
if failed:
|
||||
for rep in failed:
|
||||
pos = terminalreporter.config.cwd_relative_nodeid(rep.nodeid)
|
||||
lines.append(format %(pos,))
|
||||
lines.append(format % (pos,))
|
||||
|
||||
|
||||
def show_xfailed(terminalreporter, lines):
|
||||
xfailed = terminalreporter.stats.get("xfailed")
|
||||
|
@ -324,13 +326,15 @@ def show_xfailed(terminalreporter, lines):
|
|||
if reason:
|
||||
lines.append(" " + str(reason))
|
||||
|
||||
|
||||
def show_xpassed(terminalreporter, lines):
|
||||
xpassed = terminalreporter.stats.get("xpassed")
|
||||
if xpassed:
|
||||
for rep in xpassed:
|
||||
pos = terminalreporter.config.cwd_relative_nodeid(rep.nodeid)
|
||||
reason = rep.wasxfail
|
||||
lines.append("XPASS %s %s" %(pos, reason))
|
||||
lines.append("XPASS %s %s" % (pos, reason))
|
||||
|
||||
|
||||
def cached_eval(config, expr, d):
|
||||
if not hasattr(config, '_evalcache'):
|
||||
|
@ -355,6 +359,7 @@ def folded_skips(skipped):
|
|||
l.append((len(events),) + key)
|
||||
return l
|
||||
|
||||
|
||||
def show_skipped(terminalreporter, lines):
|
||||
tr = terminalreporter
|
||||
skipped = tr.stats.get('skipped', [])
|
||||
|
@ -370,5 +375,6 @@ def show_skipped(terminalreporter, lines):
|
|||
for num, fspath, lineno, reason in fskips:
|
||||
if reason.startswith("Skipped: "):
|
||||
reason = reason[9:]
|
||||
lines.append("SKIP [%d] %s:%d: %s" %
|
||||
lines.append(
|
||||
"SKIP [%d] %s:%d: %s" %
|
||||
(num, fspath, lineno, reason))
|
||||
|
|
84
pytest.py
84
pytest.py
|
@ -2,41 +2,7 @@
|
|||
"""
|
||||
pytest: unit and functional testing with Python.
|
||||
"""
|
||||
__all__ = [
|
||||
'main',
|
||||
'UsageError',
|
||||
'cmdline',
|
||||
'hookspec',
|
||||
'hookimpl',
|
||||
'__version__',
|
||||
'register_assert_rewrite',
|
||||
'freeze_includes',
|
||||
'set_trace',
|
||||
'warns',
|
||||
'deprecated_call',
|
||||
'fixture',
|
||||
'yield_fixture',
|
||||
'fail',
|
||||
'skip',
|
||||
'xfail',
|
||||
'importorskip',
|
||||
'exit',
|
||||
'mark',
|
||||
|
||||
'_fillfuncargs',
|
||||
|
||||
'Item',
|
||||
'File',
|
||||
'Collector',
|
||||
'Session',
|
||||
|
||||
|
||||
]
|
||||
|
||||
if __name__ == '__main__': # if run as a script or by 'python -m pytest'
|
||||
# we trigger the below "else" condition by the following import
|
||||
import pytest
|
||||
raise SystemExit(pytest.main())
|
||||
|
||||
# else we are imported
|
||||
|
||||
|
@ -60,10 +26,52 @@ from _pytest.python import (
|
|||
Module, Class, Instance, Function, Generator,
|
||||
)
|
||||
|
||||
|
||||
set_trace = __pytestPDB.set_trace
|
||||
|
||||
__all__ = [
|
||||
'main',
|
||||
'UsageError',
|
||||
'cmdline',
|
||||
'hookspec',
|
||||
'hookimpl',
|
||||
'__version__',
|
||||
'register_assert_rewrite',
|
||||
'freeze_includes',
|
||||
'set_trace',
|
||||
'warns',
|
||||
'deprecated_call',
|
||||
'fixture',
|
||||
'yield_fixture',
|
||||
'fail',
|
||||
'skip',
|
||||
'xfail',
|
||||
'importorskip',
|
||||
'exit',
|
||||
'mark',
|
||||
'approx',
|
||||
'_fillfuncargs',
|
||||
|
||||
from _pytest.compat import _setup_collect_fakemodule
|
||||
_preloadplugins() # to populate pytest.* namespace so help(pytest) works
|
||||
_setup_collect_fakemodule()
|
||||
'Item',
|
||||
'File',
|
||||
'Collector',
|
||||
'Session',
|
||||
'Module',
|
||||
'Class',
|
||||
'Instance',
|
||||
'Function',
|
||||
'Generator',
|
||||
'raises',
|
||||
|
||||
|
||||
]
|
||||
|
||||
if __name__ == '__main__':
|
||||
# if run as a script or by 'python -m pytest'
|
||||
# we trigger the below "else" condition by the following import
|
||||
import pytest
|
||||
raise SystemExit(pytest.main())
|
||||
else:
|
||||
|
||||
from _pytest.compat import _setup_collect_fakemodule
|
||||
_preloadplugins() # to populate pytest.* namespace so help(pytest) works
|
||||
_setup_collect_fakemodule()
|
||||
|
|
Loading…
Reference in New Issue