code: convert from py.path to pathlib

This commit is contained in:
Ran Benita
2020-12-19 14:11:00 +02:00
parent 7aa2240832
commit 92ba96b061
7 changed files with 90 additions and 74 deletions

View File

@@ -6,13 +6,12 @@ import inspect
import linecache
import sys
import textwrap
from pathlib import Path
from types import CodeType
from typing import Any
from typing import Dict
from typing import Optional
import py.path
import pytest
from _pytest._code import Code
from _pytest._code import Frame
@@ -352,8 +351,8 @@ def test_getfslineno() -> None:
fspath, lineno = getfslineno(f)
assert isinstance(fspath, py.path.local)
assert fspath.basename == "test_source.py"
assert isinstance(fspath, Path)
assert fspath.name == "test_source.py"
assert lineno == f.__code__.co_firstlineno - 1 # see findsource
class A:
@@ -362,8 +361,8 @@ def test_getfslineno() -> None:
fspath, lineno = getfslineno(A)
_, A_lineno = inspect.findsource(A)
assert isinstance(fspath, py.path.local)
assert fspath.basename == "test_source.py"
assert isinstance(fspath, Path)
assert fspath.name == "test_source.py"
assert lineno == A_lineno
assert getfslineno(3) == ("", -1)