Source

# Program check_test.py# Requires Python 2.4"""A program for listing the modules accessed by a Pygame unit test moduleUsage:python check_test.py <test module>e.g.python check_test.py surface_test.pyThe returned list will show which Pygame modules were imported and accessed.Each module name is followed by a list of attributes accessed."""importsysimportosimporttrackmodtrackmod.begin(pattern=['pygame','pygame.*'],continuous=True,submodule_accesses=False)skip=set(['pygame.locals','pygame.constants','pygame.base','pygame.threads'])sys.path.append('.')os.chdir('test')test_file=sys.argv[1]delsys.argv[1]try:execfile(test_file)finally:trackmod.end()print"=== Pygame package submodule accesses ==="printaccesses=[(n,a)forn,aintrackmod.get_accesses().iteritems()ifnnotinskip]accesses.sort(key=lambdat:t[0])forname,attributesinaccesses:print"%s (%s)"%(name,', '.join(attributes))