MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_callable

Method test_callable

Lib/test/test_builtin.py:336–368  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

334 self.assertEqual(-x, sys.maxsize+1)
335
336 def test_callable(self):
337 self.assertTrue(callable(len))
338 self.assertFalse(callable("a"))
339 self.assertTrue(callable(callable))
340 self.assertTrue(callable(lambda x, y: x + y))
341 self.assertFalse(callable(__builtins__))
342 def f(): pass
343 self.assertTrue(callable(f))
344
345 class C1:
346 def meth(self): pass
347 self.assertTrue(callable(C1))
348 c = C1()
349 self.assertTrue(callable(c.meth))
350 self.assertFalse(callable(c))
351
352 # __call__ is looked up on the class, not the instance
353 c.__call__ = None
354 self.assertFalse(callable(c))
355 c.__call__ = lambda self: 0
356 self.assertFalse(callable(c))
357 del c.__call__
358 self.assertFalse(callable(c))
359
360 class C2(object):
361 def __call__(self): pass
362 c2 = C2()
363 self.assertTrue(callable(c2))
364 c2.__call__ = None
365 self.assertTrue(callable(c2))
366 class C3(C2): pass
367 c3 = C3()
368 self.assertTrue(callable(c3))
369
370 def test_chr(self):
371 self.assertEqual(chr(0), '\0')

Callers

nothing calls this directly

Calls 6

callableFunction · 0.85
assertTrueMethod · 0.80
assertFalseMethod · 0.80
C1Class · 0.70
C2Class · 0.70
C3Class · 0.70

Tested by

no test coverage detected