Added __pow__(a,b) to the operator module. Completes the pattern of

all operators having a counterpart in the operator module.

Closes SF bug #577513.
This commit is contained in:
Raymond Hettinger 2002-08-19 03:19:09 +00:00
parent 7dca21e59f
commit 5959c559df
3 changed files with 23 additions and 0 deletions

View file

@ -161,6 +161,12 @@ class OperatorTestCase(unittest.TestCase):
self.failUnless(operator.pos(0) == 0)
self.failUnless(operator.pos(-0) == 0)
def test_pow(self):
self.failUnless(operator.pow(3,5) == 3**5)
self.failUnless(operator.__pow__(3,5) == 3**5)
self.assertRaises(TypeError, operator.pow, 1)
self.assertRaises(TypeError, operator.pow, 1, 2, 3)
def test_repeat(self):
a = range(3)
self.failUnless(operator.repeat(a, 2) == a+a)