Skip to content

Commit

Permalink
Fixed corner case where conftest.py wouldn't be properly gotten with …
Browse files Browse the repository at this point in the history
…previous approach when running pytest.
  • Loading branch information
fabioz committed Apr 18, 2024
1 parent 530ac84 commit d9bddb9
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions plugins/org.python.pydev.core/pysrc/runfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,26 @@ def dotted(p):
# See related issue (for which we work-around below):
# https://bitbucket.org/hpk42/pytest/issue/639/conftest-being-loaded-twice-giving

for path in sys.path:
path_dotted = dotted(path)
if curr_dotted.startswith(path_dotted):
os.chdir(path)
found_conftest = False

curdir_abs = os.path.abspath(os.curdir)
while True:
if os.path.exists(os.path.join(curdir_abs, 'conftest.py')):
os.chdir(curdir_abs)
found_conftest = True
break

parent = os.path.dirname(curdir_abs)
if curdir_abs == parent or not parent:
break
curdir_abs = parent

if not found_conftest:
for path in sys.path:
path_dotted = dotted(path)
if curr_dotted.startswith(path_dotted):
os.chdir(path)
break

remove = []
for i in range(len(argv)):
Expand Down

0 comments on commit d9bddb9

Please sign in to comment.