diff --git a/_unittests/ut_gdot/test_gdot_extension.py b/_unittests/ut_gdot/test_gdot_extension.py
index d1ee7a3..dea0ff4 100644
--- a/_unittests/ut_gdot/test_gdot_extension.py
+++ b/_unittests/ut_gdot/test_gdot_extension.py
@@ -1,6 +1,8 @@
import unittest
import logging
+import os
import sys
+from contextlib import contextmanager
from sphinx_runpython.process_rst import rst2html
from sphinx_runpython.ext_test_case import (
ExtTestCase,
@@ -10,6 +12,20 @@
)
+@contextmanager
+def unittest_going():
+ """Context manager that sets UNITTEST_GOING=1 for the duration of the block."""
+ old = os.environ.get("UNITTEST_GOING", None)
+ os.environ["UNITTEST_GOING"] = "1"
+ try:
+ yield
+ finally:
+ if old is None:
+ os.environ.pop("UNITTEST_GOING", None)
+ else:
+ os.environ["UNITTEST_GOING"] = old
+
+
class TestGDotExtension(ExtTestCase):
def setUp(self):
logger = logging.getLogger("gdot")
@@ -146,6 +162,59 @@ def test_gdot4_png(self):
return
self.assertIn("png", content)
+ @ignore_warnings(PendingDeprecationWarning)
+ def test_gdot_unittest_going_svg(self):
+ """When UNITTEST_GOING=1, a dummy SVG containing 'DISABLED FOR TESTS' is rendered."""
+ content = """
+ before
+
+ .. gdot::
+ :format: svg
+
+ digraph foo {
+ "bar" -> "baz";
+ }
+
+ after
+ """.replace(" ", "")
+
+ with unittest_going():
+ html = rst2html(
+ content, writer_name="html", new_extensions=["sphinx_runpython.gdot"]
+ )
+
+ self.assertIn("DISABLED FOR TESTS", html)
+ self.assertIn(""
+)
+
+_DUMMY_PNG_HTML = (
+ ''
+)
+
+
+def _emit_dummy_output(self, format: str = "svg"):
+ """Emit a placeholder graphic when ``UNITTEST_GOING=1`` is set."""
+ self.body.append('