diff --git a/poetry.lock b/poetry.lock index e8bfb67..a98e3d1 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. [[package]] name = "cfgv" @@ -256,13 +256,13 @@ virtualenv = ">=20.10.0" [[package]] name = "pytest" -version = "8.0.0" +version = "8.1.0" description = "pytest: simple powerful testing with Python" optional = false python-versions = ">=3.8" files = [ - {file = "pytest-8.0.0-py3-none-any.whl", hash = "sha256:50fb9cbe836c3f20f0dfa99c565201fb75dc54c8d76373cd1bde06b06657bdb6"}, - {file = "pytest-8.0.0.tar.gz", hash = "sha256:249b1b0864530ba251b7438274c4d251c58d868edaaec8762893ad4a0d71c36c"}, + {file = "pytest-8.1.0-py3-none-any.whl", hash = "sha256:ee32db7af8de4629a455806befa90559f307424c07b8413ccfc30bf5b221dd7e"}, + {file = "pytest-8.1.0.tar.gz", hash = "sha256:f8fa04ab8f98d185113ae60ea6d79c22f8143b14bc1caeced44a0ab844928323"}, ] [package.dependencies] @@ -270,11 +270,11 @@ colorama = {version = "*", markers = "sys_platform == \"win32\""} exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} iniconfig = "*" packaging = "*" -pluggy = ">=1.3.0,<2.0" -tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} +pluggy = ">=1.4,<2.0" +tomli = {version = ">=1", markers = "python_version < \"3.11\""} [package.extras] -testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] +testing = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] [[package]] name = "pyyaml" diff --git a/src/pytest_markdown_docs/plugin.py b/src/pytest_markdown_docs/plugin.py index b1e2109..7e504d1 100644 --- a/src/pytest_markdown_docs/plugin.py +++ b/src/pytest_markdown_docs/plugin.py @@ -11,10 +11,10 @@ from _pytest.pathlib import import_path from pytest_markdown_docs import hooks -try: - # pytest 8 + +if pytest.version_tuple >= (8, 0, 0): from _pytest.fixtures import TopRequest -except ImportError: +else: # pytest 7 compatible from _pytest.fixtures import FixtureRequest as TopRequest # type: ignore @@ -204,7 +204,15 @@ def find_object_tests_recursive( class MarkdownDocstringCodeModule(pytest.Module): def collect(self): - module = import_path(self.path, root=self.config.rootpath) + if pytest.version_tuple >= (8, 1, 0): + # consider_namespace_packages is a required keyword argument in pytest 8.1.0 + module = import_path( + self.path, root=self.config.rootpath, consider_namespace_packages=True + ) + else: + # but unsupported before 8.1... + module = import_path(self.path, root=self.config.rootpath) + for i, (test_code, fixture_names, start_line) in enumerate( find_object_tests_recursive(module.__name__, module.__name__, module) ): @@ -236,11 +244,11 @@ def collect(self): def pytest_collect_file( - path, + file_path, parent, ): if parent.config.option.markdowndocs: - pathlib_path = pathlib.Path(str(path)) # pytest 7/8 compat + pathlib_path = pathlib.Path(str(file_path)) # pytest 7/8 compat if pathlib_path.suffix == ".py": return MarkdownDocstringCodeModule.from_parent(parent, path=pathlib_path) elif pathlib_path.suffix in (".md", ".mdx", ".svx"):