• Home
  • Raw
  • Download

Lines Matching refs:inspect

5 import inspect
49 predicates = set([inspect.isbuiltin, inspect.isclass, inspect.iscode,
50 inspect.isframe, inspect.isfunction, inspect.ismethod,
51 inspect.ismodule, inspect.istraceback,
52 inspect.isgenerator, inspect.isgeneratorfunction])
59 if predicate == inspect.isgeneratorfunction and\
60 other == inspect.isfunction:
70 count = len(filter(lambda x:x.startswith('is'), dir(inspect)))
79 self.istest(inspect.isbuiltin, 'sys.exit')
80 self.istest(inspect.isbuiltin, '[].append')
81 self.istest(inspect.iscode, 'mod.spam.func_code')
82 self.istest(inspect.isframe, 'tb.tb_frame')
83 self.istest(inspect.isfunction, 'mod.spam')
84 self.istest(inspect.ismethod, 'mod.StupidGit.abuse')
85 self.istest(inspect.ismethod, 'git.argue')
86 self.istest(inspect.ismodule, 'mod')
87 self.istest(inspect.istraceback, 'tb')
88 self.istest(inspect.isdatadescriptor, '__builtin__.file.closed')
89 self.istest(inspect.isdatadescriptor, '__builtin__.file.softspace')
90 self.istest(inspect.isgenerator, '(x for x in xrange(2))')
91 self.istest(inspect.isgeneratorfunction, 'generator_function_example')
93 self.istest(inspect.isgetsetdescriptor,
96 self.assertFalse(inspect.isgetsetdescriptor(type(tb.tb_frame).f_locals))
98 self.istest(inspect.ismemberdescriptor, 'datetime.timedelta.days')
100 self.assertFalse(inspect.ismemberdescriptor(datetime.timedelta.days))
103 self.assertTrue(inspect.isroutine(mod.spam))
104 self.assertTrue(inspect.isroutine([].count))
107 self.istest(inspect.isclass, 'mod.StupidGit')
108 self.assertTrue(inspect.isclass(list))
111 self.assertTrue(inspect.isclass(newstyle))
116 self.assertFalse(inspect.isclass(CustomGetattr()))
124 members = dict(inspect.getmembers(x))
145 self.assertTrue(inspect.isabstract(AbstractClassExample))
146 self.assertFalse(inspect.isabstract(ClassExample))
147 self.assertFalse(inspect.isabstract(a))
148 self.assertFalse(inspect.isabstract(int))
149 self.assertFalse(inspect.isabstract(5))
159 self.istest(inspect.istraceback, 'git.ex[2]')
160 self.istest(inspect.isframe, 'mod.fr')
183 args, varargs, varkw, locals = inspect.getargvalues(mod.fr)
188 self.assertEqual(inspect.formatargvalues(args, varargs, varkw, locals),
192 args, varargs, varkw, locals = inspect.getargvalues(mod.fr.f_back)
196 self.assertEqual(inspect.formatargvalues(args, varargs, varkw, locals),
206 with open(inspect.getsourcefile(self.fodderFile)) as fp:
214 self.assertEqual(inspect.getsource(obj),
221 classes = inspect.getmembers(mod, inspect.isclass)
229 tree = inspect.getclasstree([cls[1] for cls in classes])
242 tree = inspect.getclasstree([cls[1] for cls in classes], True)
254 functions = inspect.getmembers(mod, inspect.isfunction)
261 self.assertEqual(inspect.getdoc(mod), 'A module docstring.')
262 self.assertEqual(inspect.getdoc(mod.StupidGit),
264 self.assertEqual(inspect.getdoc(git.abuse),
268 self.assertEqual(inspect.cleandoc('An\n indented\n docstring.'),
272 self.assertEqual(inspect.getcomments(mod), '# line 1\n')
273 self.assertEqual(inspect.getcomments(mod.StupidGit), '# line 20\n')
277 self.assertEqual(inspect.getmodule(mod), mod)
279 self.assertEqual(inspect.getmodule(mod.StupidGit), mod)
281 self.assertEqual(inspect.getmodule(mod.StupidGit.abuse), mod)
283 self.assertEqual(inspect.getmodule(mod.StupidGit.abuse), mod)
285 self.assertEqual(inspect.getmodule(str), sys.modules["__builtin__"])
287 self.assertEqual(inspect.getmodule(None, modfile), mod)
294 self.assertEqual(inspect.getsourcefile(mod.spam), modfile)
295 self.assertEqual(inspect.getsourcefile(git.abuse), modfile)
298 self.assertEqual(inspect.getsourcefile(co), None)
300 self.assertEqual(inspect.getsourcefile(co), fn)
303 self.assertEqual(inspect.getfile(mod.StupidGit), mod.__file__)
312 self.assertEqual(inspect.getsourcefile(m.x.func_code), '<string>')
314 inspect.getmodule(compile('a=10','','single'))
329 inspect.getsource(ns["x"])
413 self.assertRaises(IOError, inspect.getsource, unicodedata)
414 self.assertRaises(IOError, inspect.findsource, unicodedata)
419 self.assertRaises(IOError, inspect.findsource, co)
420 self.assertRaises(IOError, inspect.getsource, co)
422 self.assertEqual(inspect.findsource(co), (lines,0))
423 self.assertEqual(inspect.getsource(co), lines[0])
428 self.assertRaises(IOError, inspect.findsource, co)
429 self.assertRaises(IOError, inspect.getsource, co)
459 return [t[:3] for t in inspect.classify_class_attrs(cls)]
471 got = inspect.getmro(D)
482 got = inspect.getmro(D)
488 args, varargs, varkw, defaults = inspect.getargspec(routine)
494 self.assertEqual(inspect.formatargspec(args, varargs, varkw, defaults),
625 inspect.classify_class_attrs(builtin)
633 self.assertIn(('f', B.f), inspect.getmembers(B))
636 self.assertIn(('f', B.f), inspect.getmembers(B, inspect.ismethod))
638 self.assertIn(('f', b.f), inspect.getmembers(b))
639 self.assertIn(('f', b.f), inspect.getmembers(b, inspect.ismethod))
646 self.assertIn(('f', B.f), inspect.getmembers(B))
647 self.assertIn(('f', B.f), inspect.getmembers(B, inspect.ismethod))
649 self.assertIn(('f', b.f), inspect.getmembers(b))
650 self.assertIn(('f', b.f), inspect.getmembers(b, inspect.ismethod))