Skip to content

Commit 1cef882

Browse files
authored
Merge branch 'main' into test-support-double-rounding
2 parents dd5edc3 + b87c991 commit 1cef882

5 files changed

Lines changed: 39 additions & 9 deletions

File tree

Lib/test/_test_multiprocessing.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6310,6 +6310,8 @@ def test_resource_tracker_sigint(self):
63106310
# Catchable signal (ignored by semaphore tracker)
63116311
self.check_resource_tracker_death(signal.SIGINT, False)
63126312

6313+
@unittest.skipUnless(hasattr(signal, 'pthread_sigmask'),
6314+
'need signal.pthread_sigmask')
63136315
def test_resource_tracker_sigterm(self):
63146316
# Catchable signal (ignored by semaphore tracker)
63156317
self.check_resource_tracker_death(signal.SIGTERM, False)

Lib/test/support/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2814,6 +2814,10 @@ def exceeds_recursion_limit():
28142814
is_s390x = hasattr(os, 'uname') and os.uname().machine == 's390x'
28152815
skip_on_s390x = unittest.skipIf(is_s390x, 'skipped on s390x')
28162816

2817+
# Cygwin uses the newlib C library
2818+
skip_on_newlib = unittest.skipIf(sys.platform == 'cygwin',
2819+
'the test fails on newlib C library')
2820+
28172821
Py_TRACE_REFS = hasattr(sys, 'getobjects')
28182822

28192823
_JIT_ENABLED = sys._jit.is_enabled()

Lib/test/test_math.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,7 @@ def testHypot(self):
916916

917917
@requires_IEEE_754
918918
@skip_if_double_rounding
919+
@support.skip_on_newlib
919920
def testHypotAccuracy(self):
920921
# Verify improved accuracy in cases that were known to be inaccurate.
921922
#
@@ -1247,12 +1248,6 @@ def testLog2(self):
12471248
self.assertEqual(math.log2(4), 2.0)
12481249
self.assertEqual(math.log2(MyIndexable(4)), 2.0)
12491250

1250-
# Large integer values
1251-
self.assertEqual(math.log2(2**1023), 1023.0)
1252-
self.assertEqual(math.log2(2**1024), 1024.0)
1253-
self.assertEqual(math.log2(2**2000), 2000.0)
1254-
self.assertEqual(math.log2(MyIndexable(2**2000)), 2000.0)
1255-
12561251
self.assertRaises(ValueError, math.log2, 0.0)
12571252
self.assertRaises(ValueError, math.log2, 0)
12581253
self.assertRaises(ValueError, math.log2, MyIndexable(0))
@@ -1270,12 +1265,19 @@ def testLog2(self):
12701265
@requires_IEEE_754
12711266
# log2() is not accurate enough on Mac OS X Tiger (10.4)
12721267
@support.requires_mac_ver(10, 5)
1268+
@support.skip_on_newlib
12731269
def testLog2Exact(self):
12741270
# Check that we get exact equality for log2 of powers of 2.
12751271
actual = [math.log2(math.ldexp(1.0, n)) for n in range(-1074, 1024)]
12761272
expected = [float(n) for n in range(-1074, 1024)]
12771273
self.assertEqual(actual, expected)
12781274

1275+
# Large integer values
1276+
self.assertEqual(math.log2(2**1023), 1023.0)
1277+
self.assertEqual(math.log2(2**1024), 1024.0)
1278+
self.assertEqual(math.log2(2**2000), 2000.0)
1279+
self.assertEqual(math.log2(MyIndexable(2**2000)), 2000.0)
1280+
12791281
def testLog10(self):
12801282
self.assertRaises(TypeError, math.log10)
12811283
self.ftest('log10(0.1)', math.log10(0.1), -1)
@@ -2607,6 +2609,7 @@ def test_fma_nan_results(self):
26072609
self.assertIsNaN(math.fma(a, math.nan, b))
26082610
self.assertIsNaN(math.fma(a, b, math.nan))
26092611

2612+
@support.skip_on_newlib
26102613
def test_fma_infinities(self):
26112614
# Cases involving infinite inputs or results.
26122615
positives = [1e-300, 2.3, 1e300, math.inf]
@@ -2677,7 +2680,7 @@ def test_fma_infinities(self):
26772680
# gh-73468: On some platforms, libc fma() doesn't implement IEE 754-2008
26782681
# properly: it doesn't use the right sign when the result is zero.
26792682
@unittest.skipIf(
2680-
sys.platform.startswith(("freebsd", "wasi", "netbsd", "emscripten"))
2683+
sys.platform.startswith(("freebsd", "wasi", "netbsd", "emscripten", "cygwin"))
26812684
or (sys.platform == "android" and platform.machine() == "x86_64")
26822685
or support.linked_to_musl(), # gh-131032
26832686
f"this platform doesn't implement IEE 754-2008 properly")
@@ -2735,6 +2738,7 @@ def test_fma_zero_result(self):
27352738
self.assertIsNegativeZero(math.fma(y-x, -(x+y), -z))
27362739
self.assertIsPositiveZero(math.fma(x-y, -(x+y), z))
27372740

