From cedb45a73e7f9142c6ba264be8055d0705cbfd7c Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Wed, 30 Mar 2022 13:42:55 -0500 Subject: [PATCH] more warnigs --- nbformat/validator.py | 7 ++++++- tests/v3/test_nbbase.py | 18 +++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/nbformat/validator.py b/nbformat/validator.py index 977f3a35..49355ca6 100644 --- a/nbformat/validator.py +++ b/nbformat/validator.py @@ -284,7 +284,12 @@ def validate(nbdict=None, ref=None, version=None, version_minor=None, if repair_duplicate_cell_ids: # Best effort to repair if we find a duplicate id cell['id'] = generate_corpus_id() - get_logger().warn("Non-unique cell id '{}' detected. Corrected to '{}'.".format(cell_id, cell['id'])) + get_logger().warning( + "Non-unique cell id '{}' detected. Corrected to '{}'.".format( + cell_id, + cell['id'] + ) + ) else: raise ValidationError("Non-unique cell id '{}' detected.".format(cell_id)) seen_ids.add(cell_id) diff --git a/tests/v3/test_nbbase.py b/tests/v3/test_nbbase.py index 63f5c8b9..4b96df12 100644 --- a/tests/v3/test_nbbase.py +++ b/tests/v3/test_nbbase.py @@ -1,5 +1,7 @@ from unittest import TestCase +import pytest + from nbformat.v3.nbbase import ( NotebookNode, new_code_cell, new_text_cell, new_worksheet, new_notebook, new_output, @@ -134,17 +136,19 @@ def test_metadata(self): class TestOutputs(TestCase): def test_binary_png(self): - out = new_output(output_png=b'\x89PNG\r\n\x1a\n', output_type='display_data') + with pytest.warns(UserWarning, match='bytes instead of likely base64'): + out = new_output(output_png=b'\x89PNG\r\n\x1a\n', output_type='display_data') def test_b64b6tes_png(self): # really those tests are wrong, this is not b64, if prefixed by b - out = new_output(output_png=b'iVBORw0KG', output_type='display_data') - + with pytest.warns(UserWarning, match='bytes instead of likely base64'): + out = new_output(output_png=b'iVBORw0KG', output_type='display_data') + def test_binary_jpeg(self): - out = new_output(output_jpeg=b'\xff\xd8', output_type='display_data') + with pytest.warns(UserWarning, match='bytes instead of likely base64'): + out = new_output(output_jpeg=b'\xff\xd8', output_type='display_data') def test_b64b6tes_jpeg(self): # really those tests are wrong, this is not b64, if prefixed by b - out = new_output(output_jpeg=b'/9', output_type='display_data') - - + with pytest.warns(UserWarning, match='bytes instead of likely base64'): + out = new_output(output_jpeg=b'/9', output_type='display_data')