diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 0b9e64e2f..efc613910 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -371,7 +371,7 @@ def _in_venv(path: Path) -> bool: """Attempt to detect if ``path`` is the root of a Virtual Environment by checking for the existence of the pyvenv.cfg file.""" try: - return path.joinpath("pyvenv.cfg").exists() + return path.joinpath("pyvenv.cfg").is_file() except OSError: return False