This repository has been archived by the owner on Oct 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathrun_tests.py
104 lines (78 loc) · 2.43 KB
/
run_tests.py
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
94
95
96
97
98
99
100
101
102
103
104
"""Use Mayapy for testing
Usage:
$ mayapy run_tests.py
"""
import os
import sys
import nose
import logging
import contextlib
import six
from maya import standalone
from nose_exclude import NoseExclude
def null(*args, **kwargs):
pass
@contextlib.contextmanager
def mute():
try:
sys.stdout = six.moves.StringIO()
sys.stderr = six.moves.StringIO()
yield
finally:
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__
if __name__ == "__main__":
# Expose mgear Python package to tests
dirname = os.path.dirname(__file__)
sys.path.insert(0, os.path.join(dirname, "scripts"))
print("\n" + "-" * 70)
print("Initialising Maya..")
with mute():
standalone.initialize()
import pymel.core
import pymel.internal.startup
pymel.internal.startup.fixMayapy2011SegFault()
for name, logger in logging.Logger.manager.loggerDict.items():
if "pymel" in name:
logger.disabled = True
argv = sys.argv[:]
argv.extend([
# Sometimes, files from Windows accessed
# from Linux cause the executable flag to be
# set, and Nose has an aversion to these
# per default.
"--exe",
# Produce nice, easily readable output from each test
"--verbose",
# Run through the docstring of every module
# and run anything prefixed with ">>> "
"--with-doctest",
# Produce a coverage report post-tests
"--with-coverage",
"--cover-html",
"--cover-tests",
"--cover-erase",
"--exclude-dir=cvwrap",
"--exclude-dir=docs",
"--exclude-dir=excons",
"--exclude-dir=src",
"tests",
"scripts",
])
# Visually separate output from the above Maya initialisation
# and the actual tests.
# TODO: Mute Maya output entirely; I don't know how it manages to still
# output anything when sys.stdout and err are discarded..
print("\n" + "-" * 70)
print("Running tests..\n")
try:
# Disable messages via PyMEL, they obfuscate the report
pymel.core.displayWarning = null
pymel.core.displayError = null
nose.main(argv=argv, addplugins=[NoseExclude()])
finally:
# Only bother when running when on Travis
if os.getenv("TRAVIS_JOB_ID"):
__import__("coveralls").wear()
else:
sys.stdout.write("Skipping coveralls\n")