• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(68)  |  Call(42)  |  Derive(15)  |  Import(11)
A class used to run DocTest test cases, and accumulate statistics.
The `run` method is used to process a single DocTest case.  It
returns a tuple `(f, t)`, where `t` is the number of test cases
tried, and `f` is the number of test cases that failed.

    >>> tests = DocTestFinder().find(_TestClass)
    >>> runner = DocTestRunner(verbose=False)
    >>> tests.sort(key = lambda test: test.name)
    >>> for test in tests:
    ...     print test.name, '->', runner.run(test)
    _TestClass -> TestResults(failed=0, attempted=2)
    _TestClass.__init__ -> TestResults(failed=0, attempted=2)
    _TestClass.get -> TestResults(failed=0, attempted=2)
    _TestClass.square -> TestResults(failed=0, attempted=1)

The `summarize` method prints a summary of all the test cases that
have been run by the runner, and returns an aggregated `(f, t)`
tuple:

    >>> runner.summarize(verbose=1)
    4 items passed all tests:
       2 tests in _TestClass
       2 tests in _TestClass.__init__
       2 tests in _TestClass.get
       1 tests in _TestClass.square
    7 tests in 4 items.
    7 passed and 0 failed.
    Test passed.
    TestResults(failed=0, attempted=7)

The aggregated number of tried examples and failed examples is
also available via the `tries` and `failures` attributes:

    >>> runner.tries
    7
    >>> runner.failures
    0

The comparison between expected outputs and actual outputs is done
by an `OutputChecker`.  This comparison may be customized with a
number of option flags; see the documentation for `testmod` for
more information.  If the option flags are insufficient, then the
comparison may also be customized by passing a subclass of
`OutputChecker` to the constructor.

