~launchpad/testtools/launchpad-ppa-hardy

« back to all changes in this revision

Viewing changes to testtools/utils.py

  • Committer: Bazaar Package Importer
  • Author(s): Elliot Murphy (personal)
  • Date: 2009-04-08 15:07:49 UTC
  • Revision ID: james.westby@ubuntu.com-20090408150749-1dlph7wk00hg6ag3
Tags: upstream-0.1~r16
ImportĀ upstreamĀ versionĀ 0.1~r16

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2008 Jonathan M. Lange. See LICENSE for details.
 
2
 
 
3
"""Utilities for dealing with stuff in unittest."""
 
4
 
 
5
__metaclass__ = type
 
6
__all__ = [
 
7
    'iterate_tests',
 
8
    ]
 
9
 
 
10
 
 
11
def iterate_tests(test_suite_or_case):
 
12
    """Iterate through all of the test cases in `test_suite_or_case`."""
 
13
    try:
 
14
        suite = iter(test_suite_or_case)
 
15
    except TypeError:
 
16
        yield test_suite_or_case
 
17
    else:
 
18
        for test in suite:
 
19
            for subtest in iterate_tests(test):
 
20
                yield subtest