Skip to content

Commit e4d6af1

Browse files
fix up oversights
1 parent f70d522 commit e4d6af1

File tree

5 files changed

+53
-40
lines changed

5 files changed

+53
-40
lines changed

_pytest/fixtures.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,8 +681,9 @@ def fail_fixturefunc(fixturefunc, msg):
681681
fs, lineno = getfslineno(fixturefunc)
682682
location = "%s:%s" % (fs, lineno+1)
683683
source = _pytest._code.Source(fixturefunc)
684-
pytest.fail(msg + ":\n\n" + str(source.indent()) + "\n" + location,
685-
pytrace=False)
684+
fail(msg + ":\n\n" + str(source.indent()) + "\n" + location,
685+
pytrace=False)
686+
686687

687688
def call_fixture_func(fixturefunc, request, kwargs):
688689
yieldctx = is_generator(fixturefunc)

_pytest/python.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,6 @@ def raises(expected_exception, *args, **kwargs):
12251225
raises.Exception = fail.Exception
12261226

12271227

1228-
12291228
class RaisesContext(object):
12301229
def __init__(self, expected_exception, message, match_expr):
12311230
self.expected_exception = expected_exception

_pytest/recwarn.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import py
66
import sys
77
import warnings
8-
from collections import namedtuple
98
from _pytest.fixtures import yield_fixture
109

1110

_pytest/skipping.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def check_xfail_no_run(item):
202202
evalxfail = item._evalxfail
203203
if evalxfail.istrue():
204204
if not evalxfail.get('run', True):
205-
pytest.xfail("[NOTRUN] " + evalxfail.getexplanation())
205+
xfail("[NOTRUN] " + evalxfail.getexplanation())
206206

207207

208208
def check_strict_xfail(pyfuncitem):
@@ -214,7 +214,7 @@ def check_strict_xfail(pyfuncitem):
214214
if is_strict_xfail:
215215
del pyfuncitem._evalxfail
216216
explanation = evalxfail.getexplanation()
217-
pytest.fail('[XPASS(strict)] ' + explanation, pytrace=False)
217+
fail('[XPASS(strict)] ' + explanation, pytrace=False)
218218

219219

220220
@hookimpl(hookwrapper=True)
@@ -305,12 +305,14 @@ def pytest_terminal_summary(terminalreporter):
305305
for line in lines:
306306
tr._tw.line(line)
307307

308+
308309
def show_simple(terminalreporter, lines, stat, format):
309310
failed = terminalreporter.stats.get(stat)
310311
if failed:
311312
for rep in failed:
312313
pos = terminalreporter.config.cwd_relative_nodeid(rep.nodeid)
313-
lines.append(format %(pos,))
314+
lines.append(format % (pos,))
315+
314316

315317
def show_xfailed(terminalreporter, lines):
316318
xfailed = terminalreporter.stats.get("xfailed")
@@ -322,13 +324,15 @@ def show_xfailed(terminalreporter, lines):
322324
if reason:
323325
lines.append(" " + str(reason))
324326

327+
325328
def show_xpassed(terminalreporter, lines):
326329
xpassed = terminalreporter.stats.get("xpassed")
327330
if xpassed:
328331
for rep in xpassed:
329332
pos = terminalreporter.config.cwd_relative_nodeid(rep.nodeid)
330333
reason = rep.wasxfail
331-
lines.append("XPASS %s %s" %(pos, reason))
334+
lines.append("XPASS %s %s" % (pos, reason))
335+
332336

333337
def cached_eval(config, expr, d):
334338
if not hasattr(config, '_evalcache'):
@@ -353,6 +357,7 @@ def folded_skips(skipped):
353357
l.append((len(events),) + key)
354358
return l
355359

360+
356361
def show_skipped(terminalreporter, lines):
357362
tr = terminalreporter
358363
skipped = tr.stats.get('skipped', [])
@@ -368,5 +373,6 @@ def show_skipped(terminalreporter, lines):
368373
for num, fspath, lineno, reason in fskips:
369374
if reason.startswith("Skipped: "):
370375
reason = reason[9:]
371-
lines.append("SKIP [%d] %s:%d: %s" %
376+
lines.append(
377+
"SKIP [%d] %s:%d: %s" %
372378
(num, fspath, lineno, reason))

pytest.py

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,32 @@
22
"""
33
pytest: unit and functional testing with Python.
44
"""
5+
6+
7+
# else we are imported
8+
9+
from _pytest.config import (
10+
main, UsageError, _preloadplugins, cmdline,
11+
hookspec, hookimpl
12+
)
13+
from _pytest.fixtures import fixture, yield_fixture
14+
from _pytest.assertion import register_assert_rewrite
15+
from _pytest.freeze_support import freeze_includes
16+
from _pytest import __version__
17+
from _pytest.debugging import pytestPDB as __pytestPDB
18+
from _pytest.recwarn import warns, deprecated_call
19+
from _pytest.runner import fail, skip, importorskip, exit
20+
from _pytest.mark import MARK_GEN as mark
21+
from _pytest.skipping import xfail
22+
from _pytest.main import Item, Collector, File, Session
23+
from _pytest.fixtures import fillfixtures as _fillfuncargs
24+
from _pytest.python import (
25+
raises, approx,
26+
Module, Class, Instance, Function, Generator,
27+
)
28+
29+
set_trace = __pytestPDB.set_trace
30+
531
__all__ = [
632
'main',
733
'UsageError',
@@ -22,48 +48,30 @@
2248
'importorskip',
2349
'exit',
2450
'mark',
25-
51+
'approx',
2652
'_fillfuncargs',
2753

2854
'Item',
2955
'File',
3056
'Collector',
3157
'Session',
58+
'Module',
59+
'Class',
60+
'Instance',
61+
'Function',
62+
'Generator',
63+
'raises',
3264

3365

3466
]
3567

36-
if __name__ == '__main__': # if run as a script or by 'python -m pytest'
68+
if __name__ == '__main__':
69+
# if run as a script or by 'python -m pytest'
3770
# we trigger the below "else" condition by the following import
3871
import pytest
3972
raise SystemExit(pytest.main())
73+
else:
4074

41-
# else we are imported
42-
43-
from _pytest.config import (
44-
main, UsageError, _preloadplugins, cmdline,
45-
hookspec, hookimpl
46-
)
47-
from _pytest.fixtures import fixture, yield_fixture
48-
from _pytest.assertion import register_assert_rewrite
49-
from _pytest.freeze_support import freeze_includes
50-
from _pytest import __version__
51-
from _pytest.debugging import pytestPDB as __pytestPDB
52-
from _pytest.recwarn import warns, deprecated_call
53-
from _pytest.runner import fail, skip, importorskip, exit
54-
from _pytest.mark import MARK_GEN as mark
55-
from _pytest.skipping import xfail
56-
from _pytest.main import Item, Collector, File, Session
57-
from _pytest.fixtures import fillfixtures as _fillfuncargs
58-
from _pytest.python import (
59-
raises, approx,
60-
Module, Class, Instance, Function, Generator,
61-
)
62-
63-
64-
set_trace = __pytestPDB.set_trace
65-
66-
67-
from _pytest.compat import _setup_collect_fakemodule
68-
_preloadplugins() # to populate pytest.* namespace so help(pytest) works
69-
_setup_collect_fakemodule()
75+
from _pytest.compat import _setup_collect_fakemodule
76+
_preloadplugins() # to populate pytest.* namespace so help(pytest) works
77+
_setup_collect_fakemodule()

0 commit comments

Comments
 (0)