Fixed error when filename too long

This commit is contained in:
Robert O'Shea 2022-07-28 23:48:54 +01:00
parent b4ab2f0942
commit 7d3a5a821c
1 changed files with 8 additions and 3 deletions

View File

@ -528,9 +528,14 @@ class PytestPluginManager(PluginManager):
if i != -1:
path = path[:i]
anchor = absolutepath(current / path)
try:
if anchor.exists(): # we found some file object
self._try_load_conftest(anchor, namespace.importmode, rootpath)
foundanchor = True
except OSError:
import pytest
raise pytest.UsageError(f"file or directory not found: {anchor}")
if not foundanchor:
self._try_load_conftest(current, namespace.importmode, rootpath)