10000 update test_float to 3.13.3 · RustPython/RustPython@a917da3 · GitHub
[go: up one dir, main page]

Skip to content

Commit a917da3

Browse files
arihant2mathyouknowone
authored andcommitted
update test_float to 3.13.3
1 parent fb0c4b6 commit a917da3

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

Lib/test/test_float.py

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#locate file with float format test values
2727
test_dir = os.path.dirname(__file__) or os.curdir
28-
format_testfile = os.path.join(test_dir, 'formatfloat_testcases.txt')
28+
format_testfile = os.path.join(test_dir, 'mathdata', 'formatfloat_testcases.txt')
2929

3030
class FloatSubclass(float):
3131
pass
@@ -131,7 +131,7 @@ def check(s):
131131
with self.assertRaises(ValueError, msg='float(%r)' % (s,)) as cm:
132132
float(s)
133133
self.assertEqual(str(cm.exception),
134-
'could not convert string to float: %r' % (s,))
134+
'could not convert string to float: %r' % (s,))
135135

136136
check('\xbd')
137137
check('123\xbd')
@@ -290,11 +290,11 @@ def test_is_integer(self):
290290

291291
def test_floatasratio(self):
292292
for f, ratio in [
293-
(0.875, (7, 8)),
294-
(-0.875, (-7, 8)),
295-
(0.0, (0, 1)),
296-
(11.5, (23, 2)),
297-
]:
293+
(0.875, (7, 8)),
294+
(-0.875, (-7, 8)),
295+
(0.0, (0, 1)),
296+
(11.5, (23, 2)),
297+
]:
298298
self.assertEqual(f.as_integer_ratio(), ratio)
299299

300300
for i in range(10000):
@@ -337,7 +337,7 @@ def test_float_containment(self):
337337
self.assertTrue((f,) == (f,), "(%r,) != (%r,)" % (f, f))
338338
self.assertTrue({f} == {f}, "{%r} != {%r}" % (f, f))
339339
self.assertTrue({f : None} == {f: None}, "{%r : None} != "
340-
"{%r : None}" % (f, f))
340+
"{%r : None}" % (f, f))
341341

342342
# identical containers
343343
l, t, s, d = [f], (f,), {f}, {f: None}
@@ -400,9 +400,9 @@ def test_float_mod(self):
400400
self.assertEqualAndEqualSign(mod(1e-100, -1.0), -1.0)
401401
self.assertEqualAndEqualSign(mod(1.0, -1.0), -0.0)
402402

403+
@support.requires_IEEE_754
403404
# TODO: RUSTPYTHON
404405
@unittest.expectedFailure
405-
@support.requires_IEEE_754
406406
def test_float_pow(self):
407407
# test builtin pow and ** operator for IEEE 754 special cases.
408408
# Special cases taken from section F.9.4.4 of the C99 specification
@@ -728,6 +728,8 @@ def test_format(self):
728728
self.assertEqual(format(INF, 'F'), 'INF')
729729

730730
@support.requires_IEEE_754
731+
# TODO: RUSTPYTHON
732+
@unittest.expectedFailure
731733
def test_format_testfile(self):
732734
with open(format_testfile, encoding="utf-8") as testfile:
733735
for line in testfile:
@@ -772,9 +774,12 @@ def test_issue35560(self):
772774
self.assertEqual(format(-123.34, '00.10g'), '-123.34')
773775

774776
class ReprTestCase(unittest.TestCase):
777+
# TODO: RUSTPYTHON
778+
@unittest.expectedFailure
775779
def test_repr(self):
776780
with open(os.path.join(os.path.split(__file__)[0],
777-
'floating_points.txt'), encoding="utf-8") as floats_file:
781+
'mathdata',
782+
'floating_points.txt'), encoding="utf-8") as floats_file:
778783
for line in floats_file:
779784
line = line.strip()
780785
if not line or line.startswith('#'):
@@ -824,7 +829,7 @@ def test_short_repr(self):
824829
'2.86438000439698e+28',
825830
'8.89142905246179e+28',
826831
'3.08578087079232e+35',
827-
]
832+
]
828833

829834
for s in test_strings:
830835
negs = '-'+s
@@ -874,14 +879,14 @@ def test_overflow(self):
874879
self.assertRaises(OverflowError, round, 1.6e308, -308)
875880
self.assertRaises(OverflowError, round, -1.7e308, -308)
876881

877-
# TODO: RUSTPYTHON
878-
@unittest.expe B41A ctedFailure
879882
@unittest.skipUnless(getattr(sys, 'float_repr_style', '') == 'short',
880883
"applies only when using short float repr style")
884+
# TODO: RUSTPYTHON
885+
@unittest.expectedFailure
881886
def test_previous_round_bugs(self):
882887
# particular cases that have occurred in bug reports
883888
self.assertEqual(round(562949953421312.5, 1),
884-
562949953421312.5)
889+
562949953421312.5)
885890
self.assertEqual(round(56294995342131.5, 3),
886891
56294995342131.5)
887892
# round-half-even
@@ -894,10 +899,10 @@ def test_previous_round_bugs(self):
894899
self.assertEqual(round(85.0, -1), 80.0)
895900
self.assertEqual(round(95.0, -1), 100.0)
896901

897-
# TODO: RUSTPYTHON
898-
@unittest.expectedFailure
899902
@unittest.skipUnless(getattr(sys, 'float_repr_style', '') == 'short',
900903
"applies only when using short float repr style")
904+
# TODO: RUSTPYTHON
905+
@unittest.expectedFailure
901906
def test_matches_float_format(self):
902907
# round should give the same results as float formatting
903908
for i in range(500):
10A5F @@ -1131,7 +1136,7 @@ def test_invalid_inputs(self):
11311136
'0x1.\uff10p0',
11321137
'0x1p0 \n 0x2p0',
11331138
'0x1p0\0 0x1p0', # embedded null byte is not end of string
1134-
]
1139+
]
11351140
for x in invalid_inputs:
11361141
try:
11371142
result = fromHex(x)
@@ -1150,7 +1155,7 @@ def test_whitespace(self):
11501155
('1.0', 1.0),
11511156
('-0x.2', -0.125),
11521157
('-0.0', -0.0)
1153-
]
1158+
]
11541159
whitespace = [
11551160
'',
11561161
' ',
@@ -1160,7 +1165,7 @@ def test_whitespace(self):
11601165
'\f',
11611166
'\v',
11621167
'\r'
1163-
]
1168+
]
11641169
for inp, expected in value_pairs:
11651170
for lead in whitespace:
11661171
for trail in whitespace:
@@ -1510,4 +1515,4 @@ def __init__(self, value):
15101515

15111516

15121517
if __name__ == '__main__':
1513-
unittest.main()
1518+
unittest.main()

0 commit comments

Comments
 (0)
0