python-nbval/0001-Make-tests-pass-with-ipykernel-6.0.0.patch

32 lines
1.3 KiB
Diff
Raw Normal View History

From 3e1e6c6f31b86f5fb0e79a6901822dbe62af0891 Mon Sep 17 00:00:00 2001
From: Chih-Hsuan Yen <yan12125@gmail.com>
Date: Sat, 21 Aug 2021 11:41:01 +0800
Subject: [PATCH] Make tests pass with ipykernel >= 6.0.0
Ref: https://github.com/ipython/ipykernel/pull/685
---
tests/test_ignore.py | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
Index: nbval-0.9.6/tests/test_ignore.py
===================================================================
--- nbval-0.9.6.orig/tests/test_ignore.py
+++ nbval-0.9.6/tests/test_ignore.py
@@ -22,10 +22,13 @@ def test_conf_ignore_stderr(testdir):
# Setup notebook with stream outputs
nb = build_nb([
+ # Since ipykernel 6.0.0, sys.stdout.write and sys.stderr.write functions
+ # return the number of written bytes. Capture returned values to avoid extra
+ # text/plain fields.
"import sys",
- "sys.stdout.write('test\\n')",
- "sys.stderr.write('error output\\n')",
- "sys.stdout.write('test\\n')\nsys.stderr.write('error output\\n')",
+ "ret = sys.stdout.write('test\\n')",
+ "ret = sys.stderr.write('error output\\n')",
+ "ret = sys.stdout.write('test\\n')\nret = sys.stderr.write('error output\\n')",
], mark_run=True)
nb.cells[1].outputs.append(nbformat.v4.new_output(
'stream',