Skip to content

Commit e2daa43

Browse files
committed
fixup! fix: Don't render environment paths in source block labels
1 parent c7b79ba commit e2daa43

1 file changed

Lines changed: 15 additions & 21 deletions

File tree

tests/test_handler.py

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -347,34 +347,28 @@ def _source_labels(html: str) -> list[Path]:
347347
return labels
348348

349349

350-
_MODEL_CLASS = """
351-
class Model:
352-
'''Model docstring.'''
353-
354-
def __init__(self) -> None:
355-
'''Init docstring.'''
356-
self.model_attribute = 0
357-
358-
def method(self) -> None:
359-
'''Method docstring.'''
360-
"""
361-
362-
363350
def _write_site_packages_package(tmp_path: Path, *, single_module: bool) -> None:
364351
"""Lay out the issue-333 scenario: a package installed in a virtual environment inside the project.
365352
366353
The environment's `site-packages` directory is relative to the current
367354
working directory, so the package's `relative_filepath` is relative too,
368355
slipping past `is_absolute()` checks.
369356
"""
370-
site_packages = tmp_path / "site-packages"
371-
site_packages.mkdir(parents=True)
372-
if single_module:
373-
(site_packages / "pkg.py").write_text(dedent(_MODEL_CLASS), encoding="utf-8")
374-
else:
375-
pkg = site_packages / "pkg"
376-
pkg.mkdir()
377-
(pkg / "__init__.py").write_text(dedent(_MODEL_CLASS), encoding="utf-8")
357+
code = """
358+
class Model:
359+
'''Model docstring.'''
360+
361+
def __init__(self) -> None:
362+
'''Init docstring.'''
363+
self.model_attribute = 0
364+
365+
def method(self) -> None:
366+
'''Method docstring.'''
367+
"""
368+
site = tmp_path / "site-packages"
369+
module_path = site / "pkg.py" if single_module else site / "pkg" / "__init__.py"
370+
module_path.parent.mkdir(parents=True)
371+
module_path.write_text(dedent(code), encoding="utf-8")
378372

379373

380374
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)