Skip to content

Commit

Permalink
more warnigs
Browse files Browse the repository at this point in the history
  • Loading branch information
bollwyvl committed Mar 30, 2022
1 parent 4ba2d91 commit cedb45a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
7 changes: 6 additions & 1 deletion nbformat/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 11 additions & 7 deletions tests/v3/test_nbbase.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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')

0 comments on commit cedb45a

Please sign in to comment.