~widelands-dev/widelands-website/django_staticfiles

« back to all changes in this revision

Viewing changes to mainpage/tests.py

  • Committer: franku
  • Date: 2016-04-18 13:29:23 UTC
  • mto: This revision was merged to the branch mainline in revision 409.
  • Revision ID: somal@arcor.de-20160418132923-bfzkb5mvdr7l8mz4
added migrations to each app

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python -tt
2
2
 
3
3
# Load and runs the test from the utest subdirectory
4
 
# your unittests should append ".." to their path to
 
4
# your unittests should append ".." to their path to 
5
5
# find the files relative to this directory
6
6
 
7
7
import unittest
9
9
import os
10
10
import sys
11
11
 
12
 
prefix = ''
 
12
prefix = ""
13
13
append_path = False
14
 
if __name__ != '__main__':
 
14
if __name__ != "__main__":
15
15
    prefix = __name__[:-5]
16
16
    append_path = True
17
17
 
18
 
 
19
 
def suite():
 
18
def suite( ):
20
19
    # If we are not called directly, we have
21
20
    # to append this path to sys.path so our
22
21
    # subtests will find their files
23
22
    this_dir = os.path.dirname(__file__)
24
23
    if append_path:
25
 
        sys.path.append(this_dir)
 
24
        sys.path.append( this_dir )
26
25
 
27
26
    suite = unittest.TestSuite()
28
27
    l = unittest.TestLoader()
29
 
 
 
28
    
30
29
    dname = os.path.dirname(__file__)
31
30
 
32
 
    for f in glob('%s/utest/*.py' % dname):
 
31
    for f in glob("%s/utest/*.py" % dname):
33
32
        if os.path.basename(f) == '__init__.py':
34
33
            continue
35
 
 
36
 
        modname = '%sutest.%s' % (prefix, os.path.basename(f)[:-3])
 
34
       
 
35
        modname = "%sutest.%s" % (prefix,os.path.basename(f)[:-3])
37
36
 
38
37
        # Load tests
39
 
        tests = l.loadTestsFromName(modname)
 
38
        tests = l.loadTestsFromName( modname )
40
39
        suite.addTests(tests)
41
 
 
 
40
    
42
41
    if append_path:
43
 
        sys.path.remove(this_dir)
 
42
        sys.path.remove( this_dir )
44
43
 
45
44
    return suite
46
 
 
47
 
 
48
 
def main():
 
45
  
 
46
def main( ):
49
47
    tsuite = suite()
50
48
    runner = unittest.TextTestRunner()
51
49
    runner.run(tsuite)
52
50
    return unittest.TestResult()
53
51
 
54
52
 
 
53
 
55
54
if __name__ == '__main__':
56
55
    main()
 
56
 
 
57