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

Function test_getfslineno

testing/code/test_source.py:350–376  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

348
349
350def test_getfslineno() -> None:
351 def f(x) -> None:
352 raise NotImplementedError()
353
354 fspath, lineno = getfslineno(f)
355
356 assert isinstance(fspath, Path)
357 assert fspath.name == "test_source.py"
358 assert lineno == f.__code__.co_firstlineno - 1 # see findsource
359
360 class A:
361 pass
362
363 fspath, lineno = getfslineno(A)
364
365 _, A_lineno = inspect.findsource(A)
366 assert isinstance(fspath, Path)
367 assert fspath.name == "test_source.py"
368 assert lineno == A_lineno
369
370 assert getfslineno(3) == ("", -1)
371
372 class B:
373 pass
374
375 B.__name__ = B.__qualname__ = "B2"
376 assert getfslineno(B)[1] == -1
377
378
379def test_code_of_object_instance_with_call() -> None:

Callers

nothing calls this directly

Calls 1

getfslinenoFunction · 0.90

Tested by

no test coverage detected