Skip to content

Commit

Permalink
Merge pull request #76 from nschloe/update-pytest
Browse files Browse the repository at this point in the history
Update pytest
  • Loading branch information
nschloe authored Feb 21, 2022
2 parents 0abcea7 + dd24ac6 commit 42813d6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ classifiers = [
dynamic = ["version"]
requires-python = ">=3.7"
dependencies = [
"pytest >= 6"
"pytest >= 7.0.0"
]

[project.urls]
Expand Down
2 changes: 1 addition & 1 deletion src/pytest_codeblocks/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.13.0"
__version__ = "0.14.0"
14 changes: 8 additions & 6 deletions src/pytest_codeblocks/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# https://docs.pytest.org/en/stable/example/nonpython.html
#
import subprocess
from pathlib import Path

import pytest

Expand All @@ -18,16 +19,17 @@ def pytest_addoption(parser):

def pytest_collect_file(path, parent):
config = parent.config
if config.option.codeblocks and path.ext == ".md":
return MarkdownFile.from_parent(parent, fspath=path)
path = Path(path)
if config.option.codeblocks and path.suffix == ".md":
return MarkdownFile.from_parent(parent, path=path)


class MarkdownFile(pytest.File):
def __init__(self, fspath, parent):
super().__init__(fspath, parent)
def __init__(self, **kwargs):
super().__init__(**kwargs)

def collect(self):
for block in extract_from_file(self.fspath):
for block in extract_from_file(self.path):
if block.syntax not in ["python", "sh", "bash"]:
continue
# https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent
Expand Down Expand Up @@ -117,4 +119,4 @@ def repr_failure(self, excinfo):
# return super().repr_failure(excinfo)

def reportinfo(self):
return (self.fspath, -1, "code block check")
return (self.path, -1, "code block check")

0 comments on commit 42813d6

Please sign in to comment.