Skip to content

Commit 1e428d9

Browse files
sarahboycebmispelon
authored andcommitted
Added Sphinx clean up global state call.
1 parent 1ee5166 commit 1e428d9

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

docs/management/commands/update_docs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from sphinx.application import Sphinx
2222
from sphinx.config import Config
2323
from sphinx.errors import SphinxError
24+
from sphinx.testing.util import _clean_up_global_state
2425
from sphinx.util.docutils import docutils_namespace, patch_docutils
2526

2627
from ...models import DocumentRelease
@@ -233,6 +234,8 @@ def build_doc_release(self, release, force=False, interactive=False):
233234
"extensions": extensions,
234235
},
235236
).build()
237+
# Clean up global state after building each language.
238+
_clean_up_global_state()
236239
except SphinxError as e:
237240
self.stderr.write(
238241
"sphinx-build returned an error (release %s, builder %s): %s"

docs/tests/test_builder.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from unittest.mock import Mock, patch
22

33
from django.test import SimpleTestCase
4+
from sphinx.testing.util import _clean_up_global_state
45

56
from ..builder import DomainObject, PythonObjectsJSONHTMLBuilder
67

@@ -61,3 +62,8 @@ def test_get_doc_context(self, mock_super_get_doc_context):
6162
self.assertIn("python_objects_search", result)
6263
self.assertEqual(result["python_objects"], {"ClassA": "module1.ClassA"})
6364
self.assertEqual(result["python_objects_search"], "ClassA")
65+
66+
67+
class TestSphinxAPI(SimpleTestCase):
68+
def test_private_sphinx_function_exists(self):
69+
_clean_up_global_state()

0 commit comments

Comments
 (0)