Spaces Data
Minimal test - lines (348, 374)
path: .spaces[1].spaces[11].metrics.loc.sloc
old: 23.0
new: 27.0
path: .spaces[1].spaces[11].metrics.loc.cloc
old: 0.0
new: 4.0
path: .spaces[1].spaces[11].metrics.mi.mi_visual_studio
old: 53.409003559262565
new: 51.889967926971394
path: .spaces[1].spaces[11].metrics.mi.mi_sei
old: 56.56871412615472
new: 80.89985486991927
path: .spaces[1].spaces[11].metrics.mi.mi_original
old: 91.329396086339
new: 88.73184515512108
Code
def test_failure_in_setup_function_ignores_custom_repr(self, testdir) -> None:
testdir.makepyfile(
conftest="""
import pytest
class Function(pytest.Function):
def repr_failure(self, excinfo):
assert 0
"""
)
reports = testdir.runitem(
"""
def setup_function(func):
raise ValueError(42)
def test_func():
pass
"""
)
assert len(reports) == 2
rep = reports[0]
print(rep)
assert not rep.skipped
assert not rep.passed
assert rep.failed
# assert rep.outcome.when == "setup"
# assert rep.outcome.where.lineno == 3
# assert rep.outcome.where.path.basename == "test_func.py"
# assert instanace(rep.failed.failurerepr, PythonFailureRepr)
Minimal test - lines (126, 139)
path: .spaces[1].spaces[1].metrics.mi.mi_visual_studio
old: 58.82521274103969
new: 58.123137215372864
path: .spaces[1].spaces[1].metrics.mi.mi_original
old: 100.59111378717787
new: 99.3905646382876
path: .spaces[1].spaces[1].metrics.mi.mi_sei
old: 70.03236818267298
new: 88.41587311960973
path: .spaces[1].spaces[1].metrics.loc.cloc
old: 0.0
new: 1.0
path: .spaces[1].spaces[1].metrics.loc.sloc
old: 13.0
new: 14.0
Code
def test_failfunction(self, testdir) -> None:
reports = testdir.runitem(
"""
def test_func():
assert 0
"""
)
rep = reports[1]
assert not rep.passed
assert not rep.skipped
assert rep.failed
assert rep.when == "call"
assert rep.outcome == "failed"
# assert isinstance(rep.longrepr, ReprExceptionInfo)
Minimal test - lines (141, 159)
path: .spaces[1].spaces[2].metrics.loc.cloc
old: 0.0
new: 6.0
path: .spaces[1].spaces[2].metrics.loc.sloc
old: 13.0
new: 19.0
path: .spaces[1].spaces[2].metrics.mi.mi_original
old: 101.74693640902736
new: 95.59920453740794
path: .spaces[1].spaces[2].metrics.mi.mi_sei
old: 71.59804788795809
new: 100.96361213619107
path: .spaces[1].spaces[2].metrics.mi.mi_visual_studio
old: 59.50113240293998
new: 55.90596756573565
Code
def test_skipfunction(self, testdir) -> None:
reports = testdir.runitem(
"""
import pytest
def test_func():
pytest.skip("hello")
"""
)
rep = reports[1]
assert not rep.failed
assert not rep.passed
assert rep.skipped
assert rep.outcome == "skipped"
# assert rep.skipped.when == "call"
# assert rep.skipped.when == "call"
# assert rep.skipped == "%sreason == "hello"
# assert rep.skipped.location.lineno == 3
# assert rep.skipped.location.path
# assert not rep.skipped.failurerepr
Minimal test - lines (219, 242)
path: .spaces[1].spaces[6].metrics.mi.mi_sei
old: 61.75993618466853
new: 87.05513467092572
path: .spaces[1].spaces[6].metrics.mi.mi_original
old: 94.99825316832964
new: 92.04464394826758
path: .spaces[1].spaces[6].metrics.mi.mi_visual_studio
old: 55.55453401656705
new: 53.82727716272958
path: .spaces[1].spaces[6].metrics.loc.sloc
old: 20.0
new: 24.0
path: .spaces[1].spaces[6].metrics.loc.cloc
old: 0.0
new: 4.0
Code
def test_custom_failure_repr(self, testdir) -> None:
testdir.makepyfile(
conftest="""
import pytest
class Function(pytest.Function):
def repr_failure(self, excinfo):
return "hello"
"""
)
reports = testdir.runitem(
"""
import pytest
def test_func():
assert 0
"""
)
rep = reports[1]
assert not rep.skipped
assert not rep.passed
assert rep.failed
# assert rep.outcome.when == "call"
# assert rep.failed.where.lineno == 3
# assert rep.failed.where.path.basename == "test_func.py"
# assert rep.failed.failurerepr == "hello"
Minimal test - lines (199, 217)
path: .spaces[1].spaces[5].metrics.loc.cloc
old: 0.0
new: 2.0
path: .spaces[1].spaces[5].metrics.loc.sloc
old: 17.0
new: 19.0
path: .spaces[1].spaces[5].metrics.mi.mi_original
old: 96.059323228277
new: 94.25746793949138
path: .spaces[1].spaces[5].metrics.mi.mi_sei
old: 63.49437641699927
new: 84.98121206298754
path: .spaces[1].spaces[5].metrics.mi.mi_visual_studio
old: 56.1750428235538
new: 55.12132628040432
Code
def test_failure_in_teardown_function(self, testdir) -> None:
reports = testdir.runitem(
"""
import pytest
def teardown_function(func):
raise ValueError(42)
def test_func():
pass
"""
)
print(reports)
assert len(reports) == 3
rep = reports[2]
assert not rep.skipped
assert not rep.passed
assert rep.failed
assert rep.when == "teardown"
# assert rep.longrepr.reprcrash.lineno == 3
# assert rep.longrepr.reprtraceback.reprentries