testOutputStream is a test helper that collects "stream" messages upon executing the codeIn.
(t *testing.T, codeIn string)
| 602 | |
| 603 | // testOutputStream is a test helper that collects "stream" messages upon executing the codeIn. |
| 604 | func 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 | } |
no test coverage detected