File: run_tests.py

package info (click to toggle)
cf-python 1.3.2+dfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, stretch
  • size: 7,996 kB
  • sloc: python: 51,733; ansic: 2,736; makefile: 78; sh: 2
file content (46 lines) | stat: -rw-r--r-- 1,278 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
42
43
44
45
46
import unittest
import os
import netCDF4
import numpy
import datetime
import platform
import psutil
import sys
import cf

if platform.python_version() < '2.7.0':
    raise ValueError(
        "Bad python version for unit tests. Requires python <= 2.7.0. Got %s." %
        platform.python_version())

# Build the test suite from the tests found in the test files.
testsuite_setup = unittest.TestSuite()
testsuite_setup.addTests(unittest.TestLoader().discover('test', pattern='test_create_field.py'))

testsuite = unittest.TestSuite()
testsuite.addTests(unittest.TestLoader().discover('test', pattern='test_*.py'))

# Run the test suite.
def run_test_suite_setup(verbosity=2):
    runner = unittest.TextTestRunner(verbosity=verbosity)
    runner.run(testsuite_setup)

# Run the test suite.
def run_test_suite(verbosity=2):
    runner = unittest.TextTestRunner(verbosity=verbosity)
    runner.run(testsuite)

if __name__ == '__main__':
    original_chunksize = cf.CHUNKSIZE()
    print '--------------------'
    print 'CF-PYTHON TEST SUITE'
    print '--------------------'
    print 'Run date:', datetime.datetime.now()
    cf.ENVIRONMENT()
    print ''

    cf.CHUNKSIZE(original_chunksize)
    run_test_suite_setup()
    run_test_suite()

    cf.CHUNKSIZE(original_chunksize)