Skip to content

Commit

Permalink
testsuite: python: ensure OutputFormat precision handling
Browse files Browse the repository at this point in the history
Problem: No test in the testsuite ensures that the OutputFormat
class adjusts precision for string presentation types if the width
is adjusted due to the `+:` sentinel.

Add a test that ensures correct handling of precision.
  • Loading branch information
grondo committed Dec 21, 2024
1 parent 564814a commit 27f4c50
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions t/python/t0024-util.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,17 @@ def test_sort(self):
formatter.sort_items(items)
self.assertListEqual(items, [z, d, a])

def test_issue6530(self):
a = Item("1234567890", 0, 2.2)
b = Item("abcdefghijklmnop", 2, 13)
c = Item("c", 4, 5.0)

items = [a, b, c]
fmt = OutputFormat(
"+:{s:5.5} +:{i:4d} +:{f:.2f}", headings=self.headings
).filter(items)
self.assertEqual(fmt, "{s:16.16} {i:4d} {f:3.2f}")


if __name__ == "__main__":
unittest.main(testRunner=TAPTestRunner())

0 comments on commit 27f4c50

Please sign in to comment.