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

Method executeCode

kernel_test.go:510–540  ·  view source on GitHub ↗

executeCode creates an execute request for the given code and preforms the request. It returns the content of the reply as well as all of the messages captured from the IOPub channel during the execution.

(t *testing.T, code string)

Source from the content-addressed store, hash-verified

508// executeCode creates an execute request for the given code and preforms the request. It returns the content of the
509// reply as well as all of the messages captured from the IOPub channel during the execution.
510func (client *testJupyterClient) executeCode(t *testing.T, code string) (map[string]interface{}, []ComposedMsg) {
511 t.Helper()
512
513 // Create a message.
514 request, err := NewMsg("execute_request", ComposedMsg{})
515 if err != nil {
516 t.Fatalf("\t%s NewMsg: %s", failure, err)
517 }
518
519 // Fill in remaining header information.
520 request.Header.Session = sessionID
521 request.Header.Username = "KernelTester"
522
523 // Fill in Metadata.
524 request.Metadata = make(map[string]interface{})
525
526 // Fill in content.
527 content := make(map[string]interface{})
528 content["code"] = code
529 content["silent"] = false
530 request.Content = content
531
532 // Make the request.
533 reply, pub := client.performJupyterRequest(t, request, 10*time.Second)
534
535 // Ensure the reply is an execute_reply and extract the content from the reply.
536 assertMsgTypeEquals(t, reply, "execute_reply")
537 content = getMsgContentAsJSONObject(t, reply)
538
539 return content, pub
540}
541
542// assertMsgTypeEquals is a test helper that fails the test if the message header's MsgType is not the
543// expectedType.

Callers 3

testEvaluateFunction · 0.80
TestPanicGeneratesErrorFunction · 0.80
testOutputStreamFunction · 0.80

Calls 4

performJupyterRequestMethod · 0.95
NewMsgFunction · 0.85
assertMsgTypeEqualsFunction · 0.85

Tested by

no test coverage detected