This fixes the tests that broke.
s = c_float(math.pi)
self.failUnlessEqual(bin(struct.pack("f", math.pi)), bin(s))
# Hm, what's the precision of a float compared to a double?
- self.failUnlessAlmostEqual(s.value, math.pi, 6)
+ self.failUnlessAlmostEqual(s.value, math.pi, places=6)
s = c_float.__ctype_le__(math.pi)
- self.failUnlessAlmostEqual(s.value, math.pi, 6)
+ self.failUnlessAlmostEqual(s.value, math.pi, places=6)
self.failUnlessEqual(bin(struct.pack("<f", math.pi)), bin(s))
s = c_float.__ctype_be__(math.pi)
- self.failUnlessAlmostEqual(s.value, math.pi, 6)
+ self.failUnlessAlmostEqual(s.value, math.pi, places=6)
self.failUnlessEqual(bin(struct.pack(">f", math.pi)), bin(s))
def test_endian_double(self):
def test_constants(self):
e_expected = 2.71828182845904523536
pi_expected = 3.14159265358979323846
- self.assertAlmostEqual(cmath.pi, pi_expected, 9,
- "cmath.pi is %s; should be %s" % (cmath.pi, pi_expected))
- self.assertAlmostEqual(cmath.e, e_expected, 9,
- "cmath.e is %s; should be %s" % (cmath.e, e_expected))
+ self.assertAlmostEqual(cmath.pi, pi_expected, places=9,
+ msg="cmath.pi is %s; should be %s" % (cmath.pi, pi_expected))
+ self.assertAlmostEqual(cmath.e, e_expected, places=9,
+ msg="cmath.e is %s; should be %s" % (cmath.e, e_expected))
def test_user_object(self):
# Test automatic calling of __complex__ and __float__ by cmath
s1 += e
s2 += (e - mu) ** 2
N = len(y)
- self.assertAlmostEqual(s1/N, mu, 2)
- self.assertAlmostEqual(s2/(N-1), sigmasqrd, 2)
+ self.assertAlmostEqual(s1/N, mu, places=2)
+ self.assertAlmostEqual(s2/(N-1), sigmasqrd, places=2)
class TestModule(unittest.TestCase):
def testMagicConstants(self):