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

pytest: Use Node.from_parent(...) #493

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@

def pytest_collect_file(path, parent):
if path.ext == ".docopt" and path.basename.startswith("test"):
return DocoptTestFile(path, parent)
if hasattr(DocoptTestFile, "from_parent"):
return DocoptTestFile.from_parent(parent, fspath=path)
else:
return DocoptTestFile(path, parent)


def parse_test(raw):
Expand Down Expand Up @@ -41,7 +44,13 @@ def collect(self):
for name, doc, cases in parse_test(raw):
name = self.fspath.purebasename
for case in cases:
yield DocoptTestItem("%s(%d)" % (name, index), self, doc, case)
if hasattr(DocoptTestItem, "from_parent"):
yield DocoptTestItem.from_parent(parent=self,
name="%s(%d)" % (name, index),
doc=doc,
case=case)
else:
yield DocoptTestItem("%s(%d)" % (name, index), self, doc, case)
index += 1


Expand Down