Sort out some confusion in test_float.py: the two

separate FormatTestCase classes have been combined,
and test_short_repr has been moved from FormatTestCase
to the existing ReprTestCase.
This commit is contained in:
Mark Dickinson 2009-04-17 20:59:58 +00:00
parent 1a6b73dcdf
commit 7efad9ec5a

View File

@ -313,19 +313,6 @@ class FormatTestCase(unittest.TestCase):
self.assertRaises(ValueError, format, 1e-100, format_spec)
self.assertRaises(ValueError, format, -1e-100, format_spec)
class ReprTestCase(unittest.TestCase):
def test_repr(self):
floats_file = open(os.path.join(os.path.split(__file__)[0],
'floating_points.txt'))
for line in floats_file:
line = line.strip()
if not line or line.startswith('#'):
continue
v = eval(line)
self.assertEqual(v, eval(repr(v)))
floats_file.close()
class FormatTestCase(unittest.TestCase):
@unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
"test requires IEEE 754 doubles")
def test_format_testfile(self):
@ -341,6 +328,18 @@ class FormatTestCase(unittest.TestCase):
self.assertEqual(fmt % float(arg), rhs)
self.assertEqual(fmt % -float(arg), '-' + rhs)
class ReprTestCase(unittest.TestCase):
def test_repr(self):
floats_file = open(os.path.join(os.path.split(__file__)[0],
'floating_points.txt'))
for line in floats_file:
line = line.strip()
if not line or line.startswith('#'):
continue
v = eval(line)
self.assertEqual(v, eval(repr(v)))
floats_file.close()
@unittest.skipUnless(getattr(sys, 'float_repr_style', '') == 'short',
"applies only when using short float repr style")
def test_short_repr(self):
@ -390,8 +389,6 @@ class FormatTestCase(unittest.TestCase):
self.assertEqual(s, repr(float(s)))
self.assertEqual(negs, repr(float(negs)))
# Beginning with Python 2.6 float has cross platform compatible
# ways to create and represent inf and nan
class InfNanTest(unittest.TestCase):