Skip to content

Commit 1b08535

Browse files
marxinAA-Turner
andauthored
Clear docutils.conf in SphinxTestApp.cleanup() (#11345)
Co-authored-by: Adam Turner <[email protected]>
1 parent ce140e8 commit 1b08535

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sphinx/testing/util.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ def __init__(
112112
parallel: int = 0,
113113
) -> None:
114114

115+
self.docutils_conf_path = srcdir / 'docutils.conf'
115116
if docutilsconf is not None:
116-
(srcdir / 'docutils.conf').write_text(docutilsconf)
117+
self.docutils_conf_path.write_text(docutilsconf)
117118

118119
if builddir is None:
119120
builddir = srcdir / '_build'
@@ -154,6 +155,10 @@ def cleanup(self, doctrees: bool = False) -> None:
154155
method not in self._saved_nodeclasses:
155156
delattr(nodes.GenericNodeVisitor, 'visit_' + method[6:])
156157
delattr(nodes.GenericNodeVisitor, 'depart_' + method[6:])
158+
try:
159+
os.remove(self.docutils_conf_path)
160+
except FileNotFoundError:
161+
pass
157162

158163
def __repr__(self) -> str:
159164
return f'<{self.__class__.__name__} buildername={self.builder.name!r}>'

0 commit comments

Comments
 (0)