Spaces Data
Minimal test - lines (340, 366)
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_original
old: 91.70064566653556
new: 89.10309473531765
path: .spaces[1].spaces[11].metrics.mi.mi_visual_studio
old: 53.62610857692138
new: 52.10707294463021
path: .spaces[1].spaces[11].metrics.mi.mi_sei
old: 57.104314054436415
new: 81.43545479820096
Code
def test_failure_in_setup_function_ignores_custom_repr(self, testdir):
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 (191, 209)
path: .spaces[1].spaces[5].metrics.mi.mi_sei
old: 64.04026337116053
new: 85.5270990171488
path: .spaces[1].spaces[5].metrics.mi.mi_visual_studio
old: 56.39631767921539
new: 55.34260113606591
path: .spaces[1].spaces[5].metrics.mi.mi_original
old: 96.43770323145831
new: 94.6358479426727
path: .spaces[1].spaces[5].metrics.loc.sloc
old: 17.0
new: 19.0
path: .spaces[1].spaces[5].metrics.loc.cloc
old: 0.0
new: 2.0
Code
def test_failure_in_teardown_function(self, testdir):
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
Minimal test - lines (211, 234)
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
path: .spaces[1].spaces[6].metrics.mi.mi_sei
old: 62.41178281133068
new: 87.70698129758787
path: .spaces[1].spaces[6].metrics.mi.mi_original
old: 95.45007881975802
new: 92.49646959969596
path: .spaces[1].spaces[6].metrics.mi.mi_visual_studio
old: 55.81875954371814
new: 54.09150268988068
Code
def test_custom_failure_repr(self, testdir):
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 (118, 131)
path: .spaces[1].spaces[1].metrics.mi.mi_sei
old: 70.5979349652146
new: 88.98143990215135
path: .spaces[1].spaces[1].metrics.mi.mi_original
old: 100.98313480791496
new: 99.78258565902468
path: .spaces[1].spaces[1].metrics.mi.mi_visual_studio
old: 59.05446479995027
new: 58.35238927428344
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):
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 (133, 151)
path: .spaces[1].spaces[2].metrics.loc.sloc
old: 13.0
new: 19.0
path: .spaces[1].spaces[2].metrics.loc.cloc
old: 0.0
new: 6.0
path: .spaces[1].spaces[2].metrics.mi.mi_visual_studio
old: 59.765357930091085
new: 56.170193092886734
path: .spaces[1].spaces[2].metrics.mi.mi_sei
old: 72.24989451462024
new: 101.61545876285322
path: .spaces[1].spaces[2].metrics.mi.mi_original
old: 102.19876206045576
new: 96.05103018883632
Code
def test_skipfunction(self, testdir):
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