-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_test.py
41 lines (32 loc) · 1.01 KB
/
check_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Program check_test.py
# Requires Python 2.4
"""A program for listing the modules accessed by a Pygame unit test module
Usage:
python check_test.py <test module>
e.g.
python check_test.py surface_test.py
The returned list will show which Pygame modules were imported and accessed.
Each module name is followed by a list of attributes accessed.
"""
import sys
import os
import trackmod
trackmod.begin(pattern=['pygame', 'pygame.*'],
continuous=True,
submodule_accesses=False)
skip = set(['pygame.locals', 'pygame.constants',
'pygame.base', 'pygame.threads'])
os.chdir('test')
test_file = sys.argv[1]
del sys.argv[1]
try:
execfile(test_file)
finally:
trackmod.end()
print "=== Pygame package submodule accesses ==="
print
accesses = [(n, a) for n, a in trackmod.get_accesses().iteritems()
if n not in skip]
accesses.sort(key=lambda t: t[0])
for name, attributes in accesses:
print "%s (%s)" % (name, ', '.join(attributes))