MCPcopy Create free account
hub / github.com/SimpleITK/SimpleITK / test_image_viewer

Function test_image_viewer

Wrapping/Python/tests/sitkExternalViewerTest.py:91–138  ·  view source on GitHub ↗

Test ImageViewer class functionality This test verifies: 1. Basic viewer setup and execution 2. Title setting with special characters 3. Access to viewer parameters 4. Access to global viewer settings

(test_image, capfd, viewer_command)

Source from the content-addressed store, hash-verified

89
90
91def test_image_viewer(test_image, capfd, viewer_command):
92 """Test ImageViewer class functionality
93
94 This test verifies:
95 1. Basic viewer setup and execution
96 2. Title setting with special characters
97 3. Access to viewer parameters
98 4. Access to global viewer settings
99 """
100 viewer = sitk.ImageViewer()
101
102 # Test title with special characters
103 title = "Basic Image Viewer Test"
104 viewer.SetTitle(title)
105 viewer.Execute(test_image)
106
107 # Capture and verify viewer parameters
108 out, _ = capfd.readouterr()
109
110
111 print("\nImageViewer parameters")
112 print(" Application: ", viewer.GetApplication())
113 print(" Command: ", viewer.GetCommand())
114 print(" Extension: ", viewer.GetFileExtension())
115
116 print("\nGlobal ImageViewer parameters")
117 print(" Search path: ", sitk.ImageViewer.GetGlobalDefaultSearchPath())
118 print(
119 " Default executable names: ",
120 sitk.ImageViewer.GetGlobalDefaultExecutableNames(),
121 )
122 print(" Process delay: ", sitk.ImageViewer.GetProcessDelay())
123 print(" Debug flag: ", sitk.ImageViewer.GetGlobalDefaultDebug())
124
125 # TODO: This the output variable does not contain the expected output
126 # assert "Basic Image Viewer Test/:" in out, "Missing viewer parameter output"
127
128 # Verify viewer configuration
129 assert viewer.GetCommand(), "Viewer command not set"
130 assert viewer.GetFileExtension(), "Viewer file extension not set"
131
132 # Verify global settings
133 assert sitk.ImageViewer.GetGlobalDefaultSearchPath(), "Global search path not set"
134 assert sitk.ImageViewer.GetGlobalDefaultExecutableNames(), "Default executables not set"
135 assert isinstance(sitk.ImageViewer.GetProcessDelay(), (int, float)), \
136 "Process delay not numeric"
137 assert isinstance(sitk.ImageViewer.GetGlobalDefaultDebug(), bool), \
138 "Debug flag not boolean"
139
140
141def test_bad_image_viewer(test_image):

Callers

nothing calls this directly

Calls 5

SetTitleMethod · 0.95
ExecuteMethod · 0.95
ImageViewerMethod · 0.80
GetProcessDelayMethod · 0.80
GetGlobalDefaultDebugMethod · 0.45

Tested by

no test coverage detected