Skip to content

Commit cd77dae

Browse files
committed
gh-149879: Fix test_math on Cygwin
Skip tests which fail on Cygwin: when Python is built with newlib C library.
1 parent cb60f48 commit cd77dae

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

Lib/test/test_math.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
math_testcases = os.path.join(test_dir, 'mathdata', 'math_testcases.txt')
3838
test_file = os.path.join(test_dir, 'mathdata', 'cmath_testcases.txt')
3939

40+
skip_on_newlib = unittest.skipIf(sys.platform == 'cygwin',
41+
'the test fails on newlib C library')
42+
4043

4144
def to_ulps(x):
4245
"""Convert a non-NaN float x to an integer, in such a way that
@@ -922,6 +925,7 @@ def testHypot(self):
922925
@requires_IEEE_754
923926
@unittest.skipIf(HAVE_DOUBLE_ROUNDING,
924927
"hypot() loses accuracy on machines with double rounding")
928+
@skip_on_newlib
925929
def testHypotAccuracy(self):
926930
# Verify improved accuracy in cases that were known to be inaccurate.
927931
#
@@ -1244,6 +1248,7 @@ def testLog1p(self):
12441248
self.assertEqual(math.log1p(INF), INF)
12451249

12461250
@requires_IEEE_754
1251+
@skip_on_newlib
12471252
def testLog2(self):
12481253
self.assertRaises(TypeError, math.log2)
12491254

@@ -1276,6 +1281,7 @@ def testLog2(self):
12761281
@requires_IEEE_754
12771282
# log2() is not accurate enough on Mac OS X Tiger (10.4)
12781283
@support.requires_mac_ver(10, 5)
1284+
@skip_on_newlib
12791285
def testLog2Exact(self):
12801286
# Check that we get exact equality for log2 of powers of 2.
12811287
actual = [math.log2(math.ldexp(1.0, n)) for n in range(-1074, 1024)]
@@ -2615,6 +2621,7 @@ def test_fma_nan_results(self):
26152621
self.assertIsNaN(math.fma(a, math.nan, b))
26162622
self.assertIsNaN(math.fma(a, b, math.nan))
26172623

2624+
@skip_on_newlib
26182625
def test_fma_infinities(self):
26192626
# Cases involving infinite inputs or results.
26202627
positives = [1e-300, 2.3, 1e300, math.inf]
@@ -2685,7 +2692,7 @@ def test_fma_infinities(self):
26852692
# gh-73468: On some platforms, libc fma() doesn't implement IEE 754-2008
26862693
# properly: it doesn't use the right sign when the result is zero.
26872694
@unittest.skipIf(
2688-
sys.platform.startswith(("freebsd", "wasi", "netbsd", "emscripten"))
2695+
sys.platform.startswith(("freebsd", "wasi", "netbsd", "emscripten", "cygwin"))
26892696
or (sys.platform == "android" and platform.machine() == "x86_64")
26902697
or support.linked_to_musl(), # gh-131032
26912698
f"this platform doesn't implement IEE 754-2008 properly")
@@ -2743,6 +2750,7 @@ def test_fma_zero_result(self):
27432750
self.assertIsNegativeZero(math.fma(y-x, -(x+y), -z))
27442751
self.assertIsPositiveZero(math.fma(x-y, -(x+y), z))
27452752

2753+
@skip_on_newlib
27462754
def test_fma_overflow(self):
27472755
a = b = float.fromhex('0x1p512')
27482756
c = float.fromhex('0x1p1023')
@@ -2776,10 +2784,12 @@ def test_fma_overflow(self):
27762784
c = float.fromhex('0x1.fffffffffffffp+1023')
27772785
self.assertEqual(math.fma(a, b, -c), c)
27782786

2787+
@skip_on_newlib
27792788
def test_fma_single_round(self):
27802789
a = float.fromhex('0x1p-50')
27812790
self.assertEqual(math.fma(a - 1.0, a + 1.0, 1.0), a*a)
27822791

2792+
@skip_on_newlib
27832793
def test_random(self):
27842794
# A collection of randomly generated inputs for which the naive FMA
27852795
# (with two rounds) gives a different result from a singly-rounded FMA.

0 commit comments

Comments
 (0)