• Home
  • Raw
  • Download

Lines Matching refs:inspect

5 import inspect
50 predicates = set([inspect.isbuiltin, inspect.isclass, inspect.iscode,
51 inspect.isframe, inspect.isfunction, inspect.ismethod,
52 inspect.ismodule, inspect.istraceback,
53 inspect.isgenerator, inspect.isgeneratorfunction])
60 if predicate == inspect.isgeneratorfunction and\
61 other == inspect.isfunction:
71 count = len(filter(lambda x:x.startswith('is'), dir(inspect)))
80 self.istest(inspect.isbuiltin, 'sys.exit')
81 self.istest(inspect.isbuiltin, '[].append')
82 self.istest(inspect.iscode, 'mod.spam.func_code')
83 self.istest(inspect.isframe, 'tb.tb_frame')
84 self.istest(inspect.isfunction, 'mod.spam')
85 self.istest(inspect.ismethod, 'mod.StupidGit.abuse')
86 self.istest(inspect.ismethod, 'git.argue')
87 self.istest(inspect.ismodule, 'mod')
88 self.istest(inspect.istraceback, 'tb')
89 self.istest(inspect.isdatadescriptor, '__builtin__.file.closed')
90 self.istest(inspect.isdatadescriptor, '__builtin__.file.softspace')
91 self.istest(inspect.isgenerator, '(x for x in xrange(2))')
92 self.istest(inspect.isgeneratorfunction, 'generator_function_example')
94 self.istest(inspect.isgetsetdescriptor,
97 self.assertFalse(inspect.isgetsetdescriptor(type(tb.tb_frame).f_locals))
99 self.istest(inspect.ismemberdescriptor, 'datetime.timedelta.days')
101 self.assertFalse(inspect.ismemberdescriptor(datetime.timedelta.days))
104 self.assertTrue(inspect.isroutine(mod.spam))
105 self.assertTrue(inspect.isroutine([].count))
108 self.istest(inspect.isclass, 'mod.StupidGit')
109 self.assertTrue(inspect.isclass(list))
112 self.assertTrue(inspect.isclass(newstyle))
117 self.assertFalse(inspect.isclass(CustomGetattr()))
125 members = dict(inspect.getmembers(x))
146 self.assertTrue(inspect.isabstract(AbstractClassExample))
147 self.assertFalse(inspect.isabstract(ClassExample))
148 self.assertFalse(inspect.isabstract(a))
149 self.assertFalse(inspect.isabstract(int))
150 self.assertFalse(inspect.isabstract(5))
160 self.istest(inspect.istraceback, 'git.ex[2]')
161 self.istest(inspect.isframe, 'mod.fr')
184 args, varargs, varkw, locals = inspect.getargvalues(mod.fr)
189 self.assertEqual(inspect.formatargvalues(args, varargs, varkw, locals),
193 args, varargs, varkw, locals = inspect.getargvalues(mod.fr.f_back)
197 self.assertEqual(inspect.formatargvalues(args, varargs, varkw, locals),
207 with open(inspect.getsourcefile(self.fodderFile)) as fp:
215 self.assertEqual(inspect.getsource(obj),
222 classes = inspect.getmembers(mod, inspect.isclass)
230 tree = inspect.getclasstree([cls[1] for cls in classes])
243 tree = inspect.getclasstree([cls[1] for cls in classes], True)
255 functions = inspect.getmembers(mod, inspect.isfunction)
262 self.assertEqual(inspect.getdoc(mod), 'A module docstring.')
263 self.assertEqual(inspect.getdoc(mod.StupidGit),
265 self.assertEqual(inspect.getdoc(git.abuse),
269 self.assertEqual(inspect.cleandoc('An\n indented\n docstring.'),
273 self.assertEqual(inspect.getcomments(mod), '# line 1\n')
274 self.assertEqual(inspect.getcomments(mod.StupidGit), '# line 20\n')
278 self.assertEqual(inspect.getmodule(mod), mod)
280 self.assertEqual(inspect.getmodule(mod.StupidGit), mod)
282 self.assertEqual(inspect.getmodule(mod.StupidGit.abuse), mod)
284 self.assertEqual(inspect.getmodule(mod.StupidGit.abuse), mod)
286 self.assertEqual(inspect.getmodule(str), sys.modules["__builtin__"])
288 self.assertEqual(inspect.getmodule(None, modfile), mod)
295 self.assertEqual(inspect.getsourcefile(mod.spam), modfile)
296 self.assertEqual(inspect.getsourcefile(git.abuse), modfile)
299 self.assertEqual(inspect.getsourcefile(co), None)
301 self.assertEqual(inspect.getsourcefile(co), fn)
304 self.assertEqual(inspect.getfile(mod.StupidGit), mod.__file__)
313 self.assertEqual(inspect.getsourcefile(m.x.func_code), '<string>')
315 inspect.getmodule(compile('a=10','','single'))
330 inspect.getsource(ns["x"])
424 self.assertRaises(IOError, inspect.getsource, unicodedata)
425 self.assertRaises(IOError, inspect.findsource, unicodedata)
430 self.assertRaises(IOError, inspect.findsource, co)
431 self.assertRaises(IOError, inspect.getsource, co)
433 self.assertEqual(inspect.findsource(co), (lines,0))
434 self.assertEqual(inspect.getsource(co), lines[0])
439 self.assertRaises(IOError, inspect.findsource, co)
440 self.assertRaises(IOError, inspect.getsource, co)
470 return [t[:3] for t in inspect.classify_class_attrs(cls)]
482 got = inspect.getmro(D)
493 got = inspect.getmro(D)
499 args, varargs, varkw, defaults = inspect.getargspec(routine)
505 self.assertEqual(inspect.formatargspec(args, varargs, varkw, defaults),
656 inspect.classify_class_attrs(builtin)
664 self.assertIn(('f', B.f), inspect.getmembers(B))
667 self.assertIn(('f', B.f), inspect.getmembers(B, inspect.ismethod))
669 self.assertIn(('f', b.f), inspect.getmembers(b))
670 self.assertIn(('f', b.f), inspect.getmembers(b, inspect.ismethod))
677 self.assertIn(('f', B.f), inspect.getmembers(B))
678 self.assertIn(('f', B.f), inspect.getmembers(B, inspect.ismethod))
680 self.assertIn(('f', b.f), inspect.getmembers(b))
681 self.assertIn(('f', b.f), inspect.getmembers(b, inspect.ismethod))