File tree 2 files changed +17
-1
lines changed
src/mkdocstrings_handlers/python 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -145,7 +145,8 @@ def __init__(
145
145
super ().__init__ (* args , ** kwargs )
146
146
self ._config_file_path = config_file_path
147
147
paths = paths or []
148
- with chdir (os .path .dirname (config_file_path ) if config_file_path else "." ):
148
+ glob_base_dir = os .path .dirname (os .path .abspath (config_file_path )) if config_file_path else "."
149
+ with chdir (glob_base_dir ):
149
150
resolved_globs = [glob .glob (path ) for path in paths ]
150
151
paths = [path for glob_list in resolved_globs for path in glob_list ]
151
152
if not paths and config_file_path :
Original file line number Diff line number Diff line change 1
1
"""Tests for the `handler` module."""
2
2
3
+ import os
4
+ from glob import glob
5
+
3
6
import pytest
4
7
from griffe .docstrings .dataclasses import DocstringSectionExamples , DocstringSectionKind
5
8
@@ -83,3 +86,15 @@ def test_expand_globs(tmp_path):
83
86
)
84
87
for path in globbed_paths : # noqa: WPS440
85
88
assert str (path ) in handler ._paths # noqa: WPS437
89
+
90
+
91
+ def test_expand_globs_without_changing_directory ():
92
+ """Assert globs are correctly expanded when we are already in the right directory."""
93
+ handler = PythonHandler (
94
+ handler = "python" ,
95
+ theme = "material" ,
96
+ config_file_path = "mkdocs.yml" ,
97
+ paths = ["*.md" ],
98
+ )
99
+ for path in list (glob (os .path .abspath ("." ) + "/*.md" )):
100
+ assert path in handler ._paths # noqa: WPS437
You can’t perform that action at this time.
0 commit comments