8000 gh-128051: fix tests if sys.float_repr_style is 'legacy' by skirpichev · Pull Request #135908 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-128051: fix tests if sys.float_repr_style is 'legacy' #135908

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

Merged
merged 7 commits into from
Jun 27, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
address review: restore test
  • Loading branch information
skirpichev committed Jun 26, 2025
commit 46c798ac794f740c38d01f2b87ade160fb92d8ac
4 changes: 4 additions & 0 deletions Lib/test/test_ctypes/test_parameters.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
import unittest
import test.support
from ctypes import (CDLL, PyDLL, ArgumentError,
Expand Down Expand Up @@ -224,6 +225,8 @@ def __dict__(self):
with self.assertRaises(ZeroDivisionError):
WorseStruct().__setstate__({}, b'foo')

@unittest.skipUnless(sys.float_repr_style == 'short',
"applies only when using short float repr style")
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer to only skip 1e300 test, rather than skipping the whole test method.

def test_parameter_repr(self):
self.assertRegex(repr(c_bool.from_param(True)), r"^<cparam '\?' at 0x[A-Fa-f0-9]+>$")
self.assertEqual(repr(c_char.from_param(97)), "<cparam 'c' ('a')>")
Expand All @@ -240,6 +243,7 @@ def test_parameter_repr(self):
self.assertRegex(repr(c_ulonglong.from_param(20000)), r"^<cparam '[LIQ]' \(20000\)>$")
self.assertEqual(repr(c_float.from_param(1.5)), "<cparam 'f' (1.5)>")
self.assertEqual(repr(c_double.from_param(1.5)), "<cparam 'd' (1.5)>")
self.assertEqual(repr(c_double.from_param(1e300)), "<cparam 'd' (1e+300)>")
self.assertRegex(repr(c_longdouble.from_param(1.5)), r"^<cparam ('d' \(1.5\)|'g' at 0x[A-Fa-f0-9]+)>$")
self.assertRegex(repr(c_char_p.from_param(b'hihi')), r"^<cparam 'z' \(0x[A-Fa-f0-9]+\)>$")
self.assertRegex(repr(c_wchar_p.from_param('hihi')), r"^<cparam 'Z' \(0x[A-Fa-f0-9]+\)>$")
Expand Down
Loading
0