MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_basic_testitem_events

Method test_basic_testitem_events

testing/test_session.py:8–38  ·  view source on GitHub ↗
(self, pytester: Pytester)

Source from the content-addressed store, hash-verified

6
7class SessionTests:
8 def test_basic_testitem_events(self, pytester: Pytester) -> None:
9 tfile = pytester.makepyfile(
10 """
11 def test_one():
12 pass
13 def test_one_one():
14 assert 0
15 def test_other():
16 raise ValueError(23)
17 class TestClass(object):
18 def test_two(self, someargs):
19 pass
20 """
21 )
22 reprec = pytester.inline_run(tfile)
23 passed, skipped, failed = reprec.listoutcomes()
24 assert len(skipped) == 0
25 assert len(passed) == 1
26 assert len(failed) == 3
27
28 def end(x):
29 return x.nodeid.split("::")[-1]
30
31 assert end(failed[0]) == "test_one_one"
32 assert end(failed[1]) == "test_other"
33 itemstarted = reprec.getcalls("pytest_itemcollected")
34 assert len(itemstarted) == 4
35 # XXX check for failing funcarg setup
36 # colreports = reprec.getcalls("pytest_collectreport")
37 # assert len(colreports) == 4
38 # assert colreports[1].report.failed
39
40 def test_nested_import_error(self, pytester: Pytester) -> None:
41 tfile = pytester.makepyfile(

Callers

nothing calls this directly

Calls 4

listoutcomesMethod · 0.80
getcallsMethod · 0.80
makepyfileMethod · 0.45
inline_runMethod · 0.45

Tested by

no test coverage detected