Spaces Data

Minimal test - lines (59, 80)

path: .spaces[3].metrics.mi.mi_visual_studio
old: 53.330208290440986
new: 51.94133327178111

path: .spaces[3].metrics.mi.mi_original
old: 91.19465617665408
new: 88.81967989474569

path: .spaces[3].metrics.mi.mi_sei
old: 56.47614538604694
new: 80.11877774420533

path: .spaces[3].metrics.loc.sloc
old: 19.0
new: 22.0

path: .spaces[3].metrics.loc.cloc
old: 0.0
new: 3.0

Code

def test_excinfo_getstatement():
    def g():
        raise ValueError

    def f():
        g()

    try:
        f()
    except ValueError:
        excinfo = _pytest._code.ExceptionInfo.from_current()
    linenumbers = [
        f.__code__.co_firstlineno - 1 + 4,
        f.__code__.co_firstlineno - 1 + 1,
        g.__code__.co_firstlineno - 1 + 1,
    ]
    values = list(excinfo.traceback)
    foundlinenumbers = [x.lineno for x in values]
    assert foundlinenumbers == linenumbers
    # for x in info:
    #    print "%s:%d  %s" %(x.path.relto(root), x.lineno, x.statement)
    # xxx

Minimal test - lines (195, 199)

path: .spaces[7].spaces[7].spaces[1].metrics.loc.cloc
old: 1.0
new: 2.0

path: .spaces[7].spaces[7].spaces[1].metrics.loc.sloc
old: 4.0
new: 5.0

path: .spaces[7].spaces[7].spaces[1].metrics.mi.mi_visual_studio
old: 78.39554672677042
new: 76.28155518800422

path: .spaces[7].spaces[7].spaces[1].metrics.mi.mi_sei
old: 152.77484308930326
new: 154.10739759318386

path: .spaces[7].spaces[7].spaces[1].metrics.mi.mi_original
old: 134.0563849027774
new: 130.4414593714872

Code

        def g():
            #
            __tracebackhide__ = tracebackhide
            f()
            #

Minimal test - lines (86, 89)

path: .spaces[4].metrics.mi.mi_original
old: 142.15938490684147
new: 137.49893533312263

path: .spaces[4].metrics.mi.mi_sei
old: 168.48614000756413
new: 167.22660220636422

path: .spaces[4].metrics.mi.mi_visual_studio
old: 83.13414322037512
new: 80.40873411293721

path: .spaces[4].metrics.loc.sloc
old: 3.0
new: 4.0

path: .spaces[4].metrics.loc.cloc
old: 1.0
new: 2.0

Code

def f():
    #
    raise ValueError
    #

Minimal test - lines (99, 102)

path: .spaces[6].metrics.loc.sloc
old: 3.0
new: 4.0

path: .spaces[6].metrics.loc.cloc
old: 1.0
new: 2.0

path: .spaces[6].metrics.mi.mi_visual_studio
old: 84.71624627594792
new: 81.99083716851001

path: .spaces[6].metrics.mi.mi_sei
old: 172.3892017250539
new: 171.12966392385397

path: .spaces[6].metrics.mi.mi_original
old: 144.86478113187096
new: 140.20433155815212

Code

def h():
    #
    g()
    #

Minimal test - lines (201, 204)

path: .spaces[7].spaces[7].spaces[2].metrics.loc.cloc
old: 1.0
new: 2.0

path: .spaces[7].spaces[7].spaces[2].metrics.loc.sloc
old: 3.0
new: 4.0

path: .spaces[7].spaces[7].spaces[2].metrics.mi.mi_visual_studio
old: 84.71624627594792
new: 81.99083716851001

path: .spaces[7].spaces[7].spaces[2].metrics.mi.mi_sei
old: 172.3892017250539
new: 171.12966392385397

path: .spaces[7].spaces[7].spaces[2].metrics.mi.mi_original
old: 144.86478113187096
new: 140.20433155815212

Code

        def h():
            #
            g()
            #

Minimal test - lines (92, 96)

path: .spaces[5].metrics.mi.mi_original
old: 134.0563849027774
new: 130.4414593714872

path: .spaces[5].metrics.mi.mi_sei
old: 152.77484308930326
new: 154.10739759318386

path: .spaces[5].metrics.mi.mi_visual_studio
old: 78.39554672677042
new: 76.28155518800422

path: .spaces[5].metrics.loc.cloc
old: 1.0
new: 2.0

path: .spaces[5].metrics.loc.sloc
old: 4.0
new: 5.0

Code

def g():
    #
    __tracebackhide__ = True
    f()
    #

Minimal test - lines (190, 193)

path: .spaces[7].spaces[7].spaces[0].metrics.mi.mi_original
old: 142.15938490684147
new: 137.49893533312263

path: .spaces[7].spaces[7].spaces[0].metrics.mi.mi_visual_studio
old: 83.13414322037512
new: 80.40873411293721

path: .spaces[7].spaces[7].spaces[0].metrics.mi.mi_sei
old: 168.48614000756413
new: 167.22660220636422

path: .spaces[7].spaces[7].spaces[0].metrics.loc.cloc
old: 1.0
new: 2.0

path: .spaces[7].spaces[7].spaces[0].metrics.loc.sloc
old: 3.0
new: 4.0

Code

        def f():
            #
            raise ValueError
            #

Minimal test - lines (595, 626)

path: .spaces[18].spaces[10].metrics.loc.cloc
old: 2.0
new: 3.0

path: .spaces[18].spaces[10].metrics.loc.sloc
old: 31.0
new: 32.0

path: .spaces[18].spaces[10].metrics.mi.mi_original
old: 78.7114009424705
new: 78.1970720297743

path: .spaces[18].spaces[10].metrics.mi.mi_visual_studio
old: 46.030059030684505
new: 45.72928188875691

path: .spaces[18].spaces[10].metrics.mi.mi_sei
old: 58.14666960498886
new: 61.07133855982633

Code

    def test_repr_tracebackentry_lines(self, importasmod) -> None:
        mod = importasmod(
            """
            def func1():
                raise ValueError("hello\\nworld")
        """
        )
        excinfo = pytest.raises(ValueError, mod.func1)
        excinfo.traceback = excinfo.traceback.filter()
        p = FormattedExcinfo()
        reprtb = p.repr_traceback_entry(excinfo.traceback[-1])

        # test as intermittent entry
        lines = reprtb.lines
        assert lines[0] == "    def func1():"
        assert lines[1] == '>       raise ValueError("hello\\nworld")'

        # test as last entry
        p = FormattedExcinfo(showlocals=True)
        repr_entry = p.repr_traceback_entry(excinfo.traceback[-1], excinfo)
        lines = repr_entry.lines
        assert lines[0] == "    def func1():"
        assert lines[1] == '>       raise ValueError("hello\\nworld")'
        assert lines[2] == "E       ValueError: hello"
        assert lines[3] == "E       world"
        assert not lines[4:]

        loc = repr_entry.reprfileloc
        assert loc is not None
        assert loc.path == mod.__file__
        assert loc.lineno == 3
        # assert loc.message == "ValueError: hello"