Skip to content

Commit ffb6a07

Browse files
committed
catch warning context
1 parent 3391470 commit ffb6a07

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

tests/test_zmq_shell.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,20 @@ def test_magics(tmp_path):
219219

220220
tmp_file = tmp_path / "test.txt"
221221
tmp_file.write_text("hi", "utf8")
222-
magics.edit(str(tmp_file))
223-
payload = shell.payload_manager.read_payload()[0]
224-
assert payload["filename"] == str(tmp_file)
225-
226-
magics.clear([])
227-
magics.less(str(tmp_file))
228-
if os.name == "posix":
229-
magics.man("ls")
230-
magics.autosave("10")
222+
# This should be fixed by https://github.com/ipython/ipython/pull/14749,
223+
# but may take some time to be released,
224+
# once old, enough remove this catch warnings.
225+
with warnings.catch_warnings():
226+
warnings.filterwarnings("ignore", category=ResourceWarning, message="unclosed file")
227+
magics.edit(str(tmp_file))
228+
payload = shell.payload_manager.read_payload()[0]
229+
assert payload["filename"] == str(tmp_file)
230+
231+
magics.clear([])
232+
magics.less(str(tmp_file))
233+
if os.name == "posix":
234+
magics.man("ls")
235+
magics.autosave("10")
231236

232237
socket.close()
233238
context.destroy()

0 commit comments

Comments
 (0)