MCPcopy Index your code
hub / github.com/gopherdata/gophernotes / testEvaluate

Function testEvaluate

kernel_test.go:168–192  ·  view source on GitHub ↗

testEvaluate evaluates a cell.

(t *testing.T, codeIn string)

Source from the content-addressed store, hash-verified

166
167// testEvaluate evaluates a cell.
168func testEvaluate(t *testing.T, codeIn string) string {
169 client, closeClient := newTestJupyterClient(t)
170 defer closeClient()
171
172 content, pub := client.executeCode(t, codeIn)
173
174 status := getString(t, "content", content, "status")
175
176 if status != "ok" {
177 t.Fatalf("\t%s Execution encountered error [%s]: %s", failure, content["ename"], content["evalue"])
178 }
179
180 for _, pubMsg := range pub {
181 if pubMsg.Header.MsgType == "execute_result" {
182 content = getMsgContentAsJSONObject(t, pubMsg)
183
184 bundledMIMEData := getJSONObject(t, "content", content, "data")
185 textRep := getString(t, `content["data"]`, bundledMIMEData, "text/plain")
186
187 return textRep
188 }
189 }
190
191 return ""
192}
193
194// TestPanicGeneratesError tests that executing code with an un-recovered panic properly generates both
195// an error "execute_reply" and publishes an "error" message.

Callers 1

TestEvaluateFunction · 0.85

Calls 5

newTestJupyterClientFunction · 0.85
getStringFunction · 0.85
getJSONObjectFunction · 0.85
executeCodeMethod · 0.80

Tested by

no test coverage detected