Skip to content

Commit

Permalink
Merge 122fe60 into 4726127
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjoerd Arendsen committed Aug 30, 2021
2 parents 4726127 + 122fe60 commit 8859a69
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion import_export/formats/base_formats.py
Expand Up @@ -175,7 +175,9 @@ def create_dataset(self, in_stream):
from io import BytesIO

import openpyxl
xlsx_book = openpyxl.load_workbook(BytesIO(in_stream), read_only=True)

# 'data_only' means values are read from formula cells, not the formula itself
xlsx_book = openpyxl.load_workbook(BytesIO(in_stream), read_only=True, data_only=True)

dataset = tablib.Dataset()
sheet = xlsx_book.active
Expand Down
6 changes: 6 additions & 0 deletions tests/core/tests/test_base_formats.py
@@ -1,4 +1,5 @@
import os
import unittest
from unittest import mock

import tablib
Expand Down Expand Up @@ -86,6 +87,11 @@ def test_import(self):
with open(filename, self.format.get_read_mode()) as in_stream:
self.format.create_dataset(in_stream.read())

@mock.patch("openpyxl.load_workbook")
def test_that_load_workbook_called_with_required_args(self, mock_load_workbook):
self.format.create_dataset(b"abc")
mock_load_workbook.assert_called_with(unittest.mock.ANY, read_only=True, data_only=True)


class CSVTest(TestCase):

Expand Down

0 comments on commit 8859a69

Please sign in to comment.