Skip to content

Commit

Permalink
Merge pull request #43 from jonasundderwolf/pytest-deprecation-fix
Browse files Browse the repository at this point in the history
Remove deprecation warning at startup
  • Loading branch information
Kevin Cowan authored May 4, 2020
2 parents efbc272 + b1840ca commit f156ee5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pytest_black.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ def pytest_addoption(parser):
def pytest_collect_file(path, parent):
config = parent.config
if config.option.black and path.ext == ".py":
return BlackItem(path, parent)
if hasattr(BlackItem, "from_parent"):
return BlackItem.from_parent(parent, fspath=path)
else:
return BlackItem(path, parent)


def pytest_configure(config):
Expand All @@ -40,8 +43,8 @@ def pytest_unconfigure(config):


class BlackItem(pytest.Item, pytest.File):
def __init__(self, path, parent):
super(BlackItem, self).__init__(path, parent)
def __init__(self, fspath, parent):
super(BlackItem, self).__init__(fspath, parent)
self._nodeid += "::BLACK"
self.add_marker("black")
try:
Expand Down

0 comments on commit f156ee5

Please sign in to comment.