Skip to content

Commit

Permalink
fixed issue #9
Browse files Browse the repository at this point in the history
pytest_checkipdb.py:21: PytestDeprecationWarning: direct construction of CheckIpdbItem has been deprecated, please use CheckIpdbItem.from_parent
        return CheckIpdbItem(path, parent=parent)
  • Loading branch information
avallbona committed Jul 22, 2020
1 parent 4598f32 commit daa4bb7
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions pytest_checkipdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,22 @@ def pytest_collect_file(parent, path):
config = parent.config
if path.ext != '.py' or not config.option.check_ipdb:
return
return CheckIpdbItem(path, parent=parent)
if hasattr(CheckIpdbItem, "from_parent"):
return CheckIpdbItem.from_parent(parent, fspath=path)
else:
return CheckIpdbItem(path, parent)


class CheckIpdbItem(pytest.Item, pytest.File):

def __init__(self, path, parent):
super(CheckIpdbItem, self).__init__(path, parent=parent)
self.raw_content = self.fspath.open().read()
def __init__(self, fspath, parent):
"""fixing the raw content when instantiating the item
:param fspath:
:param parent:
"""
self.raw_content = fspath.open().read()
super(CheckIpdbItem, self).__init__(fspath, parent=parent)

def runtest(self):
t = ast.parse(self.raw_content)
Expand Down

0 comments on commit daa4bb7

Please sign in to comment.