jazzband / tablib

Python Module for Tabular Datasets in XLS, CSV, JSON, YAML, &c.
https://tablib.readthedocs.io/
MIT License
4.58k stars 589 forks source link

fix bug when checking empty file. add more coverage #535

Closed llazzaro closed 1 year ago

llazzaro commented 1 year ago

While adding some coverage discovered the using len(pickle) will raise and error since for empty files pickle is None.

Change the if condition to just not pickle since it will also work for checking if the list is empty.

Added two test cases to cover more branches.

codecov[bot] commented 1 year ago

Codecov Report

Merging #535 (4a17e3f) into master (0a3511f) will increase coverage by 0.18%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #535      +/-   ##
==========================================
+ Coverage   90.97%   91.16%   +0.18%     
==========================================
  Files          28       28              
  Lines        2660     2670      +10     
==========================================
+ Hits         2420     2434      +14     
+ Misses        240      236       -4     
Impacted Files Coverage Δ
src/tablib/core.py 85.01% <100.00%> (+0.93%) :arrow_up:
tests/test_tablib.py 98.66% <100.00%> (+0.01%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

claudep commented 1 year ago

Maybe just adapt the commit message to specify this concerns the yaml format.

claudep commented 1 year ago

Ah yes, NamedTemporaryFile constructor is already returning a file-like object, so no need to reopen later (and Windows cannot reopen when it's already open).

llazzaro commented 1 year ago