2741+
@support.skip_on_newlib
27382742
def test_fma_overflow(self):
27392743
a = b = float.fromhex('0x1p512')
27402744
c = float.fromhex('0x1p1023')
@@ -2768,11 +2772,13 @@ def test_fma_overflow(self):
27682772
c = float.fromhex('0x1.fffffffffffffp+1023')
27692773
self.assertEqual(math.fma(a, b, -c), c)
27702774

2775+
@support.skip_on_newlib
27712776
def test_fma_single_round(self):
27722777
a = float.fromhex('0x1p-50')
27732778
self.assertEqual(math.fma(a - 1.0, a + 1.0, 1.0), a*a)
27742779

2775-
def test_random(self):
2780+
@support.skip_on_newlib
2781+
def test_fma_random(self):
27762782
# A collection of randomly generated inputs for which the naive FMA
27772783
# (with two rounds) gives a different result from a singly-rounded FMA.
27782784

Lib/test/test_statistics.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import unittest
1818
from test import support
1919
from test.support import (import_helper, requires_IEEE_754,
20-
skip_if_double_rounding)
20+
skip_if_double_rounding, skip_on_newlib)
2121

2222
from decimal import Decimal
2323
from fractions import Fraction
@@ -2793,6 +2793,7 @@ def test_sqrtprod_helper_function_fundamentals(self):
27932793
@requires_IEEE_754
27942794
@skip_if_double_rounding
27952795
@support.cpython_only # Allow for a weaker sumprod() implementation
2796+
@skip_on_newlib
27962797
def test_sqrtprod_helper_function_improved_accuracy(self):
27972798
# Test a known example where accuracy is improved
27982799
x, y, target = 0.8035720646477457, 0.7957468097636939, 0.7996498651651661

Lib/test/test_strptime.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
else:
2020
glibc_ver = None
2121

22+
def skip_cygwin_locale():
23+
if sys.platform != 'cygwin':
24+
return
25+
loc = locale.getlocale(locale.LC_TIME)[0]
26+
if loc in ('my_MM', 'or_IN'):
27+
raise unittest.SkipTest('test fails on Cygwin')
28+
2229

2330
class getlang_Tests(unittest.TestCase):
2431
"""Test _getlang"""
@@ -509,6 +516,8 @@ def test_bad_timezone(self):
509516
'my_MM', 'or_IN', 'shn_MM', 'az_IR',
510517
'byn_ER', 'wal_ET', 'lzh_TW')
511518
def test_date_time_locale(self):
519+
skip_cygwin_locale()
520+
512521
# Test %c directive
513522
loc = locale.getlocale(locale.LC_TIME)[0]
514523
if glibc_ver and glibc_ver < (2, 31) and loc == 'br_FR':
@@ -536,6 +545,8 @@ def test_date_time_locale(self):
536545
'csb_PL', 'br_FR', 'gez_ET', 'brx_IN',
537546
'my_MM', 'shn_MM')
538547
def test_date_time_locale2(self):
548+
skip_cygwin_locale()
549+
539550
# Test %c directive
540551
loc = locale.getlocale(locale.LC_TIME)[0]
541552
if sys.platform.startswith('sunos'):
@@ -550,6 +561,8 @@ def test_date_time_locale2(self):
550561
'he_IL', 'eu_ES', 'ar_AE',
551562
'az_IR', 'my_MM', 'or_IN', 'shn_MM', 'lzh_TW')
552563
def test_date_locale(self):
564+
skip_cygwin_locale()
565+
553566
# Test %x directive
554567
now = time.time()
555568
self.roundtrip('%x', slice(0, 3), time.localtime(now))
@@ -567,6 +580,8 @@ def test_date_locale(self):
567580
@run_with_locales('LC_TIME', 'en_US', 'fr_FR', 'de_DE', 'ja_JP',
568581
'eu_ES', 'ar_AE', 'my_MM', 'shn_MM', 'lzh_TW')
569582
def test_date_locale2(self):
583+
skip_cygwin_locale()
584+
570585
# Test %x directive
571586
loc = locale.getlocale(locale.LC_TIME)[0]
572587
if sys.platform.startswith(('sunos', 'aix')):
@@ -587,6 +602,8 @@ def test_date_locale2(self):
587602
'ti_ET', 'tig_ER', 'wal_ET', 'lzh_TW',
588603
'ar_SA', 'bg_BG')
589604
def test_time_locale(self):
605+
skip_cygwin_locale()
606+
590607
# Test %X directive
591608
loc = locale.getlocale(locale.LC_TIME)[0]
592609
pos = slice(3, 6)

0 commit comments

Comments
 (0)