The test runner's display output can be controlled in two ways.
First, an output function (`out) can be passed to
`TestRunner.run`; this function will be called with strings that
should be displayed.  It defaults to `sys.stdout.write`.  If
capturing the output is not sufficient, then the display output
can be also customized by subclassing DocTestRunner, and
overriding the methods `report_start`, `report_success`,
`report_unexpected_exception`, and `report_failure`.

src/f/u/funkload-1.13.0/src/funkload/TestRunner.py   funkload(Download)
#
g_doctest_verbose = False
try:
    from doctest import DocTestSuite, DocFileSuite, DocTestCase, DocTestRunner
    from doctest import REPORTING_FLAGS, _unittest_reportflags
    g_has_doctest = True
except ImportError:
            optionflags |= _unittest_reportflags
        # Patching doctestcase to enable verbose mode
        global g_doctest_verbose
        runner = DocTestRunner(optionflags=optionflags,
                               checker=self._dt_checker,
                               verbose=g_doctest_verbose)
        # End of patch

src/i/p/ipython-py3k-HEAD/IPython/testing/ipunittest.py   ipython-py3k(Download)
import re
import sys
import unittest
from doctest import DocTestFinder, DocTestRunner
try:
    from doctest import TestResults
except:
            def test(self):
                # Make a new runner per function to be tested
                runner = DocTestRunner(verbose=d2u.verbose)
                list(map(runner.run, d2u.finder.find(func, func.__name__)))
                failed = count_failures(runner)
                if failed:
                    # Since we only looked at a single function's docstring,

src/n/u/nutmeg-py-HEAD/nutmeg/external/decotest.py   nutmeg-py(Download)
import unittest
 
from compiler.consts import CO_GENERATOR
from doctest import DocTestFinder, DocTestRunner
 
#-----------------------------------------------------------------------------
# nose monkeypatch, remove later
            def test(self):
                # Make a new runner per function to be tested
                runner = DocTestRunner(verbose=d2u.verbose)
                map(runner.run, d2u.finder.find(func, func.func_name))
                failed = count_failures(runner)
                if failed:
                    # Since we only looked at a single function's docstring,

src/x/i/xipy-HEAD/xipy/external/decotest.py   xipy(Download)
import unittest
 
from compiler.consts import CO_GENERATOR
from doctest import DocTestFinder, DocTestRunner
 
#-----------------------------------------------------------------------------
# nose monkeypatch, remove later
            def test(self):
                # Make a new runner per function to be tested
                runner = DocTestRunner(verbose=d2u.verbose)
                map(runner.run, d2u.finder.find(func, func.func_name))
                failed = count_failures(runner)
                if failed:
                    # Since we only looked at a single function's docstring,

src/z/a/zamboni-lib-HEAD/lib/python/IPython/testing/plugin/ipdoctest.py   zamboni-lib(Download)
 
# We are overriding the default doctest runner, so we need to import a few
# things from doctest directly
from doctest import (REPORTING_FLAGS, REPORT_ONLY_FIRST_FAILURE,
                     _unittest_reportflags, DocTestRunner,
                     _extract_future_flags, pdb, _OutputRedirectingPdb,
                     _exception_traceback,
class IPDocTestRunner(doctest.DocTestRunner,object):
    """Test runner that synchronizes the IPython namespace with test globals.
    """
 
    def run(self, test, compileflags=None, out=None, clear_globs=True):
 
        # Hack: ipython needs access to the execution context of the example,

src/i/p/ipython-py3k-HEAD/IPython/testing/plugin/ipdoctest.py   ipython-py3k(Download)
 
# We are overriding the default doctest runner, so we need to import a few
# things from doctest directly
from doctest import (REPORTING_FLAGS, REPORT_ONLY_FIRST_FAILURE,
                     _unittest_reportflags, DocTestRunner,
                     _extract_future_flags, pdb, _OutputRedirectingPdb,
                     _exception_traceback,
class IPDocTestRunner(doctest.DocTestRunner,object):
    """Test runner that synchronizes the IPython namespace with test globals.
    """
 
    def run(self, test, compileflags=None, out=None, clear_globs=True):
 
        # Hack: ipython needs access to the execution context of the example,

src/n/l/nltk-HEAD/trunk/nltk/nltk/test/doctest_driver.py   nltk(Download)
import os, os.path, sys, unittest, pdb, bdb, re, tempfile, traceback
import textwrap
from doctest import *
from doctest import DocTestCase, DocTestRunner
from optparse import OptionParser, OptionGroup, Option
from StringIO import StringIO
import coverage
class UpdateRunner(DocTestRunner):
    """
    A subclass of `DocTestRunner` that checks the output of each
    example, and replaces the expected output with the actual output
    for any examples that fail.
 
    `UpdateRunner` can be used:
class Debugger:
    # Just using this for reporting:
    runner = DocTestRunner()
 
    def __init__(self, checker=None, set_trace=None):
        if checker is None:
            checker = OutputChecker()

src/n/l/nltk-HEAD/nltk/nltk/test/doctest_driver.py   nltk(Download)
import os, os.path, sys, unittest, pdb, bdb, re, tempfile, traceback
import textwrap
from doctest import *
from doctest import DocTestCase, DocTestRunner
from optparse import OptionParser, OptionGroup, Option
from StringIO import StringIO
import coverage
class UpdateRunner(DocTestRunner):
    """
    A subclass of `DocTestRunner` that checks the output of each
    example, and replaces the expected output with the actual output
    for any examples that fail.
 
    `UpdateRunner` can be used:
class Debugger:
    # Just using this for reporting:
    runner = DocTestRunner()
 
    def __init__(self, checker=None, set_trace=None):
        if checker is None:
            checker = OutputChecker()

src/w/3/w3af-HEAD/extlib/nltk/test/doctest_driver.py   w3af(Download)
import os, os.path, sys, unittest, pdb, bdb, re, tempfile, traceback
import textwrap
from doctest import *
from doctest import DocTestCase, DocTestRunner
from optparse import OptionParser, OptionGroup, Option
from StringIO import StringIO
import coverage
class UpdateRunner(DocTestRunner):
    """
    A subclass of `DocTestRunner` that checks the output of each
    example, and replaces the expected output with the actual output
    for any examples that fail.
 
    `UpdateRunner` can be used:
class Debugger:
    # Just using this for reporting:
    runner = DocTestRunner()
 
    def __init__(self, checker=None, set_trace=None):
        if checker is None:
            checker = OutputChecker()

src/c/l/clojure-nltk-HEAD/src/clojure_nltk/python-nltk-src/nltk-2.0b7/nltk/test/doctest_driver.py   clojure-nltk(Download)
import os, os.path, sys, unittest, pdb, bdb, re, tempfile, traceback
import textwrap
from doctest import *
from doctest import DocTestCase, DocTestRunner
from optparse import OptionParser, OptionGroup, Option
from StringIO import StringIO
import coverage
class UpdateRunner(DocTestRunner):
    """
    A subclass of `DocTestRunner` that checks the output of each
    example, and replaces the expected output with the actual output
    for any examples that fail.
 
    `UpdateRunner` can be used:
class Debugger:
    # Just using this for reporting:
    runner = DocTestRunner()
 
    def __init__(self, checker=None, set_trace=None):
        if checker is None:
            checker = OutputChecker()
class MyDocTestRunner(DocTestRunner):
    def __init__(self, checker=None, verbosity=1, optionflags=0,
                 kbinterrupt_continue=False):
        DocTestRunner.__init__(self, checker, (verbosity>2), optionflags)
        self._verbosity = verbosity
        self._current_test = None
        self._term = TerminalController()

  1 | 2  Next