Skip to content

Commit 080b4c8

Browse files
committed
Use path parameter instead of fspath to make new pytest version happy
1 parent bddf379 commit 080b4c8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

conftest.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import sys
44
import yaml
5+
from pathlib import Path
56

67
import pytest
78

@@ -14,9 +15,9 @@ def pytest_collect_file(parent, path):
1415
f = None
1516
ext = path.ext
1617
if ext == ".csv":
17-
f = CSVFile.from_parent(parent, fspath=path)
18+
f = CSVFile.from_parent(parent, path=Path(path))
1819
if ext == ".yml":
19-
f = YamlFile.from_parent(parent, fspath=path)
20+
f = YamlFile.from_parent(parent, path=Path(path))
2021
return f
2122

2223

@@ -132,7 +133,7 @@ def pytest_runtest_logreport(report):
132133
class CSVFile(pytest.File):
133134

134135
def collect(self):
135-
with self.fspath.open(encoding="utf-8") as f:
136+
with self.path.open(encoding="utf-8") as f:
136137
dialect = csv.Sniffer().sniff(f.read(2000))
137138
f.seek(0)
138139
reader = csv.DictReader(f, dialect=dialect)
@@ -143,7 +144,7 @@ def collect(self):
143144
class YamlFile(pytest.File):
144145

145146
def collect(self):
146-
raw = yaml.safe_load(self.fspath.open(encoding="utf-8"))
147+
raw = yaml.safe_load(self.path.open(encoding="utf-8"))
147148
for name, spec in raw.items():
148149
yield YamlItem.from_parent(self, name=name, spec=spec)
149150

0 commit comments

Comments
 (0)