Skip to content

Add more tests for formatting floats and fractions #109546

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

Closed
serhiy-storchaka opened this issue Sep 18, 2023 · 2 comments
Closed

Add more tests for formatting floats and fractions #109546

serhiy-storchaka opened this issue Sep 18, 2023 · 2 comments
Labels
3.12 only security fixes 3.13 bugs and security fixes tests Tests in the Lib/test dir

Comments

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Sep 18, 2023

File "formatfloat_testcases.txt" contains test cases for testing printf-like formatting of floats. The same data can be used for testing new-style formatting of floats (they give the same result) and float-style formatting of Fraction (added in 3.12).

cc @mdickinson

Linked PRs

@serhiy-storchaka
Copy link
Member Author

I tried also to use this file in test_decimal, but decimals produce very different output.

I am not sure about test_complex. On one hand, complex formatting uses the same PyOS_double_to_string() as float formatting. On other hand, there is a code between __format__() and PyOS_double_to_string() which can affect interpretation of the format string.

@vstinner
Copy link
Member

It's already great to use it in test_fractions! And that you added more tests in test_float.

vstinner pushed a commit to vstinner/cpython that referenced this issue Sep 21, 2023
vstinner added a commit that referenced this issue Sep 21, 2023
…109685)

gh-109546: Add more tests for formatting floats (GH-109548)

(cherry picked from commit beb5ec5)

Co-authored-by: Serhiy Storchaka <[email protected]>
Yhg1s pushed a commit that referenced this issue Oct 2, 2023
…H-109548) (#109557)

gh-109546: Add more tests for formatting floats and fractions (GH-109548)
(cherry picked from commit beb5ec5)

Co-authored-by: Serhiy Storchaka <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 only security fixes 3.13 bugs and security fixes tests Tests in the Lib/test dir
Projects
None yet
Development

No branches or pull requests

2 participants