Python operator.repeat() Examples
The following are 8
code examples of operator.repeat().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
operator
, or try the search function
.
Example #1
Source File: test_operator.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_repeat(self): a = range(3) self.assertRaises(TypeError, operator.repeat) self.assertRaises(TypeError, operator.repeat, a, None) self.assertTrue(operator.repeat(a, 2) == a+a) self.assertTrue(operator.repeat(a, 1) == a) self.assertTrue(operator.repeat(a, 0) == []) a = (1, 2, 3) self.assertTrue(operator.repeat(a, 2) == a+a) self.assertTrue(operator.repeat(a, 1) == a) self.assertTrue(operator.repeat(a, 0) == ()) a = '123' self.assertTrue(operator.repeat(a, 2) == a+a) self.assertTrue(operator.repeat(a, 1) == a) self.assertTrue(operator.repeat(a, 0) == '') a = Seq1([4, 5, 6]) self.assertTrue(operator.repeat(a, 2) == [4, 5, 6, 4, 5, 6]) self.assertTrue(operator.repeat(a, 1) == [4, 5, 6]) self.assertTrue(operator.repeat(a, 0) == []) a = Seq2([4, 5, 6]) self.assertTrue(operator.repeat(a, 2) == [4, 5, 6, 4, 5, 6]) self.assertTrue(operator.repeat(a, 1) == [4, 5, 6]) self.assertTrue(operator.repeat(a, 0) == []) self.assertRaises(TypeError, operator.repeat, 6, 7)
Example #2
Source File: test_operator.py From BinderFilter with MIT License | 6 votes |
def test_repeat(self): a = range(3) self.assertRaises(TypeError, operator.repeat) self.assertRaises(TypeError, operator.repeat, a, None) self.assertTrue(operator.repeat(a, 2) == a+a) self.assertTrue(operator.repeat(a, 1) == a) self.assertTrue(operator.repeat(a, 0) == []) a = (1, 2, 3) self.assertTrue(operator.repeat(a, 2) == a+a) self.assertTrue(operator.repeat(a, 1) == a) self.assertTrue(operator.repeat(a, 0) == ()) a = '123' self.assertTrue(operator.repeat(a, 2) == a+a) self.assertTrue(operator.repeat(a, 1) == a) self.assertTrue(operator.repeat(a, 0) == '') a = Seq1([4, 5, 6]) self.assertTrue(operator.repeat(a, 2) == [4, 5, 6, 4, 5, 6]) self.assertTrue(operator.repeat(a, 1) == [4, 5, 6]) self.assertTrue(operator.repeat(a, 0) == []) a = Seq2([4, 5, 6]) self.assertTrue(operator.repeat(a, 2) == [4, 5, 6, 4, 5, 6]) self.assertTrue(operator.repeat(a, 1) == [4, 5, 6]) self.assertTrue(operator.repeat(a, 0) == []) self.assertRaises(TypeError, operator.repeat, 6, 7)
Example #3
Source File: test_operator.py From oss-ftp with MIT License | 6 votes |
def test_repeat(self): a = range(3) self.assertRaises(TypeError, operator.repeat) self.assertRaises(TypeError, operator.repeat, a, None) self.assertTrue(operator.repeat(a, 2) == a+a) self.assertTrue(operator.repeat(a, 1) == a) self.assertTrue(operator.repeat(a, 0) == []) a = (1, 2, 3) self.assertTrue(operator.repeat(a, 2) == a+a) self.assertTrue(operator.repeat(a, 1) == a) self.assertTrue(operator.repeat(a, 0) == ()) a = '123' self.assertTrue(operator.repeat(a, 2) == a+a) self.assertTrue(operator.repeat(a, 1) == a) self.assertTrue(operator.repeat(a, 0) == '') a = Seq1([4, 5, 6]) self.assertTrue(operator.repeat(a, 2) == [4, 5, 6, 4, 5, 6]) self.assertTrue(operator.repeat(a, 1) == [4, 5, 6]) self.assertTrue(operator.repeat(a, 0) == []) a = Seq2([4, 5, 6]) self.assertTrue(operator.repeat(a, 2) == [4, 5, 6, 4, 5, 6]) self.assertTrue(operator.repeat(a, 1) == [4, 5, 6]) self.assertTrue(operator.repeat(a, 0) == []) self.assertRaises(TypeError, operator.repeat, 6, 7)
Example #4
Source File: test_operator.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_repeat(self): a = range(3) self.assertRaises(TypeError, operator.repeat) self.assertRaises(TypeError, operator.repeat, a, None) self.assertTrue(operator.repeat(a, 2) == a+a) self.assertTrue(operator.repeat(a, 1) == a) self.assertTrue(operator.repeat(a, 0) == []) a = (1, 2, 3) self.assertTrue(operator.repeat(a, 2) == a+a) self.assertTrue(operator.repeat(a, 1) == a) self.assertTrue(operator.repeat(a, 0) == ()) a = '123' self.assertTrue(operator.repeat(a, 2) == a+a) self.assertTrue(operator.repeat(a, 1) == a) self.assertTrue(operator.repeat(a, 0) == '') a = Seq1([4, 5, 6]) self.assertTrue(operator.repeat(a, 2) == [4, 5, 6, 4, 5, 6]) self.assertTrue(operator.repeat(a, 1) == [4, 5, 6]) self.assertTrue(operator.repeat(a, 0) == []) a = Seq2([4, 5, 6]) self.assertTrue(operator.repeat(a, 2) == [4, 5, 6, 4, 5, 6]) self.assertTrue(operator.repeat(a, 1) == [4, 5, 6]) self.assertTrue(operator.repeat(a, 0) == []) self.assertRaises(TypeError, operator.repeat, 6, 7)
Example #5
Source File: expr.py From owasp-pysec with Apache License 2.0 | 5 votes |
def __repeat__(self): return Expression(self, operator.repeat)
Example #6
Source File: test_operator.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_repeat(self): a = range(3) self.failUnlessRaises(TypeError, operator.repeat) self.failUnlessRaises(TypeError, operator.repeat, a, None) self.failUnless(operator.repeat(a, 2) == a+a) self.failUnless(operator.repeat(a, 1) == a) self.failUnless(operator.repeat(a, 0) == []) a = (1, 2, 3) self.failUnless(operator.repeat(a, 2) == a+a) self.failUnless(operator.repeat(a, 1) == a) self.failUnless(operator.repeat(a, 0) == ()) a = '123' self.failUnless(operator.repeat(a, 2) == a+a) self.failUnless(operator.repeat(a, 1) == a) self.failUnless(operator.repeat(a, 0) == '') a = Seq1([4, 5, 6]) self.failUnless(operator.repeat(a, 2) == [4, 5, 6, 4, 5, 6]) self.failUnless(operator.repeat(a, 1) == [4, 5, 6]) self.failUnless(operator.repeat(a, 0) == []) a = Seq2([4, 5, 6]) self.failUnless(operator.repeat(a, 2) == [4, 5, 6, 4, 5, 6]) self.failUnless(operator.repeat(a, 1) == [4, 5, 6]) self.failUnless(operator.repeat(a, 0) == []) if not test_support.is_jython: # Jython repeat is mul self.failUnlessRaises(TypeError, operator.repeat, 6, 7)
Example #7
Source File: test_operator.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_repeat(self): a = range(3) self.failUnlessRaises(TypeError, operator.repeat) self.failUnlessRaises(TypeError, operator.repeat, a, None) self.failUnless(operator.repeat(a, 2) == a+a) self.failUnless(operator.repeat(a, 1) == a) self.failUnless(operator.repeat(a, 0) == []) a = (1, 2, 3) self.failUnless(operator.repeat(a, 2) == a+a) self.failUnless(operator.repeat(a, 1) == a) self.failUnless(operator.repeat(a, 0) == ()) a = '123' self.failUnless(operator.repeat(a, 2) == a+a) self.failUnless(operator.repeat(a, 1) == a) self.failUnless(operator.repeat(a, 0) == '') a = Seq1([4, 5, 6]) self.failUnless(operator.repeat(a, 2) == [4, 5, 6, 4, 5, 6]) self.failUnless(operator.repeat(a, 1) == [4, 5, 6]) self.failUnless(operator.repeat(a, 0) == []) a = Seq2([4, 5, 6]) self.failUnless(operator.repeat(a, 2) == [4, 5, 6, 4, 5, 6]) self.failUnless(operator.repeat(a, 1) == [4, 5, 6]) self.failUnless(operator.repeat(a, 0) == []) if not test_support.is_jython: # Jython repeat is mul self.failUnlessRaises(TypeError, operator.repeat, 6, 7)
Example #8
Source File: test_operator.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_repeat(self): a = range(3) self.failUnlessRaises(TypeError, operator.repeat) self.failUnlessRaises(TypeError, operator.repeat, a, None) self.failUnless(operator.repeat(a, 2) == a+a) self.failUnless(operator.repeat(a, 1) == a) self.failUnless(operator.repeat(a, 0) == []) a = (1, 2, 3) self.failUnless(operator.repeat(a, 2) == a+a) self.failUnless(operator.repeat(a, 1) == a) self.failUnless(operator.repeat(a, 0) == ()) a = '123' self.failUnless(operator.repeat(a, 2) == a+a) self.failUnless(operator.repeat(a, 1) == a) self.failUnless(operator.repeat(a, 0) == '') a = Seq1([4, 5, 6]) self.failUnless(operator.repeat(a, 2) == [4, 5, 6, 4, 5, 6]) self.failUnless(operator.repeat(a, 1) == [4, 5, 6]) self.failUnless(operator.repeat(a, 0) == []) a = Seq2([4, 5, 6]) self.failUnless(operator.repeat(a, 2) == [4, 5, 6, 4, 5, 6]) self.failUnless(operator.repeat(a, 1) == [4, 5, 6]) self.failUnless(operator.repeat(a, 0) == []) if not test_support.is_jython: # Jython repeat is mul self.failUnlessRaises(TypeError, operator.repeat, 6, 7)