jazzband / prettytable

Display tabular data in a visually appealing ASCII table format
https://pypi.org/project/PrettyTable/
Other
1.35k stars 154 forks source link

Fix to `min_table_width` parameter #219

Closed kzwolenik95 closed 1 year ago

kzwolenik95 commented 1 year ago

Before the change specifying min_table_width parameter changed the width of the table but the width value seemed random.

After the change width is exactly the parameter value when the content is not wide enough. At the same time this pull request fixes / preserves behavior from #216 (Long title doesn't break table layout)

Added tests for odd and even min_table_width for one, two, three columns tables.

min_table_width=50

+--------------+------------------+--------------+
|      F1      |        F2        |      F3      |
+--------------+------------------+--------------+
|     v 1      |       None       |     v 2      |
+--------------+------------------+--------------+
codecov[bot] commented 1 year ago

Codecov Report

Merging #219 (d039239) into master (aa4e316) will increase coverage by 0.19%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #219      +/-   ##
==========================================
+ Coverage   94.19%   94.38%   +0.19%     
==========================================
  Files           5        5              
  Lines        2258     2281      +23     
==========================================
+ Hits         2127     2153      +26     
+ Misses        131      128       -3     
Flag Coverage Δ
macos-latest 94.38% <100.00%> (+0.19%) :arrow_up:
ubuntu-latest 94.38% <100.00%> (+0.19%) :arrow_up:
windows-latest 94.25% <100.00%> (+0.19%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/prettytable/prettytable.py 90.69% <100.00%> (+0.26%) :arrow_up:
tests/test_prettytable.py 100.00% <100.00%> (ø)

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

etjones commented 1 year ago

Nice work, Krzysztof. I rushed that PR without doing as much testing as I should have. I'm grateful to you for cleaning up my mess.

hugovk commented 1 year ago

Thanks!