Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change directory for py27 xdist-related envs #2874

Merged

Conversation

nicoddemus
Copy link
Member

@nicoddemus nicoddemus commented Oct 26, 2017

The filter_traceback function was not filtering the frames
that belonged to the pytest internals.

"filter_traceback" was receiving relative paths when running with
xdist, and full paths in non-distributed runs; for this reason
the traceback function did not consider the received path to be
relative to the pytest internal modules:

pytest/_pytest/python.py

Lines 48 to 49 in 111d640

p = py.path.local(entry.path)
return p != cutdir1 and not p.relto(cutdir2) and not p.relto(cutdir3)

py.path.local(entry.path) will create a full path using cwd because entry.path is relative, and cwd would point to the testdir directory (as it should).

I debugged up until Code.__init__:

class Code(object):
""" wrapper around Python code objects """
def __init__(self, rawcode):
if not hasattr(rawcode, "co_filename"):
rawcode = getrawcode(rawcode)
try:
self.filename = rawcode.co_filename
self.firstlineno = rawcode.co_firstlineno - 1
self.name = rawcode.co_name

And I verified that the rawcode.co_filename is indeed a relative path when executed with xdist and a full path in non-distributed, but I don't have a clue as to why.

By running the tests in a directory other than where _pytest is, then rawcode.co_filename is always a full path and everything works.

I tried to back trace to other versions (pytest 3.1.0, execnet 1.4 and pytest-xdist 1.19) but the problem still happens in those versions, so I can't figure out why this suddenly started to fail.

I thought I would at least open a PR with my findings and a "workaround" to see if people have any suggestions.

Fix #2843

The "filter_traceback" function was not filtering the frames
that belonged to the pytest internals.

"filter_traceback" was receiving *relative* paths when running with
xdist, and full paths in non-distributed runs; for this reason
the traceback function did not consider the received path to be
relative to the pytest internal modules.

Fix pytest-dev#2843
@coveralls
Copy link

Coverage Status

Coverage remained the same at 92.244% when pulling c3ba922 on nicoddemus:fix-py27-xdist-envs-2843 into 111d640 on pytest-dev:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 92.244% when pulling 27cea34 on nicoddemus:fix-py27-xdist-envs-2843 into 111d640 on pytest-dev:master.

Copy link
Member

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok to merge, but needs a followup because it should work as is

@RonnyPfannschmidt RonnyPfannschmidt merged commit cd747c4 into pytest-dev:master Oct 30, 2017
@nicoddemus nicoddemus deleted the fix-py27-xdist-envs-2843 branch October 30, 2017 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants