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.3:

  • Implemented Suite Fixture Setup test pattern (i.e. set up a fixture once before all its interactive examples are run and clean up after they all have been run.

  • Module is hidden in tracebacks written to instances of TestResult when a failure or an error is detected.

  • Support for multiple pattern matching styles has been added in PackageTestLoader trough style parameter. By default standard regular expressions (i.e. style=REGEX) are used.

  • Unix filename pattern matching (fnmatch module) is available from now on while using PackageTestLoader. The only thing needed is to specify style=UNIX.

  • Multiple functions in previous versions contained arguments having mutable objects as default values. A message about default args sent to TiP list explains why this is really harmful. This has been fixed. Thanks to Scott David Daniels for reporting the issue with default args and Jesse Noller for the pointers about default args .

What’s new in version 0.2.2:

  • Bug fixed… The class PackageTestLoader loaded the tests defined in a packages’ chldren but not those specified in the top-level module. Now the tests specified in the module supplied in to loadTestsFromModule method are also included in the resulting test suite.

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 fixed… 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).

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.

What’s new in version 0.1.0:

doctest / unittest extensions:

  • A whole new unittest API to integrate doctest with unittest runners.

  • It allows to report the individual results of each and every interactive example executed during the test run. A separate entry is created in the corresponding TestResult instance containing the expected value and the actual result.

  • Since the match made for individual examples is reported one by one by instances of TestResult, it is quite easier to automate post-testing activities (e.g. automated test analysis). Formerly access to this information required extra work (i.e. the full report provided by doctest had to be parsed).

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

  • A new hierarchy of TestCase descendants (extensions of DocTestCase class) is now possible so for example, setUp and tearDown may be redefined across a hierarchy of TestCase s 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 TestLoader descendant now allows to load (using unittest-style) TestCase s which check the match made for doctests. It provides integration with TestProgram, supports building complex TestSuite s in a more natural way, and eases the use of specialized instances of TestCase s 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 Distributions

dutest-0.2.3.zip (20.3 kB view details)

Uploaded Source

dutest-0.2.3.tar.gz (12.8 kB view details)

Uploaded Source

dutest-0.2.3.tar.bz2 (13.0 kB view details)

Uploaded Source

Built Distribution

dutest-0.2.3-py2.5.egg (23.5 kB view details)

Uploaded Source

File details

Details for the file dutest-0.2.3.zip.

File metadata

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

File hashes

Hashes for dutest-0.2.3.zip
Algorithm Hash digest
SHA256 74a97bdf6efdc4212fac537538bdde16f13b1f9844d99d49559dd8c717d1b324
MD5 6a75d6c262d68c8541c484d1fbfc6852
BLAKE2b-256 fa72f3f808461605c918c580b71cadad2cc253c912a81f3e29e4c47f516f03a7

See more details on using hashes here.

File details

Details for the file dutest-0.2.3.tar.gz.

File metadata

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

File hashes

Hashes for dutest-0.2.3.tar.gz
Algorithm Hash digest
SHA256 1a2e4d8d6c97a181a67ec8345dbfc1daddc99862e24d0702c0f6788a10bce8f6
MD5 eb9821b6c7244c9d76305d9bdaf48cc3
BLAKE2b-256 752e356e2a53e0d1aa330ee62db5b43a38e502e92f5d1fd13ca9632ef929ded4

See more details on using hashes here.

File details

Details for the file dutest-0.2.3.tar.bz2.

File metadata

  • Download URL: dutest-0.2.3.tar.bz2
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for dutest-0.2.3.tar.bz2
Algorithm Hash digest
SHA256 b10789454cd892a22deb8462a4c06b10985fd69fcc470d672f2b3e6e7d5b919d
MD5 f1558218bc844654934d5e49e7626403
BLAKE2b-256 79ce6d2779d209e677d2c5c3d16ec76eccb10ef13ebc92f8841f01f2a35f5ae1

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for dutest-0.2.3-py2.5.egg
Algorithm Hash digest
SHA256 c8e68ae9a9678074605f585c68fd348b78f342a1d34b191c9b0f9d5494255c66
MD5 dbf8fd61e6e1c92cc20c85b21ed696db
BLAKE2b-256 8110eceb88ed7a556632348dbc725b48123346fc4e8ca719bd40b81b1b6f31c7

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