[issue14534] Add method to mark unittest.TestCases as "do not run".

R. David Murray report at bugs.python.org
Mon Apr 9 15:10:53 CEST 2012


New submission from R. David Murray <rdmurray at bitdance.com>:

A common pattern in testing is to have a base test class that implements test methods, and subclasses that provide various data that drives the tests to be run in different ways.  It is convenient for the base class to inherit from TestCase, but this causes the normal test loader to load it as a test to be run, when most times it can't run by itself.

My proposed solution is to make test case loading depend on an attribute of the class rather than the fact that it subclasses TestCase.  TestCase would then have the attribute set to True by default.  A decorator would be provided that sets the attribute to False, since that would make it visually obvious which TestCases are base classes and not to be loaded.

(Note: once this is available the 'best practices' description of test file construction in the documentation for the stdlib 'test' module should be updated to use it.)

----------
assignee: michael.foord
components: Library (Lib)
keywords: easy
messages: 157842
nosy: michael.foord, r.david.murray
priority: normal
severity: normal
stage: needs patch
status: open
title: Add method to mark unittest.TestCases as "do not run".
type: enhancement
versions: Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14534>
_______________________________________


More information about the Python-bugs-list mailing list