X-Git-Url: http://git.samba.org/samba.git/?p=nivanova%2Fsamba-autobuild%2F.git;a=blobdiff_plain;f=lib%2Ftesttools%2Ftesttools%2Futils.py;fp=lib%2Ftesttools%2Ftesttools%2Futils.py;h=0f39d8f5b6ea61bae5f8fec59ad46dc906b7d02b;hp=c0845b610c6123b2a4b3c961cca188d982f1b68d;hb=ed4253504167748c0bb829176d41c09365937189;hpb=955076530425b2c37c7ad545f9a596e8daca0321 diff --git a/lib/testtools/testtools/utils.py b/lib/testtools/testtools/utils.py index c0845b610c6..0f39d8f5b6e 100644 --- a/lib/testtools/testtools/utils.py +++ b/lib/testtools/testtools/utils.py @@ -1,39 +1,13 @@ -# Copyright (c) 2008 Jonathan M. Lange. See LICENSE for details. +# Copyright (c) 2008-2010 testtools developers. See LICENSE for details. -"""Utilities for dealing with stuff in unittest.""" +"""Utilities for dealing with stuff in unittest. +Legacy - deprecated - use testtools.testsuite.iterate_tests +""" -import sys +import warnings +warnings.warn("Please import iterate_tests from testtools.testsuite - " + "testtools.utils is deprecated.", DeprecationWarning, stacklevel=2) -__metaclass__ = type -__all__ = [ - 'iterate_tests', - ] +from testtools.testsuite import iterate_tests - -if sys.version_info > (3, 0): - def _u(s): - """Replacement for u'some string' in Python 3.""" - return s - def _b(s): - """A byte literal.""" - return s.encode("latin-1") - advance_iterator = next -else: - def _u(s): - return unicode(s, "latin-1") - def _b(s): - return s - advance_iterator = lambda it: it.next() - - -def iterate_tests(test_suite_or_case): - """Iterate through all of the test cases in 'test_suite_or_case'.""" - try: - suite = iter(test_suite_or_case) - except TypeError: - yield test_suite_or_case - else: - for test in suite: - for subtest in iterate_tests(test): - yield subtest