Skip to content

Instantly share code, notes, and snippets.

@bmaland
Created March 11, 2009 08:45
Show Gist options
  • Save bmaland/77377 to your computer and use it in GitHub Desktop.
Save bmaland/77377 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# NLTK test-suite runner
#
# Author: Bjørn Arild Mæland <[email protected]>
#
import os, sys
import doctest_driver
# Make sure that we are in the test-directory
_dir = os.path.dirname(sys.argv[0])
if os.path.isdir(_dir):
os.chdir(_dir)
# These tests are expected to fail
FAILING_TESTS = ["chat80.doctest", "classify.doctest", "corpus.doctest",
"data.doctest", "logic.doctest", "misc.doctest",
"portuguese_en.doctest",
"probability.doctest", "tag.doctest", "wordnet.doctest"]
# These tests require extra dependencies
DEPENDENT_TESTS = ["discourse.doctest", "nonmonotonic.doctest",
"gluesemantics.doctest", "inference.doctest"]
TESTS = [x for x in os.listdir(os.getcwd()) if x.endswith('.doctest') and
not x in FAILING_TESTS + DEPENDENT_TESTS]
def main():
testrun = doctest_driver.run(TESTS, 0, 1)
if not testrun.wasSuccessful():
print "Please report this error to the nltk-dev mailinglist."
exit(1)
# NOTE: is it possible to disable output when the failing tests run?
# Maybe some parameter to doctest_driver.run
testrun = doctest_driver.run(FAILING_TESTS, 0, 1)
if not len(FAILING_TESTS) == len(testrun.failures):
print "Some of the tests that were expected to fail actually passed."
print "Please report this to the nltk-dev mailinglist."
exit(1)
print
print "All tests OK! (The ones that did fail were expected to fail)"
if __name__ == '__main__': main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment