Replies: 1 comment
-
I think I may have stumbled across it in class FSCollector(Collector):
def __init__(
self, fspath: py.path.local, parent=None, config=None, session=None, nodeid=None
) -> None:
name = fspath.basename
if parent is not None:
rel = fspath.relto(parent.fspath)
if rel:
name = rel
name = name.replace(os.sep, SEP)
self.fspath = fspath
session = session or parent.session
if nodeid is None:
nodeid = self.fspath.relto(session.config.rootdir) # <------- could this be it? I think I see it, the relative path under bazel and the runfiles folder just doesn't compute for a relative path calculation. Here's a debugged version of FSCollector... class FSCollector(Collector):
def __init__(
self, fspath: py.path.local, parent=None, config=None, session=None, nodeid=None
) -> None:
name = fspath.basename
if parent is not None:
rel = fspath.relto(parent.fspath)
if rel:
name = rel
name = name.replace(os.sep, SEP)
self.fspath = fspath
session = session or parent.session
if nodeid is None:
print("\nDEBUG=====================")
print("type(self.fspath): %s" % type(self.fspath))
print("type(session.config.rootdir): %s" % type(session.config.rootdir))
print("self.fspath: %s" % self.fspath)
print("session.config.rootdir: %s" % session.config.rootdir)
nodeid = self.fspath.relto(session.config.rootdir) # <----------- unable to deal with bazel cwd
print("nodeid: %s" % nodeid)
if not nodeid:
nodeid = _check_initialpaths_for_relpath(session, fspath)
print("nodeid2: '%s'" % nodeid)
if nodeid and os.sep != SEP:
nodeid = nodeid.replace(os.sep, SEP)
print("nodeid3: '%s'" % nodeid)
print("nodeid4: '%s'" % nodeid)
super().__init__(name, parent, config, session, nodeid=nodeid, fspath=fspath) This gives the following output...
It's interesting that it's using my local repo version of the test module and not its copy in the runfiles
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I've been trying to root cause this discrepancy in pytest behavior between running pytest locally from the shell vs running it through bazel (https://stackoverflow.com/questions/71523244/why-does-a-pytest-session-executed-from-bazel-leave-the-classname-junit-attribut). I have a suspicion that in bazel's leveraging a bunch of symlinks somehow pytest's
item.nodeid
lookup from the file system falls short. I'm hoping someone can clue me into where I can add some debug print lines to where the full nodeid prefix gets determined for a specific item. To be concrete when running directly from pytest I find nodeids going liketest_foo::test_case
, whereas in bazel it's showing up just as::test_case
.Beta Was this translation helpful? Give feedback.
All reactions