def test_getfslineno(): from py.code import getfslineno def f(x): pass fspath, lineno = getfslineno(f) assert fspath.basename == "test_source.py" assert lineno == py.code.getrawcode(f).co_firstlineno-1 # see findsource class A(object): pass fspath, lineno = getfslineno(A) _, A_lineno = py.std.inspect.findsource(A) assert fspath.basename == "test_source.py" assert lineno == A_lineno assert getfslineno(3) == ("", -1) class B: pass B.__name__ = "B2" assert getfslineno(B)[1] == -1
def test_getfslineno(): from py.code import getfslineno def f(x): pass fspath, lineno = getfslineno(f) assert fspath.basename == "test_source.py" assert lineno == py.code.getrawcode(f).co_firstlineno - 1 # see findsource class A(object): pass fspath, lineno = getfslineno(A) _, A_lineno = inspect.findsource(A) assert fspath.basename == "test_source.py" assert lineno == A_lineno assert getfslineno(3) == ("", -1) class B: pass B.__name__ = "B2"
def test_getfslineno(): from py.code import getfslineno def f(x): pass fspath, lineno = getfslineno(f) fname = __file__ if fname.lower().endswith('.pyc'): fname = fname[:-1] assert fspath == py.path.local(fname) assert lineno == f.func_code.co_firstlineno - 1 # see findsource class A(object): pass fspath, lineno = getfslineno(A) _, A_lineno = py.std.inspect.findsource(A) assert fspath == py.path.local(fname) assert lineno == A_lineno
def test_getfslineno(): from py.code import getfslineno def f(x): pass fspath, lineno = getfslineno(f) fname = __file__ if fname.lower().endswith('.pyc'): fname = fname[:-1] assert fspath == py.path.local(fname) assert lineno == f.func_code.co_firstlineno-1 # see findsource class A(object): pass fspath, lineno = getfslineno(A) _, A_lineno = py.std.inspect.findsource(A) assert fspath == py.path.local(fname) assert lineno == A_lineno