File: check_test.py

package info (click to toggle)
pygame 1.9.4.post1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 10,412 kB
  • sloc: ansic: 54,632; python: 28,791; objc: 334; php: 92; sh: 76; makefile: 36; cpp: 25
file content (41 lines) | stat: -rw-r--r-- 1,032 bytes parent folder | download
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))