Skip to content

Commit

Permalink
Add rednose plugin for colored test output (#1536)
Browse files Browse the repository at this point in the history
  • Loading branch information
fievelk authored and stevenbird committed Dec 5, 2016
1 parent 12b5c2c commit 5711c62
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
18 changes: 17 additions & 1 deletion nltk/test/runtests.py
Expand Up @@ -16,17 +16,26 @@
if __name__ == '__main__':
# there shouldn't be import from NLTK for coverage to work properly
from doctest_nose_plugin import DoctestFix
try:
# Import RedNose plugin for colored test output
from rednose import RedNose
rednose_available = True
except ImportError:
rednose_available = False

class NltkPluginManager(PluginManager):
"""
Nose plugin manager that replaces standard doctest plugin
with a patched version.
with a patched version and adds RedNose plugin for colored test output.
"""
def loadPlugins(self):
for plug in builtin.plugins:
if plug != Doctest:
self.addPlugin(plug())
self.addPlugin(DoctestFix())
if rednose_available:
self.addPlugin(RedNose())

super(NltkPluginManager, self).loadPlugins()

manager = NltkPluginManager()
Expand All @@ -47,6 +56,13 @@ def loadPlugins(self):
# only extra options were passed
args += [NLTK_TEST_DIR]

# Activate RedNose and hide skipped test messages from output
if rednose_available:
args += [
'--rednose',
'--hide-skips'
]

arguments = [
'--exclude=', # why is this needed?
#'--with-xunit',
Expand Down
6 changes: 6 additions & 0 deletions tox.ini
Expand Up @@ -19,6 +19,7 @@ deps =
twython
pyparsing
python-crfsuite
rednose

changedir = nltk/test
commands =
Expand Down Expand Up @@ -48,6 +49,7 @@ deps =
twython
pyparsing
python-crfsuite
rednose

commands =
; scipy and scikit-learn requires numpy even to run setup.py so
Expand All @@ -66,6 +68,7 @@ deps =
twython
pyparsing
python-crfsuite
rednose

commands =
; scipy and scikit-learn requires numpy even to run setup.py so
Expand All @@ -79,18 +82,21 @@ commands =
basepython = python2.7
deps =
nose >= 1.2.1
rednose
commands = python runtests.py []

[testenv:py34-nodeps]
basepython = python3.4
deps =
nose >= 1.2.1
rednose
commands = python runtests.py []

[testenv:py35-nodeps]
basepython = python3.5
deps =
nose >= 1.2.1
rednose
commands = python runtests.py []

[testenv:py27-jenkins]
Expand Down

0 comments on commit 5711c62

Please sign in to comment.