mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
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:
parent
7dca21e59f
commit
5959c559df
3 changed files with 23 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue