Skip to content

gh-151162: Increase test coverage for string formatting#151161

Open
manoj-marimuthu wants to merge 1 commit into
python:mainfrom
manoj-marimuthu:add-tests-str
Open

gh-151162: Increase test coverage for string formatting#151161
manoj-marimuthu wants to merge 1 commit into
python:mainfrom
manoj-marimuthu:add-tests-str

Conversation

@manoj-marimuthu

@manoj-marimuthu manoj-marimuthu commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

In Lib/test/test_str.py, string formatting is tested for nan and inf but not for -inf. -inf could be the most important among them (since we have to check if '-' formats correctly). The following PR adds 2 test cases for -inf with %f and %F.

Existing:

self.assertEqual('%f' % NAN, 'nan')
self.assertEqual('%F' % NAN, 'NAN')
self.assertEqual('%f' % INF, 'inf')
self.assertEqual('%F' % INF, 'INF')

Added:

self.assertEqual('%f' % -INF, '-inf')
self.assertEqual('%F' % -INF, '-INF')

@bedevere-app bedevere-app Bot added awaiting review tests Tests in the Lib/test dir labels Jun 9, 2026
@manoj-marimuthu manoj-marimuthu changed the title Increase test coverage for string formatting gh-151162 :Increase test coverage for string formatting Jun 9, 2026
@skirpichev skirpichev changed the title gh-151162 :Increase test coverage for string formatting gh-151162: Increase test coverage for string formatting Jun 9, 2026
Comment thread Lib/test/test_str.py
@@ -1557,7 +1557,8 @@ def __str__(self):
self.assertEqual('%F' % NAN, 'NAN')
self.assertEqual('%f' % INF, 'inf')
self.assertEqual('%F' % INF, 'INF')

self.assertEqual('%f' % -INF, '-inf')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already covered in test_float.RoundTestCase.test_format_specials, and I don't think the second case is particularly special here.

@bedevere-app

bedevere-app Bot commented Jul 26, 2026

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@StanFromIreland StanFromIreland added the pending The issue will be closed if no feedback is provided label Jul 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting changes pending The issue will be closed if no feedback is provided skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants