File: runtests.py

package info (click to toggle)
python-django-libsass 0.9-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 184 kB
  • sloc: python: 211; makefile: 6
file content (48 lines) | stat: -rwxr-xr-x 1,228 bytes parent folder | download | duplicates (3)
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
42
43
44
45
46
47
48
#!/usr/bin/env python

import argparse
import os
import shutil
import sys
import warnings

from django.core.management import execute_from_command_line

os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'


def make_parser():
    parser = argparse.ArgumentParser()
    parser.add_argument('--deprecation', choices=['pending', 'imminent', 'none'], default='imminent')
    return parser


def parse_args(args=None):
    return make_parser().parse_known_args(args)


def runtests():
    args, rest = parse_args()

    if args.deprecation == 'pending':
        # Show all deprecation warnings
        warnings.simplefilter('default', DeprecationWarning)
        warnings.simplefilter('default', PendingDeprecationWarning)
    elif args.deprecation == 'imminent':
        # Show only imminent deprecation warnings
        warnings.simplefilter('default', DeprecationWarning)
    elif args.deprecation == 'none':
        # Deprecation warnings are ignored by default
        pass

    argv = [sys.argv[0], 'test'] + rest

    try:
        execute_from_command_line(argv)
    finally:
        from tests.settings import STATIC_ROOT
        shutil.rmtree(STATIC_ROOT, ignore_errors=True)


if __name__ == '__main__':
    runtests()