Skip to content
Browse files

Merge pull request #258 from kmike/master

Small test running improvements + better pypy support
  • Loading branch information...
2 parents f3329d1 + 50ab385 commit 7f1fad731d1bbaa9334a665221d68b86d8164dce @stevenbird stevenbird committed May 15, 2012
Showing with 54 additions and 18 deletions.
  1. +2 −0 .gitignore
  2. +6 −0 nltk/__init__.py
  3. +16 −1 nltk/test/runtests.py
  4. +5 −4 nltk/test/stem.doctest
  5. +4 −9 tox.ini
  6. +21 −4 web/dev/local_testing.rst
View
2 .gitignore
@@ -9,9 +9,11 @@
build/
dist/
nltk.egg-info/
+web/_build
# generated by tests
*.errs
# editor temporary files
*.*.sw[op]
+.idea
View
6 nltk/__init__.py
@@ -90,6 +90,12 @@
from internals import config_java
+# support numpy from pypy
+try:
+ import numpypy
+except ImportError:
+ pass
+
###########################################################
# TOP-LEVEL MODULES
###########################################################
View
17 nltk/test/runtests.py
@@ -57,11 +57,26 @@ def loadPlugins(self):
manager = NltkPluginManager()
manager.loadPlugins()
+ # allow passing extra options and running individual tests
+ # Examples:
+ #
+ # python runtests.py semantics.doctest
+ # python runtests.py --with-id -v
+ # python runtests.py --with-id -v nltk.featstruct
+
+ args = sys.argv[1:]
+ if not args:
+ args = [NLTK_TEST_DIR]
+
+ if all(arg.startswith('-') for arg in args):
+ # only extra options were passed
+ args += [NLTK_TEST_DIR]
+
nose.main(argv=_EXCLUDE_ARGV + [
#'--with-xunit',
#'--xunit-file=$WORKSPACE/nosetests.xml',
'--with-doctest',
'--doctest-extension=.doctest',
'--doctest-options=+ELLIPSIS,+NORMALIZE_WHITESPACE,+IGNORE_EXCEPTION_DETAIL',
#'--verbosity=3',
- ] + sys.argv[1:] + [NLTK_TEST_DIR], plugins=manager.plugins)
+ ] + args, plugins=manager.plugins)
View
9 nltk/test/stem.doctest
@@ -16,7 +16,7 @@ word stem.
Unit tests for the Porter stemmer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- >>> from nltk.stem.porter import *
+ >>> from nltk.stem.porter import *
Create a new Porter stemmer.
@@ -185,7 +185,7 @@ Stem a word.
>>> stemmer_german.stem(u"Schr\xe4nke")
u'schrank'
-
+
Decide not to stem stopwords.
>>> stemmer_german2 = SnowballStemmer("german", ignore_stopwords=True)
@@ -207,7 +207,8 @@ Russian words both consisting of Cyrillic and Roman letters can be stemmed.
>>> stemmer_russian.stem(u'\u0430\u0432\u0435\u043d\u0430\u043d\u0442\u043d'
... u'\u0435\u043d\u044c\u043a\u0430\u044f')
u'\u0430\u0432\u0435\u043d\u0430\u043d\u0442\u043d\u0435\u043d\u044c\u043a'
- >>> print stemmer_russian.stem(u"авенантненькая")
- авенантненьк
+ >>> stemmer_russian.stem(u"\u0430\u0432\u0435\u043d\u0430\u043d"
+ ... u"\u0442\u043d\u0435\u043d\u044c\u043a\u0430\u044f")
+ u'\u0430\u0432\u0435\u043d\u0430\u043d\u0442\u043d\u0435\u043d\u044c\u043a'
>>> stemmer_russian.stem(u"avenantnen'kai^a")
u"avenantnen'k"
View
13 tox.ini
@@ -12,12 +12,7 @@ deps =
; epydoc
numpy
nose
-
-
-; pysvmlight requires mercurial to install (and even if Mercurial is installed
-; globally it may not be available for a given python interpreter) so it is disabled now
-;
-; hg+https://bitbucket.org/wcauchois/pysvmlight
+ svmlight
changedir = nltk/test
@@ -26,13 +21,13 @@ commands =
; they can't be installed in one command
pip install --download-cache={toxworkdir}/_download scipy scikit-learn
- python runtests.py
+ python runtests.py []
[testenv:pypy]
-; numpy and pysvmlight don't work with pypy
+; pysvmlight don't work with pypy; numpy is bundled with pypy.
deps =
epydoc
nose
commands =
- python runtests.py
+ python runtests.py []
View
25 web/dev/local_testing.rst
@@ -7,12 +7,29 @@ NLTK testing
pip install virtualenv
pip install tox
-3. make sure python2.5, python2.6, python2.7 and pypy executables are in system PATH.
- It is OK not to have all the executables, tests will be executed for available interpreters.
+3. make sure python2.5, python2.6, python2.7 and pypy executables are
+ in system PATH. It is OK not to have all the executables, tests will
+ be executed for available interpreters.
4. Make sure all NLTK data is downloaded (see `nltk.download()`);
-5. run 'tox' command from the root nltk folder.
+5. run 'tox' command from the root nltk folder. It will install dependencies
+ and run `nltk/test/runtests.py` script for all available interpreters.
+ You may pass any options to runtests.py script separating them by '--'.
It may take a long time at first run, but the subsequent runs will be much faster.
-Please consult http://tox.testrun.org/ for more info about the tox tool.
+Please consult http://tox.testrun.org/ for more info about the tox tool.
+
+Examples
+--------
+
+Run tests for python 2.7 in verbose mode; executing only tests
+that failed in the last test run::
+
+ tox -e py27 -- -v --failed
+
+
+Run tree doctests for all available interpreters::
+
+ tox -- tree.doctest
+

0 comments on commit 7f1fad7

Please sign in to comment.
Something went wrong with that request. Please try again.