Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 1 | import sys |
Barry Warsaw | 00decd7 | 2006-07-27 23:43:15 +0000 | [diff] [blame] | 2 | import types |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 3 | import unittest |
| 4 | import inspect |
Barry Warsaw | 00decd7 | 2006-07-27 23:43:15 +0000 | [diff] [blame] | 5 | import datetime |
Ka-Ping Yee | 6397c7c | 2001-02-27 14:43:21 +0000 | [diff] [blame] | 6 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 7 | from test.test_support import TESTFN, run_unittest |
Ka-Ping Yee | 6397c7c | 2001-02-27 14:43:21 +0000 | [diff] [blame] | 8 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 9 | from test import inspect_fodder as mod |
| 10 | from test import inspect_fodder2 as mod2 |
Ka-Ping Yee | 6397c7c | 2001-02-27 14:43:21 +0000 | [diff] [blame] | 11 | |
R. David Murray | 996ba02 | 2009-05-13 17:14:11 +0000 | [diff] [blame] | 12 | # C module for test_findsource_binary |
R. David Murray | 8785554 | 2009-05-14 16:12:57 +0000 | [diff] [blame^] | 13 | import unicodedata |
R. David Murray | 996ba02 | 2009-05-13 17:14:11 +0000 | [diff] [blame] | 14 | |
Ka-Ping Yee | 6397c7c | 2001-02-27 14:43:21 +0000 | [diff] [blame] | 15 | # Functions tested in this suite: |
| 16 | # ismodule, isclass, ismethod, isfunction, istraceback, isframe, iscode, |
Facundo Batista | 759bfc6 | 2008-02-18 03:43:43 +0000 | [diff] [blame] | 17 | # isbuiltin, isroutine, isgenerator, isgeneratorfunction, getmembers, |
| 18 | # getdoc, getfile, getmodule, getsourcefile, getcomments, getsource, |
| 19 | # getclasstree, getargspec, getargvalues, formatargspec, formatargvalues, |
| 20 | # currentframe, stack, trace, isdatadescriptor |
Ka-Ping Yee | 6397c7c | 2001-02-27 14:43:21 +0000 | [diff] [blame] | 21 | |
Nick Coghlan | a205347 | 2008-12-14 10:54:50 +0000 | [diff] [blame] | 22 | # NOTE: There are some additional tests relating to interaction with |
| 23 | # zipimport in the test_zipimport_support test module. |
| 24 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 25 | modfile = mod.__file__ |
Georg Brandl | b2afe85 | 2006-06-09 20:43:48 +0000 | [diff] [blame] | 26 | if modfile.endswith(('c', 'o')): |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 27 | modfile = modfile[:-1] |
Ka-Ping Yee | 6397c7c | 2001-02-27 14:43:21 +0000 | [diff] [blame] | 28 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 29 | import __builtin__ |
Ka-Ping Yee | 6397c7c | 2001-02-27 14:43:21 +0000 | [diff] [blame] | 30 | |
Ka-Ping Yee | 6397c7c | 2001-02-27 14:43:21 +0000 | [diff] [blame] | 31 | try: |
| 32 | 1/0 |
| 33 | except: |
| 34 | tb = sys.exc_traceback |
| 35 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 36 | git = mod.StupidGit() |
Ka-Ping Yee | 6397c7c | 2001-02-27 14:43:21 +0000 | [diff] [blame] | 37 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 38 | class IsTestBase(unittest.TestCase): |
| 39 | predicates = set([inspect.isbuiltin, inspect.isclass, inspect.iscode, |
| 40 | inspect.isframe, inspect.isfunction, inspect.ismethod, |
Facundo Batista | 759bfc6 | 2008-02-18 03:43:43 +0000 | [diff] [blame] | 41 | inspect.ismodule, inspect.istraceback, |
| 42 | inspect.isgenerator, inspect.isgeneratorfunction]) |
Tim Peters | 5a9fb3c | 2005-01-07 16:01:32 +0000 | [diff] [blame] | 43 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 44 | def istest(self, predicate, exp): |
| 45 | obj = eval(exp) |
| 46 | self.failUnless(predicate(obj), '%s(%s)' % (predicate.__name__, exp)) |
Tim Peters | 5a9fb3c | 2005-01-07 16:01:32 +0000 | [diff] [blame] | 47 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 48 | for other in self.predicates - set([predicate]): |
Facundo Batista | 759bfc6 | 2008-02-18 03:43:43 +0000 | [diff] [blame] | 49 | if predicate == inspect.isgeneratorfunction and\ |
| 50 | other == inspect.isfunction: |
| 51 | continue |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 52 | self.failIf(other(obj), 'not %s(%s)' % (other.__name__, exp)) |
Ka-Ping Yee | 6397c7c | 2001-02-27 14:43:21 +0000 | [diff] [blame] | 53 | |
Facundo Batista | 759bfc6 | 2008-02-18 03:43:43 +0000 | [diff] [blame] | 54 | def generator_function_example(self): |
| 55 | for i in xrange(2): |
| 56 | yield i |
| 57 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 58 | class TestPredicates(IsTestBase): |
Christian Heimes | 728bee8 | 2008-03-03 20:30:29 +0000 | [diff] [blame] | 59 | def test_sixteen(self): |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 60 | count = len(filter(lambda x:x.startswith('is'), dir(inspect))) |
Facundo Batista | 759bfc6 | 2008-02-18 03:43:43 +0000 | [diff] [blame] | 61 | # This test is here for remember you to update Doc/library/inspect.rst |
Georg Brandl | 26bc177 | 2008-03-03 20:39:00 +0000 | [diff] [blame] | 62 | # which claims there are 16 such functions |
Christian Heimes | 728bee8 | 2008-03-03 20:30:29 +0000 | [diff] [blame] | 63 | expected = 16 |
Neal Norwitz | df80af7 | 2006-07-28 04:22:34 +0000 | [diff] [blame] | 64 | err_msg = "There are %d (not %d) is* functions" % (count, expected) |
| 65 | self.assertEqual(count, expected, err_msg) |
Tim Peters | 5a9fb3c | 2005-01-07 16:01:32 +0000 | [diff] [blame] | 66 | |
Facundo Batista | 759bfc6 | 2008-02-18 03:43:43 +0000 | [diff] [blame] | 67 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 68 | def test_excluding_predicates(self): |
| 69 | self.istest(inspect.isbuiltin, 'sys.exit') |
| 70 | self.istest(inspect.isbuiltin, '[].append') |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 71 | self.istest(inspect.iscode, 'mod.spam.func_code') |
| 72 | self.istest(inspect.isframe, 'tb.tb_frame') |
| 73 | self.istest(inspect.isfunction, 'mod.spam') |
| 74 | self.istest(inspect.ismethod, 'mod.StupidGit.abuse') |
| 75 | self.istest(inspect.ismethod, 'git.argue') |
| 76 | self.istest(inspect.ismodule, 'mod') |
| 77 | self.istest(inspect.istraceback, 'tb') |
| 78 | self.istest(inspect.isdatadescriptor, '__builtin__.file.closed') |
| 79 | self.istest(inspect.isdatadescriptor, '__builtin__.file.softspace') |
Facundo Batista | 759bfc6 | 2008-02-18 03:43:43 +0000 | [diff] [blame] | 80 | self.istest(inspect.isgenerator, '(x for x in xrange(2))') |
| 81 | self.istest(inspect.isgeneratorfunction, 'generator_function_example') |
Barry Warsaw | 00decd7 | 2006-07-27 23:43:15 +0000 | [diff] [blame] | 82 | if hasattr(types, 'GetSetDescriptorType'): |
| 83 | self.istest(inspect.isgetsetdescriptor, |
| 84 | 'type(tb.tb_frame).f_locals') |
| 85 | else: |
| 86 | self.failIf(inspect.isgetsetdescriptor(type(tb.tb_frame).f_locals)) |
| 87 | if hasattr(types, 'MemberDescriptorType'): |
| 88 | self.istest(inspect.ismemberdescriptor, 'datetime.timedelta.days') |
| 89 | else: |
| 90 | self.failIf(inspect.ismemberdescriptor(datetime.timedelta.days)) |
Ka-Ping Yee | 6397c7c | 2001-02-27 14:43:21 +0000 | [diff] [blame] | 91 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 92 | def test_isroutine(self): |
| 93 | self.assert_(inspect.isroutine(mod.spam)) |
| 94 | self.assert_(inspect.isroutine([].count)) |
Ka-Ping Yee | 6397c7c | 2001-02-27 14:43:21 +0000 | [diff] [blame] | 95 | |
Benjamin Peterson | 5e5fbb6 | 2009-01-17 22:27:54 +0000 | [diff] [blame] | 96 | def test_isclass(self): |
| 97 | self.istest(inspect.isclass, 'mod.StupidGit') |
| 98 | self.assertTrue(inspect.isclass(list)) |
| 99 | |
| 100 | class newstyle(object): pass |
| 101 | self.assertTrue(inspect.isclass(newstyle)) |
| 102 | |
| 103 | class CustomGetattr(object): |
| 104 | def __getattr__(self, attr): |
| 105 | return None |
| 106 | self.assertFalse(inspect.isclass(CustomGetattr())) |
| 107 | |
Amaury Forgeot d'Arc | b54447f | 2009-01-13 23:39:22 +0000 | [diff] [blame] | 108 | def test_get_slot_members(self): |
| 109 | class C(object): |
| 110 | __slots__ = ("a", "b") |
| 111 | |
| 112 | x = C() |
| 113 | x.a = 42 |
| 114 | members = dict(inspect.getmembers(x)) |
| 115 | self.assert_('a' in members) |
| 116 | self.assert_('b' not in members) |
| 117 | |
| 118 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 119 | class TestInterpreterStack(IsTestBase): |
| 120 | def __init__(self, *args, **kwargs): |
| 121 | unittest.TestCase.__init__(self, *args, **kwargs) |
Tim Peters | 5a9fb3c | 2005-01-07 16:01:32 +0000 | [diff] [blame] | 122 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 123 | git.abuse(7, 8, 9) |
Ka-Ping Yee | 6397c7c | 2001-02-27 14:43:21 +0000 | [diff] [blame] | 124 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 125 | def test_abuse_done(self): |
| 126 | self.istest(inspect.istraceback, 'git.ex[2]') |
| 127 | self.istest(inspect.isframe, 'mod.fr') |
Ka-Ping Yee | 6397c7c | 2001-02-27 14:43:21 +0000 | [diff] [blame] | 128 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 129 | def test_stack(self): |
| 130 | self.assert_(len(mod.st) >= 5) |
| 131 | self.assertEqual(mod.st[0][1:], |
Tim Peters | 5a9fb3c | 2005-01-07 16:01:32 +0000 | [diff] [blame] | 132 | (modfile, 16, 'eggs', [' st = inspect.stack()\n'], 0)) |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 133 | self.assertEqual(mod.st[1][1:], |
| 134 | (modfile, 9, 'spam', [' eggs(b + d, c + f)\n'], 0)) |
| 135 | self.assertEqual(mod.st[2][1:], |
| 136 | (modfile, 43, 'argue', [' spam(a, b, c)\n'], 0)) |
| 137 | self.assertEqual(mod.st[3][1:], |
| 138 | (modfile, 39, 'abuse', [' self.argue(a, b, c)\n'], 0)) |
Ka-Ping Yee | 6397c7c | 2001-02-27 14:43:21 +0000 | [diff] [blame] | 139 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 140 | def test_trace(self): |
| 141 | self.assertEqual(len(git.tr), 3) |
| 142 | self.assertEqual(git.tr[0][1:], (modfile, 43, 'argue', |
| 143 | [' spam(a, b, c)\n'], 0)) |
| 144 | self.assertEqual(git.tr[1][1:], (modfile, 9, 'spam', |
| 145 | [' eggs(b + d, c + f)\n'], 0)) |
| 146 | self.assertEqual(git.tr[2][1:], (modfile, 18, 'eggs', |
| 147 | [' q = y / 0\n'], 0)) |
Ka-Ping Yee | 6397c7c | 2001-02-27 14:43:21 +0000 | [diff] [blame] | 148 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 149 | def test_frame(self): |
| 150 | args, varargs, varkw, locals = inspect.getargvalues(mod.fr) |
| 151 | self.assertEqual(args, ['x', 'y']) |
| 152 | self.assertEqual(varargs, None) |
| 153 | self.assertEqual(varkw, None) |
| 154 | self.assertEqual(locals, {'x': 11, 'p': 11, 'y': 14}) |
| 155 | self.assertEqual(inspect.formatargvalues(args, varargs, varkw, locals), |
| 156 | '(x=11, y=14)') |
Ka-Ping Yee | 6397c7c | 2001-02-27 14:43:21 +0000 | [diff] [blame] | 157 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 158 | def test_previous_frame(self): |
| 159 | args, varargs, varkw, locals = inspect.getargvalues(mod.fr.f_back) |
| 160 | self.assertEqual(args, ['a', 'b', 'c', 'd', ['e', ['f']]]) |
| 161 | self.assertEqual(varargs, 'g') |
| 162 | self.assertEqual(varkw, 'h') |
| 163 | self.assertEqual(inspect.formatargvalues(args, varargs, varkw, locals), |
| 164 | '(a=7, b=8, c=9, d=3, (e=4, (f=5,)), *g=(), **h={})') |
Ka-Ping Yee | 6397c7c | 2001-02-27 14:43:21 +0000 | [diff] [blame] | 165 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 166 | class GetSourceBase(unittest.TestCase): |
| 167 | # Subclasses must override. |
| 168 | fodderFile = None |
Tim Peters | 5a9fb3c | 2005-01-07 16:01:32 +0000 | [diff] [blame] | 169 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 170 | def __init__(self, *args, **kwargs): |
| 171 | unittest.TestCase.__init__(self, *args, **kwargs) |
Ka-Ping Yee | 6397c7c | 2001-02-27 14:43:21 +0000 | [diff] [blame] | 172 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 173 | self.source = file(inspect.getsourcefile(self.fodderFile)).read() |
Ka-Ping Yee | 6397c7c | 2001-02-27 14:43:21 +0000 | [diff] [blame] | 174 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 175 | def sourcerange(self, top, bottom): |
| 176 | lines = self.source.split("\n") |
| 177 | return "\n".join(lines[top-1:bottom]) + "\n" |
Tim Peters | e0b2d7a | 2001-09-22 06:10:55 +0000 | [diff] [blame] | 178 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 179 | def assertSourceEqual(self, obj, top, bottom): |
| 180 | self.assertEqual(inspect.getsource(obj), |
| 181 | self.sourcerange(top, bottom)) |
Tim Peters | 5a9fb3c | 2005-01-07 16:01:32 +0000 | [diff] [blame] | 182 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 183 | class TestRetrievingSourceCode(GetSourceBase): |
| 184 | fodderFile = mod |
Tim Peters | 5a9fb3c | 2005-01-07 16:01:32 +0000 | [diff] [blame] | 185 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 186 | def test_getclasses(self): |
| 187 | classes = inspect.getmembers(mod, inspect.isclass) |
| 188 | self.assertEqual(classes, |
| 189 | [('FesteringGob', mod.FesteringGob), |
| 190 | ('MalodorousPervert', mod.MalodorousPervert), |
| 191 | ('ParrotDroppings', mod.ParrotDroppings), |
| 192 | ('StupidGit', mod.StupidGit)]) |
| 193 | tree = inspect.getclasstree([cls[1] for cls in classes], 1) |
| 194 | self.assertEqual(tree, |
| 195 | [(mod.ParrotDroppings, ()), |
| 196 | (mod.StupidGit, ()), |
| 197 | [(mod.MalodorousPervert, (mod.StupidGit,)), |
| 198 | [(mod.FesteringGob, (mod.MalodorousPervert, |
| 199 | mod.ParrotDroppings)) |
| 200 | ] |
| 201 | ] |
| 202 | ]) |
Tim Peters | 5a9fb3c | 2005-01-07 16:01:32 +0000 | [diff] [blame] | 203 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 204 | def test_getfunctions(self): |
| 205 | functions = inspect.getmembers(mod, inspect.isfunction) |
| 206 | self.assertEqual(functions, [('eggs', mod.eggs), |
| 207 | ('spam', mod.spam)]) |
Johannes Gijsbers | c473c99 | 2004-08-18 12:40:31 +0000 | [diff] [blame] | 208 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 209 | def test_getdoc(self): |
| 210 | self.assertEqual(inspect.getdoc(mod), 'A module docstring.') |
| 211 | self.assertEqual(inspect.getdoc(mod.StupidGit), |
| 212 | 'A longer,\n\nindented\n\ndocstring.') |
| 213 | self.assertEqual(inspect.getdoc(git.abuse), |
| 214 | 'Another\n\ndocstring\n\ncontaining\n\ntabs') |
Johannes Gijsbers | c473c99 | 2004-08-18 12:40:31 +0000 | [diff] [blame] | 215 | |
Georg Brandl | 7be19aa | 2008-06-07 15:59:10 +0000 | [diff] [blame] | 216 | def test_cleandoc(self): |
| 217 | self.assertEqual(inspect.cleandoc('An\n indented\n docstring.'), |
| 218 | 'An\nindented\ndocstring.') |
| 219 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 220 | def test_getcomments(self): |
| 221 | self.assertEqual(inspect.getcomments(mod), '# line 1\n') |
| 222 | self.assertEqual(inspect.getcomments(mod.StupidGit), '# line 20\n') |
Johannes Gijsbers | c473c99 | 2004-08-18 12:40:31 +0000 | [diff] [blame] | 223 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 224 | def test_getmodule(self): |
Nick Coghlan | c495c66 | 2006-09-07 10:50:34 +0000 | [diff] [blame] | 225 | # Check actual module |
| 226 | self.assertEqual(inspect.getmodule(mod), mod) |
| 227 | # Check class (uses __module__ attribute) |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 228 | self.assertEqual(inspect.getmodule(mod.StupidGit), mod) |
Nick Coghlan | c495c66 | 2006-09-07 10:50:34 +0000 | [diff] [blame] | 229 | # Check a method (no __module__ attribute, falls back to filename) |
| 230 | self.assertEqual(inspect.getmodule(mod.StupidGit.abuse), mod) |
| 231 | # Do it again (check the caching isn't broken) |
| 232 | self.assertEqual(inspect.getmodule(mod.StupidGit.abuse), mod) |
| 233 | # Check a builtin |
| 234 | self.assertEqual(inspect.getmodule(str), sys.modules["__builtin__"]) |
| 235 | # Check filename override |
| 236 | self.assertEqual(inspect.getmodule(None, modfile), mod) |
Johannes Gijsbers | c473c99 | 2004-08-18 12:40:31 +0000 | [diff] [blame] | 237 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 238 | def test_getsource(self): |
| 239 | self.assertSourceEqual(git.abuse, 29, 39) |
| 240 | self.assertSourceEqual(mod.StupidGit, 21, 46) |
Johannes Gijsbers | c473c99 | 2004-08-18 12:40:31 +0000 | [diff] [blame] | 241 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 242 | def test_getsourcefile(self): |
Tim Peters | 5a9fb3c | 2005-01-07 16:01:32 +0000 | [diff] [blame] | 243 | self.assertEqual(inspect.getsourcefile(mod.spam), modfile) |
| 244 | self.assertEqual(inspect.getsourcefile(git.abuse), modfile) |
Johannes Gijsbers | c473c99 | 2004-08-18 12:40:31 +0000 | [diff] [blame] | 245 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 246 | def test_getfile(self): |
| 247 | self.assertEqual(inspect.getfile(mod.StupidGit), mod.__file__) |
Johannes Gijsbers | c473c99 | 2004-08-18 12:40:31 +0000 | [diff] [blame] | 248 | |
Phillip J. Eby | 5d86bdb | 2006-07-10 19:03:29 +0000 | [diff] [blame] | 249 | def test_getmodule_recursion(self): |
Christian Heimes | c756d00 | 2007-11-27 21:34:01 +0000 | [diff] [blame] | 250 | from types import ModuleType |
Phillip J. Eby | 5d86bdb | 2006-07-10 19:03:29 +0000 | [diff] [blame] | 251 | name = '__inspect_dummy' |
Christian Heimes | c756d00 | 2007-11-27 21:34:01 +0000 | [diff] [blame] | 252 | m = sys.modules[name] = ModuleType(name) |
Tim Peters | 722b883 | 2006-07-10 21:11:49 +0000 | [diff] [blame] | 253 | m.__file__ = "<string>" # hopefully not a real filename... |
Phillip J. Eby | 5d86bdb | 2006-07-10 19:03:29 +0000 | [diff] [blame] | 254 | m.__loader__ = "dummy" # pretend the filename is understood by a loader |
| 255 | exec "def x(): pass" in m.__dict__ |
| 256 | self.assertEqual(inspect.getsourcefile(m.x.func_code), '<string>') |
| 257 | del sys.modules[name] |
Phillip J. Eby | 1a2959c | 2006-07-20 15:54:16 +0000 | [diff] [blame] | 258 | inspect.getmodule(compile('a=10','','single')) |
Phillip J. Eby | 5d86bdb | 2006-07-10 19:03:29 +0000 | [diff] [blame] | 259 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 260 | class TestDecorators(GetSourceBase): |
| 261 | fodderFile = mod2 |
Johannes Gijsbers | c473c99 | 2004-08-18 12:40:31 +0000 | [diff] [blame] | 262 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 263 | def test_wrapped_decorator(self): |
| 264 | self.assertSourceEqual(mod2.wrapped, 14, 17) |
Johannes Gijsbers | c473c99 | 2004-08-18 12:40:31 +0000 | [diff] [blame] | 265 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 266 | def test_replacing_decorator(self): |
| 267 | self.assertSourceEqual(mod2.gone, 9, 10) |
Tim Peters | e0b2d7a | 2001-09-22 06:10:55 +0000 | [diff] [blame] | 268 | |
Johannes Gijsbers | 1542f34 | 2004-12-12 16:46:28 +0000 | [diff] [blame] | 269 | class TestOneliners(GetSourceBase): |
| 270 | fodderFile = mod2 |
| 271 | def test_oneline_lambda(self): |
| 272 | # Test inspect.getsource with a one-line lambda function. |
| 273 | self.assertSourceEqual(mod2.oll, 25, 25) |
Tim Peters | 5a9fb3c | 2005-01-07 16:01:32 +0000 | [diff] [blame] | 274 | |
Johannes Gijsbers | 1542f34 | 2004-12-12 16:46:28 +0000 | [diff] [blame] | 275 | def test_threeline_lambda(self): |
| 276 | # Test inspect.getsource with a three-line lambda function, |
| 277 | # where the second and third lines are _not_ indented. |
Tim Peters | 5a9fb3c | 2005-01-07 16:01:32 +0000 | [diff] [blame] | 278 | self.assertSourceEqual(mod2.tll, 28, 30) |
| 279 | |
Johannes Gijsbers | 1542f34 | 2004-12-12 16:46:28 +0000 | [diff] [blame] | 280 | def test_twoline_indented_lambda(self): |
| 281 | # Test inspect.getsource with a two-line lambda function, |
| 282 | # where the second line _is_ indented. |
| 283 | self.assertSourceEqual(mod2.tlli, 33, 34) |
Tim Peters | 5a9fb3c | 2005-01-07 16:01:32 +0000 | [diff] [blame] | 284 | |
Johannes Gijsbers | 1542f34 | 2004-12-12 16:46:28 +0000 | [diff] [blame] | 285 | def test_onelinefunc(self): |
| 286 | # Test inspect.getsource with a regular one-line function. |
| 287 | self.assertSourceEqual(mod2.onelinefunc, 37, 37) |
Tim Peters | 5a9fb3c | 2005-01-07 16:01:32 +0000 | [diff] [blame] | 288 | |
Johannes Gijsbers | 1542f34 | 2004-12-12 16:46:28 +0000 | [diff] [blame] | 289 | def test_manyargs(self): |
| 290 | # Test inspect.getsource with a regular function where |
| 291 | # the arguments are on two lines and _not_ indented and |
| 292 | # the body on the second line with the last arguments. |
| 293 | self.assertSourceEqual(mod2.manyargs, 40, 41) |
Tim Peters | 5a9fb3c | 2005-01-07 16:01:32 +0000 | [diff] [blame] | 294 | |
Johannes Gijsbers | 1542f34 | 2004-12-12 16:46:28 +0000 | [diff] [blame] | 295 | def test_twolinefunc(self): |
| 296 | # Test inspect.getsource with a regular function where |
| 297 | # the body is on two lines, following the argument list and |
| 298 | # continued on the next line by a \\. |
| 299 | self.assertSourceEqual(mod2.twolinefunc, 44, 45) |
Tim Peters | 5a9fb3c | 2005-01-07 16:01:32 +0000 | [diff] [blame] | 300 | |
Johannes Gijsbers | 1542f34 | 2004-12-12 16:46:28 +0000 | [diff] [blame] | 301 | def test_lambda_in_list(self): |
| 302 | # Test inspect.getsource with a one-line lambda function |
| 303 | # defined in a list, indented. |
| 304 | self.assertSourceEqual(mod2.a[1], 49, 49) |
Tim Peters | 5a9fb3c | 2005-01-07 16:01:32 +0000 | [diff] [blame] | 305 | |
Johannes Gijsbers | 1542f34 | 2004-12-12 16:46:28 +0000 | [diff] [blame] | 306 | def test_anonymous(self): |
| 307 | # Test inspect.getsource with a lambda function defined |
| 308 | # as argument to another function. |
| 309 | self.assertSourceEqual(mod2.anonymous, 55, 55) |
| 310 | |
Johannes Gijsbers | a5855d5 | 2005-03-12 16:37:11 +0000 | [diff] [blame] | 311 | class TestBuggyCases(GetSourceBase): |
| 312 | fodderFile = mod2 |
| 313 | |
| 314 | def test_with_comment(self): |
| 315 | self.assertSourceEqual(mod2.with_comment, 58, 59) |
| 316 | |
| 317 | def test_multiline_sig(self): |
| 318 | self.assertSourceEqual(mod2.multiline_sig[0], 63, 64) |
| 319 | |
Armin Rigo | dd5c023 | 2005-09-25 11:45:45 +0000 | [diff] [blame] | 320 | def test_nested_class(self): |
| 321 | self.assertSourceEqual(mod2.func69().func71, 71, 72) |
| 322 | |
| 323 | def test_one_liner_followed_by_non_name(self): |
| 324 | self.assertSourceEqual(mod2.func77, 77, 77) |
| 325 | |
| 326 | def test_one_liner_dedent_non_name(self): |
| 327 | self.assertSourceEqual(mod2.cls82.func83, 83, 83) |
| 328 | |
| 329 | def test_with_comment_instead_of_docstring(self): |
| 330 | self.assertSourceEqual(mod2.func88, 88, 90) |
| 331 | |
Georg Brandl | 2463f8f | 2006-08-14 21:34:08 +0000 | [diff] [blame] | 332 | def test_method_in_dynamic_class(self): |
| 333 | self.assertSourceEqual(mod2.method_in_dynamic_class, 95, 97) |
| 334 | |
R. David Murray | 8785554 | 2009-05-14 16:12:57 +0000 | [diff] [blame^] | 335 | @unittest.skipIf( |
| 336 | not hasattr(unicodedata, '__file__') or |
| 337 | unicodedata.__file__[-4:] in (".pyc", ".pyo"), |
| 338 | "unicodedata is not an external binary module") |
R. David Murray | 996ba02 | 2009-05-13 17:14:11 +0000 | [diff] [blame] | 339 | def test_findsource_binary(self): |
R. David Murray | 8785554 | 2009-05-14 16:12:57 +0000 | [diff] [blame^] | 340 | self.assertRaises(IOError, inspect.getsource, unicodedata) |
| 341 | self.assertRaises(IOError, inspect.findsource, unicodedata) |
R. David Murray | 996ba02 | 2009-05-13 17:14:11 +0000 | [diff] [blame] | 342 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 343 | # Helper for testing classify_class_attrs. |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 344 | def attrs_wo_objs(cls): |
| 345 | return [t[:3] for t in inspect.classify_class_attrs(cls)] |
| 346 | |
Tim Peters | 5a9fb3c | 2005-01-07 16:01:32 +0000 | [diff] [blame] | 347 | class TestClassesAndFunctions(unittest.TestCase): |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 348 | def test_classic_mro(self): |
| 349 | # Test classic-class method resolution order. |
| 350 | class A: pass |
| 351 | class B(A): pass |
| 352 | class C(A): pass |
| 353 | class D(B, C): pass |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 354 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 355 | expected = (D, B, A, C) |
| 356 | got = inspect.getmro(D) |
| 357 | self.assertEqual(expected, got) |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 358 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 359 | def test_newstyle_mro(self): |
| 360 | # The same w/ new-class MRO. |
| 361 | class A(object): pass |
| 362 | class B(A): pass |
| 363 | class C(A): pass |
| 364 | class D(B, C): pass |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 365 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 366 | expected = (D, B, C, A, object) |
| 367 | got = inspect.getmro(D) |
| 368 | self.assertEqual(expected, got) |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 369 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 370 | def assertArgSpecEquals(self, routine, args_e, varargs_e = None, |
| 371 | varkw_e = None, defaults_e = None, |
| 372 | formatted = None): |
| 373 | args, varargs, varkw, defaults = inspect.getargspec(routine) |
| 374 | self.assertEqual(args, args_e) |
| 375 | self.assertEqual(varargs, varargs_e) |
| 376 | self.assertEqual(varkw, varkw_e) |
| 377 | self.assertEqual(defaults, defaults_e) |
| 378 | if formatted is not None: |
| 379 | self.assertEqual(inspect.formatargspec(args, varargs, varkw, defaults), |
| 380 | formatted) |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 381 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 382 | def test_getargspec(self): |
| 383 | self.assertArgSpecEquals(mod.eggs, ['x', 'y'], formatted = '(x, y)') |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 384 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 385 | self.assertArgSpecEquals(mod.spam, |
| 386 | ['a', 'b', 'c', 'd', ['e', ['f']]], |
| 387 | 'g', 'h', (3, (4, (5,))), |
| 388 | '(a, b, c, d=3, (e, (f,))=(4, (5,)), *g, **h)') |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 389 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 390 | def test_getargspec_method(self): |
| 391 | class A(object): |
| 392 | def m(self): |
| 393 | pass |
| 394 | self.assertArgSpecEquals(A.m, ['self']) |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 395 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 396 | def test_getargspec_sublistofone(self): |
Neal Norwitz | 33b730e | 2006-03-27 08:58:23 +0000 | [diff] [blame] | 397 | def sublistOfOne((foo,)): return 1 |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 398 | self.assertArgSpecEquals(sublistOfOne, [['foo']]) |
| 399 | |
Neal Norwitz | 33b730e | 2006-03-27 08:58:23 +0000 | [diff] [blame] | 400 | def fakeSublistOfOne((foo)): return 1 |
| 401 | self.assertArgSpecEquals(fakeSublistOfOne, ['foo']) |
| 402 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 403 | def test_classify_oldstyle(self): |
| 404 | class A: |
| 405 | def s(): pass |
| 406 | s = staticmethod(s) |
| 407 | |
| 408 | def c(cls): pass |
| 409 | c = classmethod(c) |
| 410 | |
| 411 | def getp(self): pass |
| 412 | p = property(getp) |
| 413 | |
| 414 | def m(self): pass |
| 415 | |
| 416 | def m1(self): pass |
| 417 | |
| 418 | datablob = '1' |
| 419 | |
| 420 | attrs = attrs_wo_objs(A) |
| 421 | self.assert_(('s', 'static method', A) in attrs, 'missing static method') |
| 422 | self.assert_(('c', 'class method', A) in attrs, 'missing class method') |
| 423 | self.assert_(('p', 'property', A) in attrs, 'missing property') |
| 424 | self.assert_(('m', 'method', A) in attrs, 'missing plain method') |
| 425 | self.assert_(('m1', 'method', A) in attrs, 'missing plain method') |
| 426 | self.assert_(('datablob', 'data', A) in attrs, 'missing data') |
| 427 | |
| 428 | class B(A): |
| 429 | def m(self): pass |
| 430 | |
| 431 | attrs = attrs_wo_objs(B) |
| 432 | self.assert_(('s', 'static method', A) in attrs, 'missing static method') |
| 433 | self.assert_(('c', 'class method', A) in attrs, 'missing class method') |
| 434 | self.assert_(('p', 'property', A) in attrs, 'missing property') |
| 435 | self.assert_(('m', 'method', B) in attrs, 'missing plain method') |
| 436 | self.assert_(('m1', 'method', A) in attrs, 'missing plain method') |
| 437 | self.assert_(('datablob', 'data', A) in attrs, 'missing data') |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 438 | |
| 439 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 440 | class C(A): |
| 441 | def m(self): pass |
| 442 | def c(self): pass |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 443 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 444 | attrs = attrs_wo_objs(C) |
| 445 | self.assert_(('s', 'static method', A) in attrs, 'missing static method') |
| 446 | self.assert_(('c', 'method', C) in attrs, 'missing plain method') |
| 447 | self.assert_(('p', 'property', A) in attrs, 'missing property') |
| 448 | self.assert_(('m', 'method', C) in attrs, 'missing plain method') |
| 449 | self.assert_(('m1', 'method', A) in attrs, 'missing plain method') |
| 450 | self.assert_(('datablob', 'data', A) in attrs, 'missing data') |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 451 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 452 | class D(B, C): |
| 453 | def m1(self): pass |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 454 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 455 | attrs = attrs_wo_objs(D) |
| 456 | self.assert_(('s', 'static method', A) in attrs, 'missing static method') |
| 457 | self.assert_(('c', 'class method', A) in attrs, 'missing class method') |
| 458 | self.assert_(('p', 'property', A) in attrs, 'missing property') |
| 459 | self.assert_(('m', 'method', B) in attrs, 'missing plain method') |
| 460 | self.assert_(('m1', 'method', D) in attrs, 'missing plain method') |
| 461 | self.assert_(('datablob', 'data', A) in attrs, 'missing data') |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 462 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 463 | # Repeat all that, but w/ new-style classes. |
| 464 | def test_classify_newstyle(self): |
| 465 | class A(object): |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 466 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 467 | def s(): pass |
| 468 | s = staticmethod(s) |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 469 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 470 | def c(cls): pass |
| 471 | c = classmethod(c) |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 472 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 473 | def getp(self): pass |
| 474 | p = property(getp) |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 475 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 476 | def m(self): pass |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 477 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 478 | def m1(self): pass |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 479 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 480 | datablob = '1' |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 481 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 482 | attrs = attrs_wo_objs(A) |
| 483 | self.assert_(('s', 'static method', A) in attrs, 'missing static method') |
| 484 | self.assert_(('c', 'class method', A) in attrs, 'missing class method') |
| 485 | self.assert_(('p', 'property', A) in attrs, 'missing property') |
| 486 | self.assert_(('m', 'method', A) in attrs, 'missing plain method') |
| 487 | self.assert_(('m1', 'method', A) in attrs, 'missing plain method') |
| 488 | self.assert_(('datablob', 'data', A) in attrs, 'missing data') |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 489 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 490 | class B(A): |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 491 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 492 | def m(self): pass |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 493 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 494 | attrs = attrs_wo_objs(B) |
| 495 | self.assert_(('s', 'static method', A) in attrs, 'missing static method') |
| 496 | self.assert_(('c', 'class method', A) in attrs, 'missing class method') |
| 497 | self.assert_(('p', 'property', A) in attrs, 'missing property') |
| 498 | self.assert_(('m', 'method', B) in attrs, 'missing plain method') |
| 499 | self.assert_(('m1', 'method', A) in attrs, 'missing plain method') |
| 500 | self.assert_(('datablob', 'data', A) in attrs, 'missing data') |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 501 | |
| 502 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 503 | class C(A): |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 504 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 505 | def m(self): pass |
| 506 | def c(self): pass |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 507 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 508 | attrs = attrs_wo_objs(C) |
| 509 | self.assert_(('s', 'static method', A) in attrs, 'missing static method') |
| 510 | self.assert_(('c', 'method', C) in attrs, 'missing plain method') |
| 511 | self.assert_(('p', 'property', A) in attrs, 'missing property') |
| 512 | self.assert_(('m', 'method', C) in attrs, 'missing plain method') |
| 513 | self.assert_(('m1', 'method', A) in attrs, 'missing plain method') |
| 514 | self.assert_(('datablob', 'data', A) in attrs, 'missing data') |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 515 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 516 | class D(B, C): |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 517 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 518 | def m1(self): pass |
Tim Peters | 13b49d3 | 2001-09-23 02:00:29 +0000 | [diff] [blame] | 519 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 520 | attrs = attrs_wo_objs(D) |
| 521 | self.assert_(('s', 'static method', A) in attrs, 'missing static method') |
| 522 | self.assert_(('c', 'method', C) in attrs, 'missing plain method') |
| 523 | self.assert_(('p', 'property', A) in attrs, 'missing property') |
| 524 | self.assert_(('m', 'method', B) in attrs, 'missing plain method') |
| 525 | self.assert_(('m1', 'method', D) in attrs, 'missing plain method') |
| 526 | self.assert_(('datablob', 'data', A) in attrs, 'missing data') |
Jeremy Hylton | c4bf5ed | 2003-06-27 18:43:12 +0000 | [diff] [blame] | 527 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 528 | def test_main(): |
Johannes Gijsbers | 1542f34 | 2004-12-12 16:46:28 +0000 | [diff] [blame] | 529 | run_unittest(TestDecorators, TestRetrievingSourceCode, TestOneliners, |
Johannes Gijsbers | a5855d5 | 2005-03-12 16:37:11 +0000 | [diff] [blame] | 530 | TestBuggyCases, |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 531 | TestInterpreterStack, TestClassesAndFunctions, TestPredicates) |
Martin v. Löwis | 893ffa4 | 2003-10-31 15:35:53 +0000 | [diff] [blame] | 532 | |
Johannes Gijsbers | cb9015d | 2004-12-12 16:20:22 +0000 | [diff] [blame] | 533 | if __name__ == "__main__": |
| 534 | test_main() |