Move most of utils module to compat and put iterate_tests in testsuite module
This commit is contained in:
@@ -40,8 +40,8 @@ from testtools.testresult import (
|
||||
)
|
||||
from testtools.testsuite import (
|
||||
ConcurrentTestSuite,
|
||||
iterate_tests,
|
||||
)
|
||||
from testtools.utils import iterate_tests
|
||||
|
||||
# same format as sys.version_info: "A tuple containing the five components of
|
||||
# the version number: major, minor, micro, releaselevel, and serial. All
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# 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."""
|
||||
|
||||
@@ -13,7 +13,9 @@ import traceback
|
||||
|
||||
__metaclass__ = type
|
||||
__all__ = [
|
||||
'iterate_tests',
|
||||
'advance_iterator',
|
||||
'str_is_unicode',
|
||||
'unicode_output_stream',
|
||||
]
|
||||
|
||||
|
||||
@@ -48,17 +50,6 @@ else:
|
||||
str_is_unicode = sys.platform == "cli"
|
||||
|
||||
|
||||
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
|
||||
|
||||
def unicode_output_stream(stream):
|
||||
"""Get wrapper for given stream that writes any unicode without exception
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
import codecs
|
||||
|
||||
from testtools.testresult import TestResult
|
||||
from testtools.compat import _b
|
||||
from testtools.content_type import ContentType
|
||||
from testtools.utils import _b
|
||||
|
||||
|
||||
class Content(object):
|
||||
|
||||
@@ -12,8 +12,8 @@ import os
|
||||
import unittest
|
||||
import sys
|
||||
|
||||
from testtools.utils import classtypes, istext, unicode_output_stream
|
||||
from testtools import TextTestResult
|
||||
from testtools.compat import classtypes, istext, unicode_output_stream
|
||||
|
||||
|
||||
defaultTestLoader = unittest.defaultTestLoader
|
||||
|
||||
@@ -22,9 +22,9 @@ import types
|
||||
import unittest
|
||||
|
||||
from testtools import content
|
||||
from testtools.compat import advance_iterator
|
||||
from testtools.runtest import RunTest
|
||||
from testtools.testresult import TestResult
|
||||
from testtools.utils import advance_iterator
|
||||
|
||||
|
||||
try:
|
||||
|
||||
@@ -14,7 +14,7 @@ import datetime
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from testtools.utils import _format_exc_info, str_is_unicode
|
||||
from testtools.compat import _format_exc_info, str_is_unicode
|
||||
|
||||
|
||||
class TestResult(unittest.TestResult):
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
import unittest
|
||||
from testtools.tests import (
|
||||
test_compat,
|
||||
test_content,
|
||||
test_content_type,
|
||||
test_matchers,
|
||||
@@ -11,13 +12,13 @@ from testtools.tests import (
|
||||
test_testtools,
|
||||
test_testresult,
|
||||
test_testsuite,
|
||||
test_utils,
|
||||
)
|
||||
|
||||
|
||||
def test_suite():
|
||||
suites = []
|
||||
modules = [
|
||||
test_compat,
|
||||
test_content,
|
||||
test_content_type,
|
||||
test_matchers,
|
||||
@@ -25,7 +26,6 @@ def test_suite():
|
||||
test_testresult,
|
||||
test_testsuite,
|
||||
test_testtools,
|
||||
test_utils,
|
||||
]
|
||||
for module in modules:
|
||||
suites.append(getattr(module, 'test_suite')())
|
||||
|
||||
@@ -10,7 +10,7 @@ import traceback
|
||||
|
||||
import testtools
|
||||
|
||||
from testtools.utils import (
|
||||
from testtools.compat import (
|
||||
_b,
|
||||
_detect_encoding,
|
||||
_get_source_encoding,
|
||||
@@ -1,9 +1,9 @@
|
||||
# Copyright (c) 2008 Jonathan M. Lange. See LICENSE for details.
|
||||
|
||||
import unittest
|
||||
from testtools.compat import _u
|
||||
from testtools.content import Content, TracebackContent
|
||||
from testtools.content_type import ContentType
|
||||
from testtools.utils import _u
|
||||
from testtools.tests.helpers import an_exc_info
|
||||
|
||||
|
||||
|
||||
@@ -27,9 +27,7 @@ from testtools import (
|
||||
ThreadsafeForwardingResult,
|
||||
testresult,
|
||||
)
|
||||
from testtools.content import Content, ContentType
|
||||
from testtools.matchers import DocTestMatches
|
||||
from testtools.utils import (
|
||||
from testtools.compat import (
|
||||
_b,
|
||||
_get_exception_encoding,
|
||||
_r,
|
||||
@@ -37,6 +35,8 @@ from testtools.utils import (
|
||||
str_is_unicode,
|
||||
unicode_output_stream,
|
||||
)
|
||||
from testtools.content import Content, ContentType
|
||||
from testtools.matchers import DocTestMatches
|
||||
from testtools.tests.helpers import (
|
||||
LoggingResult,
|
||||
Python26TestResult,
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
__metaclass__ = type
|
||||
__all__ = [
|
||||
'ConcurrentTestSuite',
|
||||
'iterate_tests',
|
||||
]
|
||||
|
||||
try:
|
||||
@@ -17,6 +18,18 @@ import unittest
|
||||
import testtools
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
class ConcurrentTestSuite(unittest.TestSuite):
|
||||
"""A TestSuite whose run() calls out to a concurrency strategy."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user