Python operator.isCallable() Examples
The following are 20
code examples of operator.isCallable().
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_bool.py From ironpython2 with Apache License 2.0 | 7 votes |
def test_operator(self): import operator self.assertIs(operator.truth(0), False) self.assertIs(operator.truth(1), True) with test_support.check_py3k_warnings(): self.assertIs(operator.isCallable(0), False) self.assertIs(operator.isCallable(len), True) self.assertIs(operator.isNumberType(None), False) self.assertIs(operator.isNumberType(0), True) self.assertIs(operator.not_(1), False) self.assertIs(operator.not_(0), True) self.assertIs(operator.isSequenceType(0), False) self.assertIs(operator.isSequenceType([]), True) self.assertIs(operator.contains([], 1), False) self.assertIs(operator.contains([1], 1), True) self.assertIs(operator.isMappingType(1), False) self.assertIs(operator.isMappingType({}), True) self.assertIs(operator.lt(0, 0), False) self.assertIs(operator.lt(0, 1), True) self.assertIs(operator.is_(True, True), True) self.assertIs(operator.is_(True, False), False) self.assertIs(operator.is_not(True, True), False) self.assertIs(operator.is_not(True, False), True)
Example #2
Source File: test_bool.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def test_operator(self): import operator self.assertIs(operator.truth(0), False) self.assertIs(operator.truth(1), True) with test_support.check_py3k_warnings(): self.assertIs(operator.isCallable(0), False) self.assertIs(operator.isCallable(len), True) self.assertIs(operator.isNumberType(None), False) self.assertIs(operator.isNumberType(0), True) self.assertIs(operator.not_(1), False) self.assertIs(operator.not_(0), True) self.assertIs(operator.isSequenceType(0), False) self.assertIs(operator.isSequenceType([]), True) self.assertIs(operator.contains([], 1), False) self.assertIs(operator.contains([1], 1), True) self.assertIs(operator.isMappingType(1), False) self.assertIs(operator.isMappingType({}), True) self.assertIs(operator.lt(0, 0), False) self.assertIs(operator.lt(0, 1), True) self.assertIs(operator.is_(True, True), True) self.assertIs(operator.is_(True, False), False) self.assertIs(operator.is_not(True, True), False) self.assertIs(operator.is_not(True, False), True)
Example #3
Source File: test_bool.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def test_operator(self): import operator self.assertIs(operator.truth(0), False) self.assertIs(operator.truth(1), True) with test_support.check_py3k_warnings(): self.assertIs(operator.isCallable(0), False) self.assertIs(operator.isCallable(len), True) self.assertIs(operator.isNumberType(None), False) self.assertIs(operator.isNumberType(0), True) self.assertIs(operator.not_(1), False) self.assertIs(operator.not_(0), True) self.assertIs(operator.isSequenceType(0), False) self.assertIs(operator.isSequenceType([]), True) self.assertIs(operator.contains([], 1), False) self.assertIs(operator.contains([1], 1), True) self.assertIs(operator.isMappingType(1), False) self.assertIs(operator.isMappingType({}), True) self.assertIs(operator.lt(0, 0), False) self.assertIs(operator.lt(0, 1), True) self.assertIs(operator.is_(True, True), True) self.assertIs(operator.is_(True, False), False) self.assertIs(operator.is_not(True, True), False) self.assertIs(operator.is_not(True, False), True)
Example #4
Source File: test_operator.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_isCallable(self): self.assertRaises(TypeError, operator.isCallable) class C: pass def check(self, o, v): with test_support.check_py3k_warnings(): self.assertEqual(operator.isCallable(o), v) self.assertEqual(callable(o), v) check(self, 4, 0) check(self, operator.isCallable, 1) check(self, C, 1) check(self, C(), 0)
Example #5
Source File: test_operator.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_isCallable(self): self.failUnlessRaises(TypeError, operator.isCallable) class C: pass def check(self, o, v): self.assertEqual(operator.isCallable(o), v) with test_support.check_py3k_warnings(): self.assertEqual(callable(o), v) check(self, 4, 0) check(self, operator.isCallable, 1) check(self, C, 1) check(self, C(), 0)
Example #6
Source File: test_py3kwarn.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_operator(self): from operator import isCallable, sequenceIncludes callable_warn = ("operator.isCallable() is not supported in 3.x. " "Use hasattr(obj, '__call__').") seq_warn = ("operator.sequenceIncludes() is not supported " "in 3.x. Use operator.contains().") with check_py3k_warnings() as w: self.assertWarning(isCallable(self), w, callable_warn) w.reset() self.assertWarning(sequenceIncludes(range(3), 2), w, seq_warn)
Example #7
Source File: test_operator.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_isCallable(self): self.failUnlessRaises(TypeError, operator.isCallable) class C: pass def check(self, o, v): self.assertEqual(operator.isCallable(o), v) with test_support.check_py3k_warnings(): self.assertEqual(callable(o), v) check(self, 4, 0) check(self, operator.isCallable, 1) check(self, C, 1) check(self, C(), 0)
Example #8
Source File: test_py3kwarn.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_operator(self): from operator import isCallable, sequenceIncludes callable_warn = ("operator.isCallable() is not supported in 3.x. " "Use hasattr(obj, '__call__').") seq_warn = ("operator.sequenceIncludes() is not supported " "in 3.x. Use operator.contains().") with check_py3k_warnings() as w: self.assertWarning(isCallable(self), w, callable_warn) w.reset() self.assertWarning(sequenceIncludes(range(3), 2), w, seq_warn)
Example #9
Source File: test_bool.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_operator(self): import operator self.assertIs(operator.truth(0), False) self.assertIs(operator.truth(1), True) self.assertIs(operator.isCallable(0), False) self.assertIs(operator.isCallable(len), True) self.assertIs(operator.isNumberType(None), False) self.assertIs(operator.isNumberType(0), True) self.assertIs(operator.not_(1), False) self.assertIs(operator.not_(0), True) self.assertIs(operator.isSequenceType(0), False) self.assertIs(operator.isSequenceType([]), True) self.assertIs(operator.contains([], 1), False) self.assertIs(operator.contains([1], 1), True) self.assertIs(operator.isMappingType(1), False) self.assertIs(operator.isMappingType({}), True) self.assertIs(operator.lt(0, 0), False) self.assertIs(operator.lt(0, 1), True) self.assertIs(operator.is_(True, True), True) self.assertIs(operator.is_(True, False), False) self.assertIs(operator.is_not(True, True), False) self.assertIs(operator.is_not(True, False), True)
Example #10
Source File: test_operator.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_isCallable(self): self.failUnlessRaises(TypeError, operator.isCallable) class C: pass def check(self, o, v): self.assert_(operator.isCallable(o) == callable(o) == v) check(self, 4, 0) check(self, operator.isCallable, 1) check(self, C, 1) check(self, C(), 0)
Example #11
Source File: test_bool.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_operator(self): import operator self.assertIs(operator.truth(0), False) self.assertIs(operator.truth(1), True) with test_support.check_py3k_warnings(): self.assertIs(operator.isCallable(0), False) self.assertIs(operator.isCallable(len), True) self.assertIs(operator.isNumberType(None), False) self.assertIs(operator.isNumberType(0), True) self.assertIs(operator.not_(1), False) self.assertIs(operator.not_(0), True) self.assertIs(operator.isSequenceType(0), False) self.assertIs(operator.isSequenceType([]), True) self.assertIs(operator.contains([], 1), False) self.assertIs(operator.contains([1], 1), True) self.assertIs(operator.isMappingType(1), False) self.assertIs(operator.isMappingType({}), True) self.assertIs(operator.lt(0, 0), False) self.assertIs(operator.lt(0, 1), True) self.assertIs(operator.is_(True, True), True) self.assertIs(operator.is_(True, False), False) self.assertIs(operator.is_not(True, True), False) self.assertIs(operator.is_not(True, False), True)
Example #12
Source File: test_py3kwarn.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_operator(self): from operator import isCallable, sequenceIncludes callable_warn = ("operator.isCallable() is not supported in 3.x. " "Use hasattr(obj, '__call__').") seq_warn = ("operator.sequenceIncludes() is not supported " "in 3.x. Use operator.contains().") with check_py3k_warnings() as w: self.assertWarning(isCallable(self), w, callable_warn) w.reset() self.assertWarning(sequenceIncludes(range(3), 2), w, seq_warn)
Example #13
Source File: test_py3kwarn.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_operator(self): from operator import isCallable, sequenceIncludes callable_warn = ("operator.isCallable() is not supported in 3.x. " "Use hasattr(obj, '__call__').") seq_warn = ("operator.sequenceIncludes() is not supported " "in 3.x. Use operator.contains().") with check_py3k_warnings() as w: self.assertWarning(isCallable(self), w, callable_warn) w.reset() self.assertWarning(sequenceIncludes(range(3), 2), w, seq_warn)
Example #14
Source File: test_bool.py From oss-ftp with MIT License | 5 votes |
def test_operator(self): import operator self.assertIs(operator.truth(0), False) self.assertIs(operator.truth(1), True) with test_support.check_py3k_warnings(): self.assertIs(operator.isCallable(0), False) self.assertIs(operator.isCallable(len), True) self.assertIs(operator.isNumberType(None), False) self.assertIs(operator.isNumberType(0), True) self.assertIs(operator.not_(1), False) self.assertIs(operator.not_(0), True) self.assertIs(operator.isSequenceType(0), False) self.assertIs(operator.isSequenceType([]), True) self.assertIs(operator.contains([], 1), False) self.assertIs(operator.contains([1], 1), True) self.assertIs(operator.isMappingType(1), False) self.assertIs(operator.isMappingType({}), True) self.assertIs(operator.lt(0, 0), False) self.assertIs(operator.lt(0, 1), True) self.assertIs(operator.is_(True, True), True) self.assertIs(operator.is_(True, False), False) self.assertIs(operator.is_not(True, True), False) self.assertIs(operator.is_not(True, False), True)
Example #15
Source File: test_operator.py From oss-ftp with MIT License | 5 votes |
def test_isCallable(self): self.assertRaises(TypeError, operator.isCallable) class C: pass def check(self, o, v): with test_support.check_py3k_warnings(): self.assertEqual(operator.isCallable(o), v) self.assertEqual(callable(o), v) check(self, 4, 0) check(self, operator.isCallable, 1) check(self, C, 1) check(self, C(), 0)
Example #16
Source File: test_py3kwarn.py From oss-ftp with MIT License | 5 votes |
def test_operator(self): from operator import isCallable, sequenceIncludes callable_warn = ("operator.isCallable() is not supported in 3.x. " "Use hasattr(obj, '__call__').") seq_warn = ("operator.sequenceIncludes() is not supported " "in 3.x. Use operator.contains().") with check_py3k_warnings() as w: self.assertWarning(isCallable(self), w, callable_warn) w.reset() self.assertWarning(sequenceIncludes(range(3), 2), w, seq_warn)
Example #17
Source File: test_bool.py From BinderFilter with MIT License | 5 votes |
def test_operator(self): import operator self.assertIs(operator.truth(0), False) self.assertIs(operator.truth(1), True) with test_support.check_py3k_warnings(): self.assertIs(operator.isCallable(0), False) self.assertIs(operator.isCallable(len), True) self.assertIs(operator.isNumberType(None), False) self.assertIs(operator.isNumberType(0), True) self.assertIs(operator.not_(1), False) self.assertIs(operator.not_(0), True) self.assertIs(operator.isSequenceType(0), False) self.assertIs(operator.isSequenceType([]), True) self.assertIs(operator.contains([], 1), False) self.assertIs(operator.contains([1], 1), True) self.assertIs(operator.isMappingType(1), False) self.assertIs(operator.isMappingType({}), True) self.assertIs(operator.lt(0, 0), False) self.assertIs(operator.lt(0, 1), True) self.assertIs(operator.is_(True, True), True) self.assertIs(operator.is_(True, False), False) self.assertIs(operator.is_not(True, True), False) self.assertIs(operator.is_not(True, False), True)
Example #18
Source File: test_operator.py From BinderFilter with MIT License | 5 votes |
def test_isCallable(self): self.assertRaises(TypeError, operator.isCallable) class C: pass def check(self, o, v): with test_support.check_py3k_warnings(): self.assertEqual(operator.isCallable(o), v) self.assertEqual(callable(o), v) check(self, 4, 0) check(self, operator.isCallable, 1) check(self, C, 1) check(self, C(), 0)
Example #19
Source File: test_py3kwarn.py From BinderFilter with MIT License | 5 votes |
def test_operator(self): from operator import isCallable, sequenceIncludes callable_warn = ("operator.isCallable() is not supported in 3.x. " "Use hasattr(obj, '__call__').") seq_warn = ("operator.sequenceIncludes() is not supported " "in 3.x. Use operator.contains().") with check_py3k_warnings() as w: self.assertWarning(isCallable(self), w, callable_warn) w.reset() self.assertWarning(sequenceIncludes(range(3), 2), w, seq_warn)
Example #20
Source File: test_operator.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_isCallable(self): self.assertRaises(TypeError, operator.isCallable) class C: pass def check(self, o, v): with test_support.check_py3k_warnings(): self.assertEqual(operator.isCallable(o), v) self.assertEqual(callable(o), v) check(self, 4, 0) check(self, operator.isCallable, 1) check(self, C, 1) check(self, C(), 0)