GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-109546: Add more tests for formatting floats and fractions by serhiy-storchaka · Pull Request #109548 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Sep 18, 2023 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: Add more tests for formatting floats and fractions #109546

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka
pythongh-109546: Add more tests for formatting floats and fractions
948747a
@serhiy-storchaka serhiy-storchaka added skip news needs backport to 3.12 only security fixes labels Sep 18, 2023
@serhiy-storchaka
serhiy-storchaka requested a review from mdickinson September 18, 2023 16:01
@bedevere-app bedevere-app Bot added awaiting review tests Tests in the Lib/test dir labels Sep 18, 2023
@bedevere-app bedevere-app Bot mentioned this pull request Sep 18, 2023
Add more tests for formatting floats and fractions #109546
Closed
@serhiy-storchaka serhiy-storchaka mentioned this pull request Sep 18, 2023
gh-108303: Move all math files to Lib/test/mathdata/ #109512
Merged
vstinner
vstinner reviewed Sep 18, 2023
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I would prefer to not load test_float in test_fractions just to get a filename.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_fractions.py Outdated

@requires_IEEE_754
def test_float_format_testfile(self):
from test.test_float import format_testfile

@vstinner vstinner Sep 18, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I would prefer to just copy/paste the code to get the path here:

format_testfile = os.path.join(test_dir, 'formatfloat_testcases.txt')

I prefer to not make tests inter-dependents. Sometimes, just importing a test has side effects.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mdickinson and AlexWaygood reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
Comment thread Lib/test/test_fractions.py
continue
line = line.strip()
if not line:
continue

@vstinner vstinner Sep 18, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I suppose that such logic is used in other files using formatfloat_testcases.txt. Is there a good place to share common code?

If we add mathdata/, can we add a helper function there which would iterate on the file and strip comments?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Sep 18, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I was going to add it in test_float, but it is simple enough, so I just copied it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_fractions.py
if fmt == '%r':
continue
with self.subTest(fmt=fmt, arg=arg):
f = F(float(arg))

@vstinner vstinner Sep 18, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Maybe add a variable for fmt[1:].

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Sep 18, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Done.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka
Address review comments.
22245e4
@serhiy-storchaka
serhiy-storchaka force-pushed the test_float_format_testfile branch from 18c9aab to 22245e4 Compare September 18, 2023 17:45
@mdickinson

mdickinson commented Sep 18, 2023

Copy link
Copy Markdown
Member

+1 for the idea, and code changes LGTM.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mdickinson
mdickinson approved these changes Sep 18, 2023
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting core review and removed awaiting review labels Sep 18, 2023
@serhiy-storchaka
serhiy-storchaka merged commit beb5ec5 into python:main Sep 19, 2023
@bedevere-app bedevere-app Bot removed the awaiting core review label Sep 19, 2023
@miss-islington

miss-islington commented Sep 19, 2023

Copy link
Copy Markdown
Contributor

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka
serhiy-storchaka deleted the test_float_format_testfile branch September 19, 2023 05:09
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 19, 2023
@serhiy-storchaka @miss-islington
pythongh-109546: Add more tests for formatting floats and fractions (p…
379f0a2
…ythonGH-109548)

(cherry picked from commit beb5ec5)

Co-authored-by: Serhiy Storchaka <[email protected]>
@bedevere-app

bedevere-app Bot commented Sep 19, 2023

Copy link
Copy Markdown

GH-109557 is a backport of this pull request to the 3.12 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label Sep 19, 2023
@bedevere-bot

bedevere-bot commented Sep 19, 2023

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 RHEL8 3.x has failed when building commit beb5ec5.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/185/builds/5034) and take a look at the build logs.
  4. Check if the failure is related to this commit (beb5ec5) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/185/builds/5034

Failed tests:

  • test.test_multiprocessing_fork.test_misc

Failed subtests:

  • test_nested_startmethod - test.test_multiprocessing_fork.test_misc.TestStartMethod.test_nested_startmethod

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64/build/Lib/test/_test_multiprocessing.py", line 5475, in test_nested_startmethod
    self.assertEqual(results, [2, 1])
AssertionError: Lists differ: [1, 2] != [2, 1]
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented Sep 19, 2023

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 RHEL8 FIPS Only Blake2 Builtin Hash 3.x has failed when building commit beb5ec5.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/469/builds/6024) and take a look at the build logs.
  4. Check if the failure is related to this commit (beb5ec5) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/469/builds/6024

Failed tests:

  • test.test_asyncio.test_subprocess

