Skip to content

Commit

Permalink
Invalid cell type coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
masaccio committed Jul 18, 2023
1 parent ce44529 commit 402c150
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/numbers_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

from numbers_parser.document import Document # NOQA
from numbers_parser.cell import * # NOQA
from numbers_parser.exceptions import * # NOQA

__version__ = importlib.metadata.version("numbers-parser")

Expand Down
15 changes: 13 additions & 2 deletions tests/test_coverage.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from numbers_parser import Document, UnsupportedError, Cell
from numbers_parser import Document, UnsupportedError, Cell, UnsupportedWarning
from numbers_parser.cell import xl_range, xl_rowcol_to_cell, xl_col_to_name
from numbers_parser.constants import EMPTY_STORAGE_BUFFER
from numbers_parser.cell_storage import CellStorage
Expand All @@ -17,7 +17,7 @@ def test_ranges():
assert xl_col_to_name(26) == "AA"


def test_cell_storage():
def test_cell_storage(tmp_path):
doc = Document()
table = doc.sheets[0].tables[0]

Expand All @@ -41,6 +41,17 @@ def test_cell_storage():
storage = CellStorage(doc._model, table._table_id, bytes(buffer), 0, 0)
assert "Cell storage version 4 is unsupported" in str(e)

class DummyCell(Cell):
pass

doc = Document()
doc.sheets[0].tables[0]._data[0][0] = DummyCell(0, 0, None)
new_filename = tmp_path / "new.numbers"
with pytest.warns(UnsupportedWarning) as record:
doc.save(new_filename)
assert len(record) == 1
assert "unsupported data type DummyCell" in str(record[0])


def test_range_exceptions():
with pytest.raises(IndexError) as e:
Expand Down

0 comments on commit 402c150

Please sign in to comment.