File: test.py

package info (click to toggle)
python-bumps 1.0.0b2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,144 kB
  • sloc: python: 23,941; xml: 493; ansic: 373; makefile: 209; sh: 91; javascript: 90
file content (93 lines) | stat: -rwxr-xr-x 2,195 bytes parent folder | download | duplicates (2)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python

"""
Run tests for bumps.

Usage:

./test.py
    - run all tests

./test.py --with-coverage
    - run all tests with coverage report
"""

import os
import sys
import subprocess
from glob import glob
import nose

from distutils.util import get_platform

platform = ".%s-%s" % (get_platform(), sys.version[:3])

# Make sure that we have a private version of mplconfig
mplconfig = os.path.join(os.getcwd(), ".mplconfig")
os.environ["MPLCONFIGDIR"] = mplconfig
if not os.path.exists(mplconfig):
    os.mkdir(mplconfig)
import matplotlib

matplotlib.use("Agg")


def addpath(path):
    """
    Add a directory to the python path environment, and to the PYTHONPATH
    environment variable for subprocesses.
    """
    path = os.path.abspath(path)
    if "PYTHONPATH" in os.environ:
        PYTHONPATH = path + os.pathsep + os.environ["PYTHONPATH"]
    else:
        PYTHONPATH = path
    os.environ["PYTHONPATH"] = PYTHONPATH
    sys.path.insert(0, path)


sys.dont_write_bytecode = True

sys.stderr = sys.stdout  # Doctest doesn't see sys.stderr
# import numpy as np; np.seterr(all='raise')

# Check that we are running from the root.
root = os.path.abspath(os.getcwd())
assert os.path.exists(os.path.join(root, "bumps", "cli.py")), "Not in bumps root"
addpath(root)

# Set the nosetest args
nose_args = [
    "-v",
    "--all-modules",
    "-m(^_?test_|_test$|^test$)",
    "--with-doctest",
    "--doctest-extension=.rst",
    "--doctest-options=+ELLIPSIS,+NORMALIZE_WHITESPACE",
    "--cover-package=bumps",
    "-e.*amqp_map.*",
]

# exclude gui subdirectory if wx is not available
try:
    import wx
except ImportError:
    nose_args.append("-egui")

nose_args += sys.argv[1:]  # allow coverage arguments

# Add targets
nose_args += [os.path.join(root, "bumps")]
nose_args += glob("doc/g*/*.rst")
nose_args += glob("doc/_examples/*/*.rst")

print("nosetests " + " ".join(nose_args))
if not nose.run(argv=nose_args):
    print("tests failed!")
    sys.exit(1)
print("tests passed!")

# Run the command line version of bumps which should display help text.
# for p in ['bin/bumps']:
#    ret = subprocess.call((sys.executable, p), shell=False)
#    if ret != 0: sys.exit()