[Python-3000-checkins] r56715 - python/branches/py3k-struni/Lib/test/test_complex.py

guido.van.rossum python-3000-checkins at python.org
Fri Aug 3 22:40:45 CEST 2007


Author: guido.van.rossum
Date: Fri Aug  3 22:40:44 2007
New Revision: 56715

Modified:
   python/branches/py3k-struni/Lib/test/test_complex.py
Log:
Make test_complex pass again now that floordiv and mod are illegal.


Modified: python/branches/py3k-struni/Lib/test/test_complex.py
==============================================================================
--- python/branches/py3k-struni/Lib/test/test_complex.py	(original)
+++ python/branches/py3k-struni/Lib/test/test_complex.py	Fri Aug  3 22:40:44 2007
@@ -89,8 +89,8 @@
         self.assertRaises(ZeroDivisionError, complex.__truediv__, 1+1j, 0+0j)
 
     def test_floordiv(self):
-        self.assertAlmostEqual(complex.__floordiv__(3+0j, 1.5+0j), 2)
-        self.assertRaises(ZeroDivisionError, complex.__floordiv__, 3+0j, 0+0j)
+        self.assertRaises(TypeError, complex.__floordiv__, 3+0j, 1.5+0j)
+        self.assertRaises(TypeError, complex.__floordiv__, 3+0j, 0+0j)
 
     def test_richcompare(self):
         self.assertRaises(OverflowError, complex.__eq__, 1+1j, 1<<10000)
@@ -105,18 +105,13 @@
         self.assertRaises(TypeError, complex.__ge__, 1+1j, 2+2j)
 
     def test_mod(self):
-        self.assertRaises(ZeroDivisionError, (1+1j).__mod__, 0+0j)
-
-        a = 3.33+4.43j
-        try:
-            a % 0
-        except ZeroDivisionError:
-            pass
-        else:
-            self.fail("modulo parama can't be 0")
+        # % is no longer supported on complex numbers
+        self.assertRaises(TypeError, (1+1j).__mod__, 0+0j)
+        self.assertRaises(TypeError, lambda: (3.33+4.43j) % 0)
 
     def test_divmod(self):
-        self.assertRaises(ZeroDivisionError, divmod, 1+1j, 0+0j)
+        self.assertRaises(TypeError, divmod, 1+1j, 1+0j)
+        self.assertRaises(TypeError, divmod, 1+1j, 0+0j)
 
     def test_pow(self):
         self.assertAlmostEqual(pow(1+1j, 0+0j), 1.0)


More information about the Python-3000-checkins mailing list