@@ -204,10 +204,7 @@ def test_GetMessageConnectionDot_contains_graphviz_edges():
204204
205205
206206def test_ShowMessageConnectionFigure_graphviz_writes_file (tmp_path ):
207- """Check that the Graphviz renderer writes a rendered file when available."""
208- if shutil .which ("dot" ) is None :
209- pytest .skip ("Graphviz dot executable is not available." )
210-
207+ """Check that the Graphviz renderer writes an output file."""
211208 scSim = SimulationBaseClass .SimBaseClass ()
212209 testProcess = scSim .CreateNewProcess ("testProcess" )
213210 simulationTimeStep = macros .sec2nano (1.0 ) # [ns]
@@ -222,23 +219,28 @@ def test_ShowMessageConnectionFigure_graphviz_writes_file(tmp_path):
222219 scSim .AddModelToTask ("testTask" , cModule )
223220 scSim .AddModelToTask ("testTask" , cppModule )
224221
225- outputPath = tmp_path / "messageConnections.svg"
222+ graphvizIsAvailable = shutil .which ("dot" ) is not None
223+ outputPath = tmp_path / (
224+ "messageConnections.svg" if graphvizIsAvailable else "messageConnections.dot"
225+ )
226226 renderedPath = scSim .ShowMessageConnectionFigure (
227227 renderer = "graphviz" ,
228228 fileName = str (outputPath ),
229+ graphvizFormat = "svg" if graphvizIsAvailable else "dot" ,
229230 includeUnlinked = False ,
230231 )
231232
232233 assert renderedPath == str (outputPath )
233234 assert outputPath .exists ()
234- assert outputPath .read_text ().lstrip ().startswith ("<?xml" )
235+ outputText = outputPath .read_text ()
236+ if graphvizIsAvailable :
237+ assert outputText .lstrip ().startswith ("<?xml" )
238+ else :
239+ assert "digraph BSKMessageConnections" in outputText
235240
236241
237242def test_saveScenarioGraphvizFigure_uses_documentation_image_path (tmp_path ):
238243 """Check that Graphviz scenario figures are saved to the docs image path."""
239- if shutil .which ("dot" ) is None :
240- pytest .skip ("Graphviz dot executable is not available." )
241-
242244 docsPath = tmp_path / "docs" / "source"
243245 docsPath .mkdir (parents = True )
244246 scenarioPath = tmp_path / "examples"
@@ -247,12 +249,13 @@ def test_saveScenarioGraphvizFigure_uses_documentation_image_path(tmp_path):
247249 scSim = MagicMock ()
248250 scSim .ShowMessageConnectionFigure .return_value = str (expectedPath )
249251
250- renderedPath = unitTestSupport .saveScenarioGraphvizFigure (
251- "messageFlow" ,
252- scSim ,
253- str (scenarioPath ),
254- includeUnlinked = False ,
255- )
252+ with patch ("Basilisk.utilities.unitTestSupport.shutil.which" , return_value = "dot" ):
253+ renderedPath = unitTestSupport .saveScenarioGraphvizFigure (
254+ "messageFlow" ,
255+ scSim ,
256+ str (scenarioPath ),
257+ includeUnlinked = False ,
258+ )
256259
257260 assert renderedPath == str (expectedPath )
258261 assert expectedPath .parent .exists ()
@@ -265,7 +268,7 @@ def test_saveScenarioGraphvizFigure_uses_documentation_image_path(tmp_path):
265268 )
266269
267270
268- def test_saveScenarioGraphvizFigure_skips_without_graphviz (tmp_path ):
271+ def test_saveScenarioGraphvizFigure_returns_none_without_graphviz (tmp_path ):
269272 """Check that optional Graphviz scenario figures do not require Graphviz."""
270273 docsPath = tmp_path / "docs" / "source"
271274 docsPath .mkdir (parents = True )
0 commit comments