Skip to main content

An object-oriented API to test doctests using unittest runners.

Project description

An object-oriented API to test doctests using unittest runners.

Module providing classes which extend doctest module so as to achieve better integration with unittest.

It is different from the Pyhton 2.4 doctest unittest API because:

  • A new unitest.TestLoader descendant now allows to load instances of TestCases for doctests using unittest-style, supports building complex test suites in a more natural way, and eases the use of specialized instances of TestCase built out of doctest examples.

  • Other loaders allow users to extract TestCase instances out of TestCase descendants and doctests (and any other format) in a single step.

  • In this case unittest.TestResult instances report whether individual examples have been successfully executed, or otherwise have failed or raised an unexpected exception. Formerly TestResult objects contained the whole report outputted by doctest module.

  • Test analysis require no further parsing to retrieve detailed information about failures.

  • A whole new unittest API for doctest adds object orientation and eliminates functions with big signatures.

  • It is not necessary to use DocTestRunner output streams in order to collect test results.

  • A new hierarchy of doctest TestCases is now possible so for example, setUp and tearDown may be redefined across a hierarchy of TestCases instead of providing this methods as parameters to a function (breaking OOP philosophy and logic); or maybe even failures and errors can be represented in a custom way.

  • Allows to perform regression testing over tests written using doctest.

  • Fixes a minor bug related with specifying different verbosity levels from the command line to unittest.TestProgram (alias main).

  • Loads by default test cases for doctests plus those formerly loaded by unittest.TestLoader

It is similar to the Pyhton 2.4 doctest unittest API because:

  • Provides integration with TestProgram and unittest test runners.

  • Allows to parameterize doctest behavior via doctest options

A fuller explanation can be found in the following article:

“Doctest and unittest… now they’ll live happily together”, O. Lang (2008) The Python Papers, Volume 3, Issue 1, pp. 31:51

Note: The contents of this module were first implemented by the module oop.utils.testing contained in PyOOP package.

What’s new in version 0.2.1:

  • PackageTestLoader class added to dutest module. It loads all the tests found throughout a package hierarchy using another loader. The later is used for retrieving the tests contained inside every module matching a specified pattern.

  • DocTestLoader class in oop.utils.dutest does not raise ValueError exception if no doctests are found in a module. This is doctest behavior. It was assumed up to this point, but now it has proven to be a headache when these loaders are used together with instances of PackageTestLoader in order to retrieve all the tests defined across a package hierarchy.

What’s new in version 0.1.2:

  • Bug found… DocTestCase instances could not be instantiated because None was supplied in to the initializer as the test method name. This bug remained hidden somehow while executing the test using oop.test.check_oopdbc(), and even when importing oop.utils.dutest (which is actually the same implementation).

  • Bug found… There was a missing backslash () at the end of line 32 in oop.utils.testing.

Both problems have been repaired now.

What’s new in version 0.1.1:

  • The class oop.utils.testing.VerboseTestProgram has been moved onto dutest module. Release 0.1.0 did not include it. Thanks to Michal Kwiatkowski for notifying me so [1].

  • Default test loader and runner have been added to this module as well. The default loader is an instance of MultiTestLoader that combines the suites loaded by unittest.TestLoader and dutest.DocTestLoader.

  • dutest.main is an alias for dutest.VerboseTestProgram. This class fixes a minor bug (… IMO) I found while specifying different verbosity levels from the command line to unittest.TestProgram. It also employs by default dutest.defaultTestLoader instead of unittest.defaultTestLoader.

[1] [TIP] Fwd: An OO API for doctest / unittest integration…

(http://lists.idyll.org/pipermail/testing-in-python/2008-August/000918.html)

What’s new in version 0.1.0:

doctest extensions: - A whole new unittest API to integrate doctest tests.

  • It allows to acquire the individual results of each and every DocTest instances’ example.

  • You do not need to use DocTestRunner output streams to collect test results.

  • Gathering individual examples’ results.

  • Failures and errors are collected individually into TestResults, making easier the automation of post-testing analysis.

  • A new hierarchy of doctest TestCases is now possible so for example, setUp and tearDown may be redefined across a hierarchy of TestCases instead of providing this methods as parameters to a function (breaking OOP philosophy and logic); or maybe even to represent failures and errors in a custom way.

  • A new doctest TestLoader now allows to load doctest TestCases using unittest-style, provides integration with TestProgram, supports building complex TestSuites in a more natural way, and eases the use of specialized instances of TestCases built out of doctest examples.

  • Allows to perform regression testing over tests written using doctest.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dutest-0.2.1.zip (12.8 kB view details)

Uploaded Source

Built Distributions

dutest-0.2.1.win32.exe (77.4 kB view details)

Uploaded Source

dutest-0.2.1-py2.5.egg (17.6 kB view details)

Uploaded Source

File details

Details for the file dutest-0.2.1.zip.

File metadata

  • Download URL: dutest-0.2.1.zip
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for dutest-0.2.1.zip
Algorithm Hash digest
SHA256 8d649e68ce199330d1dc0856e8633a0fd41226586b14c22a29252e4bdff4c672
MD5 d9d386f9dc343b14c12455d5e87a822c
BLAKE2b-256 bdd554a9e4c968be2c42b3771eb2917e8970ae0aefcedfc11abf7ddf293be0e0

See more details on using hashes here.

File details

Details for the file dutest-0.2.1.win32.exe.

File metadata

  • Download URL: dutest-0.2.1.win32.exe
  • Upload date:
  • Size: 77.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for dutest-0.2.1.win32.exe
Algorithm Hash digest
SHA256 9fef9d0919b81c7b0cd80620497fd0731e77e9ac3b86e8ee9f33f4f5b35d71f3
MD5 1a2c0ca9ea716b72f542d84b341ac6d7
BLAKE2b-256 487a88be5954edebe4717d13cb41b043a556539c7c7df344c444287179b1384d

See more details on using hashes here.

File details

Details for the file dutest-0.2.1-py2.5.egg.

File metadata

  • Download URL: dutest-0.2.1-py2.5.egg
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for dutest-0.2.1-py2.5.egg
Algorithm Hash digest
SHA256 4151cbf71ed54c222a74a9acb2044fa98139667c66f72b11c6188b1b33d2a887
MD5 edc6bbe736829f94294ab2d7b946ecc1
BLAKE2b-256 03541c613a8bde2b83d49b9b3ef8618cb057bb2932db030c9e458804a5756858

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page