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

Function testOutputStream

kernel_test.go:604–631  ·  view source on GitHub ↗

testOutputStream is a test helper that collects "stream" messages upon executing the codeIn.

(t *testing.T, codeIn string)

Source from the content-addressed store, hash-verified

602
603// testOutputStream is a test helper that collects "stream" messages upon executing the codeIn.
604func testOutputStream(t *testing.T, codeIn string) ([]string, []string) {
605 t.Helper()
606
607 client, closeClient := newTestJupyterClient(t)
608 defer closeClient()
609
610 _, pub := client.executeCode(t, codeIn)
611
612 var stdout, stderr []string
613 for _, pubMsg := range pub {
614 if pubMsg.Header.MsgType == "stream" {
615 content := getMsgContentAsJSONObject(t, pubMsg)
616 streamType := getString(t, "content", content, "name")
617 streamData := getString(t, "content", content, "text")
618
619 switch streamType {
620 case StreamStdout:
621 stdout = append(stdout, streamData)
622 case StreamStderr:
623 stderr = append(stderr, streamData)
624 default:
625 t.Fatalf("Unknown stream type '%s'", streamType)
626 }
627 }
628 }
629
630 return stdout, stderr
631}

Callers 2

TestPrintStdoutFunction · 0.85
TestPrintStderrFunction · 0.85

Calls 4

newTestJupyterClientFunction · 0.85
getStringFunction · 0.85
executeCodeMethod · 0.80

Tested by

no test coverage detected