File: run-tests.py

package info (click to toggle)
python-byteplay 0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 256 kB
  • sloc: python: 1,318; makefile: 36; sh: 6
file content (30 lines) | stat: -rw-r--r-- 763 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
#!/usr/bin/python

import os
import re
import shutil
import sys
import tempfile

import byteplay

def main():
    print >>sys.stderr, 'byteplay.__file__ = %r' % (byteplay.__file__,)
    source_dir = os.path.dirname(os.__file__)
    os.chdir(source_dir)
    target_dir = tempfile.mkdtemp(prefix='byteplay-test')
    is_name_interesting = re.compile('^\w+(?:[.]py)?$').match
    try:
        def ignore(root, names):
            root = root[2:]
            return [name for name in names if not is_name_interesting(name)]
        shutil.copytree('.', os.path.join(target_dir, 'Lib'), ignore=ignore)
        sys.argv[1:] = [target_dir]
        byteplay.main()
    finally:
        shutil.rmtree(target_dir)

if __name__ == '__main__':
    main()

# vim:ts=4 sw=4 et