-
-
Notifications
You must be signed in to change notification settings - Fork 593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
xlsx export: remove redundant code #541
xlsx export: remove redundant code #541
Conversation
Codecov Report
@@ Coverage Diff @@
## master #541 +/- ##
==========================================
+ Coverage 91.28% 91.39% +0.11%
==========================================
Files 28 28
Lines 2719 2720 +1
==========================================
+ Hits 2482 2486 +4
+ Misses 237 234 -3
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
tests/test_tablib.py
Outdated
_xlsx = data.export('xlsx') | ||
wb = load_workbook(filename=BytesIO(_xlsx)) | ||
# note the Cell is mocked so we don't get the 'real' value | ||
self.assertEqual(None, wb.active['A1'].value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we could try with a value really producing a ValueError
instead of this mocking/patching dance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok - have used an 'array' value which openpyxl cannot handle. This is probably clearer but means we are also testing openpyxl code, instead of mocking as an external dependency. So if they ever change their implementation to handle arrays, this test will break.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, but anyway I tend to favor this simpler version. I think the former mocking solution was also sensible to implementation changes. @hugovk might arbitrate that choice 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also prefer this simpler version, we'll just have to update the test if they change the implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reviewing guys - happy to go with the simpler approach. Over to you if you are happy to merge.
This PR removes what I believe is a redundant check from XLSX export
dset_sheet()
. It provides a minor simplification of the code.If we check the source for
openpyxl.cell.cell.Cell
, the cell value setter calls_bind_value()
. This method can raise aValueError
but not aTypeError
. Therefore I have removed the checks forTypeError
, and I assume that if this does occur somehow, then we would want this raised and not caught because this might be masking an error the user might be interested in.I also removed catching
TypeError
whenstr(col)
is called for the same reason.I have added tests to increase the coverage.