@@ -163,14 +163,14 @@ def test_singlemarkdown_access_issue(flags: Iterable[str], build_path: Path):
163163 _chmod_output (build_path , lambda mode : mode | flag )
164164
165165
166- def test_singlemarkdown_builder_methods ():
166+ def test_singlemarkdown_builder_methods (tmp_path ):
167167 """Test SingleFileMarkdownBuilder methods directly"""
168168 # Create a mock app
169169 app = mock .MagicMock ()
170170 app .srcdir = "src"
171171 app .confdir = "conf"
172172 app .outdir = "out"
173- app .doctreedir = "doctree"
173+ app .doctreedir = str ( tmp_path / "doctree" )
174174 app .config .root_doc = "index"
175175
176176 # Create a mock environment
@@ -191,8 +191,10 @@ def test_singlemarkdown_builder_methods():
191191 assert builder .get_relative_uri ("source" , "target" ) == "#target"
192192
193193
194- def test_render_partial ():
194+ def test_render_partial (tmp_path , monkeypatch ):
195195 """Test render_partial method"""
196+ monkeypatch .chdir (tmp_path )
197+
196198 # Create mocks
197199 app = mock .MagicMock ()
198200 env = mock .MagicMock ()
@@ -230,8 +232,10 @@ def test_render_partial():
230232 assert "fragment" in result
231233
232234
233- def test_get_local_toctree ():
235+ def test_get_local_toctree (tmp_path , monkeypatch ):
234236 """Test _get_local_toctree method"""
237+ monkeypatch .chdir (tmp_path )
238+
235239 # Create mocks
236240 app = mock .MagicMock ()
237241 env = mock .MagicMock ()
@@ -268,8 +272,10 @@ def test_get_local_toctree():
268272 assert "maxdepth" not in mock_toctree .call_args [1 ]
269273
270274
271- def test_assemble_toc_secnumbers ():
275+ def test_assemble_toc_secnumbers (tmp_path , monkeypatch ):
272276 """Test assemble_toc_secnumbers method"""
277+ monkeypatch .chdir (tmp_path )
278+
273279 # Create mocks
274280 app = mock .MagicMock ()
275281 env = mock .MagicMock ()
@@ -293,8 +299,10 @@ def test_assemble_toc_secnumbers():
293299 assert result ["index" ]["doc2/id2" ] == (3 , 4 )
294300
295301
296- def test_assemble_toc_fignumbers ():
302+ def test_assemble_toc_fignumbers (tmp_path , monkeypatch ):
297303 """Test assemble_toc_fignumbers method"""
304+ monkeypatch .chdir (tmp_path )
305+
298306 # Create mocks
299307 app = mock .MagicMock ()
300308 env = mock .MagicMock ()
@@ -323,8 +331,10 @@ def test_assemble_toc_fignumbers():
323331 assert result ["index" ]["doc2/table" ]["id2" ] == (3 , 4 )
324332
325333
326- def test_get_doc_context ():
334+ def test_get_doc_context (tmp_path , monkeypatch ):
327335 """Test get_doc_context method"""
336+ monkeypatch .chdir (tmp_path )
337+
328338 # Create mocks
329339 app = mock .MagicMock ()
330340 env = mock .MagicMock ()
@@ -361,8 +371,10 @@ def test_get_doc_context():
361371 assert result ["toc" ] == ""
362372
363373
364- def test_write_documents ():
374+ def test_write_documents (tmp_path , monkeypatch ):
365375 """Test write_documents method with mocks"""
376+ monkeypatch .chdir (tmp_path )
377+
366378 # Create mocks
367379 app = mock .MagicMock ()
368380 env = mock .MagicMock ()
@@ -409,8 +421,10 @@ def test_write_documents():
409421 os .remove (expected_file )
410422
411423
412- def test_write_documents_error_handling ():
424+ def test_write_documents_error_handling (tmp_path , monkeypatch ):
413425 """Test error handling in write_documents"""
426+ monkeypatch .chdir (tmp_path )
427+
414428 # Create mocks
415429 app = mock .MagicMock ()
416430 env = mock .MagicMock ()
@@ -448,8 +462,10 @@ def mock_get_doctree(docname: str):
448462 builder .write_documents (set ())
449463
450464
451- def test_write_documents_os_error ():
465+ def test_write_documents_os_error (tmp_path , monkeypatch ):
452466 """Test OS error handling in write_documents"""
467+ monkeypatch .chdir (tmp_path )
468+
453469 # Create mocks
454470 app = mock .MagicMock ()
455471 env = mock .MagicMock ()
0 commit comments