@@ -79,15 +79,18 @@ def _instrumented_format_output(
79
79
'text' : _instrumented_format_output .values ['header_text' ]
80
80
})
81
81
82
- return format_output (
82
+ output = format_output (
83
83
configuration ,
84
84
backend ,
85
85
ret_val ,
86
86
ret_msg ,
87
87
out_obj ,
88
88
outputformat ,
89
89
)
90
+ _instrumented_format_output .returned = output
91
+ return output
90
92
_instrumented_format_output .calls = []
93
+ _instrumented_format_output .returned = None
91
94
_instrumented_format_output .values = dict (
92
95
title_text = '' ,
93
96
header_text = '' ,
@@ -129,19 +132,37 @@ def __init__(self):
129
132
self .format_output = create_instrumented_format_output ()
130
133
self .retrieve_handler = create_instrumented_retrieve_handler ()
131
134
135
+ def arranged (self ):
136
+ simulated_action = self .retrieve_handler .simulated
137
+ if simulated_action is None :
138
+ return 'nothing'
139
+
140
+ return_value = simulated_action .returning
141
+ if isinstance (return_value , tuple ) and isinstance (return_value [0 ], list ):
142
+ return 'html'
143
+
144
+ raise NotImplementedError ()
145
+
132
146
def set_response (self , content , returnvalue ):
133
147
self .retrieve_handler .program (content , returnvalue )
134
148
149
+ def return_value (self ):
150
+ arranged_return_type = self .arranged ()
151
+
152
+ if arranged_return_type == 'html' :
153
+ return self .format_output .returned
154
+
155
+ raise NotImplementedError ()
156
+
135
157
136
158
class WsgibinAssertMixin :
137
159
def assertWsgibinInstrumentation (self , instrumentation = None ):
138
160
if instrumentation is None :
139
161
instrumentation = getattr (self , 'wsgibin_instrumentation' , None )
140
162
assert isinstance (instrumentation , WsgibinInstrumentation )
141
163
142
- simulated_action = instrumentation .retrieve_handler .simulated
143
- self .assertIsNotNone (simulated_action .returning ,
144
- "no response programmed" )
164
+ self .assertNotEqual (instrumentation .arranged (),
165
+ 'nothing' , "no response programmed" )
145
166
146
167
def was_called (fake ):
147
168
assert hasattr (fake , 'calls' )
@@ -151,3 +172,10 @@ def was_called(fake):
151
172
instrumentation .format_output ), "no output generated" )
152
173
self .assertTrue (was_called (
153
174
instrumentation .retrieve_handler ), "no output generated" )
175
+
176
+ return instrumentation
177
+
178
+ def assertWsgibinHtml (self , instrumentation = None ):
179
+ instrumentation = self .assertWsgibinInstrumentation (instrumentation = instrumentation )
180
+ self .assertEqual (instrumentation .arranged (), 'html' , "wsgibinsupp: arranged output was not html" )
181
+ return instrumentation .return_value ()
0 commit comments