Failed subtests:

  • test_subprocess_consistent_callbacks - test.test_asyncio.test_subprocess.SubprocessThreadedWatcherTests.test_subprocess_consistent_callbacks

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-fips-x86_64.no-builtin-hashes-except-blake2/build/Lib/test/test_asyncio/test_subprocess.py", line 788, in test_subprocess_consistent_callbacks
    self.loop.run_until_complete(main())
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-fips-x86_64.no-builtin-hashes-except-blake2/build/Lib/asyncio/base_events.py", line 664, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-fips-x86_64.no-builtin-hashes-except-blake2/build/Lib/test/test_asyncio/test_subprocess.py", line 780, in main
    self.assertEqual(events, [
AssertionError: Lists differ: [('pi[29 chars]t'), 'pipe_connection_lost', ('pipe_data_recei[57 chars]ted'] != [('pi[29 chars]t'), ('pipe_data_received', 2, b'stderr'), 'pi[57 chars]ted']
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented Sep 19, 2023

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot PPC64LE RHEL7 LTO + PGO 3.x has failed when building commit beb5ec5.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/43/builds/4246) and take a look at the build logs.
  4. Check if the failure is related to this commit (beb5ec5) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/43/builds/4246

Failed tests:

  • test.test_multiprocessing_fork.test_processes

Summary of the results of the build (if available):

==

Click to see traceback logs
remote: Enumerating objects: 6, done.        
remote: Counting objects:  16% (1/6)        
remote: Counting objects:  33% (2/6)        
remote: Counting objects:  50% (3/6)        
remote: Counting objects:  66% (4/6)        
remote: Counting objects:  83% (5/6)        
remote: Counting objects: 100% (6/6)        
remote: Counting objects: 100% (6/6), done.        
remote: Compressing objects:  16% (1/6)        
remote: Compressing objects:  33% (2/6)        
remote: Compressing objects:  50% (3/6)        
remote: Compressing objects:  66% (4/6)        
remote: Compressing objects:  83% (5/6)        
remote: Compressing objects: 100% (6/6)        
remote: Compressing objects: 100% (6/6), done.        
remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0        
From https://github.com/python/cpython
 * branch            main       -> FETCH_HEAD
Note: checking out 'beb5ec5817b645562ebbdd59f25683a93061c32c'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at beb5ec5... gh-109546: Add more tests for formatting floats and fractions (GH-109548)
Switched to and reset branch 'main'

find: ‘build’: No such file or directory
find: ‘build’: No such file or directory
find: ‘build’: No such file or directory
find: ‘build’: No such file or directory
make[2]: [Makefile:2807: clean-retain-profile] Error 1 (ignored)
./Modules/_testcapi/unicode.c: In function ‘test_string_from_format’:
./Modules/_testcapi/unicode.c:1538:1: note: variable tracking size limit exceeded with -fvar-tracking-assignments, retrying without
 test_string_from_format(PyObject *self, PyObject *Py_UNUSED(ignored))
 ^~~~~~~~~~~~~~~~~~~~~~~
./Modules/_testcapi/unicode.c: In function ‘test_string_from_format’:
./Modules/_testcapi/unicode.c:1538:1: note: variable tracking size limit exceeded with -fvar-tracking-assignments, retrying without
 test_string_from_format(PyObject *self, PyObject *Py_UNUSED(ignored))
 ^
./Modules/_decimal/libmpdec/context.c:57: warning: mpd_setminalloc: ignoring request to set MPD_MINALLOC a second time

./Modules/_decimal/libmpdec/context.c:57: warning: mpd_setminalloc: ignoring request to set MPD_MINALLOC a second time


make: *** [Makefile:2027: buildbottest] Error 5
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner added the needs backport to 3.11 only security fixes label Sep 21, 2023
@miss-islington

miss-islington commented Sep 21, 2023

Copy link
Copy Markdown
Contributor

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington

miss-islington commented Sep 21, 2023

Copy link
Copy Markdown
Contributor

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker beb5ec5817b645562ebbdd59f25683a93061c32c 3.11

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington miss-islington assigned serhiy-storchaka Sep 21, 2023
@vstinner vstinner removed the needs backport to 3.11 only security fixes label Sep 21, 2023
@vstinner

vstinner commented Sep 21, 2023

Copy link
Copy Markdown
Member

Oh. I tried to backport this change to 3.11 to prepare backporting PR #109512 to 3.11 and 3.12, but the fractions module doesn't support all formatting syntax in 3.11:

ERROR: test_float_format_testfile (test.test_fractions.FractionTest.test_float_format_testfile) (fmt='%.1g', arg='10')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vstinner/python/3.11/Lib/test/test_fractions.py", line 856, in test_float_format_testfile
    self.assertEqual(format(f, fmt2), rhs)
                     ^^^^^^^^^^^^^^^
TypeError: unsupported format string passed to Fraction.__format__

So this change cannot be backported.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner pushed a commit to vstinner/cpython that referenced this pull request Sep 21, 2023
@serhiy-storchaka @vstinner
pythongh-109546: Add more tests for formatting floats (pythonGH-109548)
6f0c599
(cherry picked from commit beb5ec5)
@bedevere-app

bedevere-app Bot commented Sep 21, 2023

Copy link
Copy Markdown

GH-109685 is a backport of this pull request to the 3.11 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Sep 21, 2023

Copy link
Copy Markdown
Member

I partially backported the change to 3.11: only test_float changes.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner mentioned this pull request Sep 21, 2023
Move test files into test subdirectories #108303
Closed
vstinner added a commit that referenced this pull request Sep 21, 2023
@vstinner @serhiy-storchaka
[3.11] gh-109546: Add more tests for formatting floats (GH-109548) (#…
84d8fdb
…109685)

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

(cherry picked from commit beb5ec5)

Co-authored-by: Serhiy Storchaka <[email protected]>
csm10495 pushed a commit to csm10495/cpython that referenced this pull request Sep 28, 2023
@serhiy-storchaka @csm10495
pythongh-109546: Add more tests for formatting floats and fractions (p…
be83a3a
…ythonGH-109548)
Yhg1s pushed a commit that referenced this pull request Oct 2, 2023
@miss-islington @serhiy-storchaka
[3.12] gh-109546: Add more tests for formatting floats and fractions (G…
acb6753
…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]>
@serhiy-storchaka serhiy-storchaka removed their assignment Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner left review comments
+1 more reviewer
@mdickinson mdickinson mdickinson approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@serhiy-storchaka @mdickinson @miss-islington @bedevere-bot @vstinner
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.