/home/fresvfqn/waterdamagerestorationandrepairsmithtown.com/Compressed/unittest.zip
PK��[��WW	runner.pynu�[���"""Running tests"""

import sys
import time
import warnings

from . import result
from .signals import registerResult

__unittest = True


class _WritelnDecorator(object):
    """Used to decorate file-like objects with a handy 'writeln' method"""
    def __init__(self,stream):
        self.stream = stream

    def __getattr__(self, attr):
        if attr in ('stream', '__getstate__'):
            raise AttributeError(attr)
        return getattr(self.stream,attr)

    def writeln(self, arg=None):
        if arg:
            self.write(arg)
        self.write('\n') # text-mode streams translate to \r\n if needed


class TextTestResult(result.TestResult):
    """A test result class that can print formatted text results to a stream.

    Used by TextTestRunner.
    """
    separator1 = '=' * 70
    separator2 = '-' * 70

    def __init__(self, stream, descriptions, verbosity):
        super(TextTestResult, self).__init__(stream, descriptions, verbosity)
        self.stream = stream
        self.showAll = verbosity > 1
        self.dots = verbosity == 1
        self.descriptions = descriptions

    def getDescription(self, test):
        doc_first_line = test.shortDescription()
        if self.descriptions and doc_first_line:
            return '\n'.join((str(test), doc_first_line))
        else:
            return str(test)

    def startTest(self, test):
        super(TextTestResult, self).startTest(test)
        if self.showAll:
            self.stream.write(self.getDescription(test))
            self.stream.write(" ... ")
            self.stream.flush()

    def addSuccess(self, test):
        super(TextTestResult, self).addSuccess(test)
        if self.showAll:
            self.stream.writeln("ok")
        elif self.dots:
            self.stream.write('.')
            self.stream.flush()

    def addError(self, test, err):
        super(TextTestResult, self).addError(test, err)
        if self.showAll:
            self.stream.writeln("ERROR")
        elif self.dots:
            self.stream.write('E')
            self.stream.flush()

    def addFailure(self, test, err):
        super(TextTestResult, self).addFailure(test, err)
        if self.showAll:
            self.stream.writeln("FAIL")
        elif self.dots:
            self.stream.write('F')
            self.stream.flush()

    def addSkip(self, test, reason):
        super(TextTestResult, self).addSkip(test, reason)
        if self.showAll:
            self.stream.writeln("skipped {0!r}".format(reason))
        elif self.dots:
            self.stream.write("s")
            self.stream.flush()

    def addExpectedFailure(self, test, err):
        super(TextTestResult, self).addExpectedFailure(test, err)
        if self.showAll:
            self.stream.writeln("expected failure")
        elif self.dots:
            self.stream.write("x")
            self.stream.flush()

    def addUnexpectedSuccess(self, test):
        super(TextTestResult, self).addUnexpectedSuccess(test)
        if self.showAll:
            self.stream.writeln("unexpected success")
        elif self.dots:
            self.stream.write("u")
            self.stream.flush()

    def printErrors(self):
        if self.dots or self.showAll:
            self.stream.writeln()
        self.printErrorList('ERROR', self.errors)
        self.printErrorList('FAIL', self.failures)

    def printErrorList(self, flavour, errors):
        for test, err in errors:
            self.stream.writeln(self.separator1)
            self.stream.writeln("%s: %s" % (flavour,self.getDescription(test)))
            self.stream.writeln(self.separator2)
            self.stream.writeln("%s" % err)


class TextTestRunner(object):
    """A test runner class that displays results in textual form.

    It prints out the names of tests as they are run, errors as they
    occur, and a summary of the results at the end of the test run.
    """
    resultclass = TextTestResult

    def __init__(self, stream=None, descriptions=True, verbosity=1,
                 failfast=False, buffer=False, resultclass=None, warnings=None,
                 *, tb_locals=False):
        """Construct a TextTestRunner.

        Subclasses should accept **kwargs to ensure compatibility as the
        interface changes.
        """
        if stream is None:
            stream = sys.stderr
        self.stream = _WritelnDecorator(stream)
        self.descriptions = descriptions
        self.verbosity = verbosity
        self.failfast = failfast
        self.buffer = buffer
        self.tb_locals = tb_locals
        self.warnings = warnings
        if resultclass is not None:
            self.resultclass = resultclass

    def _makeResult(self):
        return self.resultclass(self.stream, self.descriptions, self.verbosity)

    def run(self, test):
        "Run the given test case or test suite."
        result = self._makeResult()
        registerResult(result)
        result.failfast = self.failfast
        result.buffer = self.buffer
        result.tb_locals = self.tb_locals
        with warnings.catch_warnings():
            if self.warnings:
                # if self.warnings is set, use it to filter all the warnings
                warnings.simplefilter(self.warnings)
                # if the filter is 'default' or 'always', special-case the
                # warnings from the deprecated unittest methods to show them
                # no more than once per module, because they can be fairly
                # noisy.  The -Wd and -Wa flags can be used to bypass this
                # only when self.warnings is None.
                if self.warnings in ['default', 'always']:
                    warnings.filterwarnings('module',
                            category=DeprecationWarning,
                            message=r'Please use assert\w+ instead.')
            startTime = time.perf_counter()
            startTestRun = getattr(result, 'startTestRun', None)
            if startTestRun is not None:
                startTestRun()
            try:
                test(result)
            finally:
                stopTestRun = getattr(result, 'stopTestRun', None)
                if stopTestRun is not None:
                    stopTestRun()
            stopTime = time.perf_counter()
        timeTaken = stopTime - startTime
        result.printErrors()
        if hasattr(result, 'separator2'):
            self.stream.writeln(result.separator2)
        run = result.testsRun
        self.stream.writeln("Ran %d test%s in %.3fs" %
                            (run, run != 1 and "s" or "", timeTaken))
        self.stream.writeln()

        expectedFails = unexpectedSuccesses = skipped = 0
        try:
            results = map(len, (result.expectedFailures,
                                result.unexpectedSuccesses,
                                result.skipped))
        except AttributeError:
            pass
        else:
            expectedFails, unexpectedSuccesses, skipped = results

        infos = []
        if not result.wasSuccessful():
            self.stream.write("FAILED")
            failed, errored = len(result.failures), len(result.errors)
            if failed:
                infos.append("failures=%d" % failed)
            if errored:
                infos.append("errors=%d" % errored)
        else:
            self.stream.write("OK")
        if skipped:
            infos.append("skipped=%d" % skipped)
        if expectedFails:
            infos.append("expected failures=%d" % expectedFails)
        if unexpectedSuccesses:
            infos.append("unexpected successes=%d" % unexpectedSuccesses)
        if infos:
            self.stream.writeln(" (%s)" % (", ".join(infos),))
        else:
            self.stream.write("\n")
        return result
PK��[d��__util.pynu�[���"""Various utility functions."""

from collections import namedtuple, Counter
from os.path import commonprefix

__unittest = True

_MAX_LENGTH = 80
_PLACEHOLDER_LEN = 12
_MIN_BEGIN_LEN = 5
_MIN_END_LEN = 5
_MIN_COMMON_LEN = 5
_MIN_DIFF_LEN = _MAX_LENGTH - \
               (_MIN_BEGIN_LEN + _PLACEHOLDER_LEN + _MIN_COMMON_LEN +
                _PLACEHOLDER_LEN + _MIN_END_LEN)
assert _MIN_DIFF_LEN >= 0

def _shorten(s, prefixlen, suffixlen):
    skip = len(s) - prefixlen - suffixlen
    if skip > _PLACEHOLDER_LEN:
        s = '%s[%d chars]%s' % (s[:prefixlen], skip, s[len(s) - suffixlen:])
    return s

def _common_shorten_repr(*args):
    args = tuple(map(safe_repr, args))
    maxlen = max(map(len, args))
    if maxlen <= _MAX_LENGTH:
        return args

    prefix = commonprefix(args)
    prefixlen = len(prefix)

    common_len = _MAX_LENGTH - \
                 (maxlen - prefixlen + _MIN_BEGIN_LEN + _PLACEHOLDER_LEN)
    if common_len > _MIN_COMMON_LEN:
        assert _MIN_BEGIN_LEN + _PLACEHOLDER_LEN + _MIN_COMMON_LEN + \
               (maxlen - prefixlen) < _MAX_LENGTH
        prefix = _shorten(prefix, _MIN_BEGIN_LEN, common_len)
        return tuple(prefix + s[prefixlen:] for s in args)

    prefix = _shorten(prefix, _MIN_BEGIN_LEN, _MIN_COMMON_LEN)
    return tuple(prefix + _shorten(s[prefixlen:], _MIN_DIFF_LEN, _MIN_END_LEN)
                 for s in args)

def safe_repr(obj, short=False):
    try:
        result = repr(obj)
    except Exception:
        result = object.__repr__(obj)
    if not short or len(result) < _MAX_LENGTH:
        return result
    return result[:_MAX_LENGTH] + ' [truncated]...'

def strclass(cls):
    return "%s.%s" % (cls.__module__, cls.__qualname__)

def sorted_list_difference(expected, actual):
    """Finds elements in only one or the other of two, sorted input lists.

    Returns a two-element tuple of lists.    The first list contains those
    elements in the "expected" list but not in the "actual" list, and the
    second contains those elements in the "actual" list but not in the
    "expected" list.    Duplicate elements in either input list are ignored.
    """
    i = j = 0
    missing = []
    unexpected = []
    while True:
        try:
            e = expected[i]
            a = actual[j]
            if e < a:
                missing.append(e)
                i += 1
                while expected[i] == e:
                    i += 1
            elif e > a:
                unexpected.append(a)
                j += 1
                while actual[j] == a:
                    j += 1
            else:
                i += 1
                try:
                    while expected[i] == e:
                        i += 1
                finally:
                    j += 1
                    while actual[j] == a:
                        j += 1
        except IndexError:
            missing.extend(expected[i:])
            unexpected.extend(actual[j:])
            break
    return missing, unexpected


def unorderable_list_difference(expected, actual):
    """Same behavior as sorted_list_difference but
    for lists of unorderable items (like dicts).

    As it does a linear search per item (remove) it
    has O(n*n) performance."""
    missing = []
    while expected:
        item = expected.pop()
        try:
            actual.remove(item)
        except ValueError:
            missing.append(item)

    # anything left in actual is unexpected
    return missing, actual

def three_way_cmp(x, y):
    """Return -1 if x < y, 0 if x == y and 1 if x > y"""
    return (x > y) - (x < y)

_Mismatch = namedtuple('Mismatch', 'actual expected value')

def _count_diff_all_purpose(actual, expected):
    'Returns list of (cnt_act, cnt_exp, elem) triples where the counts differ'
    # elements need not be hashable
    s, t = list(actual), list(expected)
    m, n = len(s), len(t)
    NULL = object()
    result = []
    for i, elem in enumerate(s):
        if elem is NULL:
            continue
        cnt_s = cnt_t = 0
        for j in range(i, m):
            if s[j] == elem:
                cnt_s += 1
                s[j] = NULL
        for j, other_elem in enumerate(t):
            if other_elem == elem:
                cnt_t += 1
                t[j] = NULL
        if cnt_s != cnt_t:
            diff = _Mismatch(cnt_s, cnt_t, elem)
            result.append(diff)

    for i, elem in enumerate(t):
        if elem is NULL:
            continue
        cnt_t = 0
        for j in range(i, n):
            if t[j] == elem:
                cnt_t += 1
                t[j] = NULL
        diff = _Mismatch(0, cnt_t, elem)
        result.append(diff)
    return result

def _count_diff_hashable(actual, expected):
    'Returns list of (cnt_act, cnt_exp, elem) triples where the counts differ'
    # elements must be hashable
    s, t = Counter(actual), Counter(expected)
    result = []
    for elem, cnt_s in s.items():
        cnt_t = t.get(elem, 0)
        if cnt_s != cnt_t:
            diff = _Mismatch(cnt_s, cnt_t, elem)
            result.append(diff)
    for elem, cnt_t in t.items():
        if elem not in s:
            diff = _Mismatch(0, cnt_t, elem)
            result.append(diff)
    return result
PK��[5V����case.pynu�[���"""Test case implementation"""

import sys
import functools
import difflib
import logging
import pprint
import re
import warnings
import collections
import contextlib
import traceback
import types

from . import result
from .util import (strclass, safe_repr, _count_diff_all_purpose,
                   _count_diff_hashable, _common_shorten_repr)

__unittest = True

_subtest_msg_sentinel = object()

DIFF_OMITTED = ('\nDiff is %s characters long. '
                 'Set self.maxDiff to None to see it.')

class SkipTest(Exception):
    """
    Raise this exception in a test to skip it.

    Usually you can use TestCase.skipTest() or one of the skipping decorators
    instead of raising this directly.
    """

class _ShouldStop(Exception):
    """
    The test should stop.
    """

class _UnexpectedSuccess(Exception):
    """
    The test was supposed to fail, but it didn't!
    """


class _Outcome(object):
    def __init__(self, result=None):
        self.expecting_failure = False
        self.result = result
        self.result_supports_subtests = hasattr(result, "addSubTest")
        self.success = True
        self.skipped = []
        self.expectedFailure = None
        self.errors = []

    @contextlib.contextmanager
    def testPartExecutor(self, test_case, isTest=False):
        old_success = self.success
        self.success = True
        try:
            yield
        except KeyboardInterrupt:
            raise
        except SkipTest as e:
            self.success = False
            self.skipped.append((test_case, str(e)))
        except _ShouldStop:
            pass
        except:
            exc_info = sys.exc_info()
            if self.expecting_failure:
                self.expectedFailure = exc_info
            else:
                self.success = False
                self.errors.append((test_case, exc_info))
            # explicitly break a reference cycle:
            # exc_info -> frame -> exc_info
            exc_info = None
        else:
            if self.result_supports_subtests and self.success:
                self.errors.append((test_case, None))
        finally:
            self.success = self.success and old_success


def _id(obj):
    return obj


_module_cleanups = []
def addModuleCleanup(function, /, *args, **kwargs):
    """Same as addCleanup, except the cleanup items are called even if
    setUpModule fails (unlike tearDownModule)."""
    _module_cleanups.append((function, args, kwargs))


def doModuleCleanups():
    """Execute all module cleanup functions. Normally called for you after
    tearDownModule."""
    exceptions = []
    while _module_cleanups:
        function, args, kwargs = _module_cleanups.pop()
        try:
            function(*args, **kwargs)
        except Exception as exc:
            exceptions.append(exc)
    if exceptions:
        # Swallows all but first exception. If a multi-exception handler
        # gets written we should use that here instead.
        raise exceptions[0]


def skip(reason):
    """
    Unconditionally skip a test.
    """
    def decorator(test_item):
        if not isinstance(test_item, type):
            @functools.wraps(test_item)
            def skip_wrapper(*args, **kwargs):
                raise SkipTest(reason)
            test_item = skip_wrapper

        test_item.__unittest_skip__ = True
        test_item.__unittest_skip_why__ = reason
        return test_item
    if isinstance(reason, types.FunctionType):
        test_item = reason
        reason = ''
        return decorator(test_item)
    return decorator

def skipIf(condition, reason):
    """
    Skip a test if the condition is true.
    """
    if condition:
        return skip(reason)
    return _id

def skipUnless(condition, reason):
    """
    Skip a test unless the condition is true.
    """
    if not condition:
        return skip(reason)
    return _id

def expectedFailure(test_item):
    test_item.__unittest_expecting_failure__ = True
    return test_item

def _is_subtype(expected, basetype):
    if isinstance(expected, tuple):
        return all(_is_subtype(e, basetype) for e in expected)
    return isinstance(expected, type) and issubclass(expected, basetype)

class _BaseTestCaseContext:

    def __init__(self, test_case):
        self.test_case = test_case

    def _raiseFailure(self, standardMsg):
        msg = self.test_case._formatMessage(self.msg, standardMsg)
        raise self.test_case.failureException(msg)

class _AssertRaisesBaseContext(_BaseTestCaseContext):

    def __init__(self, expected, test_case, expected_regex=None):
        _BaseTestCaseContext.__init__(self, test_case)
        self.expected = expected
        self.test_case = test_case
        if expected_regex is not None:
            expected_regex = re.compile(expected_regex)
        self.expected_regex = expected_regex
        self.obj_name = None
        self.msg = None

    def handle(self, name, args, kwargs):
        """
        If args is empty, assertRaises/Warns is being used as a
        context manager, so check for a 'msg' kwarg and return self.
        If args is not empty, call a callable passing positional and keyword
        arguments.
        """
        try:
            if not _is_subtype(self.expected, self._base_type):
                raise TypeError('%s() arg 1 must be %s' %
                                (name, self._base_type_str))
            if not args:
                self.msg = kwargs.pop('msg', None)
                if kwargs:
                    raise TypeError('%r is an invalid keyword argument for '
                                    'this function' % (next(iter(kwargs)),))
                return self

            callable_obj, *args = args
            try:
                self.obj_name = callable_obj.__name__
            except AttributeError:
                self.obj_name = str(callable_obj)
            with self:
                callable_obj(*args, **kwargs)
        finally:
            # bpo-23890: manually break a reference cycle
            self = None


class _AssertRaisesContext(_AssertRaisesBaseContext):
    """A context manager used to implement TestCase.assertRaises* methods."""

    _base_type = BaseException
    _base_type_str = 'an exception type or tuple of exception types'

    def __enter__(self):
        return self

    def __exit__(self, exc_type, exc_value, tb):
        if exc_type is None:
            try:
                exc_name = self.expected.__name__
            except AttributeError:
                exc_name = str(self.expected)
            if self.obj_name:
                self._raiseFailure("{} not raised by {}".format(exc_name,
                                                                self.obj_name))
            else:
                self._raiseFailure("{} not raised".format(exc_name))
        else:
            traceback.clear_frames(tb)
        if not issubclass(exc_type, self.expected):
            # let unexpected exceptions pass through
            return False
        # store exception, without traceback, for later retrieval
        self.exception = exc_value.with_traceback(None)
        if self.expected_regex is None:
            return True

        expected_regex = self.expected_regex
        if not expected_regex.search(str(exc_value)):
            self._raiseFailure('"{}" does not match "{}"'.format(
                     expected_regex.pattern, str(exc_value)))
        return True


class _AssertWarnsContext(_AssertRaisesBaseContext):
    """A context manager used to implement TestCase.assertWarns* methods."""

    _base_type = Warning
    _base_type_str = 'a warning type or tuple of warning types'

    def __enter__(self):
        # The __warningregistry__'s need to be in a pristine state for tests
        # to work properly.
        for v in list(sys.modules.values()):
            if getattr(v, '__warningregistry__', None):
                v.__warningregistry__ = {}
        self.warnings_manager = warnings.catch_warnings(record=True)
        self.warnings = self.warnings_manager.__enter__()
        warnings.simplefilter("always", self.expected)
        return self

    def __exit__(self, exc_type, exc_value, tb):
        self.warnings_manager.__exit__(exc_type, exc_value, tb)
        if exc_type is not None:
            # let unexpected exceptions pass through
            return
        try:
            exc_name = self.expected.__name__
        except AttributeError:
            exc_name = str(self.expected)
        first_matching = None
        for m in self.warnings:
            w = m.message
            if not isinstance(w, self.expected):
                continue
            if first_matching is None:
                first_matching = w
            if (self.expected_regex is not None and
                not self.expected_regex.search(str(w))):
                continue
            # store warning for later retrieval
            self.warning = w
            self.filename = m.filename
            self.lineno = m.lineno
            return
        # Now we simply try to choose a helpful failure message
        if first_matching is not None:
            self._raiseFailure('"{}" does not match "{}"'.format(
                     self.expected_regex.pattern, str(first_matching)))
        if self.obj_name:
            self._raiseFailure("{} not triggered by {}".format(exc_name,
                                                               self.obj_name))
        else:
            self._raiseFailure("{} not triggered".format(exc_name))



_LoggingWatcher = collections.namedtuple("_LoggingWatcher",
                                         ["records", "output"])


class _CapturingHandler(logging.Handler):
    """
    A logging handler capturing all (raw and formatted) logging output.
    """

    def __init__(self):
        logging.Handler.__init__(self)
        self.watcher = _LoggingWatcher([], [])

    def flush(self):
        pass

    def emit(self, record):
        self.watcher.records.append(record)
        msg = self.format(record)
        self.watcher.output.append(msg)



class _AssertLogsContext(_BaseTestCaseContext):
    """A context manager used to implement TestCase.assertLogs()."""

    LOGGING_FORMAT = "%(levelname)s:%(name)s:%(message)s"

    def __init__(self, test_case, logger_name, level):
        _BaseTestCaseContext.__init__(self, test_case)
        self.logger_name = logger_name
        if level:
            self.level = logging._nameToLevel.get(level, level)
        else:
            self.level = logging.INFO
        self.msg = None

    def __enter__(self):
        if isinstance(self.logger_name, logging.Logger):
            logger = self.logger = self.logger_name
        else:
            logger = self.logger = logging.getLogger(self.logger_name)
        formatter = logging.Formatter(self.LOGGING_FORMAT)
        handler = _CapturingHandler()
        handler.setFormatter(formatter)
        self.watcher = handler.watcher
        self.old_handlers = logger.handlers[:]
        self.old_level = logger.level
        self.old_propagate = logger.propagate
        logger.handlers = [handler]
        logger.setLevel(self.level)
        logger.propagate = False
        return handler.watcher

    def __exit__(self, exc_type, exc_value, tb):
        self.logger.handlers = self.old_handlers
        self.logger.propagate = self.old_propagate
        self.logger.setLevel(self.old_level)
        if exc_type is not None:
            # let unexpected exceptions pass through
            return False
        if len(self.watcher.records) == 0:
            self._raiseFailure(
                "no logs of level {} or higher triggered on {}"
                .format(logging.getLevelName(self.level), self.logger.name))


class _OrderedChainMap(collections.ChainMap):
    def __iter__(self):
        seen = set()
        for mapping in self.maps:
            for k in mapping:
                if k not in seen:
                    seen.add(k)
                    yield k


class TestCase(object):
    """A class whose instances are single test cases.

    By default, the test code itself should be placed in a method named
    'runTest'.

    If the fixture may be used for many test cases, create as
    many test methods as are needed. When instantiating such a TestCase
    subclass, specify in the constructor arguments the name of the test method
    that the instance is to execute.

    Test authors should subclass TestCase for their own tests. Construction
    and deconstruction of the test's environment ('fixture') can be
    implemented by overriding the 'setUp' and 'tearDown' methods respectively.

    If it is necessary to override the __init__ method, the base class
    __init__ method must always be called. It is important that subclasses
    should not change the signature of their __init__ method, since instances
    of the classes are instantiated automatically by parts of the framework
    in order to be run.

    When subclassing TestCase, you can set these attributes:
    * failureException: determines which exception will be raised when
        the instance's assertion methods fail; test methods raising this
        exception will be deemed to have 'failed' rather than 'errored'.
    * longMessage: determines whether long messages (including repr of
        objects used in assert methods) will be printed on failure in *addition*
        to any explicit message passed.
    * maxDiff: sets the maximum length of a diff in failure messages
        by assert methods using difflib. It is looked up as an instance
        attribute so can be configured by individual tests if required.
    """

    failureException = AssertionError

    longMessage = True

    maxDiff = 80*8

    # If a string is longer than _diffThreshold, use normal comparison instead
    # of difflib.  See #11763.
    _diffThreshold = 2**16

    # Attribute used by TestSuite for classSetUp

    _classSetupFailed = False

    _class_cleanups = []

    def __init__(self, methodName='runTest'):
        """Create an instance of the class that will use the named test
           method when executed. Raises a ValueError if the instance does
           not have a method with the specified name.
        """
        self._testMethodName = methodName
        self._outcome = None
        self._testMethodDoc = 'No test'
        try:
            testMethod = getattr(self, methodName)
        except AttributeError:
            if methodName != 'runTest':
                # we allow instantiation with no explicit method name
                # but not an *incorrect* or missing method name
                raise ValueError("no such test method in %s: %s" %
                      (self.__class__, methodName))
        else:
            self._testMethodDoc = testMethod.__doc__
        self._cleanups = []
        self._subtest = None

        # Map types to custom assertEqual functions that will compare
        # instances of said type in more detail to generate a more useful
        # error message.
        self._type_equality_funcs = {}
        self.addTypeEqualityFunc(dict, 'assertDictEqual')
        self.addTypeEqualityFunc(list, 'assertListEqual')
        self.addTypeEqualityFunc(tuple, 'assertTupleEqual')
        self.addTypeEqualityFunc(set, 'assertSetEqual')
        self.addTypeEqualityFunc(frozenset, 'assertSetEqual')
        self.addTypeEqualityFunc(str, 'assertMultiLineEqual')

    def addTypeEqualityFunc(self, typeobj, function):
        """Add a type specific assertEqual style function to compare a type.

        This method is for use by TestCase subclasses that need to register
        their own type equality functions to provide nicer error messages.

        Args:
            typeobj: The data type to call this function on when both values
                    are of the same type in assertEqual().
            function: The callable taking two arguments and an optional
                    msg= argument that raises self.failureException with a
                    useful error message when the two arguments are not equal.
        """
        self._type_equality_funcs[typeobj] = function

    def addCleanup(*args, **kwargs):
        """Add a function, with arguments, to be called when the test is
        completed. Functions added are called on a LIFO basis and are
        called after tearDown on test failure or success.

        Cleanup items are called even if setUp fails (unlike tearDown)."""
        if len(args) >= 2:
            self, function, *args = args
        elif not args:
            raise TypeError("descriptor 'addCleanup' of 'TestCase' object "
                            "needs an argument")
        elif 'function' in kwargs:
            function = kwargs.pop('function')
            self, *args = args
            import warnings
            warnings.warn("Passing 'function' as keyword argument is deprecated",
                          DeprecationWarning, stacklevel=2)
        else:
            raise TypeError('addCleanup expected at least 1 positional '
                            'argument, got %d' % (len(args)-1))
        args = tuple(args)

        self._cleanups.append((function, args, kwargs))
    addCleanup.__text_signature__ = '($self, function, /, *args, **kwargs)'

    @classmethod
    def addClassCleanup(cls, function, /, *args, **kwargs):
        """Same as addCleanup, except the cleanup items are called even if
        setUpClass fails (unlike tearDownClass)."""
        cls._class_cleanups.append((function, args, kwargs))

    def setUp(self):
        "Hook method for setting up the test fixture before exercising it."
        pass

    def tearDown(self):
        "Hook method for deconstructing the test fixture after testing it."
        pass

    @classmethod
    def setUpClass(cls):
        "Hook method for setting up class fixture before running tests in the class."

    @classmethod
    def tearDownClass(cls):
        "Hook method for deconstructing the class fixture after running all tests in the class."

    def countTestCases(self):
        return 1

    def defaultTestResult(self):
        return result.TestResult()

    def shortDescription(self):
        """Returns a one-line description of the test, or None if no
        description has been provided.

        The default implementation of this method returns the first line of
        the specified test method's docstring.
        """
        doc = self._testMethodDoc
        return doc.strip().split("\n")[0].strip() if doc else None


    def id(self):
        return "%s.%s" % (strclass(self.__class__), self._testMethodName)

    def __eq__(self, other):
        if type(self) is not type(other):
            return NotImplemented

        return self._testMethodName == other._testMethodName

    def __hash__(self):
        return hash((type(self), self._testMethodName))

    def __str__(self):
        return "%s (%s)" % (self._testMethodName, strclass(self.__class__))

    def __repr__(self):
        return "<%s testMethod=%s>" % \
               (strclass(self.__class__), self._testMethodName)

    def _addSkip(self, result, test_case, reason):
        addSkip = getattr(result, 'addSkip', None)
        if addSkip is not None:
            addSkip(test_case, reason)
        else:
            warnings.warn("TestResult has no addSkip method, skips not reported",
                          RuntimeWarning, 2)
            result.addSuccess(test_case)

    @contextlib.contextmanager
    def subTest(self, msg=_subtest_msg_sentinel, **params):
        """Return a context manager that will return the enclosed block
        of code in a subtest identified by the optional message and
        keyword parameters.  A failure in the subtest marks the test
        case as failed but resumes execution at the end of the enclosed
        block, allowing further test code to be executed.
        """
        if self._outcome is None or not self._outcome.result_supports_subtests:
            yield
            return
        parent = self._subtest
        if parent is None:
            params_map = _OrderedChainMap(params)
        else:
            params_map = parent.params.new_child(params)
        self._subtest = _SubTest(self, msg, params_map)
        try:
            with self._outcome.testPartExecutor(self._subtest, isTest=True):
                yield
            if not self._outcome.success:
                result = self._outcome.result
                if result is not None and result.failfast:
                    raise _ShouldStop
            elif self._outcome.expectedFailure:
                # If the test is expecting a failure, we really want to
                # stop now and register the expected failure.
                raise _ShouldStop
        finally:
            self._subtest = parent

    def _feedErrorsToResult(self, result, errors):
        for test, exc_info in errors:
            if isinstance(test, _SubTest):
                result.addSubTest(test.test_case, test, exc_info)
            elif exc_info is not None:
                if issubclass(exc_info[0], self.failureException):
                    result.addFailure(test, exc_info)
                else:
                    result.addError(test, exc_info)

    def _addExpectedFailure(self, result, exc_info):
        try:
            addExpectedFailure = result.addExpectedFailure
        except AttributeError:
            warnings.warn("TestResult has no addExpectedFailure method, reporting as passes",
                          RuntimeWarning)
            result.addSuccess(self)
        else:
            addExpectedFailure(self, exc_info)

    def _addUnexpectedSuccess(self, result):
        try:
            addUnexpectedSuccess = result.addUnexpectedSuccess
        except AttributeError:
            warnings.warn("TestResult has no addUnexpectedSuccess method, reporting as failure",
                          RuntimeWarning)
            # We need to pass an actual exception and traceback to addFailure,
            # otherwise the legacy result can choke.
            try:
                raise _UnexpectedSuccess from None
            except _UnexpectedSuccess:
                result.addFailure(self, sys.exc_info())
        else:
            addUnexpectedSuccess(self)

    def _callSetUp(self):
        self.setUp()

    def _callTestMethod(self, method):
        method()

    def _callTearDown(self):
        self.tearDown()

    def _callCleanup(self, function, /, *args, **kwargs):
        function(*args, **kwargs)

    def run(self, result=None):
        orig_result = result
        if result is None:
            result = self.defaultTestResult()
            startTestRun = getattr(result, 'startTestRun', None)
            if startTestRun is not None:
                startTestRun()

        result.startTest(self)

        testMethod = getattr(self, self._testMethodName)
        if (getattr(self.__class__, "__unittest_skip__", False) or
            getattr(testMethod, "__unittest_skip__", False)):
            # If the class or method was skipped.
            try:
                skip_why = (getattr(self.__class__, '__unittest_skip_why__', '')
                            or getattr(testMethod, '__unittest_skip_why__', ''))
                self._addSkip(result, self, skip_why)
            finally:
                result.stopTest(self)
            return
        expecting_failure_method = getattr(testMethod,
                                           "__unittest_expecting_failure__", False)
        expecting_failure_class = getattr(self,
                                          "__unittest_expecting_failure__", False)
        expecting_failure = expecting_failure_class or expecting_failure_method
        outcome = _Outcome(result)
        try:
            self._outcome = outcome

            with outcome.testPartExecutor(self):
                self._callSetUp()
            if outcome.success:
                outcome.expecting_failure = expecting_failure
                with outcome.testPartExecutor(self, isTest=True):
                    self._callTestMethod(testMethod)
                outcome.expecting_failure = False
                with outcome.testPartExecutor(self):
                    self._callTearDown()

            self.doCleanups()
            for test, reason in outcome.skipped:
                self._addSkip(result, test, reason)
            self._feedErrorsToResult(result, outcome.errors)
            if outcome.success:
                if expecting_failure:
                    if outcome.expectedFailure:
                        self._addExpectedFailure(result, outcome.expectedFailure)
                    else:
                        self._addUnexpectedSuccess(result)
                else:
                    result.addSuccess(self)
            return result
        finally:
            result.stopTest(self)
            if orig_result is None:
                stopTestRun = getattr(result, 'stopTestRun', None)
                if stopTestRun is not None:
                    stopTestRun()

            # explicitly break reference cycles:
            # outcome.errors -> frame -> outcome -> outcome.errors
            # outcome.expectedFailure -> frame -> outcome -> outcome.expectedFailure
            outcome.errors.clear()
            outcome.expectedFailure = None

            # clear the outcome, no more needed
            self._outcome = None

    def doCleanups(self):
        """Execute all cleanup functions. Normally called for you after
        tearDown."""
        outcome = self._outcome or _Outcome()
        while self._cleanups:
            function, args, kwargs = self._cleanups.pop()
            with outcome.testPartExecutor(self):
                self._callCleanup(function, *args, **kwargs)

        # return this for backwards compatibility
        # even though we no longer use it internally
        return outcome.success

    @classmethod
    def doClassCleanups(cls):
        """Execute all class cleanup functions. Normally called for you after
        tearDownClass."""
        cls.tearDown_exceptions = []
        while cls._class_cleanups:
            function, args, kwargs = cls._class_cleanups.pop()
            try:
                function(*args, **kwargs)
            except Exception as exc:
                cls.tearDown_exceptions.append(sys.exc_info())

    def __call__(self, *args, **kwds):
        return self.run(*args, **kwds)

    def debug(self):
        """Run the test without collecting errors in a TestResult"""
        self.setUp()
        getattr(self, self._testMethodName)()
        self.tearDown()
        while self._cleanups:
            function, args, kwargs = self._cleanups.pop(-1)
            function(*args, **kwargs)

    def skipTest(self, reason):
        """Skip this test."""
        raise SkipTest(reason)

    def fail(self, msg=None):
        """Fail immediately, with the given message."""
        raise self.failureException(msg)

    def assertFalse(self, expr, msg=None):
        """Check that the expression is false."""
        if expr:
            msg = self._formatMessage(msg, "%s is not false" % safe_repr(expr))
            raise self.failureException(msg)

    def assertTrue(self, expr, msg=None):
        """Check that the expression is true."""
        if not expr:
            msg = self._formatMessage(msg, "%s is not true" % safe_repr(expr))
            raise self.failureException(msg)

    def _formatMessage(self, msg, standardMsg):
        """Honour the longMessage attribute when generating failure messages.
        If longMessage is False this means:
        * Use only an explicit message if it is provided
        * Otherwise use the standard message for the assert

        If longMessage is True:
        * Use the standard message
        * If an explicit message is provided, plus ' : ' and the explicit message
        """
        if not self.longMessage:
            return msg or standardMsg
        if msg is None:
            return standardMsg
        try:
            # don't switch to '{}' formatting in Python 2.X
            # it changes the way unicode input is handled
            return '%s : %s' % (standardMsg, msg)
        except UnicodeDecodeError:
            return  '%s : %s' % (safe_repr(standardMsg), safe_repr(msg))

    def assertRaises(self, expected_exception, *args, **kwargs):
        """Fail unless an exception of class expected_exception is raised
           by the callable when invoked with specified positional and
           keyword arguments. If a different type of exception is
           raised, it will not be caught, and the test case will be
           deemed to have suffered an error, exactly as for an
           unexpected exception.

           If called with the callable and arguments omitted, will return a
           context object used like this::

                with self.assertRaises(SomeException):
                    do_something()

           An optional keyword argument 'msg' can be provided when assertRaises
           is used as a context object.

           The context manager keeps a reference to the exception as
           the 'exception' attribute. This allows you to inspect the
           exception after the assertion::

               with self.assertRaises(SomeException) as cm:
                   do_something()
               the_exception = cm.exception
               self.assertEqual(the_exception.error_code, 3)
        """
        context = _AssertRaisesContext(expected_exception, self)
        try:
            return context.handle('assertRaises', args, kwargs)
        finally:
            # bpo-23890: manually break a reference cycle
            context = None

    def assertWarns(self, expected_warning, *args, **kwargs):
        """Fail unless a warning of class warnClass is triggered
           by the callable when invoked with specified positional and
           keyword arguments.  If a different type of warning is
           triggered, it will not be handled: depending on the other
           warning filtering rules in effect, it might be silenced, printed
           out, or raised as an exception.

           If called with the callable and arguments omitted, will return a
           context object used like this::

                with self.assertWarns(SomeWarning):
                    do_something()

           An optional keyword argument 'msg' can be provided when assertWarns
           is used as a context object.

           The context manager keeps a reference to the first matching
           warning as the 'warning' attribute; similarly, the 'filename'
           and 'lineno' attributes give you information about the line
           of Python code from which the warning was triggered.
           This allows you to inspect the warning after the assertion::

               with self.assertWarns(SomeWarning) as cm:
                   do_something()
               the_warning = cm.warning
               self.assertEqual(the_warning.some_attribute, 147)
        """
        context = _AssertWarnsContext(expected_warning, self)
        return context.handle('assertWarns', args, kwargs)

    def assertLogs(self, logger=None, level=None):
        """Fail unless a log message of level *level* or higher is emitted
        on *logger_name* or its children.  If omitted, *level* defaults to
        INFO and *logger* defaults to the root logger.

        This method must be used as a context manager, and will yield
        a recording object with two attributes: `output` and `records`.
        At the end of the context manager, the `output` attribute will
        be a list of the matching formatted log messages and the
        `records` attribute will be a list of the corresponding LogRecord
        objects.

        Example::

            with self.assertLogs('foo', level='INFO') as cm:
                logging.getLogger('foo').info('first message')
                logging.getLogger('foo.bar').error('second message')
            self.assertEqual(cm.output, ['INFO:foo:first message',
                                         'ERROR:foo.bar:second message'])
        """
        return _AssertLogsContext(self, logger, level)

    def _getAssertEqualityFunc(self, first, second):
        """Get a detailed comparison function for the types of the two args.

        Returns: A callable accepting (first, second, msg=None) that will
        raise a failure exception if first != second with a useful human
        readable error message for those types.
        """
        #
        # NOTE(gregory.p.smith): I considered isinstance(first, type(second))
        # and vice versa.  I opted for the conservative approach in case
        # subclasses are not intended to be compared in detail to their super
        # class instances using a type equality func.  This means testing
        # subtypes won't automagically use the detailed comparison.  Callers
        # should use their type specific assertSpamEqual method to compare
        # subclasses if the detailed comparison is desired and appropriate.
        # See the discussion in http://bugs.python.org/issue2578.
        #
        if type(first) is type(second):
            asserter = self._type_equality_funcs.get(type(first))
            if asserter is not None:
                if isinstance(asserter, str):
                    asserter = getattr(self, asserter)
                return asserter

        return self._baseAssertEqual

    def _baseAssertEqual(self, first, second, msg=None):
        """The default assertEqual implementation, not type specific."""
        if not first == second:
            standardMsg = '%s != %s' % _common_shorten_repr(first, second)
            msg = self._formatMessage(msg, standardMsg)
            raise self.failureException(msg)

    def assertEqual(self, first, second, msg=None):
        """Fail if the two objects are unequal as determined by the '=='
           operator.
        """
        assertion_func = self._getAssertEqualityFunc(first, second)
        assertion_func(first, second, msg=msg)

    def assertNotEqual(self, first, second, msg=None):
        """Fail if the two objects are equal as determined by the '!='
           operator.
        """
        if not first != second:
            msg = self._formatMessage(msg, '%s == %s' % (safe_repr(first),
                                                          safe_repr(second)))
            raise self.failureException(msg)

    def assertAlmostEqual(self, first, second, places=None, msg=None,
                          delta=None):
        """Fail if the two objects are unequal as determined by their
           difference rounded to the given number of decimal places
           (default 7) and comparing to zero, or by comparing that the
           difference between the two objects is more than the given
           delta.

           Note that decimal places (from zero) are usually not the same
           as significant digits (measured from the most significant digit).

           If the two objects compare equal then they will automatically
           compare almost equal.
        """
        if first == second:
            # shortcut
            return
        if delta is not None and places is not None:
            raise TypeError("specify delta or places not both")

        diff = abs(first - second)
        if delta is not None:
            if diff <= delta:
                return

            standardMsg = '%s != %s within %s delta (%s difference)' % (
                safe_repr(first),
                safe_repr(second),
                safe_repr(delta),
                safe_repr(diff))
        else:
            if places is None:
                places = 7

            if round(diff, places) == 0:
                return

            standardMsg = '%s != %s within %r places (%s difference)' % (
                safe_repr(first),
                safe_repr(second),
                places,
                safe_repr(diff))
        msg = self._formatMessage(msg, standardMsg)
        raise self.failureException(msg)

    def assertNotAlmostEqual(self, first, second, places=None, msg=None,
                             delta=None):
        """Fail if the two objects are equal as determined by their
           difference rounded to the given number of decimal places
           (default 7) and comparing to zero, or by comparing that the
           difference between the two objects is less than the given delta.

           Note that decimal places (from zero) are usually not the same
           as significant digits (measured from the most significant digit).

           Objects that are equal automatically fail.
        """
        if delta is not None and places is not None:
            raise TypeError("specify delta or places not both")
        diff = abs(first - second)
        if delta is not None:
            if not (first == second) and diff > delta:
                return
            standardMsg = '%s == %s within %s delta (%s difference)' % (
                safe_repr(first),
                safe_repr(second),
                safe_repr(delta),
                safe_repr(diff))
        else:
            if places is None:
                places = 7
            if not (first == second) and round(diff, places) != 0:
                return
            standardMsg = '%s == %s within %r places' % (safe_repr(first),
                                                         safe_repr(second),
                                                         places)

        msg = self._formatMessage(msg, standardMsg)
        raise self.failureException(msg)

    def assertSequenceEqual(self, seq1, seq2, msg=None, seq_type=None):
        """An equality assertion for ordered sequences (like lists and tuples).

        For the purposes of this function, a valid ordered sequence type is one
        which can be indexed, has a length, and has an equality operator.

        Args:
            seq1: The first sequence to compare.
            seq2: The second sequence to compare.
            seq_type: The expected datatype of the sequences, or None if no
                    datatype should be enforced.
            msg: Optional message to use on failure instead of a list of
                    differences.
        """
        if seq_type is not None:
            seq_type_name = seq_type.__name__
            if not isinstance(seq1, seq_type):
                raise self.failureException('First sequence is not a %s: %s'
                                        % (seq_type_name, safe_repr(seq1)))
            if not isinstance(seq2, seq_type):
                raise self.failureException('Second sequence is not a %s: %s'
                                        % (seq_type_name, safe_repr(seq2)))
        else:
            seq_type_name = "sequence"

        differing = None
        try:
            len1 = len(seq1)
        except (TypeError, NotImplementedError):
            differing = 'First %s has no length.    Non-sequence?' % (
                    seq_type_name)

        if differing is None:
            try:
                len2 = len(seq2)
            except (TypeError, NotImplementedError):
                differing = 'Second %s has no length.    Non-sequence?' % (
                        seq_type_name)

        if differing is None:
            if seq1 == seq2:
                return

            differing = '%ss differ: %s != %s\n' % (
                    (seq_type_name.capitalize(),) +
                    _common_shorten_repr(seq1, seq2))

            for i in range(min(len1, len2)):
                try:
                    item1 = seq1[i]
                except (TypeError, IndexError, NotImplementedError):
                    differing += ('\nUnable to index element %d of first %s\n' %
                                 (i, seq_type_name))
                    break

                try:
                    item2 = seq2[i]
                except (TypeError, IndexError, NotImplementedError):
                    differing += ('\nUnable to index element %d of second %s\n' %
                                 (i, seq_type_name))
                    break

                if item1 != item2:
                    differing += ('\nFirst differing element %d:\n%s\n%s\n' %
                                 ((i,) + _common_shorten_repr(item1, item2)))
                    break
            else:
                if (len1 == len2 and seq_type is None and
                    type(seq1) != type(seq2)):
                    # The sequences are the same, but have differing types.
                    return

            if len1 > len2:
                differing += ('\nFirst %s contains %d additional '
                             'elements.\n' % (seq_type_name, len1 - len2))
                try:
                    differing += ('First extra element %d:\n%s\n' %
                                  (len2, safe_repr(seq1[len2])))
                except (TypeError, IndexError, NotImplementedError):
                    differing += ('Unable to index element %d '
                                  'of first %s\n' % (len2, seq_type_name))
            elif len1 < len2:
                differing += ('\nSecond %s contains %d additional '
                             'elements.\n' % (seq_type_name, len2 - len1))
                try:
                    differing += ('First extra element %d:\n%s\n' %
                                  (len1, safe_repr(seq2[len1])))
                except (TypeError, IndexError, NotImplementedError):
                    differing += ('Unable to index element %d '
                                  'of second %s\n' % (len1, seq_type_name))
        standardMsg = differing
        diffMsg = '\n' + '\n'.join(
            difflib.ndiff(pprint.pformat(seq1).splitlines(),
                          pprint.pformat(seq2).splitlines()))

        standardMsg = self._truncateMessage(standardMsg, diffMsg)
        msg = self._formatMessage(msg, standardMsg)
        self.fail(msg)

    def _truncateMessage(self, message, diff):
        max_diff = self.maxDiff
        if max_diff is None or len(diff) <= max_diff:
            return message + diff
        return message + (DIFF_OMITTED % len(diff))

    def assertListEqual(self, list1, list2, msg=None):
        """A list-specific equality assertion.

        Args:
            list1: The first list to compare.
            list2: The second list to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.

        """
        self.assertSequenceEqual(list1, list2, msg, seq_type=list)

    def assertTupleEqual(self, tuple1, tuple2, msg=None):
        """A tuple-specific equality assertion.

        Args:
            tuple1: The first tuple to compare.
            tuple2: The second tuple to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.
        """
        self.assertSequenceEqual(tuple1, tuple2, msg, seq_type=tuple)

    def assertSetEqual(self, set1, set2, msg=None):
        """A set-specific equality assertion.

        Args:
            set1: The first set to compare.
            set2: The second set to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.

        assertSetEqual uses ducktyping to support different types of sets, and
        is optimized for sets specifically (parameters must support a
        difference method).
        """
        try:
            difference1 = set1.difference(set2)
        except TypeError as e:
            self.fail('invalid type when attempting set difference: %s' % e)
        except AttributeError as e:
            self.fail('first argument does not support set difference: %s' % e)

        try:
            difference2 = set2.difference(set1)
        except TypeError as e:
            self.fail('invalid type when attempting set difference: %s' % e)
        except AttributeError as e:
            self.fail('second argument does not support set difference: %s' % e)

        if not (difference1 or difference2):
            return

        lines = []
        if difference1:
            lines.append('Items in the first set but not the second:')
            for item in difference1:
                lines.append(repr(item))
        if difference2:
            lines.append('Items in the second set but not the first:')
            for item in difference2:
                lines.append(repr(item))

        standardMsg = '\n'.join(lines)
        self.fail(self._formatMessage(msg, standardMsg))

    def assertIn(self, member, container, msg=None):
        """Just like self.assertTrue(a in b), but with a nicer default message."""
        if member not in container:
            standardMsg = '%s not found in %s' % (safe_repr(member),
                                                  safe_repr(container))
            self.fail(self._formatMessage(msg, standardMsg))

    def assertNotIn(self, member, container, msg=None):
        """Just like self.assertTrue(a not in b), but with a nicer default message."""
        if member in container:
            standardMsg = '%s unexpectedly found in %s' % (safe_repr(member),
                                                        safe_repr(container))
            self.fail(self._formatMessage(msg, standardMsg))

    def assertIs(self, expr1, expr2, msg=None):
        """Just like self.assertTrue(a is b), but with a nicer default message."""
        if expr1 is not expr2:
            standardMsg = '%s is not %s' % (safe_repr(expr1),
                                             safe_repr(expr2))
            self.fail(self._formatMessage(msg, standardMsg))

    def assertIsNot(self, expr1, expr2, msg=None):
        """Just like self.assertTrue(a is not b), but with a nicer default message."""
        if expr1 is expr2:
            standardMsg = 'unexpectedly identical: %s' % (safe_repr(expr1),)
            self.fail(self._formatMessage(msg, standardMsg))

    def assertDictEqual(self, d1, d2, msg=None):
        self.assertIsInstance(d1, dict, 'First argument is not a dictionary')
        self.assertIsInstance(d2, dict, 'Second argument is not a dictionary')

        if d1 != d2:
            standardMsg = '%s != %s' % _common_shorten_repr(d1, d2)
            diff = ('\n' + '\n'.join(difflib.ndiff(
                           pprint.pformat(d1).splitlines(),
                           pprint.pformat(d2).splitlines())))
            standardMsg = self._truncateMessage(standardMsg, diff)
            self.fail(self._formatMessage(msg, standardMsg))

    def assertDictContainsSubset(self, subset, dictionary, msg=None):
        """Checks whether dictionary is a superset of subset."""
        warnings.warn('assertDictContainsSubset is deprecated',
                      DeprecationWarning)
        missing = []
        mismatched = []
        for key, value in subset.items():
            if key not in dictionary:
                missing.append(key)
            elif value != dictionary[key]:
                mismatched.append('%s, expected: %s, actual: %s' %
                                  (safe_repr(key), safe_repr(value),
                                   safe_repr(dictionary[key])))

        if not (missing or mismatched):
            return

        standardMsg = ''
        if missing:
            standardMsg = 'Missing: %s' % ','.join(safe_repr(m) for m in
                                                    missing)
        if mismatched:
            if standardMsg:
                standardMsg += '; '
            standardMsg += 'Mismatched values: %s' % ','.join(mismatched)

        self.fail(self._formatMessage(msg, standardMsg))


    def assertCountEqual(self, first, second, msg=None):
        """Asserts that two iterables have the same elements, the same number of
        times, without regard to order.

            self.assertEqual(Counter(list(first)),
                             Counter(list(second)))

         Example:
            - [0, 1, 1] and [1, 0, 1] compare equal.
            - [0, 0, 1] and [0, 1] compare unequal.

        """
        first_seq, second_seq = list(first), list(second)
        try:
            first = collections.Counter(first_seq)
            second = collections.Counter(second_seq)
        except TypeError:
            # Handle case with unhashable elements
            differences = _count_diff_all_purpose(first_seq, second_seq)
        else:
            if first == second:
                return
            differences = _count_diff_hashable(first_seq, second_seq)

        if differences:
            standardMsg = 'Element counts were not equal:\n'
            lines = ['First has %d, Second has %d:  %r' % diff for diff in differences]
            diffMsg = '\n'.join(lines)
            standardMsg = self._truncateMessage(standardMsg, diffMsg)
            msg = self._formatMessage(msg, standardMsg)
            self.fail(msg)

    def assertMultiLineEqual(self, first, second, msg=None):
        """Assert that two multi-line strings are equal."""
        self.assertIsInstance(first, str, 'First argument is not a string')
        self.assertIsInstance(second, str, 'Second argument is not a string')

        if first != second:
            # don't use difflib if the strings are too long
            if (len(first) > self._diffThreshold or
                len(second) > self._diffThreshold):
                self._baseAssertEqual(first, second, msg)
            firstlines = first.splitlines(keepends=True)
            secondlines = second.splitlines(keepends=True)
            if len(firstlines) == 1 and first.strip('\r\n') == first:
                firstlines = [first + '\n']
                secondlines = [second + '\n']
            standardMsg = '%s != %s' % _common_shorten_repr(first, second)
            diff = '\n' + ''.join(difflib.ndiff(firstlines, secondlines))
            standardMsg = self._truncateMessage(standardMsg, diff)
            self.fail(self._formatMessage(msg, standardMsg))

    def assertLess(self, a, b, msg=None):
        """Just like self.assertTrue(a < b), but with a nicer default message."""
        if not a < b:
            standardMsg = '%s not less than %s' % (safe_repr(a), safe_repr(b))
            self.fail(self._formatMessage(msg, standardMsg))

    def assertLessEqual(self, a, b, msg=None):
        """Just like self.assertTrue(a <= b), but with a nicer default message."""
        if not a <= b:
            standardMsg = '%s not less than or equal to %s' % (safe_repr(a), safe_repr(b))
            self.fail(self._formatMessage(msg, standardMsg))

    def assertGreater(self, a, b, msg=None):
        """Just like self.assertTrue(a > b), but with a nicer default message."""
        if not a > b:
            standardMsg = '%s not greater than %s' % (safe_repr(a), safe_repr(b))
            self.fail(self._formatMessage(msg, standardMsg))

    def assertGreaterEqual(self, a, b, msg=None):
        """Just like self.assertTrue(a >= b), but with a nicer default message."""
        if not a >= b:
            standardMsg = '%s not greater than or equal to %s' % (safe_repr(a), safe_repr(b))
            self.fail(self._formatMessage(msg, standardMsg))

    def assertIsNone(self, obj, msg=None):
        """Same as self.assertTrue(obj is None), with a nicer default message."""
        if obj is not None:
            standardMsg = '%s is not None' % (safe_repr(obj),)
            self.fail(self._formatMessage(msg, standardMsg))

    def assertIsNotNone(self, obj, msg=None):
        """Included for symmetry with assertIsNone."""
        if obj is None:
            standardMsg = 'unexpectedly None'
            self.fail(self._formatMessage(msg, standardMsg))

    def assertIsInstance(self, obj, cls, msg=None):
        """Same as self.assertTrue(isinstance(obj, cls)), with a nicer
        default message."""
        if not isinstance(obj, cls):
            standardMsg = '%s is not an instance of %r' % (safe_repr(obj), cls)
            self.fail(self._formatMessage(msg, standardMsg))

    def assertNotIsInstance(self, obj, cls, msg=None):
        """Included for symmetry with assertIsInstance."""
        if isinstance(obj, cls):
            standardMsg = '%s is an instance of %r' % (safe_repr(obj), cls)
            self.fail(self._formatMessage(msg, standardMsg))

    def assertRaisesRegex(self, expected_exception, expected_regex,
                          *args, **kwargs):
        """Asserts that the message in a raised exception matches a regex.

        Args:
            expected_exception: Exception class expected to be raised.
            expected_regex: Regex (re.Pattern object or string) expected
                    to be found in error message.
            args: Function to be called and extra positional args.
            kwargs: Extra kwargs.
            msg: Optional message used in case of failure. Can only be used
                    when assertRaisesRegex is used as a context manager.
        """
        context = _AssertRaisesContext(expected_exception, self, expected_regex)
        return context.handle('assertRaisesRegex', args, kwargs)

    def assertWarnsRegex(self, expected_warning, expected_regex,
                         *args, **kwargs):
        """Asserts that the message in a triggered warning matches a regexp.
        Basic functioning is similar to assertWarns() with the addition
        that only warnings whose messages also match the regular expression
        are considered successful matches.

        Args:
            expected_warning: Warning class expected to be triggered.
            expected_regex: Regex (re.Pattern object or string) expected
                    to be found in error message.
            args: Function to be called and extra positional args.
            kwargs: Extra kwargs.
            msg: Optional message used in case of failure. Can only be used
                    when assertWarnsRegex is used as a context manager.
        """
        context = _AssertWarnsContext(expected_warning, self, expected_regex)
        return context.handle('assertWarnsRegex', args, kwargs)

    def assertRegex(self, text, expected_regex, msg=None):
        """Fail the test unless the text matches the regular expression."""
        if isinstance(expected_regex, (str, bytes)):
            assert expected_regex, "expected_regex must not be empty."
            expected_regex = re.compile(expected_regex)
        if not expected_regex.search(text):
            standardMsg = "Regex didn't match: %r not found in %r" % (
                expected_regex.pattern, text)
            # _formatMessage ensures the longMessage option is respected
            msg = self._formatMessage(msg, standardMsg)
            raise self.failureException(msg)

    def assertNotRegex(self, text, unexpected_regex, msg=None):
        """Fail the test if the text matches the regular expression."""
        if isinstance(unexpected_regex, (str, bytes)):
            unexpected_regex = re.compile(unexpected_regex)
        match = unexpected_regex.search(text)
        if match:
            standardMsg = 'Regex matched: %r matches %r in %r' % (
                text[match.start() : match.end()],
                unexpected_regex.pattern,
                text)
            # _formatMessage ensures the longMessage option is respected
            msg = self._formatMessage(msg, standardMsg)
            raise self.failureException(msg)


    def _deprecate(original_func):
        def deprecated_func(*args, **kwargs):
            warnings.warn(
                'Please use {0} instead.'.format(original_func.__name__),
                DeprecationWarning, 2)
            return original_func(*args, **kwargs)
        return deprecated_func

    # see #9424
    failUnlessEqual = assertEquals = _deprecate(assertEqual)
    failIfEqual = assertNotEquals = _deprecate(assertNotEqual)
    failUnlessAlmostEqual = assertAlmostEquals = _deprecate(assertAlmostEqual)
    failIfAlmostEqual = assertNotAlmostEquals = _deprecate(assertNotAlmostEqual)
    failUnless = assert_ = _deprecate(assertTrue)
    failUnlessRaises = _deprecate(assertRaises)
    failIf = _deprecate(assertFalse)
    assertRaisesRegexp = _deprecate(assertRaisesRegex)
    assertRegexpMatches = _deprecate(assertRegex)
    assertNotRegexpMatches = _deprecate(assertNotRegex)



class FunctionTestCase(TestCase):
    """A test case that wraps a test function.

    This is useful for slipping pre-existing test functions into the
    unittest framework. Optionally, set-up and tidy-up functions can be
    supplied. As with TestCase, the tidy-up ('tearDown') function will
    always be called if the set-up ('setUp') function ran successfully.
    """

    def __init__(self, testFunc, setUp=None, tearDown=None, description=None):
        super(FunctionTestCase, self).__init__()
        self._setUpFunc = setUp
        self._tearDownFunc = tearDown
        self._testFunc = testFunc
        self._description = description

    def setUp(self):
        if self._setUpFunc is not None:
            self._setUpFunc()

    def tearDown(self):
        if self._tearDownFunc is not None:
            self._tearDownFunc()

    def runTest(self):
        self._testFunc()

    def id(self):
        return self._testFunc.__name__

    def __eq__(self, other):
        if not isinstance(other, self.__class__):
            return NotImplemented

        return self._setUpFunc == other._setUpFunc and \
               self._tearDownFunc == other._tearDownFunc and \
               self._testFunc == other._testFunc and \
               self._description == other._description

    def __hash__(self):
        return hash((type(self), self._setUpFunc, self._tearDownFunc,
                     self._testFunc, self._description))

    def __str__(self):
        return "%s (%s)" % (strclass(self.__class__),
                            self._testFunc.__name__)

    def __repr__(self):
        return "<%s tec=%s>" % (strclass(self.__class__),
                                     self._testFunc)

    def shortDescription(self):
        if self._description is not None:
            return self._description
        doc = self._testFunc.__doc__
        return doc and doc.split("\n")[0].strip() or None


class _SubTest(TestCase):

    def __init__(self, test_case, message, params):
        super().__init__()
        self._message = message
        self.test_case = test_case
        self.params = params
        self.failureException = test_case.failureException

    def runTest(self):
        raise NotImplementedError("subtests cannot be run directly")

    def _subDescription(self):
        parts = []
        if self._message is not _subtest_msg_sentinel:
            parts.append("[{}]".format(self._message))
        if self.params:
            params_desc = ', '.join(
                "{}={!r}".format(k, v)
                for (k, v) in self.params.items())
            parts.append("({})".format(params_desc))
        return " ".join(parts) or '(<subtest>)'

    def id(self):
        return "{} {}".format(self.test_case.id(), self._subDescription())

    def shortDescription(self):
        """Returns a one-line description of the subtest, or None if no
        description has been provided.
        """
        return self.test_case.shortDescription()

    def __str__(self):
        return "{} {}".format(self.test_case, self._subDescription())
PK��[؁�N�X�X	loader.pynu�[���"""Loading unittests."""

import os
import re
import sys
import traceback
import types
import functools
import warnings

from fnmatch import fnmatch, fnmatchcase

from . import case, suite, util

__unittest = True

# what about .pyc (etc)
# we would need to avoid loading the same tests multiple times
# from '.py', *and* '.pyc'
VALID_MODULE_NAME = re.compile(r'[_a-z]\w*\.py$', re.IGNORECASE)


class _FailedTest(case.TestCase):
    _testMethodName = None

    def __init__(self, method_name, exception):
        self._exception = exception
        super(_FailedTest, self).__init__(method_name)

    def __getattr__(self, name):
        if name != self._testMethodName:
            return super(_FailedTest, self).__getattr__(name)
        def testFailure():
            raise self._exception
        return testFailure


def _make_failed_import_test(name, suiteClass):
    message = 'Failed to import test module: %s\n%s' % (
        name, traceback.format_exc())
    return _make_failed_test(name, ImportError(message), suiteClass, message)

def _make_failed_load_tests(name, exception, suiteClass):
    message = 'Failed to call load_tests:\n%s' % (traceback.format_exc(),)
    return _make_failed_test(
        name, exception, suiteClass, message)

def _make_failed_test(methodname, exception, suiteClass, message):
    test = _FailedTest(methodname, exception)
    return suiteClass((test,)), message

def _make_skipped_test(methodname, exception, suiteClass):
    @case.skip(str(exception))
    def testSkipped(self):
        pass
    attrs = {methodname: testSkipped}
    TestClass = type("ModuleSkipped", (case.TestCase,), attrs)
    return suiteClass((TestClass(methodname),))

def _jython_aware_splitext(path):
    if path.lower().endswith('$py.class'):
        return path[:-9]
    return os.path.splitext(path)[0]


class TestLoader(object):
    """
    This class is responsible for loading tests according to various criteria
    and returning them wrapped in a TestSuite
    """
    testMethodPrefix = 'test'
    sortTestMethodsUsing = staticmethod(util.three_way_cmp)
    testNamePatterns = None
    suiteClass = suite.TestSuite
    _top_level_dir = None

    def __init__(self):
        super(TestLoader, self).__init__()
        self.errors = []
        # Tracks packages which we have called into via load_tests, to
        # avoid infinite re-entrancy.
        self._loading_packages = set()

    def loadTestsFromTestCase(self, testCaseClass):
        """Return a suite of all test cases contained in testCaseClass"""
        if issubclass(testCaseClass, suite.TestSuite):
            raise TypeError("Test cases should not be derived from "
                            "TestSuite. Maybe you meant to derive from "
                            "TestCase?")
        testCaseNames = self.getTestCaseNames(testCaseClass)
        if not testCaseNames and hasattr(testCaseClass, 'runTest'):
            testCaseNames = ['runTest']
        loaded_suite = self.suiteClass(map(testCaseClass, testCaseNames))
        return loaded_suite

    # XXX After Python 3.5, remove backward compatibility hacks for
    # use_load_tests deprecation via *args and **kws.  See issue 16662.
    def loadTestsFromModule(self, module, *args, pattern=None, **kws):
        """Return a suite of all test cases contained in the given module"""
        # This method used to take an undocumented and unofficial
        # use_load_tests argument.  For backward compatibility, we still
        # accept the argument (which can also be the first position) but we
        # ignore it and issue a deprecation warning if it's present.
        if len(args) > 0 or 'use_load_tests' in kws:
            warnings.warn('use_load_tests is deprecated and ignored',
                          DeprecationWarning)
            kws.pop('use_load_tests', None)
        if len(args) > 1:
            # Complain about the number of arguments, but don't forget the
            # required `module` argument.
            complaint = len(args) + 1
            raise TypeError('loadTestsFromModule() takes 1 positional argument but {} were given'.format(complaint))
        if len(kws) != 0:
            # Since the keyword arguments are unsorted (see PEP 468), just
            # pick the alphabetically sorted first argument to complain about,
            # if multiple were given.  At least the error message will be
            # predictable.
            complaint = sorted(kws)[0]
            raise TypeError("loadTestsFromModule() got an unexpected keyword argument '{}'".format(complaint))
        tests = []
        for name in dir(module):
            obj = getattr(module, name)
            if isinstance(obj, type) and issubclass(obj, case.TestCase):
                tests.append(self.loadTestsFromTestCase(obj))

        load_tests = getattr(module, 'load_tests', None)
        tests = self.suiteClass(tests)
        if load_tests is not None:
            try:
                return load_tests(self, tests, pattern)
            except Exception as e:
                error_case, error_message = _make_failed_load_tests(
                    module.__name__, e, self.suiteClass)
                self.errors.append(error_message)
                return error_case
        return tests

    def loadTestsFromName(self, name, module=None):
        """Return a suite of all test cases given a string specifier.

        The name may resolve either to a module, a test case class, a
        test method within a test case class, or a callable object which
        returns a TestCase or TestSuite instance.

        The method optionally resolves the names relative to a given module.
        """
        parts = name.split('.')
        error_case, error_message = None, None
        if module is None:
            parts_copy = parts[:]
            while parts_copy:
                try:
                    module_name = '.'.join(parts_copy)
                    module = __import__(module_name)
                    break
                except ImportError:
                    next_attribute = parts_copy.pop()
                    # Last error so we can give it to the user if needed.
                    error_case, error_message = _make_failed_import_test(
                        next_attribute, self.suiteClass)
                    if not parts_copy:
                        # Even the top level import failed: report that error.
                        self.errors.append(error_message)
                        return error_case
            parts = parts[1:]
        obj = module
        for part in parts:
            try:
                parent, obj = obj, getattr(obj, part)
            except AttributeError as e:
                # We can't traverse some part of the name.
                if (getattr(obj, '__path__', None) is not None
                    and error_case is not None):
                    # This is a package (no __path__ per importlib docs), and we
                    # encountered an error importing something. We cannot tell
                    # the difference between package.WrongNameTestClass and
                    # package.wrong_module_name so we just report the
                    # ImportError - it is more informative.
                    self.errors.append(error_message)
                    return error_case
                else:
                    # Otherwise, we signal that an AttributeError has occurred.
                    error_case, error_message = _make_failed_test(
                        part, e, self.suiteClass,
                        'Failed to access attribute:\n%s' % (
                            traceback.format_exc(),))
                    self.errors.append(error_message)
                    return error_case

        if isinstance(obj, types.ModuleType):
            return self.loadTestsFromModule(obj)
        elif isinstance(obj, type) and issubclass(obj, case.TestCase):
            return self.loadTestsFromTestCase(obj)
        elif (isinstance(obj, types.FunctionType) and
              isinstance(parent, type) and
              issubclass(parent, case.TestCase)):
            name = parts[-1]
            inst = parent(name)
            # static methods follow a different path
            if not isinstance(getattr(inst, name), types.FunctionType):
                return self.suiteClass([inst])
        elif isinstance(obj, suite.TestSuite):
            return obj
        if callable(obj):
            test = obj()
            if isinstance(test, suite.TestSuite):
                return test
            elif isinstance(test, case.TestCase):
                return self.suiteClass([test])
            else:
                raise TypeError("calling %s returned %s, not a test" %
                                (obj, test))
        else:
            raise TypeError("don't know how to make test from: %s" % obj)

    def loadTestsFromNames(self, names, module=None):
        """Return a suite of all test cases found using the given sequence
        of string specifiers. See 'loadTestsFromName()'.
        """
        suites = [self.loadTestsFromName(name, module) for name in names]
        return self.suiteClass(suites)

    def getTestCaseNames(self, testCaseClass):
        """Return a sorted sequence of method names found within testCaseClass
        """
        def shouldIncludeMethod(attrname):
            if not attrname.startswith(self.testMethodPrefix):
                return False
            testFunc = getattr(testCaseClass, attrname)
            if not callable(testFunc):
                return False
            fullName = f'%s.%s.%s' % (
                testCaseClass.__module__, testCaseClass.__qualname__, attrname
            )
            return self.testNamePatterns is None or \
                any(fnmatchcase(fullName, pattern) for pattern in self.testNamePatterns)
        testFnNames = list(filter(shouldIncludeMethod, dir(testCaseClass)))
        if self.sortTestMethodsUsing:
            testFnNames.sort(key=functools.cmp_to_key(self.sortTestMethodsUsing))
        return testFnNames

    def discover(self, start_dir, pattern='test*.py', top_level_dir=None):
        """Find and return all test modules from the specified start
        directory, recursing into subdirectories to find them and return all
        tests found within them. Only test files that match the pattern will
        be loaded. (Using shell style pattern matching.)

        All test modules must be importable from the top level of the project.
        If the start directory is not the top level directory then the top
        level directory must be specified separately.

        If a test package name (directory with '__init__.py') matches the
        pattern then the package will be checked for a 'load_tests' function. If
        this exists then it will be called with (loader, tests, pattern) unless
        the package has already had load_tests called from the same discovery
        invocation, in which case the package module object is not scanned for
        tests - this ensures that when a package uses discover to further
        discover child tests that infinite recursion does not happen.

        If load_tests exists then discovery does *not* recurse into the package,
        load_tests is responsible for loading all tests in the package.

        The pattern is deliberately not stored as a loader attribute so that
        packages can continue discovery themselves. top_level_dir is stored so
        load_tests does not need to pass this argument in to loader.discover().

        Paths are sorted before being imported to ensure reproducible execution
        order even on filesystems with non-alphabetical ordering like ext3/4.
        """
        set_implicit_top = False
        if top_level_dir is None and self._top_level_dir is not None:
            # make top_level_dir optional if called from load_tests in a package
            top_level_dir = self._top_level_dir
        elif top_level_dir is None:
            set_implicit_top = True
            top_level_dir = start_dir

        top_level_dir = os.path.abspath(top_level_dir)

        if not top_level_dir in sys.path:
            # all test modules must be importable from the top level directory
            # should we *unconditionally* put the start directory in first
            # in sys.path to minimise likelihood of conflicts between installed
            # modules and development versions?
            sys.path.insert(0, top_level_dir)
        self._top_level_dir = top_level_dir

        is_not_importable = False
        is_namespace = False
        tests = []
        if os.path.isdir(os.path.abspath(start_dir)):
            start_dir = os.path.abspath(start_dir)
            if start_dir != top_level_dir:
                is_not_importable = not os.path.isfile(os.path.join(start_dir, '__init__.py'))
        else:
            # support for discovery from dotted module names
            try:
                __import__(start_dir)
            except ImportError:
                is_not_importable = True
            else:
                the_module = sys.modules[start_dir]
                top_part = start_dir.split('.')[0]
                try:
                    start_dir = os.path.abspath(
                       os.path.dirname((the_module.__file__)))
                except AttributeError:
                    # look for namespace packages
                    try:
                        spec = the_module.__spec__
                    except AttributeError:
                        spec = None

                    if spec and spec.loader is None:
                        if spec.submodule_search_locations is not None:
                            is_namespace = True

                            for path in the_module.__path__:
                                if (not set_implicit_top and
                                    not path.startswith(top_level_dir)):
                                    continue
                                self._top_level_dir = \
                                    (path.split(the_module.__name__
                                         .replace(".", os.path.sep))[0])
                                tests.extend(self._find_tests(path,
                                                              pattern,
                                                              namespace=True))
                    elif the_module.__name__ in sys.builtin_module_names:
                        # builtin module
                        raise TypeError('Can not use builtin modules '
                                        'as dotted module names') from None
                    else:
                        raise TypeError(
                            'don\'t know how to discover from {!r}'
                            .format(the_module)) from None

                if set_implicit_top:
                    if not is_namespace:
                        self._top_level_dir = \
                           self._get_directory_containing_module(top_part)
                        sys.path.remove(top_level_dir)
                    else:
                        sys.path.remove(top_level_dir)

        if is_not_importable:
            raise ImportError('Start directory is not importable: %r' % start_dir)

        if not is_namespace:
            tests = list(self._find_tests(start_dir, pattern))
        return self.suiteClass(tests)

    def _get_directory_containing_module(self, module_name):
        module = sys.modules[module_name]
        full_path = os.path.abspath(module.__file__)

        if os.path.basename(full_path).lower().startswith('__init__.py'):
            return os.path.dirname(os.path.dirname(full_path))
        else:
            # here we have been given a module rather than a package - so
            # all we can do is search the *same* directory the module is in
            # should an exception be raised instead
            return os.path.dirname(full_path)

    def _get_name_from_path(self, path):
        if path == self._top_level_dir:
            return '.'
        path = _jython_aware_splitext(os.path.normpath(path))

        _relpath = os.path.relpath(path, self._top_level_dir)
        assert not os.path.isabs(_relpath), "Path must be within the project"
        assert not _relpath.startswith('..'), "Path must be within the project"

        name = _relpath.replace(os.path.sep, '.')
        return name

    def _get_module_from_name(self, name):
        __import__(name)
        return sys.modules[name]

    def _match_path(self, path, full_path, pattern):
        # override this method to use alternative matching strategy
        return fnmatch(path, pattern)

    def _find_tests(self, start_dir, pattern, namespace=False):
        """Used by discovery. Yields test suites it loads."""
        # Handle the __init__ in this package
        name = self._get_name_from_path(start_dir)
        # name is '.' when start_dir == top_level_dir (and top_level_dir is by
        # definition not a package).
        if name != '.' and name not in self._loading_packages:
            # name is in self._loading_packages while we have called into
            # loadTestsFromModule with name.
            tests, should_recurse = self._find_test_path(
                start_dir, pattern, namespace)
            if tests is not None:
                yield tests
            if not should_recurse:
                # Either an error occurred, or load_tests was used by the
                # package.
                return
        # Handle the contents.
        paths = sorted(os.listdir(start_dir))
        for path in paths:
            full_path = os.path.join(start_dir, path)
            tests, should_recurse = self._find_test_path(
                full_path, pattern, namespace)
            if tests is not None:
                yield tests
            if should_recurse:
                # we found a package that didn't use load_tests.
                name = self._get_name_from_path(full_path)
                self._loading_packages.add(name)
                try:
                    yield from self._find_tests(full_path, pattern, namespace)
                finally:
                    self._loading_packages.discard(name)

    def _find_test_path(self, full_path, pattern, namespace=False):
        """Used by discovery.

        Loads tests from a single file, or a directories' __init__.py when
        passed the directory.

        Returns a tuple (None_or_tests_from_file, should_recurse).
        """
        basename = os.path.basename(full_path)
        if os.path.isfile(full_path):
            if not VALID_MODULE_NAME.match(basename):
                # valid Python identifiers only
                return None, False
            if not self._match_path(basename, full_path, pattern):
                return None, False
            # if the test file matches, load it
            name = self._get_name_from_path(full_path)
            try:
                module = self._get_module_from_name(name)
            except case.SkipTest as e:
                return _make_skipped_test(name, e, self.suiteClass), False
            except:
                error_case, error_message = \
                    _make_failed_import_test(name, self.suiteClass)
                self.errors.append(error_message)
                return error_case, False
            else:
                mod_file = os.path.abspath(
                    getattr(module, '__file__', full_path))
                realpath = _jython_aware_splitext(
                    os.path.realpath(mod_file))
                fullpath_noext = _jython_aware_splitext(
                    os.path.realpath(full_path))
                if realpath.lower() != fullpath_noext.lower():
                    module_dir = os.path.dirname(realpath)
                    mod_name = _jython_aware_splitext(
                        os.path.basename(full_path))
                    expected_dir = os.path.dirname(full_path)
                    msg = ("%r module incorrectly imported from %r. Expected "
                           "%r. Is this module globally installed?")
                    raise ImportError(
                        msg % (mod_name, module_dir, expected_dir))
                return self.loadTestsFromModule(module, pattern=pattern), False
        elif os.path.isdir(full_path):
            if (not namespace and
                not os.path.isfile(os.path.join(full_path, '__init__.py'))):
                return None, False

            load_tests = None
            tests = None
            name = self._get_name_from_path(full_path)
            try:
                package = self._get_module_from_name(name)
            except case.SkipTest as e:
                return _make_skipped_test(name, e, self.suiteClass), False
            except:
                error_case, error_message = \
                    _make_failed_import_test(name, self.suiteClass)
                self.errors.append(error_message)
                return error_case, False
            else:
                load_tests = getattr(package, 'load_tests', None)
                # Mark this package as being in load_tests (possibly ;))
                self._loading_packages.add(name)
                try:
                    tests = self.loadTestsFromModule(package, pattern=pattern)
                    if load_tests is not None:
                        # loadTestsFromModule(package) has loaded tests for us.
                        return tests, False
                    return tests, True
                finally:
                    self._loading_packages.discard(name)
        else:
            return None, False


defaultTestLoader = TestLoader()


def _makeLoader(prefix, sortUsing, suiteClass=None, testNamePatterns=None):
    loader = TestLoader()
    loader.sortTestMethodsUsing = sortUsing
    loader.testMethodPrefix = prefix
    loader.testNamePatterns = testNamePatterns
    if suiteClass:
        loader.suiteClass = suiteClass
    return loader

def getTestCaseNames(testCaseClass, prefix, sortUsing=util.three_way_cmp, testNamePatterns=None):
    return _makeLoader(prefix, sortUsing, testNamePatterns=testNamePatterns).getTestCaseNames(testCaseClass)

def makeSuite(testCaseClass, prefix='test', sortUsing=util.three_way_cmp,
              suiteClass=suite.TestSuite):
    return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromTestCase(
        testCaseClass)

def findTestCases(module, prefix='test', sortUsing=util.three_way_cmp,
                  suiteClass=suite.TestSuite):
    return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromModule(\
        module)
PK��[ڗ��c	c	
signals.pynu�[���import signal
import weakref

from functools import wraps

__unittest = True


class _InterruptHandler(object):
    def __init__(self, default_handler):
        self.called = False
        self.original_handler = default_handler
        if isinstance(default_handler, int):
            if default_handler == signal.SIG_DFL:
                # Pretend it's signal.default_int_handler instead.
                default_handler = signal.default_int_handler
            elif default_handler == signal.SIG_IGN:
                # Not quite the same thing as SIG_IGN, but the closest we
                # can make it: do nothing.
                def default_handler(unused_signum, unused_frame):
                    pass
            else:
                raise TypeError("expected SIGINT signal handler to be "
                                "signal.SIG_IGN, signal.SIG_DFL, or a "
                                "callable object")
        self.default_handler = default_handler

    def __call__(self, signum, frame):
        installed_handler = signal.getsignal(signal.SIGINT)
        if installed_handler is not self:
            # if we aren't the installed handler, then delegate immediately
            # to the default handler
            self.default_handler(signum, frame)

        if self.called:
            self.default_handler(signum, frame)
        self.called = True
        for result in _results.keys():
            result.stop()

_results = weakref.WeakKeyDictionary()
def registerResult(result):
    _results[result] = 1

def removeResult(result):
    return bool(_results.pop(result, None))

_interrupt_handler = None
def installHandler():
    global _interrupt_handler
    if _interrupt_handler is None:
        default_handler = signal.getsignal(signal.SIGINT)
        _interrupt_handler = _InterruptHandler(default_handler)
        signal.signal(signal.SIGINT, _interrupt_handler)


def removeHandler(method=None):
    if method is not None:
        @wraps(method)
        def inner(*args, **kwargs):
            initial = signal.getsignal(signal.SIGINT)
            removeHandler()
            try:
                return method(*args, **kwargs)
            finally:
                signal.signal(signal.SIGINT, initial)
        return inner

    global _interrupt_handler
    if _interrupt_handler is not None:
        signal.signal(signal.SIGINT, _interrupt_handler.original_handler)
PK��[2��|22suite.pynu�[���"""TestSuite"""

import sys

from . import case
from . import util

__unittest = True


def _call_if_exists(parent, attr):
    func = getattr(parent, attr, lambda: None)
    func()


class BaseTestSuite(object):
    """A simple test suite that doesn't provide class or module shared fixtures.
    """
    _cleanup = True

    def __init__(self, tests=()):
        self._tests = []
        self._removed_tests = 0
        self.addTests(tests)

    def __repr__(self):
        return "<%s tests=%s>" % (util.strclass(self.__class__), list(self))

    def __eq__(self, other):
        if not isinstance(other, self.__class__):
            return NotImplemented
        return list(self) == list(other)

    def __iter__(self):
        return iter(self._tests)

    def countTestCases(self):
        cases = self._removed_tests
        for test in self:
            if test:
                cases += test.countTestCases()
        return cases

    def addTest(self, test):
        # sanity checks
        if not callable(test):
            raise TypeError("{} is not callable".format(repr(test)))
        if isinstance(test, type) and issubclass(test,
                                                 (case.TestCase, TestSuite)):
            raise TypeError("TestCases and TestSuites must be instantiated "
                            "before passing them to addTest()")
        self._tests.append(test)

    def addTests(self, tests):
        if isinstance(tests, str):
            raise TypeError("tests must be an iterable of tests, not a string")
        for test in tests:
            self.addTest(test)

    def run(self, result):
        for index, test in enumerate(self):
            if result.shouldStop:
                break
            test(result)
            if self._cleanup:
                self._removeTestAtIndex(index)
        return result

    def _removeTestAtIndex(self, index):
        """Stop holding a reference to the TestCase at index."""
        try:
            test = self._tests[index]
        except TypeError:
            # support for suite implementations that have overridden self._tests
            pass
        else:
            # Some unittest tests add non TestCase/TestSuite objects to
            # the suite.
            if hasattr(test, 'countTestCases'):
                self._removed_tests += test.countTestCases()
            self._tests[index] = None

    def __call__(self, *args, **kwds):
        return self.run(*args, **kwds)

    def debug(self):
        """Run the tests without collecting errors in a TestResult"""
        for test in self:
            test.debug()


class TestSuite(BaseTestSuite):
    """A test suite is a composite test consisting of a number of TestCases.

    For use, create an instance of TestSuite, then add test case instances.
    When all tests have been added, the suite can be passed to a test
    runner, such as TextTestRunner. It will run the individual test cases
    in the order in which they were added, aggregating the results. When
    subclassing, do not forget to call the base class constructor.
    """

    def run(self, result, debug=False):
        topLevel = False
        if getattr(result, '_testRunEntered', False) is False:
            result._testRunEntered = topLevel = True

        for index, test in enumerate(self):
            if result.shouldStop:
                break

            if _isnotsuite(test):
                self._tearDownPreviousClass(test, result)
                self._handleModuleFixture(test, result)
                self._handleClassSetUp(test, result)
                result._previousTestClass = test.__class__

                if (getattr(test.__class__, '_classSetupFailed', False) or
                    getattr(result, '_moduleSetUpFailed', False)):
                    continue

            if not debug:
                test(result)
            else:
                test.debug()

            if self._cleanup:
                self._removeTestAtIndex(index)

        if topLevel:
            self._tearDownPreviousClass(None, result)
            self._handleModuleTearDown(result)
            result._testRunEntered = False
        return result

    def debug(self):
        """Run the tests without collecting errors in a TestResult"""
        debug = _DebugResult()
        self.run(debug, True)

    ################################

    def _handleClassSetUp(self, test, result):
        previousClass = getattr(result, '_previousTestClass', None)
        currentClass = test.__class__
        if currentClass == previousClass:
            return
        if result._moduleSetUpFailed:
            return
        if getattr(currentClass, "__unittest_skip__", False):
            return

        try:
            currentClass._classSetupFailed = False
        except TypeError:
            # test may actually be a function
            # so its class will be a builtin-type
            pass

        setUpClass = getattr(currentClass, 'setUpClass', None)
        if setUpClass is not None:
            _call_if_exists(result, '_setupStdout')
            try:
                setUpClass()
            except Exception as e:
                if isinstance(result, _DebugResult):
                    raise
                currentClass._classSetupFailed = True
                className = util.strclass(currentClass)
                self._createClassOrModuleLevelException(result, e,
                                                        'setUpClass',
                                                        className)
            finally:
                _call_if_exists(result, '_restoreStdout')
                if currentClass._classSetupFailed is True:
                    currentClass.doClassCleanups()
                    if len(currentClass.tearDown_exceptions) > 0:
                        for exc in currentClass.tearDown_exceptions:
                            self._createClassOrModuleLevelException(
                                    result, exc[1], 'setUpClass', className,
                                    info=exc)

    def _get_previous_module(self, result):
        previousModule = None
        previousClass = getattr(result, '_previousTestClass', None)
        if previousClass is not None:
            previousModule = previousClass.__module__
        return previousModule


    def _handleModuleFixture(self, test, result):
        previousModule = self._get_previous_module(result)
        currentModule = test.__class__.__module__
        if currentModule == previousModule:
            return

        self._handleModuleTearDown(result)


        result._moduleSetUpFailed = False
        try:
            module = sys.modules[currentModule]
        except KeyError:
            return
        setUpModule = getattr(module, 'setUpModule', None)
        if setUpModule is not None:
            _call_if_exists(result, '_setupStdout')
            try:
                setUpModule()
            except Exception as e:
                try:
                    case.doModuleCleanups()
                except Exception as exc:
                    self._createClassOrModuleLevelException(result, exc,
                                                            'setUpModule',
                                                            currentModule)
                if isinstance(result, _DebugResult):
                    raise
                result._moduleSetUpFailed = True
                self._createClassOrModuleLevelException(result, e,
                                                        'setUpModule',
                                                        currentModule)
            finally:
                _call_if_exists(result, '_restoreStdout')

    def _createClassOrModuleLevelException(self, result, exc, method_name,
                                           parent, info=None):
        errorName = f'{method_name} ({parent})'
        self._addClassOrModuleLevelException(result, exc, errorName, info)

    def _addClassOrModuleLevelException(self, result, exception, errorName,
                                        info=None):
        error = _ErrorHolder(errorName)
        addSkip = getattr(result, 'addSkip', None)
        if addSkip is not None and isinstance(exception, case.SkipTest):
            addSkip(error, str(exception))
        else:
            if not info:
                result.addError(error, sys.exc_info())
            else:
                result.addError(error, info)

    def _handleModuleTearDown(self, result):
        previousModule = self._get_previous_module(result)
        if previousModule is None:
            return
        if result._moduleSetUpFailed:
            return

        try:
            module = sys.modules[previousModule]
        except KeyError:
            return

        tearDownModule = getattr(module, 'tearDownModule', None)
        if tearDownModule is not None:
            _call_if_exists(result, '_setupStdout')
            try:
                tearDownModule()
            except Exception as e:
                if isinstance(result, _DebugResult):
                    raise
                self._createClassOrModuleLevelException(result, e,
                                                        'tearDownModule',
                                                        previousModule)
            finally:
                _call_if_exists(result, '_restoreStdout')
                try:
                    case.doModuleCleanups()
                except Exception as e:
                    self._createClassOrModuleLevelException(result, e,
                                                            'tearDownModule',
                                                            previousModule)

    def _tearDownPreviousClass(self, test, result):
        previousClass = getattr(result, '_previousTestClass', None)
        currentClass = test.__class__
        if currentClass == previousClass:
            return
        if getattr(previousClass, '_classSetupFailed', False):
            return
        if getattr(result, '_moduleSetUpFailed', False):
            return
        if getattr(previousClass, "__unittest_skip__", False):
            return

        tearDownClass = getattr(previousClass, 'tearDownClass', None)
        if tearDownClass is not None:
            _call_if_exists(result, '_setupStdout')
            try:
                tearDownClass()
            except Exception as e:
                if isinstance(result, _DebugResult):
                    raise
                className = util.strclass(previousClass)
                self._createClassOrModuleLevelException(result, e,
                                                        'tearDownClass',
                                                        className)
            finally:
                _call_if_exists(result, '_restoreStdout')
                previousClass.doClassCleanups()
                if len(previousClass.tearDown_exceptions) > 0:
                    for exc in previousClass.tearDown_exceptions:
                        className = util.strclass(previousClass)
                        self._createClassOrModuleLevelException(result, exc[1],
                                                                'tearDownClass',
                                                                className,
                                                                info=exc)


class _ErrorHolder(object):
    """
    Placeholder for a TestCase inside a result. As far as a TestResult
    is concerned, this looks exactly like a unit test. Used to insert
    arbitrary errors into a test suite run.
    """
    # Inspired by the ErrorHolder from Twisted:
    # http://twistedmatrix.com/trac/browser/trunk/twisted/trial/runner.py

    # attribute used by TestResult._exc_info_to_string
    failureException = None

    def __init__(self, description):
        self.description = description

    def id(self):
        return self.description

    def shortDescription(self):
        return None

    def __repr__(self):
        return "<ErrorHolder description=%r>" % (self.description,)

    def __str__(self):
        return self.id()

    def run(self, result):
        # could call result.addError(...) - but this test-like object
        # shouldn't be run anyway
        pass

    def __call__(self, result):
        return self.run(result)

    def countTestCases(self):
        return 0

def _isnotsuite(test):
    "A crude way to tell apart testcases and suites with duck-typing"
    try:
        iter(test)
    except TypeError:
        return True
    return False


class _DebugResult(object):
    "Used by the TestSuite to hold previous class when running in debug."
    _previousTestClass = None
    _moduleSetUpFailed = False
    shouldStop = False
PK��[l�k�+__pycache__/async_case.cpython-38.opt-2.pycnu�[���U

e5d��@s0ddlZddlZddlmZGdd�de�ZdS)�N�)�TestCasecs�eZdZd�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zd �fdd�	Z�ZS)!�IsolatedAsyncioTestCase�runTestcst��|�d|_d|_dS�N)�super�__init__�_asyncioTestLoop�_asyncioCallsQueue)�selfZ
methodName��	__class__��+/usr/lib64/python3.8/unittest/async_case.pyr"sz IsolatedAsyncioTestCase.__init__c�sdSrr�rrrr�
asyncSetUp'sz"IsolatedAsyncioTestCase.asyncSetUpc�sdSrrrrrr�
asyncTearDown*sz%IsolatedAsyncioTestCase.asyncTearDowncOs|j|f|�|�dSr)Z
addCleanup)r�func�args�kwargsrrr�addAsyncCleanup-s
z'IsolatedAsyncioTestCase.addAsyncCleanupcCs|��|�|j�dSr)ZsetUp�
_callAsyncrrrrr�
_callSetUp<sz"IsolatedAsyncioTestCase._callSetUpcCs|�|�dSr��_callMaybeAsync)r�methodrrr�_callTestMethod@sz'IsolatedAsyncioTestCase._callTestMethodcCs|�|j�|��dSr)rrZtearDownrrrr�
_callTearDownCsz%IsolatedAsyncioTestCase._callTearDowncOs|j|f|�|�dSrr)rZfunctionrrrrr�_callCleanupGsz$IsolatedAsyncioTestCase._callCleanupcOs0|||�}|j��}|j�||f�|j�|�Sr)r	�
create_futurer
�
put_nowait�run_until_complete�rrrr�ret�futrrrrJs

z"IsolatedAsyncioTestCase._callAsynccOsB|||�}t�|�r:|j��}|j�||f�|j�|�S|SdSr)�inspectZisawaitabler	rr
r r!r"rrrrRs


z'IsolatedAsyncioTestCase._callMaybeAsyncc
�s�t��|_}|�d�|��IdH}|��|dkr:dS|\}}z |IdH}|��s`|�|�Wqttfk
r|�Yqt	tj
fk
r�}z|��s�|�|�W5d}~XYqXqdSr)�asyncioZQueuer
Z
set_result�getZ	task_done�	cancelled�
SystemExit�KeyboardInterrupt�
BaseExceptionZCancelledErrorZ
set_exception)rr$ZqueueZqueryZ	awaitabler#Zexrrr�_asyncioLoopRunner\s 

z*IsolatedAsyncioTestCase._asyncioLoopRunnercCsJt��}t�|�|�d�||_|��}|�|�|��|_|�	|�dS)NT)
r&Znew_event_loop�set_event_loopZ	set_debugr	rZcreate_taskr,Z_asyncioCallsTaskr!)r�loopr$rrr�_setupAsyncioLoopos

z)IsolatedAsyncioTestCase._setupAsyncioLoopc	Cs�|j}d|_|j�d�|�|j���z�t�|�}|s@W�vdS|D]}|�	�qD|�tj
||dd���|D]0}|��r|qn|��dk	rn|�
d|��|d��qn|�|���W5t�d�|��XdS)NT)r.Zreturn_exceptionsz(unhandled exception during test shutdown)�message�	exception�task)r	r
r r!�joinr&r-�closeZ	all_tasksZcancelZgatherr(r1Zcall_exception_handlerZshutdown_asyncgens)rr.Z	to_cancelr2rrr�_tearDownAsyncioLoopys2

��

z,IsolatedAsyncioTestCase._tearDownAsyncioLoopNcs(|��zt��|�W�S|��XdSr)r/r5r�run)r�resultrrrr6�szIsolatedAsyncioTestCase.run)r)N)�__name__�
__module__�__qualname__rrrrrrrrrrr,r/r5r6�
__classcell__rrrrrs

"r)r&r%Zcaserrrrrr�<module>sPK��[:��'__pycache__/runner.cpython-38.opt-2.pycnu�[���U

e5dW�@sjddlZddlZddlZddlmZddlmZdZGdd�de�Z	Gdd	�d	ej
�ZGd
d�de�ZdS)�N�)�result)�registerResultTc@s&eZdZdd�Zdd�Zddd�ZdS)	�_WritelnDecoratorcCs
||_dS�N)�stream)�selfr�r	�'/usr/lib64/python3.8/unittest/runner.py�__init__sz_WritelnDecorator.__init__cCs|dkrt|��t|j|�S)N)r�__getstate__)�AttributeError�getattrr)r�attrr	r	r
�__getattr__sz_WritelnDecorator.__getattr__NcCs|r|�|�|�d�dS�N�
)�write)r�argr	r	r
�writelns
z_WritelnDecorator.writeln)N)�__name__�
__module__�__qualname__rrrr	r	r	r
r
srcs�eZdZdZdZ�fdd�Zdd�Z�fdd�Z�fd	d
�Z�fdd�Z	�fd
d�Z
�fdd�Z�fdd�Z�fdd�Z
dd�Zdd�Z�ZS)�TextTestResultzF======================================================================zF----------------------------------------------------------------------cs8tt|��|||�||_|dk|_|dk|_||_dS)Nr)�superrrr�showAll�dots�descriptions)rrr�	verbosity��	__class__r	r
r%s


zTextTestResult.__init__cCs0|��}|jr$|r$d�t|�|f�St|�SdSr)ZshortDescriptionr�join�str)r�testZdoc_first_liner	r	r
�getDescription,s
zTextTestResult.getDescriptioncsBtt|��|�|jr>|j�|�|��|j�d�|j��dS)Nz ... )rr�	startTestrrrr$�flush�rr#rr	r
r%3s
zTextTestResult.startTestcsDtt|��|�|jr$|j�d�n|jr@|j�d�|j��dS)N�ok�.)	rr�
addSuccessrrrrrr&r'rr	r
r*:szTextTestResult.addSuccesscsFtt|��||�|jr&|j�d�n|jrB|j�d�|j��dS)N�ERROR�E)	rr�addErrorrrrrrr&�rr#�errrr	r
r-BszTextTestResult.addErrorcsFtt|��||�|jr&|j�d�n|jrB|j�d�|j��dS)N�FAIL�F)	rr�
addFailurerrrrrr&r.rr	r
r2JszTextTestResult.addFailurecsLtt|��||�|jr,|j�d�|��n|jrH|j�d�|j�	�dS)Nz
skipped {0!r}�s)
rr�addSkiprrr�formatrrr&)rr#�reasonrr	r
r4RszTextTestResult.addSkipcsFtt|��||�|jr&|j�d�n|jrB|j�d�|j��dS)Nzexpected failure�x)	rr�addExpectedFailurerrrrrr&r.rr	r
r8Zsz!TextTestResult.addExpectedFailurecsDtt|��|�|jr$|j�d�n|jr@|j�d�|j��dS)Nzunexpected success�u)	rr�addUnexpectedSuccessrrrrrr&r'rr	r
r:bsz#TextTestResult.addUnexpectedSuccesscCs6|js|jr|j��|�d|j�|�d|j�dS)Nr+r0)rrrr�printErrorList�errors�failures�rr	r	r
�printErrorsjs
zTextTestResult.printErrorscCsX|D]N\}}|j�|j�|j�d||�|�f�|j�|j�|j�d|�qdS)Nz%s: %sz%s)rr�
separator1r$�
separator2)rZflavourr<r#r/r	r	r
r;ps
zTextTestResult.printErrorList)rrrr@rArr$r%r*r-r2r4r8r:r?r;�
__classcell__r	r	rr
rsrc@s0eZdZeZddd�dd�Zdd	�Zd
d�ZdS)
�TextTestRunnerNTrF)�	tb_localsc	CsN|dkrtj}t|�|_||_||_||_||_||_||_	|dk	rJ||_
dSr)�sys�stderrrrrr�failfast�bufferrD�warnings�resultclass)	rrrrrGrHrJrIrDr	r	r
r�s
zTextTestRunner.__init__cCs|�|j|j|j�Sr)rJrrrr>r	r	r
�_makeResult�szTextTestRunner._makeResultcCs2|��}t|�|j|_|j|_|j|_t����|jr^t�|j�|jdkr^tjdt	dd�t
��}t|dd�}|dk	r�|�z||�W5t|dd�}|dk	r�|�Xt
��}W5QRX||}|�
�t|d�r�|j�|j�|j}|j�d||d	ko�d
�pd|f�|j��d}	}
}ztt|j|j|jf�}Wntk
�rTYnX|\}	}
}g}
|���s�|j�d
�t|j�t|j�}}|�r�|
�d|�|�r�|
�d|�n|j�d�|�r�|
�d|�|	�r�|
�d|	�|
�r|
�d|
�|
�r"|j�dd�|
�f�n|j�d�|S)N)�default�always�modulezPlease use assert\w+ instead.)�category�message�startTestRun�stopTestRunrAzRan %d test%s in %.3fsrr3�rZFAILEDzfailures=%dz	errors=%dZOKz
skipped=%dzexpected failures=%dzunexpected successes=%dz (%s)z, r)rKrrGrHrDrI�catch_warnings�simplefilter�filterwarnings�DeprecationWarning�time�perf_counterrr?�hasattrrrrAZtestsRun�map�lenZexpectedFailures�unexpectedSuccesses�skippedr
Z
wasSuccessfulrr=r<�appendr!)rr#rZ	startTimerQrRZstopTimeZ	timeTaken�runZ
expectedFailsr]r^ZresultsZinfosZfailedZerroredr	r	r
r`�sx

�
�
�


zTextTestRunner.run)NTrFFNN)rrrrrJrrKr`r	r	r	r
rCxs��rC)
rErXrIrSrZsignalsrZ
__unittest�objectrZ
TestResultrrCr	r	r	r
�<module>s[PK��[��e�WW)__pycache__/__init__.cpython-38.opt-2.pycnu�[���U

e5d��@s�dddddddddd	d
ddd
ddddddgZe�dddg�dZddlmZddlmZddlmZm	Z	m
Z
mZmZm
Z
mZmZddlmZmZddlmZmZmZmZmZddlmZmZddlmZmZdd lmZm Z m!Z!m"Z"eZ#d!d"�Z$d#S)$�
TestResult�TestCase�IsolatedAsyncioTestCase�	TestSuite�TextTestRunner�
TestLoader�FunctionTestCase�main�defaultTestLoader�SkipTest�skip�skipIf�
skipUnless�expectedFailure�TextTestResult�installHandler�registerResult�removeResult�
removeHandler�addModuleCleanup�getTestCaseNames�	makeSuite�
findTestCasesT�)r)r)rrrr
rrr
r)�
BaseTestSuiter)rr	rrr)�TestProgramr)rr)rrrrcCs"ddl}|j�t�}|j||d�S)N�)Z	start_dir�pattern)Zos.path�path�dirname�__file__Zdiscover)�loaderZtestsr�osZthis_dir�r"�)/usr/lib64/python3.8/unittest/__init__.py�
load_testsLsr$N)%�__all__�extendZ
__unittest�resultrZ
async_caserZcaserrrr
rrr
rZsuiterrr rr	rrrrrZrunnerrrZsignalsrrrrZ_TextTestResultr$r"r"r"r#�<module>/s:�(PK��[���pp)__pycache__/__main__.cpython-38.opt-2.pycnu�[���U

e5d��@s\ddlZejd�d�r>ddlZej�ej�Zedejd<[dZddl	m	Z	e	dd�dS)�Nz__main__.pyz -m unittestT�)�main)�module)
�sys�argv�endswithZos.path�os�path�basename�
executableZ
__unittestr�rr�)/usr/lib64/python3.8/unittest/__main__.py�<module>sPK��[a!n�}}'__pycache__/result.cpython-38.opt-1.pycnu�[���U

e5d�@s\dZddlZddlZddlZddlmZddlmZdZdd�Z	d	Z
d
ZGdd�de�Z
dS)
zTest result object�N�)�util��wrapsTcst���fdd��}|S)Ncs$t|dd�r|���|f|�|�S)N�failfastF)�getattr�stop)�self�args�kw��method��'/usr/lib64/python3.8/unittest/result.py�inner
szfailfast.<locals>.innerr)r
rrrrrsrz
Stdout:
%sz
Stderr:
%sc@s�eZdZdZdZdZdZd.dd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zedd��Zedd��Zdd�Zdd�Zdd�Zdd�Zed d!��Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�ZdS)/�
TestResulta�Holder for test result information.

    Test results are automatically managed by the TestCase and TestSuite
    classes, and do not need to be explicitly manipulated by writers of tests.

    Each instance holds the total number of tests run, and collections of
    failures and errors that occurred among those test runs. The collections
    contain tuples of (testcase, exceptioninfo), where exceptioninfo is the
    formatted traceback of the error that occurred.
    NFcCsbd|_g|_g|_d|_g|_g|_g|_d|_d|_d|_	d|_
d|_tj
|_tj|_d|_dS)NFr)r�failures�errors�testsRun�skipped�expectedFailures�unexpectedSuccesses�
shouldStop�buffer�	tb_locals�_stdout_buffer�_stderr_buffer�sys�stdout�_original_stdout�stderr�_original_stderr�
_mirrorOutput)r	�streamZdescriptions�	verbosityrrr�__init__&szTestResult.__init__cCsdS)z#Called by TestRunner after test runNr�r	rrr�printErrors7szTestResult.printErrorscCs |jd7_d|_|��dS)z-Called when the given test is about to be runrFN)rr"�_setupStdout�r	�testrrr�	startTest:szTestResult.startTestcCs8|jr4|jdkr$t��|_t��|_|jt_|jt_dS)N)rr�io�StringIOrrrr r&rrrr(@s


zTestResult._setupStdoutcCsdS)zpCalled once before any tests are executed.

        See startTest for a method called before each test.
        Nrr&rrr�startTestRunHszTestResult.startTestRuncCs|��d|_dS)z'Called when the given test has been runFN)�_restoreStdoutr"r)rrr�stopTestNszTestResult.stopTestcCs�|jr�|jrltj��}tj��}|rF|�d�s6|d7}|j�t	|�|rl|�d�s\|d7}|j
�t|�|jt_|j
t_|j�
d�|j��|j�
d�|j��dS)N�
r)rr"rr�getvaluer �endswithr�write�STDOUT_LINEr!�STDERR_LINEr�seek�truncater)r	�output�errorrrrr/Ss$




zTestResult._restoreStdoutcCsdS)zmCalled once after all tests are executed.

        See stopTest for a method called after each test.
        Nrr&rrr�stopTestRunhszTestResult.stopTestRuncCs"|j�||�||�f�d|_dS)zmCalled when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info().
        TN)r�append�_exc_info_to_stringr"�r	r*�errrrr�addErrornszTestResult.addErrorcCs"|j�||�||�f�d|_dS)zdCalled when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info().TN)rr<r=r"r>rrr�
addFailurevszTestResult.addFailurecCsZ|dk	rVt|dd�r|��t|d|j�r4|j}n|j}|�||�||�f�d|_dS)z�Called at the end of a subtest.
        'err' is None if the subtest ended successfully, otherwise it's a
        tuple of values as returned by sys.exc_info().
        NrFrT)	rr�
issubclass�failureExceptionrrr<r=r")r	r*Zsubtestr?rrrr�
addSubTest}szTestResult.addSubTestcCsdS)z-Called when a test has completed successfullyNrr)rrr�
addSuccess�szTestResult.addSuccesscCs|j�||f�dS)zCalled when a test is skipped.N)rr<)r	r*�reasonrrr�addSkip�szTestResult.addSkipcCs|j�||�||�f�dS)z/Called when an expected failure/error occurred.N)rr<r=r>rrr�addExpectedFailure�s�zTestResult.addExpectedFailurecCs|j�|�dS)z5Called when a test was expected to fail, but succeed.N)rr<r)rrr�addUnexpectedSuccess�szTestResult.addUnexpectedSuccesscCs>t|j�t|j�kodkno<t|d�p<t|j�dkS)z/Tells whether or not this result was a success.rr)�lenrr�hasattrrr&rrr�
wasSuccessful�s$�zTestResult.wasSuccessfulcCs
d|_dS)z+Indicates that the tests should be aborted.TN)rr&rrrr�szTestResult.stopcCs�|\}}}|r |�|�r |j}q
||jkr6|�|�}nd}tj|||||jd�}t|���}|j	r�t
j��}	t
j
��}
|	r�|	�d�s�|	d7}	|�t|	�|
r�|
�d�s�|
d7}
|�t|
�d�|�S)z>Converts a sys.exc_info()-style tuple of values into a string.N)�limit�capture_localsr1�)�_is_relevant_tb_level�tb_nextrC�_count_relevant_tb_levels�	traceback�TracebackExceptionr�list�formatrrrr2r r3r<r5r6�join)r	r?r*�exctype�value�tb�lengthZtb_eZmsgLinesr9r:rrrr=�s4

�



zTestResult._exc_info_to_stringcCsd|jjkS)N�
__unittest)�tb_frame�	f_globals)r	rZrrrrP�sz TestResult._is_relevant_tb_levelcCs&d}|r"|�|�s"|d7}|j}q|S)Nrr)rPrQ)r	rZr[rrrrR�s
z$TestResult._count_relevant_tb_levelscCs&dt�|j�|jt|j�t|j�fS)Nz!<%s run=%i errors=%i failures=%i>)rZstrclass�	__class__rrJrrr&rrr�__repr__�s
��zTestResult.__repr__)NNN)�__name__�
__module__�__qualname__�__doc__Z_previousTestClassZ_testRunEnteredZ_moduleSetUpFailedr%r'r+r(r.r0r/r;rr@rArDrErGrHrIrLrr=rPrRr`rrrrrs8




	r)rdr,rrSrOr�	functoolsrr\rr5r6�objectrrrrr�<module>sPK��[��QQ__pycache__/util.cpython-38.pycnu�[���U

e5d_�@s�dZddlmZmZddlmZdZdZdZdZ	dZ
dZee	eeee
Zedks\t
�dd	�Zd
d�Zdd
d�Zdd�Zdd�Zdd�Zdd�Zedd�Zdd�Zdd�ZdS)zVarious utility functions.�)�
namedtuple�Counter)�commonprefixT�P��cCsBt|�||}|tkr>d|d|�||t|�|d�f}|S)Nz%s[%d chars]%s)�len�_PLACEHOLDER_LEN)�s�	prefixlenZ	suffixlen�skip�r
�%/usr/lib64/python3.8/unittest/util.py�_shortens&rcs�ttt|��}ttt|��}|tkr(|St|��t���t|�tt}|t	kr�ttt	|�tkspt
�t�t|��t��fdd�|D��St�tt	��t��fdd�|D��S)Nc3s|]}�|�d�VqdS�Nr
��.0r
��prefixrr
r�	<genexpr>'sz'_common_shorten_repr.<locals>.<genexpr>c3s&|]}�t|�d�tt�VqdSr)r�
_MIN_DIFF_LEN�_MIN_END_LENrrr
rr*s�)�tuple�map�	safe_repr�maxr�_MAX_LENGTHr�_MIN_BEGIN_LENr	�_MIN_COMMON_LEN�AssertionErrorr)�args�maxlenZ
common_lenr
rr�_common_shorten_reprs*�
���r"FcCsPzt|�}Wntk
r*t�|�}YnX|r<t|�tkr@|S|dt�dS)Nz [truncated]...)�repr�	Exception�object�__repr__rr)�objZshort�resultr
r
rr-srcCsd|j|jfS)Nz%s.%s)�
__module__�__qualname__)�clsr
r
r�strclass6sr,cCsd}}g}g}z�||}||}||krT|�|�|d7}|||kr�|d7}q<nv||kr�|�|�|d7}|||kr�|d7}qnnD|d7}z|||kr�|d7}q�W5|d7}|||kr�|d7}q�XWqtk
�r|�||d��|�||d��Y�qYqXq||fS)arFinds elements in only one or the other of two, sorted input lists.

    Returns a two-element tuple of lists.    The first list contains those
    elements in the "expected" list but not in the "actual" list, and the
    second contains those elements in the "actual" list but not in the
    "expected" list.    Duplicate elements in either input list are ignored.
    r�N)�append�
IndexError�extend)�expected�actual�i�j�missingZ
unexpected�e�ar
r
r�sorted_list_difference9s8

r8cCsHg}|r@|��}z|�|�Wqtk
r<|�|�YqXq||fS)z�Same behavior as sorted_list_difference but
    for lists of unorderable items (like dicts).

    As it does a linear search per item (remove) it
    has O(n*n) performance.)�pop�remove�
ValueErrorr.)r1r2r5�itemr
r
r�unorderable_list_differencebsr=cCs||k||kS)z.Return -1 if x < y, 0 if x == y and 1 if x > yr
)�x�yr
r
r�
three_way_cmpssr@ZMismatchzactual expected valuecCs,t|�t|�}}t|�t|�}}t�}g}t|�D]�\}}	|	|krHq6d}
}t||�D] }|||	krZ|
d7}
|||<qZt|�D] \}}
|
|	kr�|d7}|||<q�|
|kr6t|
||	�}|�|�q6t|�D]X\}}	|	|kr�q�d}t||�D] }|||	kr�|d7}|||<q�td||	�}|�|�q�|S)�HReturns list of (cnt_act, cnt_exp, elem) triples where the counts differrr-)�listrr%�	enumerate�range�	_Mismatchr.)r2r1r
�t�m�nZNULLr(r3�elem�cnt_s�cnt_tr4Z
other_elem�diffr
r
r�_count_diff_all_purposeys<


rMc	Cs�t|�t|�}}g}|��D]2\}}|�|d�}||krt|||�}|�|�q|��D]&\}}||krZtd||�}|�|�qZ|S)rAr)r�items�getrEr.)	r2r1r
rFr(rIrJrKrLr
r
r�_count_diff_hashable�srPN)F)�__doc__�collectionsrrZos.pathrZ
__unittestrr	rrrrrrr"rr,r8r=r@rErMrPr
r
r
r�<module>s4
���
	)
#PK��[P�<��(__pycache__/signals.cpython-38.opt-2.pycnu�[���U

e5dc	�@sbddlZddlZddlmZdZGdd�de�Ze��Zdd�Z	dd	�Z
dad
d�Zddd
�Z
dS)�N)�wrapsTc@seZdZdd�Zdd�ZdS)�_InterruptHandlercCsNd|_||_t|t�rD|tjkr(tj}n|tjkr<dd�}ntd��||_	dS)NFcSsdS�N�)Z
unused_signumZunused_framerr�(/usr/lib64/python3.8/unittest/signals.py�default_handlersz3_InterruptHandler.__init__.<locals>.default_handlerzYexpected SIGINT signal handler to be signal.SIG_IGN, signal.SIG_DFL, or a callable object)
�called�original_handler�
isinstance�int�signal�SIG_DFL�default_int_handler�SIG_IGN�	TypeErrorr)�selfrrrr�__init__
s



z_InterruptHandler.__init__cCsRt�tj�}||k	r |�||�|jr2|�||�d|_t��D]}|��q@dS)NT)r�	getsignal�SIGINTrr�_results�keys�stop)rZsignum�frameZinstalled_handler�resultrrr�__call__sz_InterruptHandler.__call__N)�__name__�
__module__�__qualname__rrrrrrr	srcCsdt|<dS)N�)r�rrrr�registerResult*sr cCstt�|d��Sr)�boolr�poprrrr�removeResult-sr#cCs.tdkr*t�tj�}t|�at�tjt�dSr)�_interrupt_handlerrrrr)rrrr�installHandler1sr%cs<�dk	r t���fdd��}|Stdk	r8t�tjtj�dS)Nc
s6t�tj�}t�z�||�W�St�tj|�XdSr)rrr�
removeHandler)�args�kwargs�initial��methodrr�inner;s
zremoveHandler.<locals>.inner)rr$rrr	)r+r,rr*rr&9sr&)N)r�weakref�	functoolsrZ
__unittest�objectr�WeakKeyDictionaryrr r#r$r%r&rrrr�<module>s PK��[���8�8!__pycache__/loader.cpython-38.pycnu�[���U

e5d�X�@sdZddlZddlZddlZddlZddlZddlZddlZddlmZm	Z	ddl
mZmZm
Z
dZe�dej�ZGdd	�d	ej�Zd
d�Zdd
�Zdd�Zdd�Zdd�ZGdd�de�Ze�Zddd�Ze
jdfdd�Zde
jejfdd�Z de
jejfdd�Z!dS) zLoading unittests.�N)�fnmatch�fnmatchcase�)�case�suite�utilTz[_a-z]\w*\.py$cs,eZdZdZ�fdd�Z�fdd�Z�ZS)�_FailedTestNcs||_tt|��|�dS�N)�
_exception�superr�__init__)�selfZmethod_name�	exception��	__class__��'/usr/lib64/python3.8/unittest/loader.pyrsz_FailedTest.__init__cs*|�jkrtt���|�S�fdd�}|S)Ncs
�j�dSr	)r
r�r
rr�testFailure!sz,_FailedTest.__getattr__.<locals>.testFailure)�_testMethodNamerr�__getattr__)r
�namerrrrrs
z_FailedTest.__getattr__)�__name__�
__module__�__qualname__rrr�
__classcell__rrrrrsrcCs"d|t��f}t|t|�||�S)Nz#Failed to import test module: %s
%s)�	traceback�
format_exc�_make_failed_test�ImportError)r�
suiteClass�messagerrr�_make_failed_import_test&s
�r"cCsdt��f}t||||�S)NzFailed to call load_tests:
%s)rrr)rrr r!rrr�_make_failed_load_tests+s�r#cCst||�}||f�|fSr	)r)�
methodnamerr r!�testrrrr0s
rcCs<t�t|��dd��}||i}tdtjf|�}|||�f�S)NcSsdSr	rrrrr�testSkipped5sz'_make_skipped_test.<locals>.testSkippedZ
ModuleSkipped)r�skip�str�type�TestCase)r$rr r&�attrsZ	TestClassrrr�_make_skipped_test4s

r,cCs*|���d�r|dd�Stj�|�dS)Nz	$py.classi����r)�lower�endswith�os�path�splitext)r0rrr�_jython_aware_splitext<sr2cs�eZdZdZdZeej�ZdZ	e
jZdZ
�fdd�Zdd�Zdd�d	d
�Zd!dd�Zd"d
d�Zdd�Zd#dd�Zdd�Zdd�Zdd�Zdd�Zd$dd�Zd%dd �Z�ZS)&�
TestLoaderz�
    This class is responsible for loading tests according to various criteria
    and returning them wrapped in a TestSuite
    r%Ncs tt|���g|_t�|_dSr	)rr3r�errors�set�_loading_packagesrrrrrMszTestLoader.__init__cCsFt|tj�rtd��|�|�}|s2t|d�r2dg}|�t||��}|S)z;Return a suite of all test cases contained in testCaseClasszYTest cases should not be derived from TestSuite. Maybe you meant to derive from TestCase?ZrunTest)�
issubclassr�	TestSuite�	TypeError�getTestCaseNames�hasattrr �map)r
�
testCaseClassZ
testCaseNamesZloaded_suiterrr�loadTestsFromTestCaseTs
z TestLoader.loadTestsFromTestCase��patternc

Os:t|�dksd|kr,t�dt�|�dd�t|�dkrRt|�d}td�|���t|�dkrxt|�d}td�|���g}t|�D]4}t	||�}t
|t�r�t|t
j�r�|�|�|��q�t	|dd�}	|�|�}|	dk	�r6z|	|||�WStk
�r4}
z,t|j|
|j�\}}|j�|�|WY�Sd}
~
XYnX|S)	z>Return a suite of all test cases contained in the given modulerZuse_load_testsz(use_load_tests is deprecated and ignoredNrzCloadTestsFromModule() takes 1 positional argument but {} were givenz=loadTestsFromModule() got an unexpected keyword argument '{}'�
load_tests)�len�warnings�warn�DeprecationWarning�popr9�format�sorted�dir�getattr�
isinstancer)r7rr*�appendr>r �	Exceptionr#rr4)
r
�moduler@�argsZkwsZ	complaint�testsr�objrA�e�
error_case�
error_messagerrr�loadTestsFromModulebs<�


�zTestLoader.loadTestsFromModulecCsX|�d�}d\}}|dkr�|dd�}|r�zd�|�}t|�}Wq�Wq&tk
r�|��}t||j�\}}|s�|j�|�|YSYq&Xq&|dd�}|}	|D]�}
z|	t	|	|
�}}	Wq�t
k
�rN}zvt	|	dd�dk	�r|dk	�r|j�|�|WY�DSt|
||jdt�
�f�\}}|j�|�|WY�
SW5d}~XYq�Xq�t|	tj��rj|�|	�St|	t��r�t|	tj��r�|�|	�St|	tj��r�t|t��r�t|tj��r�|d}||�}
tt	|
|�tj��s�|�|
g�Snt|	tj��r�|	St|	��rH|	�}t|tj��r|St|tj��r6|�|g�Std|	|f��ntd	|	��dS)
aSReturn a suite of all test cases given a string specifier.

        The name may resolve either to a module, a test case class, a
        test method within a test case class, or a callable object which
        returns a TestCase or TestSuite instance.

        The method optionally resolves the names relative to a given module.
        �.)NNNr�__path__zFailed to access attribute:
%s���z"calling %s returned %s, not a testz$don't know how to make test from: %s)�split�join�
__import__rrFr"r r4rLrJ�AttributeErrorrrrrK�types�
ModuleTyperUr)r7rr*r>�FunctionTyperr8�callabler9)r
rrN�partsrSrTZ
parts_copy�module_nameZnext_attributerQ�part�parentrR�instr%rrr�loadTestsFromName�s�	

����$

�
�
�zTestLoader.loadTestsFromNamecs��fdd�|D�}��|�S)z�Return a suite of all test cases found using the given sequence
        of string specifiers. See 'loadTestsFromName()'.
        csg|]}��|���qSr)rf)�.0r�rNr
rr�
<listcomp>�sz1TestLoader.loadTestsFromNames.<locals>.<listcomp>)r )r
�namesrNZsuitesrrhr�loadTestsFromNames�szTestLoader.loadTestsFromNamescs>��fdd�}tt|t����}�jr:|jt��j�d�|S)zLReturn a sorted sequence of method names found within testCaseClass
        csZ|��j�sdSt�|�}t|�s&dSd�j�j|f��jdkpXt�fdd��jD��S)NFz%s.%s.%sc3s|]}t�|�VqdSr	)r)rgr@�ZfullNamerr�	<genexpr>�szKTestLoader.getTestCaseNames.<locals>.shouldIncludeMethod.<locals>.<genexpr>)�
startswith�testMethodPrefixrJr`rr�testNamePatterns�any)�attrnameZtestFunc�r
r=rlr�shouldIncludeMethod�s
�
�z8TestLoader.getTestCaseNames.<locals>.shouldIncludeMethod)�key)�list�filterrI�sortTestMethodsUsing�sort�	functools�
cmp_to_key)r
r=rtZtestFnNamesrrsrr:�s
zTestLoader.getTestCaseNames�test*.pycCsJd}|dkr|jdk	r|j}n|dkr.d}|}tj�|�}|tjkrRtj�d|�||_d}d}g}tj�tj�|��r�tj�|�}||kr�tj�tj�|d��}�npzt	|�Wnt
k
r�d}Y�nJXtj|}|�d�d}	ztj�tj�
|j��}Wn�tk
�r�z
|j}
Wntk
�r8d}
YnX|
�r�|
jdk�r�|
jdk	�r�d}|jD]P}|�s||�|��s|�qb|�|j�dtjj��d|_|�|j||dd���qbn*|jtjk�r�td�d�ntd	�|��d�YnX|�r|�s|�|	�|_tj�|�ntj�|�|�r*t
d
|��|�s@t|�||��}|� |�S)a%Find and return all test modules from the specified start
        directory, recursing into subdirectories to find them and return all
        tests found within them. Only test files that match the pattern will
        be loaded. (Using shell style pattern matching.)

        All test modules must be importable from the top level of the project.
        If the start directory is not the top level directory then the top
        level directory must be specified separately.

        If a test package name (directory with '__init__.py') matches the
        pattern then the package will be checked for a 'load_tests' function. If
        this exists then it will be called with (loader, tests, pattern) unless
        the package has already had load_tests called from the same discovery
        invocation, in which case the package module object is not scanned for
        tests - this ensures that when a package uses discover to further
        discover child tests that infinite recursion does not happen.

        If load_tests exists then discovery does *not* recurse into the package,
        load_tests is responsible for loading all tests in the package.

        The pattern is deliberately not stored as a loader attribute so that
        packages can continue discovery themselves. top_level_dir is stored so
        load_tests does not need to pass this argument in to loader.discover().

        Paths are sorted before being imported to ensure reproducible execution
        order even on filesystems with non-alphabetical ordering like ext3/4.
        FNTr�__init__.pyrV)�	namespacez2Can not use builtin modules as dotted module namesz$don't know how to discover from {!r}z%Start directory is not importable: %r)!�_top_level_dirr/r0�abspath�sys�insert�isdir�isfilerZr[r�modulesrY�dirname�__file__r\�__spec__�loader�submodule_search_locationsrWrnr�replace�sep�extend�_find_tests�builtin_module_namesr9rG� _get_directory_containing_module�removervr )r
�	start_dirr@Z
top_level_dirZset_implicit_topZis_not_importable�is_namespacerPZ
the_moduleZtop_part�specr0rrr�discover�s�

�


�
���
������zTestLoader.discovercCsRtj|}tj�|j�}tj�|����d�rBtj�	tj�	|��Stj�	|�SdS)Nr})
r�r�r/r0r�r��basenamer-rnr�)r
rbrN�	full_pathrrrr�`s

z+TestLoader._get_directory_containing_modulecCsh||jkrdSttj�|��}tj�||j�}tj�|�rBtd��|�d�rTtd��|�	tjj
d�}|S)NrVzPath must be within the projectz..)rr2r/r0�normpath�relpath�isabs�AssertionErrorrnr�r�)r
r0Z_relpathrrrr�_get_name_from_pathls
zTestLoader._get_name_from_pathcCst|�tj|Sr	)r[r�r�)r
rrrr�_get_module_from_namexsz TestLoader._get_module_from_namecCs
t||�Sr	)r)r
r0r�r@rrr�_match_path|szTestLoader._match_pathFc

cs�|�|�}|dkrD||jkrD|�|||�\}}|dk	r<|V|sDdStt�|��}|D]t}tj�||�}	|�|	||�\}}|dk	r�|V|rV|�|	�}|j�|�z|�
|	||�EdHW5|j�	|�XqVdS)z/Used by discovery. Yields test suites it loads.rVN)r�r6�_find_test_pathrHr/�listdirr0rZ�add�discardr�)
r
r�r@r~rrPZshould_recurse�pathsr0r�rrrr��s6
��
zTestLoader._find_testsc
Csttj�|�}tj�|��rVt�|�s(dS|�|||�s:dS|�|�}z|�|�}Wnht	j
k
r�}zt|||j�dfWY�Sd}~XYn�t
||j�\}}	|j�|	�|dfYSXtj�t|d|��}
ttj�|
��}ttj�|��}|��|��k�r@tj�|�}
ttj�|��}tj�|�}d}t|||
|f��|j||d�dfS�ntj�|��rl|�s�tj�tj�|d���s�dSd}d}|�|�}z|�|�}Wnjt	j
k
�r�}zt|||j�dfWY�Sd}~XYn�t
||j�\}}	|j�|	�|dfYSXt|dd�}|j�|�z0|j||d�}|dk	�rP|dfW�S|d	fW�S|j�|�XndSdS)
z�Used by discovery.

        Loads tests from a single file, or a directories' __init__.py when
        passed the directory.

        Returns a tuple (None_or_tests_from_file, should_recurse).
        )NFFNr�zW%r module incorrectly imported from %r. Expected %r. Is this module globally installed?r?r}rAT)r/r0r�r��VALID_MODULE_NAME�matchr�r�r�rZSkipTestr,r r"r4rLr�rJr2�realpathr-r�rrUr�rZr6r�r�)r
r�r@r~r�rrNrRrSrTZmod_filer�Zfullpath_noextZ
module_dirZmod_nameZexpected_dir�msgrArP�packagerrrr��s|

&
�
�
�
�
���
&
�
zTestLoader._find_test_path)N)N)r|N)F)F)rrr�__doc__ro�staticmethodr�
three_way_cmprxrprr8r rrr>rUrfrkr:r�r�r�r�r�r�r�rrrrrr3Bs&
(
N

n
"r3cCs&t�}||_||_||_|r"||_|Sr	)r3rxrorpr )�prefix�	sortUsingr rpr�rrr�_makeLoader�sr�cCst|||d��|�S)N)rp)r�r:)r=r�r�rprrrr:�sr:r%cCst|||��|�Sr	)r�r>)r=r�r�r rrr�	makeSuite�s�r�cCst|||��|�Sr	)r�rU)rNr�r�r rrr�
findTestCasess�r�)NN)"r�r/�rer�rr]rzrCrr�rrrZ
__unittest�compile�
IGNORECASEr�r*rr"r#rr,r2�objectr3ZdefaultTestLoaderr�r�r:r8r�r�rrrr�<module>s</
	�
�PK��[P�<��"__pycache__/signals.cpython-38.pycnu�[���U

e5dc	�@sbddlZddlZddlmZdZGdd�de�Ze��Zdd�Z	dd	�Z
dad
d�Zddd
�Z
dS)�N)�wrapsTc@seZdZdd�Zdd�ZdS)�_InterruptHandlercCsNd|_||_t|t�rD|tjkr(tj}n|tjkr<dd�}ntd��||_	dS)NFcSsdS�N�)Z
unused_signumZunused_framerr�(/usr/lib64/python3.8/unittest/signals.py�default_handlersz3_InterruptHandler.__init__.<locals>.default_handlerzYexpected SIGINT signal handler to be signal.SIG_IGN, signal.SIG_DFL, or a callable object)
�called�original_handler�
isinstance�int�signal�SIG_DFL�default_int_handler�SIG_IGN�	TypeErrorr)�selfrrrr�__init__
s



z_InterruptHandler.__init__cCsRt�tj�}||k	r |�||�|jr2|�||�d|_t��D]}|��q@dS)NT)r�	getsignal�SIGINTrr�_results�keys�stop)rZsignum�frameZinstalled_handler�resultrrr�__call__sz_InterruptHandler.__call__N)�__name__�
__module__�__qualname__rrrrrrr	srcCsdt|<dS)N�)r�rrrr�registerResult*sr cCstt�|d��Sr)�boolr�poprrrr�removeResult-sr#cCs.tdkr*t�tj�}t|�at�tjt�dSr)�_interrupt_handlerrrrr)rrrr�installHandler1sr%cs<�dk	r t���fdd��}|Stdk	r8t�tjtj�dS)Nc
s6t�tj�}t�z�||�W�St�tj|�XdSr)rrr�
removeHandler)�args�kwargs�initial��methodrr�inner;s
zremoveHandler.<locals>.inner)rr$rrr	)r+r,rr*rr&9sr&)N)r�weakref�	functoolsrZ
__unittest�objectr�WeakKeyDictionaryrr r#r$r%r&rrrr�<module>s PK��[|�Eo%__pycache__/util.cpython-38.opt-1.pycnu�[���U

e5d_�@s�dZddlmZmZddlmZdZdZdZdZ	dZ
dZee	eeee
Zdd	�Z
d
d�Zdd
d�Zdd�Zdd�Zdd�Zdd�Zedd�Zdd�Zdd�ZdS)zVarious utility functions.�)�
namedtuple�Counter)�commonprefixT�P��cCsBt|�||}|tkr>d|d|�||t|�|d�f}|S)Nz%s[%d chars]%s)�len�_PLACEHOLDER_LEN)�s�	prefixlenZ	suffixlen�skip�r
�%/usr/lib64/python3.8/unittest/util.py�_shortens&rcs�ttt|��}ttt|��}|tkr(|St|��t���t|�tt}|t	krxt
�t|��t��fdd�|D��St
�tt	��t��fdd�|D��S)Nc3s|]}�|�d�VqdS�Nr
��.0r
��prefixrr
r�	<genexpr>'sz'_common_shorten_repr.<locals>.<genexpr>c3s&|]}�t|�d�tt�VqdSr)r�
_MIN_DIFF_LEN�_MIN_END_LENrrr
rr*s�)�tuple�map�	safe_repr�maxr�_MAX_LENGTHr�_MIN_BEGIN_LENr	�_MIN_COMMON_LENr)�args�maxlenZ
common_lenr
rr�_common_shorten_reprs ��r!FcCsPzt|�}Wntk
r*t�|�}YnX|r<t|�tkr@|S|dt�dS)Nz [truncated]...)�repr�	Exception�object�__repr__rr)�objZshort�resultr
r
rr-srcCsd|j|jfS)Nz%s.%s)�
__module__�__qualname__)�clsr
r
r�strclass6sr+cCsd}}g}g}z�||}||}||krT|�|�|d7}|||kr�|d7}q<nv||kr�|�|�|d7}|||kr�|d7}qnnD|d7}z|||kr�|d7}q�W5|d7}|||kr�|d7}q�XWqtk
�r|�||d��|�||d��Y�qYqXq||fS)arFinds elements in only one or the other of two, sorted input lists.

    Returns a two-element tuple of lists.    The first list contains those
    elements in the "expected" list but not in the "actual" list, and the
    second contains those elements in the "actual" list but not in the
    "expected" list.    Duplicate elements in either input list are ignored.
    r�N)�append�
IndexError�extend)�expected�actual�i�j�missingZ
unexpected�e�ar
r
r�sorted_list_difference9s8

r7cCsHg}|r@|��}z|�|�Wqtk
r<|�|�YqXq||fS)z�Same behavior as sorted_list_difference but
    for lists of unorderable items (like dicts).

    As it does a linear search per item (remove) it
    has O(n*n) performance.)�pop�remove�
ValueErrorr-)r0r1r4�itemr
r
r�unorderable_list_differencebsr<cCs||k||kS)z.Return -1 if x < y, 0 if x == y and 1 if x > yr
)�x�yr
r
r�
three_way_cmpssr?ZMismatchzactual expected valuecCs,t|�t|�}}t|�t|�}}t�}g}t|�D]�\}}	|	|krHq6d}
}t||�D] }|||	krZ|
d7}
|||<qZt|�D] \}}
|
|	kr�|d7}|||<q�|
|kr6t|
||	�}|�|�q6t|�D]X\}}	|	|kr�q�d}t||�D] }|||	kr�|d7}|||<q�td||	�}|�|�q�|S)�HReturns list of (cnt_act, cnt_exp, elem) triples where the counts differrr,)�listrr$�	enumerate�range�	_Mismatchr-)r1r0r
�t�m�nZNULLr'r2�elem�cnt_s�cnt_tr3Z
other_elem�diffr
r
r�_count_diff_all_purposeys<


rLc	Cs�t|�t|�}}g}|��D]2\}}|�|d�}||krt|||�}|�|�q|��D]&\}}||krZtd||�}|�|�qZ|S)r@r)r�items�getrDr-)	r1r0r
rEr'rHrIrJrKr
r
r�_count_diff_hashable�srON)F)�__doc__�collectionsrrZos.pathrZ
__unittestrr	rrrrrr!rr+r7r<r?rDrLrOr
r
r
r�<module>s2
���
	)
#PK��[���58.8.%__pycache__/mock.cpython-38.opt-1.pycnu�[���U

e5d��@s�dZdZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZddl
mZddlmZmZdd�ee�D�Zd	ZeZd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zd�dd�Zdd�Zdd�Zdd�Z dd �Z!d�d!d"�Z"d#d$�Z#d%d&�Z$d'd(�Z%Gd)d*�d*e&�Z'Gd+d,�d,e&�Z(e(�Z)e)j*Z*e)j+Z,e)j-Z.d-d.d/d0d1d2d3d4hZ/d5d6�Z0Gd7d8�d8e1�Z2d9d:�Z3Gd;d<�d<e&�Z4Gd=d>�d>e&�Z5Gd?d@�d@e5�Z6dAdB�Z7GdCdD�dDe5�Z8GdEdF�dFe8e6�Z9dGdH�Z:dIdJ�Z;GdKdL�dLe&�Z<dMdN�Z=e*dddddfdOdP�Z>d�dQdR�Z?e*dddddfdSdT�Z@GdUdV�dVe&�ZAdWdX�ZBdYdZ�ZCe>e@_&eAe@_De?e@_EeCe@_Fd[e@_Gd\ZHd]ZId^�Jd_d`�eI�K�D��ZLd^�Jdad`�eI�K�D��ZMdbdcdddedfdgdhdidjdkdldmdndodpdqdrdshZNdtdu�ZOdvd�d^�JeHeIeLeMg��K�D�ZPdwdxdyhZQdzhZReQeRBZSePeNBZTeTeSBZUd{d|d}d~dd�d�d�hZVd�d��d�d��d�d��d�d��d��ZWeXeXeXeXd�dddd�d�d	d�dd��
ZYd�d��ZZd�d��Z[d�d��Z\d�d��Z]eZe[e\e]d��Z^d�d��Z_Gd�d��d�e5�Z`Gd�d��d�e`e6�ZaGd�d��d�e`�ZbGd�d��d�e`e9�ZcGd�d��d�e5�ZdGd�d��d�e5�ZeGd�d��d�eeebe9�ZfGd�d��d�e&�Zgeg�Zhd�d��ZiGd�d��d�ej�Zkekdd��Zld�d�d��Zmd�d��ZnGd�d��d�e&�Zoepem�epehjq�fZrdasd�d��Ztd�d�d��ZuGd�d��d�e9�Zvd�d��ZwGd�d��d��ZxdS)�)�Mock�	MagicMock�patch�sentinel�DEFAULT�ANY�call�create_autospec�	AsyncMock�
FILTER_DIR�NonCallableMock�NonCallableMagicMock�	mock_open�PropertyMock�sealz1.0�N)�CodeType�
ModuleType�
MethodType)�	safe_repr)�wraps�partialcCsh|]}|�d�s|�qS��_��
startswith)�.0�name�r�%/usr/lib64/python3.8/unittest/mock.py�	<setcomp>(s
rTcCs>t|�rt|t�sdSt|d�r*t|d�}t�|�p<t�|�S)NF�__func__)	�_is_instance_mock�
isinstancer	�hasattr�getattr�asyncio�iscoroutinefunction�inspectZisawaitable��objrrr�
_is_async_obj0s


r*cCst|dd�rt�|�SdSdS)N�__code__F)r$r%r&��funcrrr�_is_async_func8s
r.cCstt|�t�S�N)�
issubclass�typerr(rrrr!?sr!cCst|t�pt|t�ot|t�Sr/)r"�
BaseExceptionr1r0r(rrr�
_is_exceptionEs
�r3cCs"t|t�rt|d�r|jS|SdS�N�mock)r"�
FunctionTypesr#r5r(rrr�
_extract_mockLsr7cCs�t|t�r|s|j}d}n,t|t�sFz
|j}Wntk
rDYdSX|rVt|d�}n|}z|t�|�fWSt	k
r�YdSXdS)z�
    Given an arbitrary, possibly callable object, try to create a suitable
    signature object.
    Return a (reduced func, signature) tuple, or None.
    TN)
r"r1�__init__r6�__call__�AttributeErrorrr'�	signature�
ValueError)r-Zas_instanceZeat_selfZsig_funcrrr�_get_signature_objectUs

r=FcsNt|||���dkrdS�\}��fdd�}t||�|t|�_�t|�_dS)Ncs�j||�dSr/��bind��self�args�kwargs��sigrr�checksigwsz"_check_signature.<locals>.checksig)r=�_copy_func_detailsr1�_mock_check_sig�
__signature__)r-r5�	skipfirst�instancerFrrDr�_check_signaturers

rLc	Cs:dD]0}zt||t||��Wqtk
r2YqXqdS)N)�__name__�__doc__�__text_signature__�
__module__�__defaults__�__kwdefaults__)�setattrr$r:)r-�funcopy�	attributerrrrG~s
rGcCs@t|t�rdSt|tttf�r(t|j�St|dd�dk	r<dSdS)NTr9F)r"r1�staticmethod�classmethodr�	_callabler r$r(rrrrX�s

rXcCst|�ttfkSr/)r1�list�tupler(rrr�_is_list�sr[cCsFt|t�st|dd�dk	S|f|jD]}|j�d�dk	r&dSq&dS)ztGiven an object, return True if the object is callable.
    For classes, return True if instances would be callable.r9NTF)r"r1r$�__mro__�__dict__�get)r)�baserrr�_instance_callable�s
r`cs�t|t�}t|||�}|dkr"|S|\}��fdd�}t||�|j}|��sRd}||d�}d|}	t|	|�||}
t|
|��|
S)Ncs�j||�dSr/r>�rBrCrDrrrF�sz _set_signature.<locals>.checksigrT)Z
_checksig_r5zYdef %s(*args, **kwargs):
    _checksig_(*args, **kwargs)
    return mock(*args, **kwargs))r"r1r=rGrM�isidentifier�exec�_setup_func)r5�originalrKrJ�resultr-rFr�context�srcrTrrDr�_set_signature�s$


�
rics���_�fdd�}�fdd�}�fdd�}�fdd�}�fd	d
�}�fdd�}�fd
d�}	��fdd�}
d�_d�_d�_t��_t��_t��_�j�_�j	�_	�j
�_
|�_|�_|�_
|	�_|
�_|�_|�_|�_|�_��_dS)Ncs�j||�Sr/)�assert_called_withra�r5rrrj�sz'_setup_func.<locals>.assert_called_withcs�j||�Sr/)�
assert_calledrarkrrrl�sz"_setup_func.<locals>.assert_calledcs�j||�Sr/)�assert_not_calledrarkrrrm�sz&_setup_func.<locals>.assert_not_calledcs�j||�Sr/)�assert_called_oncerarkrrrn�sz'_setup_func.<locals>.assert_called_oncecs�j||�Sr/)�assert_called_once_withrarkrrro�sz,_setup_func.<locals>.assert_called_once_withcs�j||�Sr/)�assert_has_callsrarkrrrp�sz%_setup_func.<locals>.assert_has_callscs�j||�Sr/)�assert_any_callrarkrrrq�sz$_setup_func.<locals>.assert_any_callcs:t��_t��_����j}t|�r6|�k	r6|��dSr/)�	_CallList�method_calls�
mock_calls�
reset_mock�return_valuer!)�ret�rTr5rrru�sz_setup_func.<locals>.reset_mockFr)r5�called�
call_count�	call_argsrr�call_args_listrsrtrv�side_effect�_mock_childrenrjrorprqrurlrmrnrI�_mock_delegate)rTr5rErjrlrmrnrorprqrurrxrrd�s8rdcsJtjj�_d�_d�_t��_�fdd�}dD]}t�|t||��q.dS)Nrcst�j|�||�Sr/)r$r5)�attrrBrCrkrr�wrapper�sz"_setup_async_mock.<locals>.wrapper)�assert_awaited�assert_awaited_once�assert_awaited_with�assert_awaited_once_with�assert_any_await�assert_has_awaits�assert_not_awaited)	r%�
coroutines�
_is_coroutine�await_count�
await_argsrr�await_args_listrSr)r5r�rUrrkr�_setup_async_mock�s
r�cCsd|dd�|kS)N�__%s__����r�rrrr�	_is_magicsr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_SentinelObjectz!A unique, named, sentinel object.cCs
||_dSr/r��rArrrrr8sz_SentinelObject.__init__cCs
d|jS�Nzsentinel.%sr��rArrr�__repr__sz_SentinelObject.__repr__cCs
d|jSr�r�r�rrr�
__reduce__sz_SentinelObject.__reduce__N)rMrP�__qualname__rNr8r�r�rrrrr�sr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�	_SentinelzAAccess attributes to return a named object, usable as a sentinel.cCs
i|_dSr/)�
_sentinelsr�rrrr8#sz_Sentinel.__init__cCs|dkrt�|j�|t|��S)N�	__bases__)r:r��
setdefaultr�r�rrr�__getattr__&sz_Sentinel.__getattr__cCsdS)Nrrr�rrrr�,sz_Sentinel.__reduce__N)rMrPr�rNr8r�r�rrrrr�!sr�rv�_mock_return_valuer}�_mock_side_effect�_mock_parent�_mock_new_parent�
_mock_name�_mock_new_namecCs8t�|�d|}||fdd�}||fdd�}t||�S)NZ_mock_cSs"|j}|dkrt||�St||�Sr/)rr$)rAr�	_the_namerErrr�_getAs
z"_delegating_property.<locals>._getcSs*|j}|dkr||j|<nt|||�dSr/)rr]rS)rA�valuerr�rErrr�_setFsz"_delegating_property.<locals>._set)�_allowed_names�add�property)rr�r�r�rrr�_delegating_property>s

r�c@seZdZdd�Zdd�ZdS)rrcCslt|t�st�||�St|�}t|�}||kr2dStd||d�D]"}||||�}||krDdSqDdS)NFr�T)r"rY�__contains__�len�range)rAr�Z	len_valueZlen_self�iZsub_listrrrr�Ss
z_CallList.__contains__cCst�t|��Sr/)�pprintZpformatrYr�rrrr�asz_CallList.__repr__N)rMrPr�r�r�rrrrrrQsrrcCs|t|�}t|�sdS|js4|js4|jdk	s4|jdk	r8dS|}|dk	rX||krPdS|j}q<|rh||_||_|rx||_||_dS)NFT)r7r!r�r�r�r�)�parentr�r�new_name�_parentrrr�_check_and_set_parentes*��r�c@seZdZdd�Zdd�ZdS)�	_MockItercCst|�|_dSr/)�iterr))rAr)rrrr8�sz_MockIter.__init__cCs
t|j�Sr/)�nextr)r�rrr�__next__�sz_MockIter.__next__N)rMrPr�r8r�rrrrr��sr�c@seZdZeZdZdd�ZdS)�BaseNcOsdSr/rr@rrrr8�sz
Base.__init__)rMrPr�rr�r�r8rrrrr��sr�c@sdeZdZdZdd�ZdLdd�Zd	d
�ZdMdd�ZdNd
d�Zdd�Z	dd�Z
dZee	e
e�Z
edd��Zed�Zed�Zed�Zed�Zed�Zdd�Zdd�Zeee�ZdOddd�d d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Z dPd3d4�Z!d5d6�Z"d7d8�Z#d9d:�Z$d;d<�Z%d=d>�Z&d?d@�Z'dAdB�Z(dQdCdD�Z)dEdF�Z*dGdH�Z+dRdJdK�Z,dS)Srz A non-callable version of `Mock`c	Os�|f}t|t�s^t�tj�}|j|f|�|�j}dd�|��D�}|r^t	||d�r^t
|f}t|j|d|j
i�}tt|��|�}|S)NcSsg|]}|�d�r|�qS��specr�r�argrrr�
<listcomp>�s
�z+NonCallableMock.__new__.<locals>.<listcomp>rrN)r0r	r'r;rr8Zbind_partialZ	arguments�keysr*�AsyncMockMixinr1rMrN�_safe_super�__new__)	�clsrB�kw�basesrEZ
bound_argsZspec_arg�newrKrrrr��s
�zNonCallableMock.__new__N�FcKs�|dkr|}|j}
||
d<||
d<||
d<||
d<d|
d<|dk	rJ|}d}|
dkrZ|dk	}
|�|||	|
�i|
d<||
d	<d|
d
<d|
d<d|
d<d
|
d<t�|
d<t�|
d<t�|
d<||
d<|r�|jf|�tt|��||||||�dS)Nr�r�r�r�F�_mock_sealedTr~�_mock_wrapsrZ_mock_calledZ_mock_call_argsrZ_mock_call_countZ_mock_call_args_listZ_mock_mock_callsrs�_mock_unsafe)r]�_mock_add_specrr�configure_mockr�rr8)rAr�rr�spec_setr��_spec_state�	_new_name�_new_parent�_spec_as_instance�	_eat_selfZunsaferCr]rrrr8�sD



�zNonCallableMock.__init__cCs0t|�}d|_d|_d|_d|_t|||�dS)z�
        Attach a mock as an attribute of this one, replacing its name and
        parent. Calls to the attached mock will be recorded in the
        `method_calls` and `mock_calls` attributes of this one.Nr�)r7r�r�r�r�rS)rAr5rUZ
inner_mockrrr�attach_mock�szNonCallableMock.attach_mockcCs|�||�dS�z�Add a spec to a mock. `spec` can either be an object or a
        list of strings. Only attributes on the `spec` can be fetched as
        attributes from the mock.

        If `spec_set` is True then only attributes on the spec can be set.N)r��rAr�r�rrr�
mock_add_spec�szNonCallableMock.mock_add_speccCs�d}d}g}t|�D] }t�t||d��r|�|�q|dk	r~t|�s~t|t�rV|}nt|�}t|||�}	|	ot|	d}t|�}|j	}
||
d<||
d<||
d<||
d<||
d<dS)Nr��_spec_class�	_spec_set�_spec_signature�
_mock_methods�_spec_asyncs)
�dirr%r&r$�appendr[r"r1r=r])rAr�r�r�r�r�r�r�r��resr]rrrr��s,
�zNonCallableMock._mock_add_speccCs8|j}|jdk	r|jj}|tkr4|j|dd�}||_|S)N�()�r�r�)r�rrvr�_get_child_mock)rArwrrrZ__get_return_values
�z"NonCallableMock.__get_return_valuecCs,|jdk	r||j_n||_t||dd�dS)Nr�)rrvr�r�)rAr�rrrZ__set_return_values

z"NonCallableMock.__set_return_valuez1The value to be returned when the mock is called.cCs|jdkrt|�S|jSr/)r�r1r�rrr�	__class__!s
zNonCallableMock.__class__ryrzr{r|rtcCsN|j}|dkr|jS|j}|dk	rJt|�sJt|t�sJt|�sJt|�}||_|Sr/)rr�r}�callabler"r�r3)rA�	delegatedZsfrrrZ__get_side_effect.s��z!NonCallableMock.__get_side_effectcCs(t|�}|j}|dkr||_n||_dSr/)�	_try_iterrr�r})rAr�r�rrrZ__set_side_effect9s
z!NonCallableMock.__set_side_effect)rvr}cCs�|dkrg}t|�|krdS|�t|��d|_d|_d|_t�|_t�|_t�|_|r^t	|_
|rhd|_|j�
�D]"}t|t�sr|tkr�qr|�|�qr|j
}t|�r�||k	r�|�|�dS)z-Restore the mock object to its initial state.NFr)�idr�ryr{rzrrrtr|rsrr�r�r~�valuesr"�
_SpecState�_deletedrur!)rAZvisitedrvr}�childrwrrrruDs,zNonCallableMock.reset_mockcKsXt|��dd�d�D]>\}}|�d�}|��}|}|D]}t||�}q6t|||�qdS)aZSet attributes on the mock through keyword arguments.

        Attributes plus return values and side effects can be set on child
        mocks using standard dot notation and unpacking a dictionary in the
        method call:

        >>> attrs = {'method.return_value': 3, 'other.side_effect': KeyError}
        >>> mock.configure_mock(**attrs)cSs|d�d�S)Nr�.)�count)�entryrrr�<lambda>o�z0NonCallableMock.configure_mock.<locals>.<lambda>)�keyr�N)�sorted�items�split�popr$rS)rArCr��valrB�finalr)r�rrrr�bs	�
zNonCallableMock.configure_mockcCs�|dkrt|��n:|jdk	r<||jks.|tkrLtd|��nt|�rLt|��|jsd|�d�rdtd��|j�|�}|tkr�t|��np|dkr�d}|j	dk	r�t
|j	|�}|j|||||d�}||j|<n.t|t
�r�t|j|j|j|j|j�}||j|<|S)N>r�r�zMock object has no attribute %r)�assertZassretz1Attributes cannot start with 'assert' or 'assret')r�rrr�r�)r:r��_all_magicsr�r�rr~r^r�r�r$r�r"r�rr�r�rKr�r)rArrfrrrrr�xsF




�
�
zNonCallableMock.__getattr__cCs�|jg}|j}|}d}|dgkr$d}|dk	rZ|}|�|j|�d}|jdkrRd}|j}q$tt|��}|jpnd}t|�dkr�|ddkr�|d7}||d<d�|�S)Nr�r�r�r5r�)r�z().r)r�r�r�rY�reversedr�r��join)rAZ
_name_listr�Zlast�dotZ_firstrrr�_extract_mock_name�s(


z"NonCallableMock._extract_mock_namecCs^|��}d}|dkrd|}d}|jdk	rDd}|jr8d}||jj}dt|�j||t|�fS)Nr�)r5zmock.z name=%rz spec=%rz spec_set=%rz<%s%s%s id='%s'>)r�r�r�rMr1r�)rArZname_stringZspec_stringrrrr��s 
�zNonCallableMock.__repr__cCsvtst�|�S|jpg}tt|��}t|j�}dd�|j�	�D�}dd�|D�}dd�|D�}t
t||||��S)z8Filter the output of `dir(mock)` to only useful members.cSsg|]\}}|tk	r|�qSr)r�)rZm_nameZm_valuerrrr��s�z+NonCallableMock.__dir__.<locals>.<listcomp>cSsg|]}|�d�s|�qSrr�r�errrr��s
cSs"g|]}|�d�rt|�r|�qSr)rr�rrrrr��s
�)r
�object�__dir__r�r�r1rYr]r~r�r��set)rAZextrasZ	from_typeZ	from_dictZfrom_child_mocksrrrr�s


�zNonCallableMock.__dir__csT|tkrt��||�S�jrH�jdk	rH|�jkrH|�jkrHtd|��n�|tkrbd|}t|��n�|tkr�jdk	r�|�jkr�td|��t	|�s�t
t��|t||��|���fdd�}n(t
�|d|�t
t��||�|�j|<n,|dkr�|�_dSt
�|||��r|�j|<�j�rFt�|��sF����d|��}td|����t��||�S)Nz!Mock object has no attribute '%s'z.Attempting to set unsupported magic method %r.cs��f|�|�Sr/r�rBr��rerArrr��r�z-NonCallableMock.__setattr__.<locals>.<lambda>r�r�zCannot set )r�r�__setattr__r�r�r]r:�_unsupported_magicsr�r!rSr1�_get_methodr�r~r�r�r#r�)rArr��msg�	mock_namerrrr�s<��

zNonCallableMock.__setattr__cCs�|tkr2|t|�jkr2tt|�|�||jkr2dS|j�|t�}||jkr\tt|��	|�n|t
krlt|��|tk	r||j|=t
|j|<dSr/)r�r1r]�delattrr~r^�_missingr�r�__delattr__r�r:)rArr)rrrrs

zNonCallableMock.__delattr__cCs|jpd}t|||�Sr4)r��_format_call_signature�rArBrCrrrr�_format_mock_call_signatures
z+NonCallableMock._format_mock_call_signaturercCs.d}|�||�}|j}|j|�}||||fS)Nz.expected %s not found.
Expected: %s
Actual: %s)rr{)rArBrC�action�message�expected_stringr{Z
actual_stringrrr�_format_mock_failure_messages

z,NonCallableMock._format_mock_failure_messagecCsj|s
|jSd}|�dd��d�}|j}|D]:}|�|�}|dksJt|t�rPqfq*t|�}|j}|j}q*|S)aH
        * If call objects are asserted against a method/function like obj.meth1
        then there could be no name for the call object to lookup. Hence just
        return the spec_signature of the method/function being asserted against.
        * If the name is not empty then remove () and split by '.' to get
        list of names to iterate through the children until a potential
        match is found. A child mock is created only during attribute access
        so if we get a _SpecState then no attributes of the spec were accessed
        and can be safely exited.
        Nr�r�r�)r��replacer�r~r^r"r�r7)rArrE�namesZchildrenr�rrr�_get_call_signature_from_name's
z-NonCallableMock._get_call_signature_from_namec
Cs�t|t�r&t|�dkr&|�|d�}n|j}|dk	r�t|�dkrNd}|\}}n
|\}}}z||j||�fWStk
r�}z|�d�WY�Sd}~XYq�Xn|SdS)a
        Given a call (or simply an (args, kwargs) tuple), return a
        comparison key suitable for matching with other calls.
        This is a best effort method which relies on the spec's signature,
        if available, or falls back on the arguments themselves.
        r�rNr�)r"rZr�rr�r?�	TypeError�with_traceback)rA�_callrErrBrCrrrr�
_call_matcherHs

"zNonCallableMock._call_matchercCs0|jdkr,d|jpd|j|��f}t|��dS)z/assert that the mock was never called.
        rz9Expected '%s' to not have been called. Called %s times.%sr5N�rzr��_calls_repr�AssertionError�rAr
rrrrmbs
��z!NonCallableMock.assert_not_calledcCs$|jdkr d|jpd}t|��dS)z6assert that the mock was called at least once
        rz"Expected '%s' to have been called.r5N)rzr�rr rrrrlls

�zNonCallableMock.assert_calledcCs0|jdks,d|jpd|j|��f}t|��dS)z3assert that the mock was called only once.
        r�z:Expected '%s' to have been called once. Called %s times.%sr5Nrr rrrrnts
��z"NonCallableMock.assert_called_oncecs��jdkr.�����}d}d||f}t|�����fdd�}����f�}���j�}||kr~t|t�rn|nd}t|��|�dS)z�assert that the last call was made with the specified arguments.

        Raises an AssertionError if the args and keyword args passed in are
        different to the last call to the mock.Nznot called.z0expected call not found.
Expected: %s
Actual: %scs�����}|Sr/�r�r
�rBrCrArr�_error_message�sz:NonCallableMock.assert_called_with.<locals>._error_message)r{rrrr"�	Exception)rArBrC�expected�actualZ
error_messager$�causerr#rrj~s
�z"NonCallableMock.assert_called_withcOs8|jdks,d|jpd|j|��f}t|��|j||�S)ziassert that the mock was called exactly once and that that call was
        with the specified arguments.r�z3Expected '%s' to be called once. Called %s times.%sr5)rzr�rrrj�rArBrCr
rrrro�s
��z'NonCallableMock.assert_called_once_withc		s�fdd�|D�}tdd�|D�d�}t�fdd��jD��}|s�||kr�|dkrXd}nd�d	d�|D��}t|�d
t|���jdd��d
����|�dSt|�}g}|D]2}z|�|�Wq�t	k
r�|�
|�Yq�Xq�|�rtd�jp�dt|�|f�|�dS)a�assert the mock has been called with the specified calls.
        The `mock_calls` list is checked for the calls.

        If `any_order` is False (the default) then the calls must be
        sequential. There can be extra calls before or after the
        specified calls.

        If `any_order` is True then the calls can be in any order, but
        they must all appear in `mock_calls`.csg|]}��|��qSr�r�r�cr�rrr��sz4NonCallableMock.assert_has_calls.<locals>.<listcomp>css|]}t|t�r|VqdSr/�r"r%rrrr�	<genexpr>�s
z3NonCallableMock.assert_has_calls.<locals>.<genexpr>Nc3s|]}��|�VqdSr/r*r+r�rrr.�szCalls not found.z+Error processing expected calls.
Errors: {}cSsg|]}t|t�r|nd�qSr/r-rrrrr��s��
Expected: ZActual)�prefixr�z@%r does not contain all of %r in its call list, found %r insteadr5)
r�rrrt�formatrr�rstriprY�remover<r�r�rZ)	rA�calls�	any_orderr&r(Z	all_calls�problem�	not_found�kallrr�rrp�sH
��"������z NonCallableMock.assert_has_callscsZ��||f�}�fdd��jD�}||krVt|t�r8|nd}��||�}td|�|�dS)z�assert the mock has been called with the specified arguments.

        The assert passes if the mock has *ever* been called, unlike
        `assert_called_with` and `assert_called_once_with` that only pass if
        the call is the most recent one.csg|]}��|��qSrr*r+r�rrr��sz3NonCallableMock.assert_any_call.<locals>.<listcomp>Nz%s call not found)rr|r"r%rr�rArBrCr&r'r(rrr�rrq�s��zNonCallableMock.assert_any_callcKs�|�d�}||jdkr"tf|�St|�}t|t�rB|tkrBt}nbt|t�rp|tksd|j	rj||j	krjt}q�t}n4t|t
�s�t|t�r�t}q�t|t�r�t
}n
|jd}|jr�d|kr�d|dnd}|��|}t|��|f|�S)aPCreate the child mocks for attributes and return value.
        By default child mocks will be the same type as the parent.
        Subclasses of Mock may want to override this to customize the way
        child mocks are made.

        For non-callable mocks the callable variant will be used (rather than
        any custom subclass).r�r�r�rr�r�)r^r]r	r1r0r�_async_method_magicsr��_all_sync_magicsr��
CallableMixinrrrr\r�r�r:)rAr�r��_type�klassrUrrrrr��s2


��



zNonCallableMock._get_child_mock�CallscCs"|js
dSd|�dt|j��d�S)z�Renders self.mock_calls as a string.

        Example: "
Calls: [call(1), call(2)]."

        If self.mock_calls is empty, an empty string is returned. The
        output will be truncated if very long.
        r��
z: r�)rtr)rAr0rrrrszNonCallableMock._calls_repr)NNNNNNr�NFNF)F)FF)N)r)F)r?)-rMrPr�rNr�r8r�r�r�Z"_NonCallableMock__get_return_valueZ"_NonCallableMock__set_return_valueZ"_NonCallableMock__return_value_docr�rvr�r�ryrzr{r|rtZ!_NonCallableMock__get_side_effectZ!_NonCallableMock__set_side_effectr}rur�r�r�r�rrrrrrrrmrlrnrjrorprqr�rrrrrr�sp�
-
	�

�

''
!


-'rcCsL|dkr|St|�r|St|�r$|Sz
t|�WStk
rF|YSXdSr/)r3rXr�rr(rrrr�s
r�c
@sReZdZddedddddddf
dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)r<Nr�c	Ks6||jd<tt|�j|||||||	|
f|�||_dS)Nr�)r]r�r<r8r})rAr�r}rvrrr�r�r�r�r�rCrrrr8#s

��zCallableMixin.__init__cOsdSr/rr@rrrrH/szCallableMixin._mock_check_sigcOs$|j||�|j||�|j||�Sr/)rH�_increment_mock_call�
_mock_callr@rrrr94szCallableMixin.__call__cOs|j||�Sr/)�_execute_mock_callr@rrrrB<szCallableMixin._mock_callcOsd|_|jd7_t||fdd�}||_|j�|�|jdk	}|j}|j}|dk}|j	�td||f��|j
}|dk	r�|r�|j�t|||f��|jdk	}|r�|jd|}t|||f�}	|j	�|	�|jr�|r�d}
nd}
|jdk}|j|
|}|j
}qpdS)NTr���twor�r�r�)ryrz�_Callr{r|r�r�r�r�rtr�rs)rArBrCrZdo_method_callsZmethod_call_nameZmock_call_nameZ	is_a_callr�Zthis_mock_callr�rrrrA?s4


z"CallableMixin._increment_mock_callcOs||j}|dk	rPt|�r|�n(t|�s:t|�}t|�rD|�n
|||�}|tk	rP|S|jtk	r`|jS|jdk	rv|j||�S|jSr/)r}r3rXr�rr�rvr�)rArBrC�effectrfrrrrCms 


z CallableMixin._execute_mock_call)
rMrPr�rr8rHr9rBrArCrrrrr<!s�
.r<c@seZdZdZdS)ra�	
    Create a new `Mock` object. `Mock` takes several optional arguments
    that specify the behaviour of the Mock object:

    * `spec`: This can be either a list of strings or an existing object (a
      class or instance) that acts as the specification for the mock object. If
      you pass in an object then a list of strings is formed by calling dir on
      the object (excluding unsupported magic attributes and methods). Accessing
      any attribute not in this list will raise an `AttributeError`.

      If `spec` is an object (rather than a list of strings) then
      `mock.__class__` returns the class of the spec object. This allows mocks
      to pass `isinstance` tests.

    * `spec_set`: A stricter variant of `spec`. If used, attempting to *set*
      or get an attribute on the mock that isn't on the object passed as
      `spec_set` will raise an `AttributeError`.

    * `side_effect`: A function to be called whenever the Mock is called. See
      the `side_effect` attribute. Useful for raising exceptions or
      dynamically changing return values. The function is called with the same
      arguments as the mock, and unless it returns `DEFAULT`, the return
      value of this function is used as the return value.

      If `side_effect` is an iterable then each call to the mock will return
      the next value from the iterable. If any of the members of the iterable
      are exceptions they will be raised instead of returned.

    * `return_value`: The value returned when the mock is called. By default
      this is a new Mock (created on first access). See the
      `return_value` attribute.

    * `wraps`: Item for the mock object to wrap. If `wraps` is not None then
      calling the Mock will pass the call through to the wrapped object
      (returning the real result). Attribute access on the mock will return a
      Mock object that wraps the corresponding attribute of the wrapped object
      (so attempting to access an attribute that doesn't exist will raise an
      `AttributeError`).

      If the mock has an explicit `return_value` set then calls are not passed
      to the wrapped object and the `return_value` is returned instead.

    * `name`: If the mock has a name then it will be used in the repr of the
      mock. This can be useful for debugging. The name is propagated to child
      mocks.

    Mocks can also be called with arbitrary keyword arguments. These will be
    used to set attributes on the mock after it is created.
    N�rMrPr�rNrrrrr�srcCs8zt||�WStk
r2t|�t||�YSXdSr/)r$r:�
__import__)�thing�comp�import_pathrrr�_dot_lookup�s
rMcCsB|�d�}|�d�}t|�}|D]}|d|7}t|||�}q |S)Nr�rz.%s)r�r�rIrM)�targetZ
componentsrLrJrKrrr�	_importer�s

rOc@szeZdZdZgZdd�Zdd�Zdd�Zdd	�Ze	j
d
d��Zdd
�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS)�_patchNc

Csn|dk	r(|tk	rtd��|dk	r(td��||_||_||_||_||_||_d|_||_	||_
|	|_g|_dS)Nz,Cannot use 'new' and 'new_callable' togetherz1Cannot use 'autospec' and 'new_callable' togetherF)
rr<�getterrUr��new_callabler��createZ	has_localr��autospecrC�additional_patchers)
rArQrUr�r�rSr�rTrRrCrrrr8�s(��z_patch.__init__c
CsHt|j|j|j|j|j|j|j|j|j	�	}|j
|_
dd�|jD�|_|S)NcSsg|]}|���qSr)�copy)r�prrrr��sz_patch.copy.<locals>.<listcomp>)rPrQrUr�r�rSr�rTrRrC�attribute_namerU)rA�patcherrrrrV�s ��z_patch.copycCs2t|t�r|�|�St�|�r(|�|�S|�|�Sr/)r"r1�decorate_classr'r&�decorate_async_callable�decorate_callable�rAr-rrrr9�s




z_patch.__call__cCsNt|�D]@}|�tj�sqt||�}t|d�s0q|��}t||||��q|S�Nr9)r�rr�TEST_PREFIXr$r#rVrS)rAr>r��
attr_valuerYrrrrZs

z_patch.decorate_classc	csrg}t���\}|jD]8}|�|�}|jdk	r8|�|�q|jtkr|�|�q|t	|�7}||fVW5QRXdSr/)
�
contextlib�	ExitStack�	patchings�
enter_contextrX�updater�rr�rZ)rA�patchedrB�keywargs�
extra_args�
exit_stack�patchingr�rrr�decoration_helpers




z_patch.decoration_helpercs>t�d�r�j����St�����fdd����g�_�S)Nrcc
s4���||��\}}�||�W5QR�SQRXdSr/�rk�rBrgZnewargsZnewkeywargs�r-rfrArrrf(s�z)_patch.decorate_callable.<locals>.patched�r#rcr�rr]rrnrr\"s
z_patch.decorate_callablecs>t�d�r�j����St�����fdd����g�_�S)Nrcc
�s:���||��"\}}�||�IdHW5QR�SQRXdSr/rlrmrnrrrf9s�z/_patch.decorate_async_callable.<locals>.patchedror]rrnrr[3s
z_patch.decorate_async_callablec	Cs�|��}|j}t}d}z|j|}Wn$ttfk
rHt||t�}YnXd}|tkrft|t	�rfd|_
|j
s�|tkr�td||f��||fS)NFTz!%s does not have the attribute %r)rQrUrr]r:�KeyErrorr$�	_builtinsr"rrS)rArNrre�localrrr�get_originalDs 
�z_patch.get_originalcCs�|j|j|j}}}|j|j}}|j}|��|_|dkr@d}|dkrLd}|dkrXd}|dk	rp|dk	rptd��|dk	s�|dk	r�|dkr�td��|�	�\}}|t
k�r||dk�r|d}	|dkr�|}|dkr�|}d}n&|dk	r�|dkr�|}d}n|dkr�|}|dk	�s|dk	�r.|t
k�rtd��t|t��r.d}	|dk�rHt
|��rHt}
nt}
i}|dk	�r`|}
n^|dk	�st|dk	�r�|}|dk	�r�|}t|��r�d|k}
n
t|�}
t
|��r�t}
n
|
�r�t}
|dk	�r�||d	<|dk	�r�||d
<t|
t��rt|
t��r|j�r|j|d<|�|�|
f|�}|	�r�t|��r�|}|dk	�rB|}t|��sZt|��sZt}
|�d�|
f|dd
�|��|_nl|dk	�r�|t
k	�r�td��|t
k�r�td��t|�}|dk�r�|}t|f||jd�|��}n|�r�td��|}||_||_t� �|_!zrt"|j|j|�|j#dk	�rpi}|jt
k�r:|||j#<|j$D](}|j!�%|�}|jt
k�r@|�|��q@|WS|WS|j&t'�(���s��YnXdS)zPerform the patch.FNzCan't specify spec and autospec)TNz6Can't provide explicit spec_set *and* spec or autospecTz!Can't use 'spec' with create=Truer9r�r�rr�r�zBautospec creates the mock for you. Can't specify autospec and new.z%Can't use 'autospec' with create=True)r��_namez.Can't pass kwargs to a mock we aren't creating))r�r�r�rTrCrRrQrNrrsrr"r1r*r	rr[r�rr0rrUrer!r`r�rv�boolr�
temp_original�is_localrarb�_exit_stackrSrXrUrd�__exit__�sys�exc_info)rAr�r�r�rTrCrRrerrZinherit�Klass�_kwargsZ	this_specZnot_callableZnew_attrrhrjr�rrr�	__enter__\s�
�








��




�
�


�

��


z_patch.__enter__cGs�|jr$|jtk	r$t|j|j|j�n>t|j|j�|jsbt|j|j�rP|jdkrbt|j|j|j�|`|`|`|j	}|`	|j
|�S)zUndo the patch.)rNrPrQ�__annotations__rR)rwrvrrSrNrUrrSr#rxry)rAr{rirrrry�s�z_patch.__exit__cCs|��}|j�|�|S)z-Activate a patch, returning any created mock.)r~�_active_patchesr�)rArfrrr�start�sz_patch.startcCs6z|j�|�Wntk
r&YdSX|�ddd�S)zStop an active patch.N)r�r3r<ryr�rrr�stop�s
z_patch.stop)rMrPr�rXr�r8rVr9rZra�contextmanagerrkr\r[rsr~ryr�r�rrrrrP�s 

rPc	sPz��dd�\�}Wn&ttfk
r:td�f��YnX�fdd�}||fS)Nr�r�z.Need a valid target to patch. You supplied: %rcst��Sr/�rOr�rNrrr�r�z_get_target.<locals>.<lambda>)�rsplitrr<)rNrUrQrr�r�_get_target
s�r�c

s>t��tkrt��d����fdd�}	t|	||||||||�	S)a
    patch the named member (`attribute`) on an object (`target`) with a mock
    object.

    `patch.object` can be used as a decorator, class decorator or a context
    manager. Arguments `new`, `spec`, `create`, `spec_set`,
    `autospec` and `new_callable` have the same meaning as for `patch`. Like
    `patch`, `patch.object` takes arbitrary keyword arguments for configuring
    the mock object it creates.

    When used as a class decorator `patch.object` honours `patch.TEST_PREFIX`
    for choosing which methods to wrap.
    z3 must be the actual object to be patched, not a strcs�Sr/rrr�rrr�*r�z_patch_object.<locals>.<lambda>)r1�strrrP)
rNrUr�r�rSr�rTrRrCrQrr�r�
_patch_objects ��r�c
s�t��tkr�fdd�}n�fdd�}|s2td��t|���}|d\}	}
t||	|
|||||i�	}|	|_|dd�D]2\}	}
t||	|
|||||i�	}|	|_|j�|�qt|S)a�Perform multiple patches in a single call. It takes the object to be
    patched (either as an object or a string to fetch the object by importing)
    and keyword arguments for the patches::

        with patch.multiple(settings, FIRST_PATCH='one', SECOND_PATCH='two'):
            ...

    Use `DEFAULT` as the value if you want `patch.multiple` to create
    mocks for you. In this case the created mocks are passed into a decorated
    function by keyword, and a dictionary is returned when `patch.multiple` is
    used as a context manager.

    `patch.multiple` can be used as a decorator, class decorator or a context
    manager. The arguments `spec`, `spec_set`, `create`,
    `autospec` and `new_callable` have the same meaning as for `patch`. These
    arguments will be applied to *all* patches done by `patch.multiple`.

    When used as a class decorator `patch.multiple` honours `patch.TEST_PREFIX`
    for choosing which methods to wrap.
    cst��Sr/r�rr�rrr�Hr�z!_patch_multiple.<locals>.<lambda>cs�Sr/rrr�rrr�Jr�z=Must supply at least one keyword argument with patch.multiplerr�N)	r1r�r<rYr�rPrXrUr�)
rNr�rSr�rTrRrCrQr�rUr�rYZthis_patcherrr�r�_patch_multiple1sH���r�c

Ks$t|�\}}	t||	|||||||�	S)a7
    `patch` acts as a function decorator, class decorator or a context
    manager. Inside the body of the function or with statement, the `target`
    is patched with a `new` object. When the function/with statement exits
    the patch is undone.

    If `new` is omitted, then the target is replaced with an
    `AsyncMock if the patched object is an async function or a
    `MagicMock` otherwise. If `patch` is used as a decorator and `new` is
    omitted, the created mock is passed in as an extra argument to the
    decorated function. If `patch` is used as a context manager the created
    mock is returned by the context manager.

    `target` should be a string in the form `'package.module.ClassName'`. The
    `target` is imported and the specified object replaced with the `new`
    object, so the `target` must be importable from the environment you are
    calling `patch` from. The target is imported when the decorated function
    is executed, not at decoration time.

    The `spec` and `spec_set` keyword arguments are passed to the `MagicMock`
    if patch is creating one for you.

    In addition you can pass `spec=True` or `spec_set=True`, which causes
    patch to pass in the object being mocked as the spec/spec_set object.

    `new_callable` allows you to specify a different class, or callable object,
    that will be called to create the `new` object. By default `AsyncMock` is
    used for async functions and `MagicMock` for the rest.

    A more powerful form of `spec` is `autospec`. If you set `autospec=True`
    then the mock will be created with a spec from the object being replaced.
    All attributes of the mock will also have the spec of the corresponding
    attribute of the object being replaced. Methods and functions being
    mocked will have their arguments checked and will raise a `TypeError` if
    they are called with the wrong signature. For mocks replacing a class,
    their return value (the 'instance') will have the same spec as the class.

    Instead of `autospec=True` you can pass `autospec=some_object` to use an
    arbitrary object as the spec instead of the one being replaced.

    By default `patch` will fail to replace attributes that don't exist. If
    you pass in `create=True`, and the attribute doesn't exist, patch will
    create the attribute for you when the patched function is called, and
    delete it again afterwards. This is useful for writing tests against
    attributes that your production code creates at runtime. It is off by
    default because it can be dangerous. With it switched on you can write
    passing tests against APIs that don't actually exist!

    Patch can be used as a `TestCase` class decorator. It works by
    decorating each test method in the class. This reduces the boilerplate
    code when your test methods share a common patchings set. `patch` finds
    tests by looking for method names that start with `patch.TEST_PREFIX`.
    By default this is `test`, which matches the way `unittest` finds tests.
    You can specify an alternative prefix by setting `patch.TEST_PREFIX`.

    Patch can be used as a context manager, with the with statement. Here the
    patching applies to the indented block after the with statement. If you
    use "as" then the patched object will be bound to the name after the
    "as"; very useful if `patch` is creating a mock object for you.

    `patch` takes arbitrary keyword arguments. These will be passed to
    the `Mock` (or `new_callable`) on construction.

    `patch.dict(...)`, `patch.multiple(...)` and `patch.object(...)` are
    available for alternate use-cases.
    )r�rP)
rNr�r�rSr�rTrRrCrQrUrrrrbsF�rc@sReZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
eZe
ZdS)�_patch_dicta#
    Patch a dictionary, or dictionary like object, and restore the dictionary
    to its original state after the test.

    `in_dict` can be a dictionary or a mapping like container. If it is a
    mapping then it must at least support getting, setting and deleting items
    plus iterating over keys.

    `in_dict` can also be a string specifying the name of the dictionary, which
    will then be fetched by importing it.

    `values` can be a dictionary of values to set in the dictionary. `values`
    can also be an iterable of `(key, value)` pairs.

    If `clear` is True then the dictionary will be cleared before the new
    values are set.

    `patch.dict` can also be called with arbitrary keyword arguments to set
    values in the dictionary::

        with patch.dict('sys.modules', mymodule=Mock(), other_module=Mock()):
            ...

    `patch.dict` can be used as a context manager, decorator or class
    decorator. When used as a class decorator `patch.dict` honours
    `patch.TEST_PREFIX` for choosing which methods to wrap.
    rFcKs,||_t|�|_|j�|�||_d|_dSr/)�in_dict�dictr�re�clear�	_original)rAr�r�r�rCrrrr8�s

z_patch_dict.__init__cs.t�t�r����St����fdd��}|S)Ncs&���z�||�W�S���XdSr/)r��
_unpatch_dictr��frArr�_inner�sz$_patch_dict.__call__.<locals>._inner)r"r1rZr)rAr�r�rr�rr9�s


z_patch_dict.__call__cCsXt|�D]J}t||�}|�tj�rt|d�rt|j|j|j	�}||�}t
|||�q|Sr^)r�r$rrr_r#r�r�r�r�rS)rAr>r�r`Z	decoratorZ	decoratedrrrrZ�s
�z_patch_dict.decorate_classcCs|��|jS)zPatch the dict.)r�r�r�rrrr~�sz_patch_dict.__enter__cCs�|j}t|jt�rt|j�|_|j}|j}z|��}Wn.tk
rdi}|D]}||||<qNYnX||_|rxt	|�z|�
|�Wn*tk
r�|D]}||||<q�YnXdSr/)r�r"r�r�rOr�rVr:r��_clear_dictre)rAr�r�r�rer�rrrr��s&z_patch_dict._patch_dictcCsR|j}|j}t|�z|�|�Wn*tk
rL|D]}||||<q6YnXdSr/)r�r�r�rer:)rAr�rer�rrrr�sz_patch_dict._unpatch_dictcGs|��dS)zUnpatch the dict.F)r�)rArBrrrrysz_patch_dict.__exit__N)rF)
rMrPr�rNr8r9rZr~r�r�ryr�r�rrrrr��s
	
r�cCs>z|��Wn,tk
r8t|�}|D]
}||=q(YnXdSr/)r�r:rY)r�r�r�rrrr�&sr�cCsttj�D]}|��q
dS)z7Stop all active patches. LIFO to unroll nested patches.N)r�rPr�r�)rrrr�_patch_stopall/sr�Ztestz�lt le gt ge eq ne getitem setitem delitem len contains iter hash str sizeof enter exit divmod rdivmod neg pos abs invert complex int float index round trunc floor ceil bool next fspath aiter zHadd sub mul matmul div floordiv mod lshift rshift and xor or pow truediv� ccs|]}d|VqdS)zi%sNr�r�nrrrr.Nsr.ccs|]}d|VqdS)zr%sNrr�rrrr.Os�__get__�__set__�
__delete__�__reversed__�__missing__r��
__reduce_ex__Z__getinitargs__�__getnewargs__�__getstate__�__setstate__�
__getformat__Z
__setformat__r�r�__subclasses__�
__format__�__getnewargs_ex__cs�fdd�}||_|S)z:Turns a callable object (like a mock) into a real functioncs�|f|�|�Sr/r�rArBr�r,rr�method`sz_get_method.<locals>.method)rM)rr-r�rr,rr	^sr	cCsh|]}d|�qS)r�r)rr�rrrrfs�
__aenter__�	__aexit__�	__anext__�	__aiter__r�rr8r��__prepare__�__instancecheck__�__subclasscheck__�__del__cCs
t�|�Sr/)r�__hash__r�rrrr�|r�r�cCs
t�|�Sr/)r�__str__r�rrrr�}r�cCs
t�|�Sr/)r�
__sizeof__r�rrrr�~r�cCs"t|�j�d|���dt|���S)N�/)r1rMr�r�r�rrrr�r�)r�r�r��
__fspath__r�y�?g�?)
�__lt__�__gt__�__le__�__ge__�__int__r��__len__ry�__complex__�	__float__�__bool__�	__index__r�cs�fdd�}|S)Ncs$�jj}|tk	r|S�|kr dStS�NT)�__eq__r�r�NotImplemented)�other�ret_valr�rrr��sz_get_eq.<locals>.__eq__r)rAr�rr�r�_get_eq�sr�cs�fdd�}|S)Ncs �jjtk	rtS�|krdStS�NF)�__ne__r�rr�)r�r�rrr��s
z_get_ne.<locals>.__ne__r)rAr�rr�r�_get_ne�sr�cs�fdd�}|S)Ncs �jj}|tkrtg�St|�Sr/)�__iter__r�rr��r�r�rrr��sz_get_iter.<locals>.__iter__r)rAr�rr�r�	_get_iter�sr�cs�fdd�}|S)Ncs(�jj}|tkrttg��Stt|��Sr/)r�r�r�_AsyncIteratorr�r�r�rrr��sz"_get_async_iter.<locals>.__aiter__r)rAr�rr�r�_get_async_iter�sr�)r�r�r�r�cCsbt�|t�}|tk	r||_dSt�|�}|dk	rB||�}||_dSt�|�}|dk	r^||�|_dSr/)�_return_valuesr^rrv�_calculate_return_value�_side_effect_methodsr})r5r�rZfixedZreturn_calculatorrvZ
side_effectorrrr�_set_return_value�s

r�c@seZdZdd�Zdd�ZdS)�
MagicMixincOs&|��tt|�j||�|��dSr/)�_mock_set_magicsr�r�r8r�rrrr8�szMagicMixin.__init__cCs�ttB}|}t|dd�dk	rX|�|j�}t�}||}|D]}|t|�jkr:t||�q:|tt|�j�}t|�}|D]}t	||t
||��qvdS)Nr�)�_magicsr:r$�intersectionr�rr1r]rrS�
MagicProxy)rAZorig_magicsZthese_magicsZ
remove_magicsr�r=rrrr��szMagicMixin._mock_set_magicsN)rMrPr�r8r�rrrrr��sr�c@seZdZdZddd�ZdS)rz-A version of `MagicMock` that isn't callable.FcCs|�||�|��dSr��r�r�r�rrrr��sz"NonCallableMagicMock.mock_add_specN)F�rMrPr�rNr�rrrrr�src@seZdZdd�ZdS)�AsyncMagicMixincOs&|��tt|�j||�|��dSr/)r�r�r�r8r�rrrr8�szAsyncMagicMixin.__init__N�rMrPr�r8rrrrr��sr�c@seZdZdZddd�ZdS)ra�
    MagicMock is a subclass of Mock with default implementations
    of most of the magic methods. You can use MagicMock without having to
    configure the magic methods yourself.

    If you use the `spec` or `spec_set` arguments then *only* magic
    methods that exist in the spec will be created.

    Attributes and the return value of a `MagicMock` will also be `MagicMocks`.
    FcCs|�||�|��dSr�r�r�rrrr�szMagicMock.mock_add_specN)Fr�rrrrrs
rc@s&eZdZdd�Zdd�Zddd�ZdS)	r�cCs||_||_dSr/�rr�)rArr�rrrr8szMagicProxy.__init__cCs8|j}|j}|j|||d�}t|||�t|||�|S)N)rr�r�)rr�r�rSr�)rAr�r��mrrr�create_mocks�zMagicProxy.create_mockNcCs|��Sr/)r�)rAr)r=rrrr�(szMagicProxy.__get__)N)rMrPr�r8r�r�rrrrr�s	r�cs�eZdZed�Zed�Zed�Z�fdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
ddd�Zdd�Z�fdd�Z�ZS)r�r�r�r�cs\t�j||�tjj|jd<d|jd<d|jd<t�|jd<ttd�}t	j
|_||jd<dS)Nr�rZ_mock_await_countZ_mock_await_argsZ_mock_await_args_list�r�r+)�superr8r%r�r�r]rrrrr'ZCO_COROUTINE�co_flags)rArBrC�	code_mock�r�rrr81s


zAsyncMockMixin.__init__c�st||fdd�}|jd7_||_|j�|�|j}|dk	r�t|�rL|�nbt|�s�zt|�}Wnt	k
rxt
�YnXt|�r�|�n&t�|�r�|||�IdH}n
|||�}|t
k	r�|S|jt
k	r�|jS|jdk	r�t�|j�r�|j||�IdHS|j||�S|jS)NTrDr�)rFr�r�r�r�r}r3rXr��
StopIteration�StopAsyncIterationr%r&rr�rvr�)rArBrCrrGrfrrrrCAs6




z!AsyncMockMixin._execute_mock_callcCs(|jdkr$d|jpd�d�}t|��dS)zA
        Assert that the mock was awaited at least once.
        r�	Expected r5z to have been awaited.N�r�r�rr rrrr�is
zAsyncMockMixin.assert_awaitedcCs0|jdks,d|jpd�d|j�d�}t|��dS)z@
        Assert that the mock was awaited exactly once.
        r�r�r5�$ to have been awaited once. Awaited � times.Nr�r rrrr�qs
z"AsyncMockMixin.assert_awaited_oncecsz�jdkr&�����}td|�d������fdd�}����f�}���j�}||krvt|t�rf|nd}t|��|�dS)zN
        Assert that the last await was with the specified arguments.
        NzExpected await: z
Not awaitedcs�j��dd�}|S)N�await)rr!r"r#rrr$�sz:AsyncMockMixin.assert_awaited_with.<locals>._error_message)r�rrrr"r%)rArBrCr&r$r'r(rr#rr�zs
z"AsyncMockMixin.assert_awaited_withcOs8|jdks,d|jpd�d|j�d�}t|��|j||�S)zi
        Assert that the mock was awaited exactly once and with the specified
        arguments.
        r�r�r5r�r�)r�r�rr�r)rrrr��s
z'AsyncMockMixin.assert_awaited_once_withcsZ��||f�}�fdd��jD�}||krVt|t�r8|nd}��||�}td|�|�dS)zU
        Assert the mock has ever been awaited with the specified arguments.
        csg|]}��|��qSrr*r+r�rrr��sz3AsyncMockMixin.assert_any_await.<locals>.<listcomp>Nz%s await not found)rr�r"r%rrr9rr�rr��s��zAsyncMockMixin.assert_any_awaitFc		s��fdd�|D�}tdd�|D�d�}t�fdd��jD��}|s�||kr�|dkrXd}nd�d	d�|D��}t|�d
t|��d�j���|�dSt|�}g}|D]2}z|�|�Wq�tk
r�|�|�Yq�Xq�|r�tdt	|�f�|�dS)
a�
        Assert the mock has been awaited with the specified calls.
        The :attr:`await_args_list` list is checked for the awaits.

        If `any_order` is False (the default) then the awaits must be
        sequential. There can be extra calls before or after the
        specified awaits.

        If `any_order` is True then the awaits can be in any order, but
        they must all appear in :attr:`await_args_list`.
        csg|]}��|��qSrr*r+r�rrr��sz4AsyncMockMixin.assert_has_awaits.<locals>.<listcomp>css|]}t|t�r|VqdSr/r-rrrrr.�s
z3AsyncMockMixin.assert_has_awaits.<locals>.<genexpr>Nc3s|]}��|�VqdSr/r*r+r�rrr.�szAwaits not found.z,Error processing expected awaits.
Errors: {}cSsg|]}t|t�r|nd�qSr/r-rrrrr��s�r/z	
Actual: z%r not all found in await list)
r�rrr�r1rrYr3r<r�rZ)	rAr4r5r&r(Z
all_awaitsr6r7r8rr�rr��s>������z AsyncMockMixin.assert_has_awaitscCs0|jdkr,d|jpd�d|j�d�}t|��dS)z9
        Assert that the mock was never awaited.
        rr�r5z# to not have been awaited. Awaited r�Nr�r rrrr��s
z!AsyncMockMixin.assert_not_awaitedcs&t�j||�d|_d|_t�|_dS)z0
        See :func:`.Mock.reset_mock()`
        rN)r�rur�r�rrr�r@r�rrru�szAsyncMockMixin.reset_mock)F)rMrPr�r�r�r�r�r8rCr�r�r�r�r�r�r�ru�
__classcell__rrr�rr�,s(	
,	r�c@seZdZdZdS)r	aa
    Enhance :class:`Mock` with features allowing to mock
    an async function.

    The :class:`AsyncMock` object will behave so the object is
    recognized as an async function, and the result of a call is an awaitable:

    >>> mock = AsyncMock()
    >>> asyncio.iscoroutinefunction(mock)
    True
    >>> inspect.isawaitable(mock())
    True


    The result of ``mock()`` is an async function which will have the outcome
    of ``side_effect`` or ``return_value``:

    - if ``side_effect`` is a function, the async function will return the
      result of that function,
    - if ``side_effect`` is an exception, the async function will raise the
      exception,
    - if ``side_effect`` is an iterable, the async function will return the
      next value of the iterable, however, if the sequence of result is
      exhausted, ``StopIteration`` is raised immediately,
    - if ``side_effect`` is not defined, the async function will return the
      value defined by ``return_value``, hence, by default, the async function
      returns a new :class:`AsyncMock` object.

    If the outcome of ``side_effect`` or ``return_value`` is an async function,
    the mock async function obtained when the mock object is called will be this
    async function itself (and not an async function returning an async
    function).

    The test author can also specify a wrapped object with ``wraps``. In this
    case, the :class:`Mock` object behavior is the same as with an
    :class:`.Mock` object: the wrapped object may have methods
    defined as async function functions.

    Based on Martin Richard's asynctest project.
    NrHrrrrr	�sr	c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_ANYz2A helper object that compares equal to everything.cCsdSr�r�rAr�rrrr�	sz_ANY.__eq__cCsdSr�rr�rrrr�	sz_ANY.__ne__cCsdS)Nz<ANY>rr�rrrr�	sz
_ANY.__repr__N)rMrPr�rNr�r�r�rrrrr�	sr�cCs`d|}d}d�dd�|D��}d�dd�|��D��}|r@|}|rX|rP|d7}||7}||S)Nz%s(%%s)r�z, cSsg|]}t|��qSr)�reprr�rrrr�!	sz*_format_call_signature.<locals>.<listcomp>cSsg|]\}}d||f�qS)z%s=%rr)rr�r�rrrr�"	s)r�r�)rrBrCrZformatted_argsZargs_stringZ
kwargs_stringrrrr	s
�rc@s�eZdZdZd!dd�Zd"d	d
�Zdd�ZejZd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zedd��Zedd��Zdd�Zdd �ZdS)#rFa�
    A tuple for holding the results of a call to a mock, either in the form
    `(args, kwargs)` or `(name, args, kwargs)`.

    If args or kwargs are empty then a call tuple will compare equal to
    a tuple without those values. This makes comparisons less verbose::

        _Call(('name', (), {})) == ('name',)
        _Call(('name', (1,), {})) == ('name', (1,))
        _Call(((), {'a': 'b'})) == ({'a': 'b'},)

    The `_Call` object provides a useful shortcut for comparing with call::

        _Call(((1, 2), {'a': 3})) == call(1, 2, a=3)
        _Call(('foo', (1, 2), {'a': 3})) == call.foo(1, 2, a=3)

    If the _Call has no name then it will match any name.
    rr�NFTcCs�d}i}t|�}|dkr$|\}}}nr|dkrd|\}	}
t|	t�rX|	}t|
t�rR|
}qb|
}q�|	|
}}n2|dkr�|\}t|t�r�|}nt|t�r�|}n|}|r�t�|||f�St�||||f�S)Nr�r�r�)r�r"r�rZr�)r�r�rr�rE�	from_kallrBrC�_len�first�secondrrrr�C	s.



z
_Call.__new__cCs||_||_||_dSr/)r�r��_mock_from_kall)rAr�rr�rEr�rrrr8c	sz_Call.__init__cCsh|tkrdSzt|�}Wntk
r.YdSXd}t|�dkrJ|\}}n
|\}}}t|dd�r|t|dd�r||j|jkr|dSd}|dkr�di}}n�|dkr�|\}}}n�|d	kr�|\}	t|	t�r�|	}i}n"t|	t�r�|	}di}}nd}|	}nV|dk�r@|\}
}t|
t��r4|
}t|t��r(|i}}n
d|}}n
|
|}}ndS|�rX||k�rXdS||f||fkS)
NTFr�r�r�rrr�r�)rr�rr$r�r"rZr�)rAr�Z	len_otherZ	self_nameZ	self_argsZself_kwargsZ
other_nameZ
other_argsZother_kwargsr�r�r�rrrr�j	sR


�


z_Call.__eq__cOs<|jdkrtd||fdd�S|jd}t|j||f||d�S)Nr�r�r�r��r�rFrrrrr9�	s

z_Call.__call__cCs2|jdkrt|dd�Sd|j|f}t||dd�S)NF)rr�z%s.%s)rr�r�r�)rAr�rrrrr��	s
z_Call.__getattr__cCs|tjkrt�t�||�Sr/)rZr]r:�__getattribute__)rAr�rrrr��	s
z_Call.__getattribute__cOs|�d�||�S)Nr��r�r@rrrr��	sz_Call.countcOs|�d�||�S)N�indexr�r@rrrr��	sz_Call.indexcCs(t|�dkr|\}}n
|\}}}||fS)Nr�)r�rrrr�_get_call_arguments�	s

z_Call._get_call_argumentscCs|��dS�Nr�r�r�rrrrB�	sz
_Call.argscCs|��dS)Nr�r�r�rrrrC�	sz_Call.kwargscCs||js&|jpd}|�d�r"d|}|St|�dkr@d}|\}}n0|\}}}|sTd}n|�d�shd|}nd|}t|||�S)Nrr�zcall%sr�zcall.%s)r�r�rr�r)rArrBrCrrrr��	s





z_Call.__repr__cCs4g}|}|dk	r(|jr |�|�|j}qtt|��S)z�For a call object that represents multiple calls, `call_list`
        returns a list of all the intermediate calls as well as the
        final call.N)r�r�r�rrr�)rAZvalsrJrrr�	call_list�	s
z_Call.call_list)rr�NFT)rNNFT)rMrPr�rNr�r8r�rr�r9r�r�r�r�r�r�rBrCr�r�rrrrrF0	s*�
 �
7

rF)r�c	Kslt|�rt|�}t|t�}t|�}d|i}|r8d|i}n|dkrDi}|rT|rTd|d<|�|�t}	t�|�rri}n8|r�|r�td��t	}	n"t
|�s�t}	n|r�|r�t|�s�t}	|�
d|�}|}
|dkr�d}
|	f|||
|d	�|��}t|t��rt||�}|�rt|�nt||||�|dk	�r,|�s,||j|<|�rV|�sVd
|k�rVt||dd|d�|_t|�D�]}t|��rr�q^zt||�}
Wntk
�r�Y�q^YnXd|
i}|�r�d|
i}t|
t��s�t|
||||�}||j|<np|}t|t��r�|j}t|||�}||d
<t�|
��rt	}nt}|f||||d�|��}||j|<t|
||d�t|t��r^t|||��q^|S)aICreate a mock object using another object as a spec. Attributes on the
    mock will use the corresponding attribute on the `spec` object as their
    spec.

    Functions or methods being mocked will have their arguments checked
    to check that they are called with the correct signature.

    If `spec_set` is True then attempting to set attributes that don't exist
    on the spec object will raise an `AttributeError`.

    If a class is used as a spec then the return value of the mock (the
    instance of the class) will have the same spec. You can use a class as the
    spec for an instance object by passing `instance=True`. The returned mock
    will only be callable if instances of the mock are callable.

    `create_autospec` also takes arbitrary keyword arguments that are passed to
    the constructor of the created mock.r�r�NTr�zJInstance can not be True when create_autospec is mocking an async functionrr�)r�r�r�rrvr�)rKrtr�r�)r�rr�r�)rJ)r[r1r"r.rerr'Zisdatadescriptor�RuntimeErrorr	rXrr`r�r6rir�rLr~rrvr�r�r$r:r�r5�
_must_skipr%r&rS)r�r�rKr�rtrC�is_typeZ
is_async_funcr}r|r�r5r�rer�r�rJZchild_klassrrrr�	s�




��


�

��
rcCsxt|t�s$|t|di�krdS|j}|jD]H}|j�|t�}|tkrFq*t|tt	f�rZdSt|t
�rl|SdSq*|S)z[
    Return whether we should skip the first argument on spec's `entry`
    attribute.
    r]F)r"r1r$r�r\r]r^rrVrWr6)r�r�r�r>rfrrrr�w
s


r�c@seZdZddd�ZdS)r�FNcCs(||_||_||_||_||_||_dSr/)r��idsr�r�rKr)rAr�r�r�rr�rKrrrr8�
sz_SpecState.__init__)FNNNFr�rrrrr��
s
�r�cCs"t|t�rt�|�St�|�SdSr/)r"�bytes�io�BytesIO�StringIO)�	read_datarrr�
_to_stream�
s

rr�cs&t��}|dg���fdd�}��fdd�}��fdd����fdd	����fd
d�}tdkr�ddl}ttt|j���tt|j����a|dkr�t	d
t
d�}t	td����j_d�j
_d�j_d�j_d�j_|�j_���d<�d�j_|�j_��j_|�j_����fdd�}||_�|_|S)a�
    A helper function to create a mock to replace the use of `open`. It works
    for `open` called directly or used as a context manager.

    The `mock` argument is the mock object to configure. If `None` (the
    default) then a `MagicMock` will be created for you, with the API limited
    to methods or attributes available on standard file handles.

    `read_data` is a string for the `read`, `readline` and `readlines` of the
    file handle to return.  This is an empty string by default.
    Ncs$�jjdk	r�jjS�dj||�Sr�)�	readlinesrvra��_state�handlerr�_readlines_side_effect�
sz)mock_open.<locals>._readlines_side_effectcs$�jjdk	r�jjS�dj||�Sr�)�readrvrarrr�_read_side_effect�
sz$mock_open.<locals>._read_side_effectc?s$��EdH�dj||�VqdSr�)�readlinera)�_iter_side_effectrrr�_readline_side_effect�
sz(mock_open.<locals>._readline_side_effectc3s0�jjdk	r�jjVq�dD]
}|Vq dSr�)rrv)�linerrrr
�
sz$mock_open.<locals>._iter_side_effectcs �jjdk	r�jjSt�d�Sr�)rrvr�rrrr�_next_side_effect�
sz$mock_open.<locals>._next_side_effectr�open)rr�r�r�cs6t���d<�jj�dkr2���d<�d�j_tS)Nrr�)rrr}rra)rrrrrr�
reset_data�
s

zmock_open.<locals>.reset_data)r�	file_spec�_iorYrr��
TextIOWrapper�unionrrrr~rv�writer
rrr}r�r�)r5rZ
_read_datar	rrrrr)r
rrrrrr
�
s8"

r
c@s*eZdZdZdd�Zd	dd�Zdd�ZdS)
raW
    A mock intended to be used as a property, or other descriptor, on a class.
    `PropertyMock` provides `__get__` and `__set__` methods so you can specify
    a return value when it is fetched.

    Fetching a `PropertyMock` instance from an object calls the mock, with
    no args. Setting it calls the mock with the value being set.
    cKs
tf|�Sr/)r)rArCrrrr�szPropertyMock._get_child_mockNcCs|�Sr/r)rAr)Zobj_typerrrr�szPropertyMock.__get__cCs||�dSr/r)rAr)r�rrrr�
szPropertyMock.__set__)N)rMrPr�rNr�r�r�rrrrr�
s
rc	Cs^d|_t|�D]J}zt||�}Wntk
r8YqYnXt|t�sFq|j|krt|�qdS)a�Disable the automatic generation of child mocks.

    Given an input Mock, seals it to ensure no further mocks will be generated
    when accessing an attribute that was not already defined.

    The operation recursively seals the mock passed in, meaning that
    the mock itself, any mocks generated by accessing one of its attributes,
    and all assigned mocks without a name or spec will be sealed.
    TN)r�r�r$r:r"rr�r)r5r�r�rrrrs



rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	r�z8
    Wraps an iterator in an asynchronous iterator.
    cCs&||_ttd�}tj|_||jd<dS)Nr�r+)�iteratorrrr'ZCO_ITERABLE_COROUTINEr�r])rArr�rrrr8+s
z_AsyncIterator.__init__cCs|Sr/rr�rrrr�1sz_AsyncIterator.__aiter__c�s*zt|j�WStk
r YnXt�dSr/)r�rr�r�r�rrrr�4s
z_AsyncIterator.__anext__N)rMrPr�rNr8r�r�rrrrr�'sr�)F)F)NFNNN)FFNN)Nr�)y�__all__�__version__r%rarr'r�rz�builtins�typesrrrZ
unittest.utilr�	functoolsrrr�rqr
r�r�r*r.r!r3r7r=rLrGrXr[r`rirdr�r�rr�r�rr�MISSINGr
ZDELETEDr�r�r�rYrrr�r�r�rr�r<rrMrOrPr�r�r�rr�r�r�r�ZmultipleZstopallr_Z
magic_methodsZnumericsr�r�Zinplace�rightZ
_non_defaultsr	r�r:Z_sync_async_magicsZ
_async_magicsr;r�rr�r�r�r�r�r�r�r�r�r�rr�rr�r�r	r�rrrZrFrrr�r�r1r�r6rrr
rrr�rrrr�<module>s~	



1�	h4<�
�
2�
Mw	���	�
���
	
	�	8+B
�
�
NPK��[�6��jj!__pycache__/runner.cpython-38.pycnu�[���U

e5dW�@sndZddlZddlZddlZddlmZddlmZdZGdd�de	�Z
Gd	d
�d
ej�ZGdd�de	�Z
dS)
z
Running tests�N�)�result)�registerResultTc@s*eZdZdZdd�Zdd�Zd	dd�ZdS)
�_WritelnDecoratorz@Used to decorate file-like objects with a handy 'writeln' methodcCs
||_dS�N)�stream)�selfr�r	�'/usr/lib64/python3.8/unittest/runner.py�__init__sz_WritelnDecorator.__init__cCs|dkrt|��t|j|�S)N)r�__getstate__)�AttributeError�getattrr)r�attrr	r	r
�__getattr__sz_WritelnDecorator.__getattr__NcCs|r|�|�|�d�dS�N�
)�write)r�argr	r	r
�writelns
z_WritelnDecorator.writeln)N)�__name__�
__module__�__qualname__�__doc__rrrr	r	r	r
r
srcs�eZdZdZdZdZ�fdd�Zdd�Z�fdd	�Z�fd
d�Z	�fdd
�Z
�fdd�Z�fdd�Z�fdd�Z
�fdd�Zdd�Zdd�Z�ZS)�TextTestResultzhA test result class that can print formatted text results to a stream.

    Used by TextTestRunner.
    zF======================================================================zF----------------------------------------------------------------------cs8tt|��|||�||_|dk|_|dk|_||_dS)Nr)�superrrr�showAll�dots�descriptions)rrr�	verbosity��	__class__r	r
r%s


zTextTestResult.__init__cCs0|��}|jr$|r$d�t|�|f�St|�SdSr)ZshortDescriptionr�join�str)r�testZdoc_first_liner	r	r
�getDescription,s
zTextTestResult.getDescriptioncsBtt|��|�|jr>|j�|�|��|j�d�|j��dS)Nz ... )rr�	startTestrrrr%�flush�rr$r r	r
r&3s
zTextTestResult.startTestcsDtt|��|�|jr$|j�d�n|jr@|j�d�|j��dS)N�ok�.)	rr�
addSuccessrrrrrr'r(r r	r
r+:szTextTestResult.addSuccesscsFtt|��||�|jr&|j�d�n|jrB|j�d�|j��dS)N�ERROR�E)	rr�addErrorrrrrrr'�rr$�errr r	r
r.BszTextTestResult.addErrorcsFtt|��||�|jr&|j�d�n|jrB|j�d�|j��dS)N�FAIL�F)	rr�
addFailurerrrrrr'r/r r	r
r3JszTextTestResult.addFailurecsLtt|��||�|jr,|j�d�|��n|jrH|j�d�|j�	�dS)Nz
skipped {0!r}�s)
rr�addSkiprrr�formatrrr')rr$�reasonr r	r
r5RszTextTestResult.addSkipcsFtt|��||�|jr&|j�d�n|jrB|j�d�|j��dS)Nzexpected failure�x)	rr�addExpectedFailurerrrrrr'r/r r	r
r9Zsz!TextTestResult.addExpectedFailurecsDtt|��|�|jr$|j�d�n|jr@|j�d�|j��dS)Nzunexpected success�u)	rr�addUnexpectedSuccessrrrrrr'r(r r	r
r;bsz#TextTestResult.addUnexpectedSuccesscCs6|js|jr|j��|�d|j�|�d|j�dS)Nr,r1)rrrr�printErrorList�errors�failures�rr	r	r
�printErrorsjs
zTextTestResult.printErrorscCsX|D]N\}}|j�|j�|j�d||�|�f�|j�|j�|j�d|�qdS)Nz%s: %sz%s)rr�
separator1r%�
separator2)rZflavourr=r$r0r	r	r
r<ps
zTextTestResult.printErrorList)rrrrrArBrr%r&r+r.r3r5r9r;r@r<�
__classcell__r	r	r r
rsrc@s4eZdZdZeZd
dd�dd�Zd	d
�Zdd�ZdS)�TextTestRunnerz�A test runner class that displays results in textual form.

    It prints out the names of tests as they are run, errors as they
    occur, and a summary of the results at the end of the test run.
    NTrF)�	tb_localsc	CsN|dkrtj}t|�|_||_||_||_||_||_||_	|dk	rJ||_
dS)z�Construct a TextTestRunner.

        Subclasses should accept **kwargs to ensure compatibility as the
        interface changes.
        N)�sys�stderrrrrr�failfast�bufferrE�warnings�resultclass)	rrrrrHrIrKrJrEr	r	r
r�s
zTextTestRunner.__init__cCs|�|j|j|j�Sr)rKrrrr?r	r	r
�_makeResult�szTextTestRunner._makeResultcCs2|��}t|�|j|_|j|_|j|_t����|jr^t�|j�|jdkr^tjdt	dd�t
��}t|dd�}|dk	r�|�z||�W5t|dd�}|dk	r�|�Xt
��}W5QRX||}|�
�t|d�r�|j�|j�|j}|j�d	||d
ko�d�pd|f�|j��d
}	}
}ztt|j|j|jf�}Wntk
�rTYnX|\}	}
}g}
|���s�|j�d�t|j�t|j�}}|�r�|
�d|�|�r�|
�d|�n|j�d�|�r�|
�d|�|	�r�|
�d|	�|
�r|
�d|
�|
�r"|j�dd�|
�f�n|j�d�|S)z&Run the given test case or test suite.)�default�always�modulezPlease use assert\w+ instead.)�category�message�startTestRunN�stopTestRunrBzRan %d test%s in %.3fsrr4�rZFAILEDzfailures=%dz	errors=%dZOKz
skipped=%dzexpected failures=%dzunexpected successes=%dz (%s)z, r)rLrrHrIrErJ�catch_warnings�simplefilter�filterwarnings�DeprecationWarning�time�perf_counterrr@�hasattrrrrBZtestsRun�map�lenZexpectedFailures�unexpectedSuccesses�skippedr
Z
wasSuccessfulrr>r=�appendr")rr$rZ	startTimerRrSZstopTimeZ	timeTaken�runZ
expectedFailsr^r_ZresultsZinfosZfailedZerroredr	r	r
ra�sx

�
�
�


zTextTestRunner.run)NTrFFNN)	rrrrrrKrrLrar	r	r	r
rDxs��rD)rrFrYrJrTrZsignalsrZ
__unittest�objectrZ
TestResultrrDr	r	r	r
�<module>s[PK��[��.z�&�&&__pycache__/suite.cpython-38.opt-1.pycnu�[���U

e5d2�@s|dZddlZddlmZddlmZdZdd�ZGd	d
�d
e�ZGdd�de�Z	Gdd
�d
e�Z
dd�ZGdd�de�ZdS)�	TestSuite�N�)�case)�utilTcCst||dd��}|�dS)NcSsdS�N�rrr�&/usr/lib64/python3.8/unittest/suite.py�<lambda>�z!_call_if_exists.<locals>.<lambda>)�getattr)�parent�attr�funcrrr�_call_if_existssrc@sneZdZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�
BaseTestSuitezNA simple test suite that doesn't provide class or module shared fixtures.
    TrcCsg|_d|_|�|�dS�Nr)�_tests�_removed_tests�addTests)�self�testsrrr�__init__szBaseTestSuite.__init__cCsdt�|j�t|�fS)Nz
<%s tests=%s>)r�strclass�	__class__�list�rrrr�__repr__szBaseTestSuite.__repr__cCs t||j�stSt|�t|�kSr)�
isinstancer�NotImplementedr)r�otherrrr�__eq__szBaseTestSuite.__eq__cCs
t|j�Sr)�iterrrrrr�__iter__"szBaseTestSuite.__iter__cCs$|j}|D]}|r
||��7}q
|Sr)r�countTestCases)rZcases�testrrrr#%s
zBaseTestSuite.countTestCasescCsLt|�std�t|����t|t�r<t|tjt	f�r<td��|j
�|�dS)Nz{} is not callablezNTestCases and TestSuites must be instantiated before passing them to addTest())�callable�	TypeError�format�reprr�type�
issubclassrZTestCaserr�append�rr$rrr�addTest,s�zBaseTestSuite.addTestcCs*t|t�rtd��|D]}|�|�qdS)Nz0tests must be an iterable of tests, not a string)r�strr&r-)rrr$rrrr6s
zBaseTestSuite.addTestscCs8t|�D]*\}}|jrq4||�|jr|�|�q|Sr)�	enumerate�
shouldStop�_cleanup�_removeTestAtIndex)r�result�indexr$rrr�run<szBaseTestSuite.runcCsNz|j|}Wntk
r"Yn(Xt|d�r@|j|��7_d|j|<dS)z2Stop holding a reference to the TestCase at index.r#N)rr&�hasattrrr#)rr4r$rrrr2Es
z BaseTestSuite._removeTestAtIndexcOs|j||�Sr�r5)r�args�kwdsrrr�__call__SszBaseTestSuite.__call__cCs|D]}|��qdS)�7Run the tests without collecting errors in a TestResultN)�debugr,rrrr<VszBaseTestSuite.debugN)r)�__name__�
__module__�__qualname__�__doc__r1rrr r"r#r-rr5r2r:r<rrrrrs

	rc@s^eZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zddd�Z	ddd�Z
dd�Zdd�Zd
S)ra�A test suite is a composite test consisting of a number of TestCases.

    For use, create an instance of TestSuite, then add test case instances.
    When all tests have been added, the suite can be passed to a test
    runner, such as TextTestRunner. It will run the individual test cases
    in the order in which they were added, aggregating the results. When
    subclassing, do not forget to call the base class constructor.
    FcCs�d}t|dd�dkrd|_}t|�D]�\}}|jr8q�t|�r�|�||�|�||�|�||�|j|_	t|jdd�s&t|dd�r�q&|s�||�n|�
�|jr&|�|�q&|r�|�d|�|�
|�d|_|S)NF�_testRunEnteredT�_classSetupFailed�_moduleSetUpFailed)rrAr/r0�_isnotsuite�_tearDownPreviousClass�_handleModuleFixture�_handleClassSetUpr�_previousTestClassr<r1r2�_handleModuleTearDown)rr3r<ZtopLevelr4r$rrrr5fs2

�

z
TestSuite.runcCst�}|�|d�dS)r;TN)�_DebugResultr5)rr<rrrr<�szTestSuite.debugc	Cs2t|dd�}|j}||krdS|jr(dSt|dd�r8dSz
d|_Wntk
rVYnXt|dd�}|dk	�r.t|d�z^z
|�WnNt
k
r�}z0t|t�r��d|_t
�|�}|�	||d|�W5d}~XYnXW5t|d�|jdk�r,|��t|j�dk�r,|jD]}|j	||d	d||d
��qXdS)NrH�__unittest_skip__F�
setUpClass�_setupStdout�_restoreStdoutTrr��info)rrrCrBr&r�doClassCleanups�len�tearDown_exceptions�"_createClassOrModuleLevelException�	ExceptionrrJrr)	rr$r3�
previousClass�currentClassrL�exc�	className�errrrG�sL





�

�zTestSuite._handleClassSetUpcCs"d}t|dd�}|dk	r|j}|S)NrH)rr>)rr3�previousModulerVrrr�_get_previous_module�s
zTestSuite._get_previous_modulec	
Cs|�|�}|jj}||krdS|�|�d|_ztj|}Wntk
rRYdSXt|dd�}|dk	�rt	|d�z�z
|�Wn�t
k
�r}zfzt��Wn2t
k
r�}z|�
||d|�W5d}~XYnXt|t�r�d|_|�
||d|�W5d}~XYnXW5t	|d�XdS)NF�setUpModulerMrNT)r\rr>rIrC�sys�modules�KeyErrorrrrUr�doModuleCleanupsrTrrJ)	rr$r3r[Z
currentModule�moduler]rZrXrrrrF�s>




�
�zTestSuite._handleModuleFixtureNcCs$|�d|�d�}|�||||�dS)Nz (�))�_addClassOrModuleLevelException)rr3rXZmethod_namerrP�	errorNamerrrrT�sz,TestSuite._createClassOrModuleLevelExceptioncCs^t|�}t|dd�}|dk	r8t|tj�r8||t|��n"|sN|�|t���n|�||�dS)N�addSkip)	�_ErrorHolderrrrZSkipTestr.ZaddErrorr^�exc_info)rr3Z	exceptionrerP�errorrfrrrrd�sz)TestSuite._addClassOrModuleLevelExceptioncCs|�|�}|dkrdS|jr dSztj|}Wntk
rDYdSXt|dd�}|dk	�rt|d�zNz
|�Wn>t	k
r�}z t|t�r��|�
||d|�W5d}~XYnXW5t|d�zt��Wn4t	k
�r}z|�
||d|�W5d}~XYnXXdS)N�tearDownModulerMrN)
r\rCr^r_r`rrrrarUrTrrJ)rr3r[rbrjrZrrrrI�s:




�
�zTestSuite._handleModuleTearDownc	Cst|dd�}|j}||krdSt|dd�r.dSt|dd�r>dSt|dd�rNdSt|dd�}|dk	�rt|d�zXz
|�WnHt	k
r�}z*t
|t�r��t�|�}|�||d|�W5d}~XYnXW5t|d�|��t|j�d	k�r|jD]&}t�|�}|j||d
d||d�q�XdS)NrHrBFrCrK�
tearDownClassrMrNrrrO)rrrrQrRrSrrrTrUrrJ)	rr$r3rVrWrkrXrYrZrrrrEsB




�


�z TestSuite._tearDownPreviousClass)F)N)N)
r=r>r?r@r5r<rGr\rFrTrdrIrErrrrr\s	
!($�
�
 c@sTeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�ZdS)rgz�
    Placeholder for a TestCase inside a result. As far as a TestResult
    is concerned, this looks exactly like a unit test. Used to insert
    arbitrary errors into a test suite run.
    NcCs
||_dSr��description)rrmrrrrBsz_ErrorHolder.__init__cCs|jSrrlrrrr�idEsz_ErrorHolder.idcCsdSrrrrrr�shortDescriptionHsz_ErrorHolder.shortDescriptioncCsd|jfS)Nz<ErrorHolder description=%r>rlrrrrrKsz_ErrorHolder.__repr__cCs|��Sr)rnrrrr�__str__Nsz_ErrorHolder.__str__cCsdSrr�rr3rrrr5Qsz_ErrorHolder.runcCs
|�|�Srr7rqrrrr:Vsz_ErrorHolder.__call__cCsdSrrrrrrr#Ysz_ErrorHolder.countTestCases)
r=r>r?r@ZfailureExceptionrrnrorrpr5r:r#rrrrrg6s	rgcCs(zt|�Wntk
r"YdSXdS)z?A crude way to tell apart testcases and suites with duck-typingTF)r!r&)r$rrrrD\s
rDc@seZdZdZdZdZdZdS)rJzCUsed by the TestSuite to hold previous class when running in debug.NF)r=r>r?r@rHrCr0rrrrrJesrJ)
r@r^�rrZ
__unittestr�objectrrrgrDrJrrrr�<module>sL[&	PK��[�6��jj'__pycache__/runner.cpython-38.opt-1.pycnu�[���U

e5dW�@sndZddlZddlZddlZddlmZddlmZdZGdd�de	�Z
Gd	d
�d
ej�ZGdd�de	�Z
dS)
z
Running tests�N�)�result)�registerResultTc@s*eZdZdZdd�Zdd�Zd	dd�ZdS)
�_WritelnDecoratorz@Used to decorate file-like objects with a handy 'writeln' methodcCs
||_dS�N)�stream)�selfr�r	�'/usr/lib64/python3.8/unittest/runner.py�__init__sz_WritelnDecorator.__init__cCs|dkrt|��t|j|�S)N)r�__getstate__)�AttributeError�getattrr)r�attrr	r	r
�__getattr__sz_WritelnDecorator.__getattr__NcCs|r|�|�|�d�dS�N�
)�write)r�argr	r	r
�writelns
z_WritelnDecorator.writeln)N)�__name__�
__module__�__qualname__�__doc__rrrr	r	r	r
r
srcs�eZdZdZdZdZ�fdd�Zdd�Z�fdd	�Z�fd
d�Z	�fdd
�Z
�fdd�Z�fdd�Z�fdd�Z
�fdd�Zdd�Zdd�Z�ZS)�TextTestResultzhA test result class that can print formatted text results to a stream.

    Used by TextTestRunner.
    zF======================================================================zF----------------------------------------------------------------------cs8tt|��|||�||_|dk|_|dk|_||_dS)Nr)�superrrr�showAll�dots�descriptions)rrr�	verbosity��	__class__r	r
r%s


zTextTestResult.__init__cCs0|��}|jr$|r$d�t|�|f�St|�SdSr)ZshortDescriptionr�join�str)r�testZdoc_first_liner	r	r
�getDescription,s
zTextTestResult.getDescriptioncsBtt|��|�|jr>|j�|�|��|j�d�|j��dS)Nz ... )rr�	startTestrrrr%�flush�rr$r r	r
r&3s
zTextTestResult.startTestcsDtt|��|�|jr$|j�d�n|jr@|j�d�|j��dS)N�ok�.)	rr�
addSuccessrrrrrr'r(r r	r
r+:szTextTestResult.addSuccesscsFtt|��||�|jr&|j�d�n|jrB|j�d�|j��dS)N�ERROR�E)	rr�addErrorrrrrrr'�rr$�errr r	r
r.BszTextTestResult.addErrorcsFtt|��||�|jr&|j�d�n|jrB|j�d�|j��dS)N�FAIL�F)	rr�
addFailurerrrrrr'r/r r	r
r3JszTextTestResult.addFailurecsLtt|��||�|jr,|j�d�|��n|jrH|j�d�|j�	�dS)Nz
skipped {0!r}�s)
rr�addSkiprrr�formatrrr')rr$�reasonr r	r
r5RszTextTestResult.addSkipcsFtt|��||�|jr&|j�d�n|jrB|j�d�|j��dS)Nzexpected failure�x)	rr�addExpectedFailurerrrrrr'r/r r	r
r9Zsz!TextTestResult.addExpectedFailurecsDtt|��|�|jr$|j�d�n|jr@|j�d�|j��dS)Nzunexpected success�u)	rr�addUnexpectedSuccessrrrrrr'r(r r	r
r;bsz#TextTestResult.addUnexpectedSuccesscCs6|js|jr|j��|�d|j�|�d|j�dS)Nr,r1)rrrr�printErrorList�errors�failures�rr	r	r
�printErrorsjs
zTextTestResult.printErrorscCsX|D]N\}}|j�|j�|j�d||�|�f�|j�|j�|j�d|�qdS)Nz%s: %sz%s)rr�
separator1r%�
separator2)rZflavourr=r$r0r	r	r
r<ps
zTextTestResult.printErrorList)rrrrrArBrr%r&r+r.r3r5r9r;r@r<�
__classcell__r	r	r r
rsrc@s4eZdZdZeZd
dd�dd�Zd	d
�Zdd�ZdS)�TextTestRunnerz�A test runner class that displays results in textual form.

    It prints out the names of tests as they are run, errors as they
    occur, and a summary of the results at the end of the test run.
    NTrF)�	tb_localsc	CsN|dkrtj}t|�|_||_||_||_||_||_||_	|dk	rJ||_
dS)z�Construct a TextTestRunner.

        Subclasses should accept **kwargs to ensure compatibility as the
        interface changes.
        N)�sys�stderrrrrr�failfast�bufferrE�warnings�resultclass)	rrrrrHrIrKrJrEr	r	r
r�s
zTextTestRunner.__init__cCs|�|j|j|j�Sr)rKrrrr?r	r	r
�_makeResult�szTextTestRunner._makeResultcCs2|��}t|�|j|_|j|_|j|_t����|jr^t�|j�|jdkr^tjdt	dd�t
��}t|dd�}|dk	r�|�z||�W5t|dd�}|dk	r�|�Xt
��}W5QRX||}|�
�t|d�r�|j�|j�|j}|j�d	||d
ko�d�pd|f�|j��d
}	}
}ztt|j|j|jf�}Wntk
�rTYnX|\}	}
}g}
|���s�|j�d�t|j�t|j�}}|�r�|
�d|�|�r�|
�d|�n|j�d�|�r�|
�d|�|	�r�|
�d|	�|
�r|
�d|
�|
�r"|j�dd�|
�f�n|j�d�|S)z&Run the given test case or test suite.)�default�always�modulezPlease use assert\w+ instead.)�category�message�startTestRunN�stopTestRunrBzRan %d test%s in %.3fsrr4�rZFAILEDzfailures=%dz	errors=%dZOKz
skipped=%dzexpected failures=%dzunexpected successes=%dz (%s)z, r)rLrrHrIrErJ�catch_warnings�simplefilter�filterwarnings�DeprecationWarning�time�perf_counterrr@�hasattrrrrBZtestsRun�map�lenZexpectedFailures�unexpectedSuccesses�skippedr
Z
wasSuccessfulrr>r=�appendr")rr$rZ	startTimerRrSZstopTimeZ	timeTaken�runZ
expectedFailsr^r_ZresultsZinfosZfailedZerroredr	r	r
ra�sx

�
�
�


zTextTestRunner.run)NTrFFNN)	rrrrrrKrrLrar	r	r	r
rDxs��rD)rrFrYrJrTrZsignalsrZ
__unittest�objectrZ
TestResultrrDr	r	r	r
�<module>s[PK��[��F�88)__pycache__/__init__.cpython-38.opt-1.pycnu�[���U

e5d��@s�dZddddddddd	d
ddd
dddddddgZe�dddg�dZddlmZddlmZddlm	Z	m
Z
mZmZm
Z
mZmZmZddlmZmZddlmZmZmZmZmZddlmZmZdd lmZmZdd!lm Z m!Z!m"Z"m#Z#eZ$d"d#�Z%d$S)%a�
Python unit testing framework, based on Erich Gamma's JUnit and Kent Beck's
Smalltalk testing framework (used with permission).

This module contains the core framework classes that form the basis of
specific test cases and suites (TestCase, TestSuite etc.), and also a
text-based utility class for running the tests and reporting the results
 (TextTestRunner).

Simple usage:

    import unittest

    class IntegerArithmeticTestCase(unittest.TestCase):
        def testAdd(self):  # test method names begin with 'test'
            self.assertEqual((1 + 2), 3)
            self.assertEqual(0 + 1, 1)
        def testMultiply(self):
            self.assertEqual((0 * 10), 0)
            self.assertEqual((5 * 8), 40)

    if __name__ == '__main__':
        unittest.main()

Further information is available in the bundled documentation, and from

  http://docs.python.org/library/unittest.html

Copyright (c) 1999-2003 Steve Purcell
Copyright (c) 2003-2010 Python Software Foundation
This module is free software, and you may redistribute it and/or modify
it under the same terms as Python itself, so long as this copyright message
and disclaimer are retained in their original form.

IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.

THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE.  THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
�
TestResult�TestCase�IsolatedAsyncioTestCase�	TestSuite�TextTestRunner�
TestLoader�FunctionTestCase�main�defaultTestLoader�SkipTest�skip�skipIf�
skipUnless�expectedFailure�TextTestResult�installHandler�registerResult�removeResult�
removeHandler�addModuleCleanup�getTestCaseNames�	makeSuite�
findTestCasesT�)r)r)rrrr
rrr
r)�
BaseTestSuiter)rr	rrr)�TestProgramr)rr)rrrrcCs"ddl}|j�t�}|j||d�S)N�)Z	start_dir�pattern)Zos.path�path�dirname�__file__Zdiscover)�loaderZtestsr�osZthis_dir�r"�)/usr/lib64/python3.8/unittest/__init__.py�
load_testsLsr$N)&�__doc__�__all__�extendZ
__unittest�resultrZ
async_caserZcaserrrr
rrr
rZsuiterrr rr	rrrrrZrunnerrrZsignalsrrrrZ_TextTestResultr$r"r"r"r#�<module>s<.�(PK��[���vpp__pycache__/main.cpython-38.pycnu�[���U

e5d�+�@stdZddlZddlZddlZddlmZmZddlmZdZ	dZ
dZd	d
�Zdd�Z
d
d�ZGdd�de�ZeZdS)zUnittest main program�N�)�loader�runner)�installHandlerTaExamples:
  %(prog)s test_module               - run tests from test_module
  %(prog)s module.TestClass          - run tests from module.TestClass
  %(prog)s module.Class.test_method  - run specified test method
  %(prog)s path/to/test_file.py      - run tests from test_file.py
aFExamples:
  %(prog)s                           - run default set of tests
  %(prog)s MyTestSuite               - run suite 'MyTestSuite'
  %(prog)s MyTestCase.testSomething  - run MyTestCase.testSomething
  %(prog)s MyTestCase                - run all 'test*' test methods
                                       in MyTestCase
cCsxtj�|�rt|���d�rttj�|�rXtj�|t���}tj�|�sP|�tj	�rT|S|}|dd��
dd��
dd�S|S)Nz.py����\�.�/)�os�path�isfile�lower�endswith�isabs�relpath�getcwd�
startswith�pardir�replace)�nameZrel_path�r�%/usr/lib64/python3.8/unittest/main.py�
_convert_namesrcCsdd�|D�S)NcSsg|]}t|��qSr)r)�.0rrrr�
<listcomp>.sz"_convert_names.<locals>.<listcomp>r)�namesrrr�_convert_names-srcCsd|krd|}|S)N�*z*%s*r)�patternrrr�_convert_select_pattern1src@s�eZdZdZdZdZdZZZZ	Z
ZdZdddde
jddddddfdd�dd	�Zdd
d�Zdd
�Zdd�Zddd�Zdd�Zdd�Zdd�Zdd�Zd dd�Zdd�ZdS)!�TestProgramzA command-line program that runs a set of tests; this is primarily
       for making test modules conveniently executable.
    Nr�__main__TF)�	tb_localscCs�t|t�r<t|�|_|�d�dd�D]}
t|j|
�|_q&n||_|dkrPtj}||_||_	|	|_
||_|
|_||_
|dkr�tjs�d|_n||_||_||_||_tj�|d�|_|�|�|��dS)Nrr�defaultr)�
isinstance�str�
__import__�module�split�getattr�sys�argv�exit�failfast�
catchbreak�	verbosity�bufferr"�warnoptions�warnings�defaultTest�
testRunner�
testLoaderr
r�basename�progName�	parseArgs�runTests)�selfr'r3r+r4r5r,r/r-r.r0r2r"�partrrr�__init__As,


zTestProgram.__init__cCs4|rt|�|jdkr|��|��t�d�dS)N�)�print�_discovery_parser�_initArgParsers�_print_helpr*r,)r:�msgrrr�	usageExitgs
zTestProgram.usageExitcOsZ|jdkr6t|j���ttd|ji�|j��n t|j���ttd|ji�dS)N�prog)	r'r>�_main_parserZformat_help�
MAIN_EXAMPLESr7r?�
print_help�MODULE_EXAMPLES)r:�args�kwargsrrrrAos
zTestProgram._print_helpcCs�|��|jdkrpt|�dkrD|d��dkrD|�|dd��dS|j�|dd�|�|js�|�g�dSn|j�|dd�|�|jr�t|j�|_	t
dkr�d|_n6|jdkr�d|_	n$t|jt
�r�|jf|_	nt|j�|_	|��dS)Nr�discoverr=r!)r@r'�lenr
�
_do_discoveryrE�
parse_args�testsr�	testNames�__name__r3r$r%�list�createTests)r:r+rrrr8xs(


zTestProgram.parseArgscCst|jr|j|j_|r@|dkr"|jn|�}|�|j|j|j�|_n0|jdkr\|j�|j	�|_n|j�
|j|j	�|_dS�N)�testNamePatternsr5rK�startr�top�testrPZloadTestsFromModuler'ZloadTestsFromNames)r:�from_discovery�LoaderrrrrrS�s


�zTestProgram.createTestscCs$|��}|�|�|_|�|�|_dSrT)�_getParentArgParser�_getMainArgParserrE�_getDiscoveryArgParserr?)r:Z
parent_parserrrrr@�szTestProgram._initArgParserscCs�tjdd�}|jddddddd	�|jd
ddddd
d	�|jddddd�|jdkrn|jdddddd�d|_|jdkr�|jdddddd�d|_|jdkr�|jdddddd�d|_|jdkr�|jdd d!td"d#�g|_|S)$NF)Zadd_helpz-vz	--verboser/Zstore_constr=zVerbose output)�dest�actionZconst�helpz-qz--quietrzQuiet outputz--localsr"�
store_truez"Show local variables in tracebacks)r^r_r`z-fz
--failfastr-zStop on first fail or errorz-cz--catchr.z'Catch Ctrl-C and display results so farz-bz--bufferr0z%Buffer stdout and stderr during testsz-krU�appendz.Only run tests which match the given substring)r^r_�typer`)�argparse�ArgumentParser�add_argumentr-r.r0rUr)r:�parserrrrr[�sR
�
��

�

�

�
�zTestProgram._getParentArgParsercCs2tj|gd�}|j|_|j|_|jdddd�|S)N��parentsrOrz?a list of any number of test modules, classes and test methods.)�nargsr`)rdrer7rDrArGrf)r:�parentrgrrrr\�s�zTestProgram._getMainArgParsercCsztj|gd�}d|j|_d|_|jddddd�|jd	d
ddd�|jd
dddd�dD]}|j|dtjtjd�qZ|S)Nrhz%s discoverzcFor test discovery all test modules must be importable from the top level directory of the project.z-sz--start-directoryrVz*Directory to start discovery ('.' default))r^r`z-pz	--patternrz+Pattern to match tests ('test*.py' default)z-tz--top-level-directoryrWz<Top level directory of project (defaults to start directory))rVrrW�?)rjr#r`)rdrer7rDZepilogrfZSUPPRESS)r:rkrg�argrrrr]�s$
�
�
��z"TestProgram._getDiscoveryArgParsercCsLd|_d|_d|_|dk	r:|jdkr,|��|j�||�|jd|d�dS)Nrztest*.pyT)rYrZ)rVrrWr?r@rNrS)r:r+rZrrrrM�s
zTestProgram._do_discoveryc	Cs�|jrt�|jdkrtj|_t|jt�r�zVz"|j|j|j|j	|j
|jd�}Wn.tk
r||j|j|j|j	|j
d�}YnXWq�tk
r�|��}Yq�Xn|j}|�
|j�|_|jr�t�|j���dS)N)r/r-r0r2r")r/r-r0r2)r.rr4rZTextTestRunnerr$rcr/r-r0r2r"�	TypeError�runrX�resultr,r*Z
wasSuccessful)r:r4rrrr9�s2
�
�zTestProgram.runTests)N)FN)N)rQ�
__module__�__qualname__�__doc__r'r/r-r.r0r7r2rUr?rZdefaultTestLoaderr<rCrAr8rSr@r[r\r]rMr9rrrrr 7s6��&
	
#

r )rsr*rdr
�rrZsignalsrZ
__unittestrFrHrrr�objectr �mainrrrr�<module>s	]PK��[��F�88#__pycache__/__init__.cpython-38.pycnu�[���U

e5d��@s�dZddddddddd	d
ddd
dddddddgZe�dddg�dZddlmZddlmZddlm	Z	m
Z
mZmZm
Z
mZmZmZddlmZmZddlmZmZmZmZmZddlmZmZdd lmZmZdd!lm Z m!Z!m"Z"m#Z#eZ$d"d#�Z%d$S)%a�
Python unit testing framework, based on Erich Gamma's JUnit and Kent Beck's
Smalltalk testing framework (used with permission).

This module contains the core framework classes that form the basis of
specific test cases and suites (TestCase, TestSuite etc.), and also a
text-based utility class for running the tests and reporting the results
 (TextTestRunner).

Simple usage:

    import unittest

    class IntegerArithmeticTestCase(unittest.TestCase):
        def testAdd(self):  # test method names begin with 'test'
            self.assertEqual((1 + 2), 3)
            self.assertEqual(0 + 1, 1)
        def testMultiply(self):
            self.assertEqual((0 * 10), 0)
            self.assertEqual((5 * 8), 40)

    if __name__ == '__main__':
        unittest.main()

Further information is available in the bundled documentation, and from

  http://docs.python.org/library/unittest.html

Copyright (c) 1999-2003 Steve Purcell
Copyright (c) 2003-2010 Python Software Foundation
This module is free software, and you may redistribute it and/or modify
it under the same terms as Python itself, so long as this copyright message
and disclaimer are retained in their original form.

IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.

THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE.  THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
�
TestResult�TestCase�IsolatedAsyncioTestCase�	TestSuite�TextTestRunner�
TestLoader�FunctionTestCase�main�defaultTestLoader�SkipTest�skip�skipIf�
skipUnless�expectedFailure�TextTestResult�installHandler�registerResult�removeResult�
removeHandler�addModuleCleanup�getTestCaseNames�	makeSuite�
findTestCasesT�)r)r)rrrr
rrr
r)�
BaseTestSuiter)rr	rrr)�TestProgramr)rr)rrrrcCs"ddl}|j�t�}|j||d�S)N�)Z	start_dir�pattern)Zos.path�path�dirname�__file__Zdiscover)�loaderZtestsr�osZthis_dir�r"�)/usr/lib64/python3.8/unittest/__init__.py�
load_testsLsr$N)&�__doc__�__all__�extendZ
__unittest�resultrZ
async_caserZcaserrrr
rrr
rZsuiterrr rr	rrrrrZrunnerrrZsignalsrrrrZ_TextTestResultr$r"r"r"r#�<module>s<.�(PK��[ߜ|}�}�%__pycache__/mock.cpython-38.opt-2.pycnu�[���U

e5d��@s�dZdZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZddl
mZddlmZmZdd�ee�D�Zd	ZeZd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zd�dd�Zdd�Zdd�Zdd�Z dd �Z!d�d!d"�Z"d#d$�Z#d%d&�Z$d'd(�Z%Gd)d*�d*e&�Z'Gd+d,�d,e&�Z(e(�Z)e)j*Z*e)j+Z,e)j-Z.d-d.d/d0d1d2d3d4hZ/d5d6�Z0Gd7d8�d8e1�Z2d9d:�Z3Gd;d<�d<e&�Z4Gd=d>�d>e&�Z5Gd?d@�d@e5�Z6dAdB�Z7GdCdD�dDe5�Z8GdEdF�dFe8e6�Z9dGdH�Z:dIdJ�Z;GdKdL�dLe&�Z<dMdN�Z=e*dddddfdOdP�Z>d�dQdR�Z?e*dddddfdSdT�Z@GdUdV�dVe&�ZAdWdX�ZBdYdZ�ZCe>e@_&eAe@_De?e@_EeCe@_Fd[e@_Gd\ZHd]ZId^�Jd_d`�eI�K�D��ZLd^�Jdad`�eI�K�D��ZMdbdcdddedfdgdhdidjdkdldmdndodpdqdrdshZNdtdu�ZOdvd�d^�JeHeIeLeMg��K�D�ZPdwdxdyhZQdzhZReQeRBZSePeNBZTeTeSBZUd{d|d}d~dd�d�d�hZVd�d��d�d��d�d��d�d��d��ZWeXeXeXeXd�dddd�d�d	d�dd��
ZYd�d��ZZd�d��Z[d�d��Z\d�d��Z]eZe[e\e]d��Z^d�d��Z_Gd�d��d�e5�Z`Gd�d��d�e`e6�ZaGd�d��d�e`�ZbGd�d��d�e`e9�ZcGd�d��d�e5�ZdGd�d��d�e5�ZeGd�d��d�eeebe9�ZfGd�d��d�e&�Zgeg�Zhd�d��ZiGd�d��d�ej�Zkekdd��Zld�d�d��Zmd�d��ZnGd�d��d�e&�Zoepem�epehjq�fZrdasd�d��Ztd�d�d��ZuGd�d��d�e9�Zvd�d��ZwGd�d��d��ZxdS)�)�Mock�	MagicMock�patch�sentinel�DEFAULT�ANY�call�create_autospec�	AsyncMock�
FILTER_DIR�NonCallableMock�NonCallableMagicMock�	mock_open�PropertyMock�sealz1.0�N)�CodeType�
ModuleType�
MethodType)�	safe_repr)�wraps�partialcCsh|]}|�d�s|�qS��_��
startswith)�.0�name�r�%/usr/lib64/python3.8/unittest/mock.py�	<setcomp>(s
rTcCs>t|�rt|t�sdSt|d�r*t|d�}t�|�p<t�|�S)NF�__func__)	�_is_instance_mock�
isinstancer	�hasattr�getattr�asyncio�iscoroutinefunction�inspectZisawaitable��objrrr�
_is_async_obj0s


r*cCst|dd�rt�|�SdSdS)N�__code__F)r$r%r&��funcrrr�_is_async_func8s
r.cCstt|�t�S�N)�
issubclass�typerr(rrrr!?sr!cCst|t�pt|t�ot|t�Sr/)r"�
BaseExceptionr1r0r(rrr�
_is_exceptionEs
�r3cCs"t|t�rt|d�r|jS|SdS�N�mock)r"�
FunctionTypesr#r5r(rrr�
_extract_mockLsr7cCs�t|t�r|s|j}d}n,t|t�sFz
|j}Wntk
rDYdSX|rVt|d�}n|}z|t�|�fWSt	k
r�YdSXdS�NT)
r"r1�__init__r6�__call__�AttributeErrorrr'�	signature�
ValueError)r-Zas_instanceZeat_selfZsig_funcrrr�_get_signature_objectUs

r>FcsNt|||���dkrdS�\}��fdd�}t||�|t|�_�t|�_dS)Ncs�j||�dSr/��bind��self�args�kwargs��sigrr�checksigwsz"_check_signature.<locals>.checksig)r>�_copy_func_detailsr1�_mock_check_sig�
__signature__)r-r5�	skipfirst�instancerGrrEr�_check_signaturers

rMc	Cs:dD]0}zt||t||��Wqtk
r2YqXqdS)N)�__name__�__doc__�__text_signature__�
__module__�__defaults__�__kwdefaults__)�setattrr$r;)r-�funcopy�	attributerrrrH~s
rHcCs@t|t�rdSt|tttf�r(t|j�St|dd�dk	r<dSdS)NTr:F)r"r1�staticmethod�classmethodr�	_callabler r$r(rrrrY�s

rYcCst|�ttfkSr/)r1�list�tupler(rrr�_is_list�sr\cCsFt|t�st|dd�dk	S|f|jD]}|j�d�dk	r&dSq&dS)Nr:TF)r"r1r$�__mro__�__dict__�get)r)�baserrr�_instance_callable�s
racs�t|t�}t|||�}|dkr"|S|\}��fdd�}t||�|j}|��sRd}||d�}d|}	t|	|�||}
t|
|��|
S)Ncs�j||�dSr/r?�rCrDrErrrG�sz _set_signature.<locals>.checksigrU)Z
_checksig_r5zYdef %s(*args, **kwargs):
    _checksig_(*args, **kwargs)
    return mock(*args, **kwargs))r"r1r>rHrN�isidentifier�exec�_setup_func)r5�originalrLrK�resultr-rGr�context�srcrUrrEr�_set_signature�s$


�
rjcs���_�fdd�}�fdd�}�fdd�}�fdd�}�fd	d
�}�fdd�}�fd
d�}	��fdd�}
d�_d�_d�_t��_t��_t��_�j�_�j	�_	�j
�_
|�_|�_|�_
|	�_|
�_|�_|�_|�_|�_��_dS)Ncs�j||�Sr/)�assert_called_withrb�r5rrrk�sz'_setup_func.<locals>.assert_called_withcs�j||�Sr/)�
assert_calledrbrlrrrm�sz"_setup_func.<locals>.assert_calledcs�j||�Sr/)�assert_not_calledrbrlrrrn�sz&_setup_func.<locals>.assert_not_calledcs�j||�Sr/)�assert_called_oncerbrlrrro�sz'_setup_func.<locals>.assert_called_oncecs�j||�Sr/)�assert_called_once_withrbrlrrrp�sz,_setup_func.<locals>.assert_called_once_withcs�j||�Sr/)�assert_has_callsrbrlrrrq�sz%_setup_func.<locals>.assert_has_callscs�j||�Sr/)�assert_any_callrbrlrrrr�sz$_setup_func.<locals>.assert_any_callcs:t��_t��_����j}t|�r6|�k	r6|��dSr/)�	_CallList�method_calls�
mock_calls�
reset_mock�return_valuer!)�ret�rUr5rrrv�sz_setup_func.<locals>.reset_mockFr)r5�called�
call_count�	call_argsrs�call_args_listrtrurw�side_effect�_mock_childrenrkrprqrrrvrmrnrorJ�_mock_delegate)rUr5rFrkrmrnrorprqrrrvrryrre�s8recsJtjj�_d�_d�_t��_�fdd�}dD]}t�|t||��q.dS)Nrcst�j|�||�Sr/)r$r5)�attrrCrDrlrr�wrapper�sz"_setup_async_mock.<locals>.wrapper)�assert_awaited�assert_awaited_once�assert_awaited_with�assert_awaited_once_with�assert_any_await�assert_has_awaits�assert_not_awaited)	r%�
coroutines�
_is_coroutine�await_count�
await_argsrs�await_args_listrTr)r5r�rVrrlr�_setup_async_mock�s
r�cCsd|dd�|kS)N�__%s__����r�rrrr�	_is_magicsr�c@s$eZdZdd�Zdd�Zdd�ZdS)�_SentinelObjectcCs
||_dSr/r��rBrrrrr9sz_SentinelObject.__init__cCs
d|jS�Nzsentinel.%sr��rBrrr�__repr__sz_SentinelObject.__repr__cCs
d|jSr�r�r�rrr�
__reduce__sz_SentinelObject.__reduce__N)rNrQ�__qualname__r9r�r�rrrrr�sr�c@s$eZdZdd�Zdd�Zdd�ZdS)�	_SentinelcCs
i|_dSr/)�
_sentinelsr�rrrr9#sz_Sentinel.__init__cCs|dkrt�|j�|t|��S)N�	__bases__)r;r��
setdefaultr�r�rrr�__getattr__&sz_Sentinel.__getattr__cCsdS)Nrrr�rrrr�,sz_Sentinel.__reduce__N)rNrQr�r9r�r�rrrrr�!sr�rw�_mock_return_valuer~�_mock_side_effect�_mock_parent�_mock_new_parent�
_mock_name�_mock_new_namecCs8t�|�d|}||fdd�}||fdd�}t||�S)NZ_mock_cSs"|j}|dkrt||�St||�Sr/)r�r$)rBr�	_the_namerFrrr�_getAs
z"_delegating_property.<locals>._getcSs*|j}|dkr||j|<nt|||�dSr/)r�r^rT)rB�valuerr�rFrrr�_setFsz"_delegating_property.<locals>._set)�_allowed_names�add�property)rr�r�r�rrr�_delegating_property>s

r�c@seZdZdd�Zdd�ZdS)rscCslt|t�st�||�St|�}t|�}||kr2dStd||d�D]"}||||�}||krDdSqDdS)NFr�T)r"rZ�__contains__�len�range)rBr�Z	len_valueZlen_self�iZsub_listrrrr�Ss
z_CallList.__contains__cCst�t|��Sr/)�pprintZpformatrZr�rrrr�asz_CallList.__repr__N)rNrQr�r�r�rrrrrsQsrscCs|t|�}t|�sdS|js4|js4|jdk	s4|jdk	r8dS|}|dk	rX||krPdS|j}q<|rh||_||_|rx||_||_dS)NFT)r7r!r�r�r�r�)�parentr�r�new_name�_parentrrr�_check_and_set_parentes*��r�c@seZdZdd�Zdd�ZdS)�	_MockItercCst|�|_dSr/)�iterr))rBr)rrrr9�sz_MockIter.__init__cCs
t|j�Sr/)�nextr)r�rrr�__next__�sz_MockIter.__next__N)rNrQr�r9r�rrrrr��sr�c@seZdZeZdZdd�ZdS)�BaseNcOsdSr/rrArrrr9�sz
Base.__init__)rNrQr�rr�r�r9rrrrr��sr�c@s`eZdZdd�ZdKdd�Zdd	�ZdLd
d�ZdMdd
�Zdd�Zdd�Z	dZ
eee	e
�Zedd��Z
ed�Zed�Zed�Zed�Zed�Zdd�Zdd�Zeee�ZdNddd�dd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�ZdOd2d3�Z d4d5�Z!d6d7�Z"d8d9�Z#d:d;�Z$d<d=�Z%d>d?�Z&d@dA�Z'dPdBdC�Z(dDdE�Z)dFdG�Z*dQdIdJ�Z+dS)Rrc	Os�|f}t|t�s^t�tj�}|j|f|�|�j}dd�|��D�}|r^t	||d�r^t
|f}t|j|d|j
i�}tt|��|�}|S)NcSsg|]}|�d�r|�qS��specr�r�argrrr�
<listcomp>�s
�z+NonCallableMock.__new__.<locals>.<listcomp>rrO)r0r	r'r<rr9Zbind_partialZ	arguments�keysr*�AsyncMockMixinr1rNrO�_safe_super�__new__)	�clsrC�kw�basesrFZ
bound_argsZspec_arg�newrLrrrr��s
�zNonCallableMock.__new__N�FcKs�|dkr|}|j}
||
d<||
d<||
d<||
d<d|
d<|dk	rJ|}d}|
dkrZ|dk	}
|�|||	|
�i|
d<||
d	<d|
d
<d|
d<d|
d<d
|
d<t�|
d<t�|
d<t�|
d<||
d<|r�|jf|�tt|��||||||�dS)Nr�r�r�r�F�_mock_sealedTr�_mock_wrapsr�Z_mock_calledZ_mock_call_argsrZ_mock_call_countZ_mock_call_args_listZ_mock_mock_callsrt�_mock_unsafe)r^�_mock_add_specrs�configure_mockr�rr9)rBr�rr�spec_setr��_spec_state�	_new_name�_new_parent�_spec_as_instance�	_eat_selfZunsaferDr^rrrr9�sD



�zNonCallableMock.__init__cCs0t|�}d|_d|_d|_d|_t|||�dS)Nr�)r7r�r�r�r�rT)rBr5rVZ
inner_mockrrr�attach_mock�szNonCallableMock.attach_mockcCs|�||�dSr/)r��rBr�r�rrr�
mock_add_spec�szNonCallableMock.mock_add_speccCs�d}d}g}t|�D] }t�t||d��r|�|�q|dk	r~t|�s~t|t�rV|}nt|�}t|||�}	|	ot|	d}t|�}|j	}
||
d<||
d<||
d<||
d<||
d<dS)Nr��_spec_class�	_spec_set�_spec_signature�
_mock_methods�_spec_asyncs)
�dirr%r&r$�appendr\r"r1r>r^)rBr�r�r�r�r�r�r�r��resr^rrrr��s,
�zNonCallableMock._mock_add_speccCs8|j}|jdk	r|jj}|tkr4|j|dd�}||_|S)N�()�r�r�)r�r�rwr�_get_child_mock)rBrxrrrZ__get_return_values
�z"NonCallableMock.__get_return_valuecCs,|jdk	r||j_n||_t||dd�dS)Nr�)r�rwr�r�)rBr�rrrZ__set_return_values

z"NonCallableMock.__set_return_valuez1The value to be returned when the mock is called.cCs|jdkrt|�S|jSr/)r�r1r�rrr�	__class__!s
zNonCallableMock.__class__rzr{r|r}rucCsN|j}|dkr|jS|j}|dk	rJt|�sJt|t�sJt|�sJt|�}||_|Sr/)r�r�r~�callabler"r�r3)rB�	delegatedZsfrrrZ__get_side_effect.s��z!NonCallableMock.__get_side_effectcCs(t|�}|j}|dkr||_n||_dSr/)�	_try_iterr�r�r~)rBr�r�rrrZ__set_side_effect9s
z!NonCallableMock.__set_side_effect)rwr~cCs�|dkrg}t|�|krdS|�t|��d|_d|_d|_t�|_t�|_t�|_|r^t	|_
|rhd|_|j�
�D]"}t|t�sr|tkr�qr|�|�qr|j
}t|�r�||k	r�|�|�dS)NFr)�idr�rzr|r{rsrur}rtrr�r�r�valuesr"�
_SpecState�_deletedrvr!)rBZvisitedrwr~�childrxrrrrvDs,zNonCallableMock.reset_mockcKsXt|��dd�d�D]>\}}|�d�}|��}|}|D]}t||�}q6t|||�qdS)NcSs|d�d�S)Nr�.)�count)�entryrrr�<lambda>o�z0NonCallableMock.configure_mock.<locals>.<lambda>)�keyr�)�sorted�items�split�popr$rT)rBrDr��valrC�finalr)r�rrrr�bs	�
zNonCallableMock.configure_mockcCs�|dkrt|��n:|jdk	r<||jks.|tkrLtd|��nt|�rLt|��|jsd|�d�rdtd��|j�|�}|tkr�t|��np|dkr�d}|j	dk	r�t
|j	|�}|j|||||d�}||j|<n.t|t
�r�t|j|j|j|j|j�}||j|<|S)N>r�r�zMock object has no attribute %r)�assertZassretz1Attributes cannot start with 'assert' or 'assret')r�rrr�r�)r;r��_all_magicsr�r�rrr_r�r�r$r�r"r�rr�r�rLr�r)rBrrgrrrrr�xsF




�
�
zNonCallableMock.__getattr__cCs�|jg}|j}|}d}|dgkr$d}|dk	rZ|}|�|j|�d}|jdkrRd}|j}q$tt|��}|jpnd}t|�dkr�|ddkr�|d7}||d<d�|�S)Nr�r�r�r5r�)r�z().r)r�r�r�rZ�reversedr�r��join)rBZ
_name_listr�Zlast�dotZ_firstrrr�_extract_mock_name�s(


z"NonCallableMock._extract_mock_namecCs^|��}d}|dkrd|}d}|jdk	rDd}|jr8d}||jj}dt|�j||t|�fS)Nr�)r5zmock.z name=%rz spec=%rz spec_set=%rz<%s%s%s id='%s'>)r�r�r�rNr1r�)rBrZname_stringZspec_stringrrrr��s 
�zNonCallableMock.__repr__cCsvtst�|�S|jpg}tt|��}t|j�}dd�|j�	�D�}dd�|D�}dd�|D�}t
t||||��S)NcSsg|]\}}|tk	r|�qSr)r�)rZm_nameZm_valuerrrr��s�z+NonCallableMock.__dir__.<locals>.<listcomp>cSsg|]}|�d�s|�qSrr�r�errrr��s
cSs"g|]}|�d�rt|�r|�qSr)rr�rrrrr��s
�)r
�object�__dir__r�r�r1rZr^rr�r��set)rBZextrasZ	from_typeZ	from_dictZfrom_child_mocksrrrr�s


�zNonCallableMock.__dir__csT|tkrt��||�S�jrH�jdk	rH|�jkrH|�jkrHtd|��n�|tkrbd|}t|��n�|tkr�jdk	r�|�jkr�td|��t	|�s�t
t��|t||��|���fdd�}n(t
�|d|�t
t��||�|�j|<n,|dkr�|�_dSt
�|||��r|�j|<�j�rFt�|��sF����d|��}td|����t��||�S)Nz!Mock object has no attribute '%s'z.Attempting to set unsupported magic method %r.cs��f|�|�Sr/r�rCr��rfrBrrr��r�z-NonCallableMock.__setattr__.<locals>.<lambda>r�r�zCannot set )r�r�__setattr__r�r�r^r;�_unsupported_magicsr�r!rTr1�_get_methodr�rr�r�r#r�)rBrr��msg�	mock_namerrrr�s<��

zNonCallableMock.__setattr__cCs�|tkr2|t|�jkr2tt|�|�||jkr2dS|j�|t�}||jkr\tt|��	|�n|t
krlt|��|tk	r||j|=t
|j|<dSr/)r�r1r^�delattrrr_�_missingr�r�__delattr__r�r;)rBrr)rrrrs

zNonCallableMock.__delattr__cCs|jpd}t|||�Sr4)r��_format_call_signature�rBrCrDrrrr�_format_mock_call_signatures
z+NonCallableMock._format_mock_call_signaturercCs.d}|�||�}|j}|j|�}||||fS)Nz.expected %s not found.
Expected: %s
Actual: %s)rr|)rBrCrD�action�message�expected_stringr|Z
actual_stringrrr�_format_mock_failure_messages

z,NonCallableMock._format_mock_failure_messagecCsj|s
|jSd}|�dd��d�}|j}|D]:}|�|�}|dksJt|t�rPqfq*t|�}|j}|j}q*|S)Nr�r�r�)r��replacer�rr_r"r�r7)rBrrF�namesZchildrenr�rrr�_get_call_signature_from_name's
z-NonCallableMock._get_call_signature_from_namec
Cs�t|t�r&t|�dkr&|�|d�}n|j}|dk	r�t|�dkrNd}|\}}n
|\}}}z||j||�fWStk
r�}z|�d�WY�Sd}~XYq�Xn|SdS)Nr�rr�)r"r[r�rr�r@�	TypeError�with_traceback)rB�_callrFrrCrDrrrr�
_call_matcherHs

"zNonCallableMock._call_matchercCs0|jdkr,d|jpd|j|��f}t|��dS)Nrz9Expected '%s' to not have been called. Called %s times.%sr5�r{r��_calls_repr�AssertionError�rBr
rrrrnbs
��z!NonCallableMock.assert_not_calledcCs$|jdkr d|jpd}t|��dS)Nrz"Expected '%s' to have been called.r5)r{r�rr rrrrmls

�zNonCallableMock.assert_calledcCs0|jdks,d|jpd|j|��f}t|��dS)Nr�z:Expected '%s' to have been called once. Called %s times.%sr5rr rrrrots
��z"NonCallableMock.assert_called_oncecs��jdkr.�����}d}d||f}t|�����fdd�}����f�}���j�}||kr~t|t�rn|nd}t|��|�dS)Nznot called.z0expected call not found.
Expected: %s
Actual: %scs�����}|Sr/�r�r
�rCrDrBrr�_error_message�sz:NonCallableMock.assert_called_with.<locals>._error_message)r|rrrr"�	Exception)rBrCrD�expected�actualZ
error_messager$�causerr#rrk~s
�z"NonCallableMock.assert_called_withcOs8|jdks,d|jpd|j|��f}t|��|j||�S)Nr�z3Expected '%s' to be called once. Called %s times.%sr5)r{r�rrrk�rBrCrDr
rrrrp�s
��z'NonCallableMock.assert_called_once_withc		s�fdd�|D�}tdd�|D�d�}t�fdd��jD��}|s�||kr�|dkrXd}nd�dd�|D��}t|�d	t|���jd
d��d����|�dSt|�}g}|D]2}z|�|�Wq�t	k
r�|�
|�Yq�Xq�|�rtd
�jp�dt|�|f�|�dS)Ncsg|]}��|��qSr�r�r�cr�rrr��sz4NonCallableMock.assert_has_calls.<locals>.<listcomp>css|]}t|t�r|VqdSr/�r"r%rrrr�	<genexpr>�s
z3NonCallableMock.assert_has_calls.<locals>.<genexpr>c3s|]}��|�VqdSr/r*r+r�rrr.�szCalls not found.z+Error processing expected calls.
Errors: {}cSsg|]}t|t�r|nd�qSr/r-rrrrr��s��
Expected: ZActual)�prefixr�z@%r does not contain all of %r in its call list, found %r insteadr5)
r�rsru�formatrr�rstriprZ�remover=r�r�r[)	rB�calls�	any_orderr&r(Z	all_calls�problem�	not_found�kallrr�rrq�sH
��"������z NonCallableMock.assert_has_callscsZ��||f�}�fdd��jD�}||krVt|t�r8|nd}��||�}td|�|�dS)Ncsg|]}��|��qSrr*r+r�rrr��sz3NonCallableMock.assert_any_call.<locals>.<listcomp>z%s call not found)rr}r"r%rr�rBrCrDr&r'r(rrr�rrr�s��zNonCallableMock.assert_any_callcKs�|�d�}||jdkr"tf|�St|�}t|t�rB|tkrBt}nbt|t�rp|tksd|j	rj||j	krjt}q�t}n4t|t
�s�t|t�r�t}q�t|t�r�t
}n
|jd}|jr�d|kr�d|dnd}|��|}t|��|f|�S)Nr�r�r�rr�r�)r_r^r	r1r0r�_async_method_magicsr��_all_sync_magicsr��
CallableMixinrrrr]r�r�r;)rBr�r��_type�klassrVrrrrr��s2


��



zNonCallableMock._get_child_mock�CallscCs"|js
dSd|�dt|j��d�S)Nr��
z: r�)rur)rBr0rrrrszNonCallableMock._calls_repr)NNNNNNr�NFNF)F)FF)N)r)F)r?),rNrQr�r�r9r�r�r�Z"_NonCallableMock__get_return_valueZ"_NonCallableMock__set_return_valueZ"_NonCallableMock__return_value_docr�rwr�r�rzr{r|r}ruZ!_NonCallableMock__get_side_effectZ!_NonCallableMock__set_side_effectr~rvr�r�r�r�rrrrrrrrnrmrorkrprqrrr�rrrrrr�sn�
-
	�

�

''
!


-'rcCsL|dkr|St|�r|St|�r$|Sz
t|�WStk
rF|YSXdSr/)r3rYr�rr(rrrr�s
r�c
@sReZdZddedddddddf
dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)r<Nr�c	Ks6||jd<tt|�j|||||||	|
f|�||_dS)Nr�)r^r�r<r9r~)rBr�r~rwrrr�r�r�r�r�rDrrrr9#s

��zCallableMixin.__init__cOsdSr/rrArrrrI/szCallableMixin._mock_check_sigcOs$|j||�|j||�|j||�Sr/)rI�_increment_mock_call�
_mock_callrArrrr:4szCallableMixin.__call__cOs|j||�Sr/)�_execute_mock_callrArrrrB<szCallableMixin._mock_callcOsd|_|jd7_t||fdd�}||_|j�|�|jdk	}|j}|j}|dk}|j	�td||f��|j
}|dk	r�|r�|j�t|||f��|jdk	}|r�|jd|}t|||f�}	|j	�|	�|jr�|r�d}
nd}
|jdk}|j|
|}|j
}qpdS)NTr���twor�r�r�)rzr{�_Callr|r}r�r�r�r�rur�rt)rBrCrDrZdo_method_callsZmethod_call_nameZmock_call_nameZ	is_a_callr�Zthis_mock_callr�rrrrA?s4


z"CallableMixin._increment_mock_callcOs||j}|dk	rPt|�r|�n(t|�s:t|�}t|�rD|�n
|||�}|tk	rP|S|jtk	r`|jS|jdk	rv|j||�S|jSr/)r~r3rYr�rr�rwr�)rBrCrD�effectrgrrrrCms 


z CallableMixin._execute_mock_call)
rNrQr�rr9rIr:rBrArCrrrrr<!s�
.r<c@seZdZdS)rN�rNrQr�rrrrr�srcCs8zt||�WStk
r2t|�t||�YSXdSr/)r$r;�
__import__)�thing�comp�import_pathrrr�_dot_lookup�s
rMcCsB|�d�}|�d�}t|�}|D]}|d|7}t|||�}q |S)Nr�rz.%s)r�r�rIrM)�targetZ
componentsrLrJrKrrr�	_importer�s

rOc@szeZdZdZgZdd�Zdd�Zdd�Zdd	�Ze	j
d
d��Zdd
�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS)�_patchNc

Csn|dk	r(|tk	rtd��|dk	r(td��||_||_||_||_||_||_d|_||_	||_
|	|_g|_dS)Nz,Cannot use 'new' and 'new_callable' togetherz1Cannot use 'autospec' and 'new_callable' togetherF)
rr=�getterrVr��new_callabler��createZ	has_localr��autospecrD�additional_patchers)
rBrQrVr�r�rSr�rTrRrDrrrr9�s(��z_patch.__init__c
CsHt|j|j|j|j|j|j|j|j|j	�	}|j
|_
dd�|jD�|_|S)NcSsg|]}|���qSr)�copy)r�prrrr��sz_patch.copy.<locals>.<listcomp>)rPrQrVr�r�rSr�rTrRrD�attribute_namerU)rB�patcherrrrrV�s ��z_patch.copycCs2t|t�r|�|�St�|�r(|�|�S|�|�Sr/)r"r1�decorate_classr'r&�decorate_async_callable�decorate_callable�rBr-rrrr:�s




z_patch.__call__cCsNt|�D]@}|�tj�sqt||�}t|d�s0q|��}t||||��q|S�Nr:)r�rr�TEST_PREFIXr$r#rVrT)rBr>r��
attr_valuerYrrrrZs

z_patch.decorate_classc	csrg}t���\}|jD]8}|�|�}|jdk	r8|�|�q|jtkr|�|�q|t	|�7}||fVW5QRXdSr/)
�
contextlib�	ExitStack�	patchings�
enter_contextrX�updater�rr�r[)rB�patchedrC�keywargs�
extra_args�
exit_stack�patchingr�rrr�decoration_helpers




z_patch.decoration_helpercs>t�d�r�j����St�����fdd����g�_�S)Nrcc
s4���||��\}}�||�W5QR�SQRXdSr/�rk�rCrgZnewargsZnewkeywargs�r-rfrBrrrf(s�z)_patch.decorate_callable.<locals>.patched�r#rcr�rr]rrnrr\"s
z_patch.decorate_callablecs>t�d�r�j����St�����fdd����g�_�S)Nrcc
�s:���||��"\}}�||�IdHW5QR�SQRXdSr/rlrmrnrrrf9s�z/_patch.decorate_async_callable.<locals>.patchedror]rrnrr[3s
z_patch.decorate_async_callablec	Cs�|��}|j}t}d}z|j|}Wn$ttfk
rHt||t�}YnXd}|tkrft|t	�rfd|_
|j
s�|tkr�td||f��||fS)NFTz!%s does not have the attribute %r)rQrVrr^r;�KeyErrorr$�	_builtinsr"rrS)rBrNrrf�localrrr�get_originalDs 
�z_patch.get_originalcCs�|j|j|j}}}|j|j}}|j}|��|_|dkr@d}|dkrLd}|dkrXd}|dk	rp|dk	rptd��|dk	s�|dk	r�|dkr�td��|�	�\}}|t
k�r||dk�r|d}	|dkr�|}|dkr�|}d}n&|dk	r�|dkr�|}d}n|dkr�|}|dk	�s|dk	�r.|t
k�rtd��t|t��r.d}	|dk�rHt
|��rHt}
nt}
i}|dk	�r`|}
n^|dk	�st|dk	�r�|}|dk	�r�|}t|��r�d|k}
n
t|�}
t
|��r�t}
n
|
�r�t}
|dk	�r�||d<|dk	�r�||d	<t|
t��rt|
t��r|j�r|j|d
<|�|�|
f|�}|	�r�t|��r�|}|dk	�rB|}t|��sZt|��sZt}
|�d
�|
f|dd�|��|_nl|dk	�r�|t
k	�r�td
��|t
k�r�td��t|�}|dk�r�|}t|f||jd�|��}n|�r�td��|}||_||_t� �|_!zrt"|j|j|�|j#dk	�rpi}|jt
k�r:|||j#<|j$D](}|j!�%|�}|jt
k�r@|�|��q@|WS|WS|j&t'�(���s��YnXdS)NFzCan't specify spec and autospec)TNz6Can't provide explicit spec_set *and* spec or autospecTz!Can't use 'spec' with create=Truer:r�r�rr�r�zBautospec creates the mock for you. Can't specify autospec and new.z%Can't use 'autospec' with create=True)r��_namez.Can't pass kwargs to a mock we aren't creating))r�r�r�rTrDrRrQrNrrsrr"r1r*r	rr\r�rr0rrVrer!rar�rw�boolr�
temp_original�is_localrarb�_exit_stackrTrXrUrd�__exit__�sys�exc_info)rBr�r�r�rTrDrRrfrrZinherit�Klass�_kwargsZ	this_specZnot_callableZnew_attrrhrjr�rrr�	__enter__\s�
�








��




�
�


�

��


z_patch.__enter__cGs�|jr$|jtk	r$t|j|j|j�n>t|j|j�|jsbt|j|j�rP|jdkrbt|j|j|j�|`|`|`|j	}|`	|j
|�S)N)rOrQrR�__annotations__rS)rwrvrrTrNrVrrSr#rxry)rBr{rirrrry�s�z_patch.__exit__cCs|��}|j�|�|Sr/)r~�_active_patchesr�)rBrgrrr�start�sz_patch.startcCs6z|j�|�Wntk
r&YdSX|�ddd�Sr/)r�r3r=ryr�rrr�stop�s
z_patch.stop)rNrQr�rXr�r9rVr:rZra�contextmanagerrkr\r[rsr~ryr�r�rrrrrP�s 

rPc	sPz��dd�\�}Wn&ttfk
r:td�f��YnX�fdd�}||fS)Nr�r�z.Need a valid target to patch. You supplied: %rcst��Sr/�rOr�rNrrr�r�z_get_target.<locals>.<lambda>)�rsplitrr=)rNrVrQrr�r�_get_target
s�r�c

s>t��tkrt��d����fdd�}	t|	||||||||�	S)Nz3 must be the actual object to be patched, not a strcs�Sr/rrr�rrr�*r�z_patch_object.<locals>.<lambda>)r1�strrrP)
rNrVr�r�rSr�rTrRrDrQrr�r�
_patch_objects ��r�c
s�t��tkr�fdd�}n�fdd�}|s2td��t|���}|d\}	}
t||	|
|||||i�	}|	|_|dd�D]2\}	}
t||	|
|||||i�	}|	|_|j�|�qt|S)Ncst��Sr/r�rr�rrr�Hr�z!_patch_multiple.<locals>.<lambda>cs�Sr/rrr�rrr�Jr�z=Must supply at least one keyword argument with patch.multiplerr�)	r1r�r=rZr�rPrXrUr�)
rNr�rSr�rTrRrDrQr�rVr�rYZthis_patcherrr�r�_patch_multiple1sH���r�c

Ks$t|�\}}	t||	|||||||�	Sr/)r�rP)
rNr�r�rSr�rTrRrDrQrVrrrrbsF�rc@sNeZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	eZ
e	ZdS)�_patch_dictrFcKs,||_t|�|_|j�|�||_d|_dSr/)�in_dict�dictr�re�clear�	_original)rBr�r�r�rDrrrr9�s

z_patch_dict.__init__cs.t�t�r����St����fdd��}|S)Ncs&���z�||�W�S���XdSr/)r��
_unpatch_dictr��frBrr�_inner�sz$_patch_dict.__call__.<locals>._inner)r"r1rZr)rBr�r�rr�rr:�s


z_patch_dict.__call__cCsXt|�D]J}t||�}|�tj�rt|d�rt|j|j|j	�}||�}t
|||�q|Sr^)r�r$rrr_r#r�r�r�r�rT)rBr>r�r`Z	decoratorZ	decoratedrrrrZ�s
�z_patch_dict.decorate_classcCs|��|jSr/)r�r�r�rrrr~�sz_patch_dict.__enter__cCs�|j}t|jt�rt|j�|_|j}|j}z|��}Wn.tk
rdi}|D]}||||<qNYnX||_|rxt	|�z|�
|�Wn*tk
r�|D]}||||<q�YnXdSr/)r�r"r�r�rOr�rVr;r��_clear_dictre)rBr�r�r�rfr�rrrr��s&z_patch_dict._patch_dictcCsR|j}|j}t|�z|�|�Wn*tk
rL|D]}||||<q6YnXdSr/)r�r�r�rer;)rBr�rfr�rrrr�sz_patch_dict._unpatch_dictcGs|��dS�NF)r�)rBrCrrrrysz_patch_dict.__exit__N)rF)rNrQr�r9r:rZr~r�r�ryr�r�rrrrr��s
	
r�cCs>z|��Wn,tk
r8t|�}|D]
}||=q(YnXdSr/)r�r;rZ)r�r�r�rrrr�&sr�cCsttj�D]}|��q
dSr/)r�rPr�r�)rrrr�_patch_stopall/sr�Ztestz�lt le gt ge eq ne getitem setitem delitem len contains iter hash str sizeof enter exit divmod rdivmod neg pos abs invert complex int float index round trunc floor ceil bool next fspath aiter zHadd sub mul matmul div floordiv mod lshift rshift and xor or pow truediv� ccs|]}d|VqdS)zi%sNr�r�nrrrr.Nsr.ccs|]}d|VqdS)zr%sNrr�rrrr.Os�__get__�__set__�
__delete__�__reversed__�__missing__r��
__reduce_ex__Z__getinitargs__�__getnewargs__�__getstate__�__setstate__�
__getformat__Z
__setformat__r�r�__subclasses__�
__format__�__getnewargs_ex__cs�fdd�}||_|S)Ncs�|f|�|�Sr/r�rBrCr�r,rr�method`sz_get_method.<locals>.method)rN)rr-r�rr,rr	^sr	cCsh|]}d|�qS)r�r)rr�rrrrfs�
__aenter__�	__aexit__�	__anext__�	__aiter__r�rr9r��__prepare__�__instancecheck__�__subclasscheck__�__del__cCs
t�|�Sr/)r�__hash__r�rrrr�|r�r�cCs
t�|�Sr/)r�__str__r�rrrr�}r�cCs
t�|�Sr/)r�
__sizeof__r�rrrr�~r�cCs"t|�j�d|���dt|���S)N�/)r1rNr�r�r�rrrr�r�)r�r�r��
__fspath__r�y�?g�?)
�__lt__�__gt__�__le__�__ge__�__int__r��__len__ry�__complex__�	__float__�__bool__�	__index__r�cs�fdd�}|S)Ncs$�jj}|tk	r|S�|kr dStSr8)�__eq__r�r�NotImplemented)�other�ret_valr�rrr��sz_get_eq.<locals>.__eq__r)rBr�rr�r�_get_eq�sr�cs�fdd�}|S)Ncs �jjtk	rtS�|krdStSr�)�__ne__r�rr�)r�r�rrr��s
z_get_ne.<locals>.__ne__r)rBr�rr�r�_get_ne�sr�cs�fdd�}|S)Ncs �jj}|tkrtg�St|�Sr/)�__iter__r�rr��r�r�rrr��sz_get_iter.<locals>.__iter__r)rBr�rr�r�	_get_iter�sr�cs�fdd�}|S)Ncs(�jj}|tkrttg��Stt|��Sr/)r�r�r�_AsyncIteratorr�r�r�rrr��sz"_get_async_iter.<locals>.__aiter__r)rBr�rr�r�_get_async_iter�sr�)r�r�r�r�cCsbt�|t�}|tk	r||_dSt�|�}|dk	rB||�}||_dSt�|�}|dk	r^||�|_dSr/)�_return_valuesr_rrw�_calculate_return_value�_side_effect_methodsr~)r5r�rZfixedZreturn_calculatorrwZ
side_effectorrrr�_set_return_value�s

r�c@seZdZdd�Zdd�ZdS)�
MagicMixincOs&|��tt|�j||�|��dSr/)�_mock_set_magicsr�r�r9r�rrrr9�szMagicMixin.__init__cCs�ttB}|}t|dd�dk	rX|�|j�}t�}||}|D]}|t|�jkr:t||�q:|tt|�j�}t|�}|D]}t	||t
||��qvdS)Nr�)�_magicsr:r$�intersectionr�rr1r^rrT�
MagicProxy)rBZorig_magicsZthese_magicsZ
remove_magicsr�r=rrrr��szMagicMixin._mock_set_magicsN)rNrQr�r9r�rrrrr��sr�c@seZdZddd�ZdS)rFcCs|�||�|��dSr/�r�r�r�rrrr��sz"NonCallableMagicMock.mock_add_specN)F�rNrQr�r�rrrrr�src@seZdZdd�ZdS)�AsyncMagicMixincOs&|��tt|�j||�|��dSr/)r�r�r�r9r�rrrr9�szAsyncMagicMixin.__init__N�rNrQr�r9rrrrr��sr�c@seZdZddd�ZdS)rFcCs|�||�|��dSr/r�r�rrrr�szMagicMock.mock_add_specN)Fr�rrrrrsrc@s&eZdZdd�Zdd�Zddd�ZdS)	r�cCs||_||_dSr/�rr�)rBrr�rrrr9szMagicProxy.__init__cCs8|j}|j}|j|||d�}t|||�t|||�|S)N)rr�r�)rr�r�rTr�)rBr�r��mrrr�create_mocks�zMagicProxy.create_mockNcCs|��Sr/)r�)rBr)r=rrrr�(szMagicProxy.__get__)N)rNrQr�r9r�r�rrrrr�s	r�cs�eZdZed�Zed�Zed�Z�fdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
ddd�Zdd�Z�fdd�Z�ZS)r�r�r�r�cs\t�j||�tjj|jd<d|jd<d|jd<t�|jd<ttd�}t	j
|_||jd<dS)Nr�rZ_mock_await_countZ_mock_await_argsZ_mock_await_args_list�r�r+)�superr9r%r�r�r^rsrrr'ZCO_COROUTINE�co_flags)rBrCrD�	code_mock�r�rrr91s


zAsyncMockMixin.__init__c�st||fdd�}|jd7_||_|j�|�|j}|dk	r�t|�rL|�nbt|�s�zt|�}Wnt	k
rxt
�YnXt|�r�|�n&t�|�r�|||�IdH}n
|||�}|t
k	r�|S|jt
k	r�|jS|jdk	r�t�|j�r�|j||�IdHS|j||�S|jS)NTrDr�)rFr�r�r�r�r~r3rYr��
StopIteration�StopAsyncIterationr%r&rr�rwr�)rBrCrDrrGrgrrrrCAs6




z!AsyncMockMixin._execute_mock_callcCs(|jdkr$d|jpd�d�}t|��dS)Nr�	Expected r5z to have been awaited.�r�r�rr rrrr�is
zAsyncMockMixin.assert_awaitedcCs0|jdks,d|jpd�d|j�d�}t|��dS�Nr�r�r5z$ to have been awaited once. Awaited � times.r�r rrrr�qs
z"AsyncMockMixin.assert_awaited_oncecsz�jdkr&�����}td|�d������fdd�}����f�}���j�}||krvt|t�rf|nd}t|��|�dS)NzExpected await: z
Not awaitedcs�j��dd�}|S)N�await)rr!r"r#rrr$�sz:AsyncMockMixin.assert_awaited_with.<locals>._error_message)r�rrrr"r%)rBrCrDr&r$r'r(rr#rr�zs
z"AsyncMockMixin.assert_awaited_withcOs8|jdks,d|jpd�d|j�d�}t|��|j||�Sr�)r�r�rr�r)rrrr��s
z'AsyncMockMixin.assert_awaited_once_withcsZ��||f�}�fdd��jD�}||krVt|t�r8|nd}��||�}td|�|�dS)Ncsg|]}��|��qSrr*r+r�rrr��sz3AsyncMockMixin.assert_any_await.<locals>.<listcomp>z%s await not found)rr�r"r%rrr9rr�rr��s��zAsyncMockMixin.assert_any_awaitFc		s��fdd�|D�}tdd�|D�d�}t�fdd��jD��}|s�||kr�|dkrXd}nd�dd�|D��}t|�d	t|��d
�j���|�dSt|�}g}|D]2}z|�|�Wq�tk
r�|�|�Yq�Xq�|r�tdt	|�f�|�dS)Ncsg|]}��|��qSrr*r+r�rrr��sz4AsyncMockMixin.assert_has_awaits.<locals>.<listcomp>css|]}t|t�r|VqdSr/r-rrrrr.�s
z3AsyncMockMixin.assert_has_awaits.<locals>.<genexpr>c3s|]}��|�VqdSr/r*r+r�rrr.�szAwaits not found.z,Error processing expected awaits.
Errors: {}cSsg|]}t|t�r|nd�qSr/r-rrrrr��s�r/z	
Actual: z%r not all found in await list)
r�rsr�r1rrZr3r=r�r[)	rBr4r5r&r(Z
all_awaitsr6r7r8rr�rr��s>������z AsyncMockMixin.assert_has_awaitscCs0|jdkr,d|jpd�d|j�d�}t|��dS)Nrr�r5z# to not have been awaited. Awaited r�r�r rrrr��s
z!AsyncMockMixin.assert_not_awaitedcs&t�j||�d|_d|_t�|_dS�Nr)r�rvr�r�rsr�rAr�rrrv�szAsyncMockMixin.reset_mock)F)rNrQr�r�r�r�r�r9rCr�r�r�r�r�r�r�rv�
__classcell__rrr�rr�,s(	
,	r�c@seZdZdS)r	NrHrrrrr	�sr	c@s$eZdZdd�Zdd�Zdd�ZdS)�_ANYcCsdSr8r�rBr�rrrr�	sz_ANY.__eq__cCsdSr�rr�rrrr�	sz_ANY.__ne__cCsdS)Nz<ANY>rr�rrrr�	sz
_ANY.__repr__N)rNrQr�r�r�r�rrrrr�	sr�cCs`d|}d}d�dd�|D��}d�dd�|��D��}|r@|}|rX|rP|d7}||7}||S)Nz%s(%%s)r�z, cSsg|]}t|��qSr)�reprr�rrrr�!	sz*_format_call_signature.<locals>.<listcomp>cSsg|]\}}d||f�qS)z%s=%rr)rr�r�rrrr�"	s)r�r�)rrCrDrZformatted_argsZargs_stringZ
kwargs_stringrrrr	s
�rc@s�eZdZd dd�Zd!dd	�Zd
d�ZejZdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
edd��Zedd��Zdd�Zdd�ZdS)"rFrr�NFTcCs�d}i}t|�}|dkr$|\}}}nr|dkrd|\}	}
t|	t�rX|	}t|
t�rR|
}qb|
}q�|	|
}}n2|dkr�|\}t|t�r�|}nt|t�r�|}n|}|r�t�|||f�St�||||f�S)Nr�r�r�)r�r"r�r[r�)r�r�rr�rE�	from_kallrCrD�_len�first�secondrrrr�C	s.



z
_Call.__new__cCs||_||_||_dSr/)r�r��_mock_from_kall)rBr�rr�rEr�rrrr9c	sz_Call.__init__cCsh|tkrdSzt|�}Wntk
r.YdSXd}t|�dkrJ|\}}n
|\}}}t|dd�r|t|dd�r||j|jkr|dSd}|dkr�di}}n�|dkr�|\}}}n�|d	kr�|\}	t|	t�r�|	}i}n"t|	t�r�|	}di}}nd}|	}nV|dk�r@|\}
}t|
t��r4|
}t|t��r(|i}}n
d|}}n
|
|}}ndS|�rX||k�rXdS||f||fkS)
NTFr�r�r�rrr�r�)rr�rr$r�r"r[r�)rBr�Z	len_otherZ	self_nameZ	self_argsZself_kwargsZ
other_nameZ
other_argsZother_kwargsr�r�r�rrrr�j	sR


�


z_Call.__eq__cOs<|jdkrtd||fdd�S|jd}t|j||f||d�S)Nr�r�r�r��r�rFrrrrr:�	s

z_Call.__call__cCs2|jdkrt|dd�Sd|j|f}t||dd�S)NF)rr�z%s.%s)rr�r�r�)rBr�rrrrr��	s
z_Call.__getattr__cCs|tjkrt�t�||�Sr/)r[r^r;�__getattribute__)rBr�rrrr��	s
z_Call.__getattribute__cOs|�d�||�S)Nr��r�rArrrr��	sz_Call.countcOs|�d�||�S)N�indexr�rArrrr��	sz_Call.indexcCs(t|�dkr|\}}n
|\}}}||fS)Nr�)r�rrrr�_get_call_arguments�	s

z_Call._get_call_argumentscCs|��dSr��r�r�rrrrC�	sz
_Call.argscCs|��dS)Nr�r�r�rrrrD�	sz_Call.kwargscCs||js&|jpd}|�d�r"d|}|St|�dkr@d}|\}}n0|\}}}|sTd}n|�d�shd|}nd|}t|||�S)Nrr�zcall%sr�zcall.%s)r�r�rr�r)rBrrCrDrrrr��	s





z_Call.__repr__cCs4g}|}|dk	r(|jr |�|�|j}qtt|��Sr/)r�r�r�rsr�)rBZvalsrJrrr�	call_list�	s
z_Call.call_list)rr�NFT)rNNFT)rNrQr�r�r9r�rr�r:r�r�r�r�r�r�rCrDr�r�rrrrrF0	s(�
 �
7

rF)r�c	Kslt|�rt|�}t|t�}t|�}d|i}|r8d|i}n|dkrDi}|rT|rTd|d<|�|�t}	t�|�rri}n8|r�|r�td��t	}	n"t
|�s�t}	n|r�|r�t|�s�t}	|�
d|�}|}
|dkr�d}
|	f|||
|d�|��}t|t��rt||�}|�rt|�nt||||�|dk	�r,|�s,||j|<|�rV|�sVd	|k�rVt||dd
|d�|_t|�D�]}t|��rr�q^zt||�}
Wntk
�r�Y�q^YnXd|
i}|�r�d|
i}t|
t��s�t|
||||�}||j|<np|}t|t��r�|j}t|||�}||d<t�|
��rt	}nt}|f||||d
�|��}||j|<t|
||d�t|t��r^t|||��q^|S)Nr�r�Tr�zJInstance can not be True when create_autospec is mocking an async functionrr�)r�r�r�rrwr�)rLrtr�r�)r�rr�r�)rK)r\r1r"r.rerr'Zisdatadescriptor�RuntimeErrorr	rYrrar�r6rjr�rMrrrwr�r�r$r;r�r5�
_must_skipr%r&rT)r�r�rLr�rtrD�is_typeZ
is_async_funcr}r|r�r5r�rfr�r�rKZchild_klassrrrr�	s�




��


�

��
rcCsxt|t�s$|t|di�krdS|j}|jD]H}|j�|t�}|tkrFq*t|tt	f�rZdSt|t
�rl|SdSq*|S)Nr^F)r"r1r$r�r]r^r_rrWrXr6)r�r�r�r>rgrrrr�w
s


r�c@seZdZddd�ZdS)r�FNcCs(||_||_||_||_||_||_dSr/)r��idsr�r�rLr)rBr�r�r�rr�rLrrrr9�
sz_SpecState.__init__)FNNNFr�rrrrr��
s
�r�cCs"t|t�rt�|�St�|�SdSr/)r"�bytes�io�BytesIO�StringIO)�	read_datarrr�
_to_stream�
s

rr�cs&t��}|dg���fdd�}��fdd�}��fdd����fdd����fd	d
�}tdkr�ddl}ttt|j���tt|j����a|dkr�t	dt
d
�}t	td����j_d�j
_d�j_d�j_d�j_|�j_���d<�d�j_|�j_��j_|�j_����fdd�}||_�|_|S)Ncs$�jjdk	r�jjS�dj||�Sr�)�	readlinesrwrb��_state�handlerr�_readlines_side_effect�
sz)mock_open.<locals>._readlines_side_effectcs$�jjdk	r�jjS�dj||�Sr�)�readrwrbrrr�_read_side_effect�
sz$mock_open.<locals>._read_side_effectc?s$��EdH�dj||�VqdSr�)�readlinerb)�_iter_side_effectrrr�_readline_side_effect�
sz(mock_open.<locals>._readline_side_effectc3s0�jjdk	r�jjVq�dD]
}|Vq dSr�)rrw)�linerrrr�
sz$mock_open.<locals>._iter_side_effectcs �jjdk	r�jjSt�d�Sr�)rrwr�rrrr�_next_side_effect�
sz$mock_open.<locals>._next_side_effectr�open)rr�r�r�cs6t���d<�jj�dkr2���d<�d�j_tS)Nrr�)rrr~rrb)r
rrrrr�
reset_data�
s

zmock_open.<locals>.reset_data)r�	file_spec�_iorZrr��
TextIOWrapper�unionrrrr~rw�writer	rrr~r�r�)r5rZ
_read_datarr
rrrr)rr
rrrrr
�
s8"

r
c@s&eZdZdd�Zddd�Zdd�ZdS)	rcKs
tf|�Sr/)r)rBrDrrrr�szPropertyMock._get_child_mockNcCs|�Sr/r)rBr)Zobj_typerrrr�szPropertyMock.__get__cCs||�dSr/r)rBr)r�rrrr�
szPropertyMock.__set__)N)rNrQr�r�r�r�rrrrr�
s	
rc	Cs^d|_t|�D]J}zt||�}Wntk
r8YqYnXt|t�sFq|j|krt|�qdSr8)r�r�r$r;r"rr�r)r5r�r�rrrrs



rc@s$eZdZdd�Zdd�Zdd�ZdS)r�cCs&||_ttd�}tj|_||jd<dS)Nr�r+)�iteratorrrr'ZCO_ITERABLE_COROUTINEr�r^)rBrr�rrrr9+s
z_AsyncIterator.__init__cCs|Sr/rr�rrrr�1sz_AsyncIterator.__aiter__c�s*zt|j�WStk
r YnXt�dSr/)r�rr�r�r�rrrr�4s
z_AsyncIterator.__anext__N)rNrQr�r9r�r�rrrrr�'sr�)F)F)NFNNN)FFNN)Nr�)y�__all__�__version__r%rar�r'r�rz�builtins�typesrrrZ
unittest.utilr�	functoolsrrr�rqr
r�r�r*r.r!r3r7r>rMrHrYr\rarjrer�r�rr�r�rr�MISSINGr
ZDELETEDr�r�r�rZrsr�r�r�rr�r<rrMrOrPr�r�r�rr�r�r�r�ZmultipleZstopallr_Z
magic_methodsZnumericsr�r�Zinplace�rightZ
_non_defaultsr	r�r:Z_sync_async_magicsZ
_async_magicsr;r�rr�r�r�r�r�r�r�r�r�r�rr�rr�r�r	r�rrr[rFrrr�r�r1r�r6rrr
rrr�rrrr�<module>s~	



1�	h4<�
�
2�
Mw	���	�
���
	
	�	8+B
�
�
NPK��[��W�؉؉%__pycache__/case.cpython-38.opt-2.pycnu�[���U

e5d���@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZmZmZmZmZdZe�ZdZGdd�de�ZGd	d
�d
e�ZGdd�de�ZGd
d�de�Zdd�ZgZdd�Zdd�Zdd�Z dd�Z!dd�Z"dd�Z#dd�Z$Gdd �d �Z%Gd!d"�d"e%�Z&Gd#d$�d$e&�Z'Gd%d&�d&e&�Z(e�)d'd(d)g�Z*Gd*d+�d+ej+�Z,Gd,d-�d-e%�Z-Gd.d/�d/ej.�Z/Gd0d1�d1e�Z0Gd2d3�d3e0�Z1Gd4d5�d5e0�Z2dS)6�N�)�result)�strclass�	safe_repr�_count_diff_all_purpose�_count_diff_hashable�_common_shorten_reprTz@
Diff is %s characters long. Set self.maxDiff to None to see it.c@seZdZdS)�SkipTestN��__name__�
__module__�__qualname__�rr�%/usr/lib64/python3.8/unittest/case.pyr	sr	c@seZdZdS)�_ShouldStopNr
rrrrr"src@seZdZdS)�_UnexpectedSuccessNr
rrrrr'src@s&eZdZddd�Zejddd��ZdS)	�_OutcomeNcCs4d|_||_t|d�|_d|_g|_d|_g|_dS)NF�
addSubTestT)�expecting_failurer�hasattr�result_supports_subtests�success�skipped�expectedFailure�errors)�selfrrrr�__init__.sz_Outcome.__init__Fc
cs�|j}d|_z�z
dVWn�tk
r.�Yn�tk
rh}zd|_|j�|t|�f�W5d}~XYnjtk
rzYnXt��}|j	r�||_
nd|_|j�||f�d}YnX|jr�|jr�|j�|df�W5|jo�||_XdS)NTF)
r�KeyboardInterruptr	r�append�strr�sys�exc_inforrrr)r�	test_case�isTestZold_success�er!rrr�testPartExecutor7s*
$
z_Outcome.testPartExecutor)N)F)rrr
r�
contextlib�contextmanagerr%rrrrr-s
	rcCs|S�Nr)�objrrr�_idUsr*cOst�|||f�dSr()�_module_cleanupsr)�function�args�kwargsrrr�addModuleCleanupZsr/c
Csdg}trTt��\}}}z|||�Wqtk
rP}z|�|�W5d}~XYqXq|r`|d�dS�Nr)r+�pop�	Exceptionr)�
exceptionsr,r-r.�excrrr�doModuleCleanups`sr5cs,�fdd�}t�tj�r(�}d�||�S|S)Ncs4t|t�s$t�|��fdd��}|}d|_�|_|S)Ncst���dSr(�r	�r-r.��reasonrr�skip_wrappervsz-skip.<locals>.decorator.<locals>.skip_wrapperT)�
isinstance�type�	functools�wraps�__unittest_skip__�__unittest_skip_why__)�	test_itemr:r8rr�	decoratorts
zskip.<locals>.decorator�)r;�types�FunctionType)r9rBrArr8r�skipps
rFcCs|rt|�StSr(�rFr*�Z	conditionr9rrr�skipIf�srIcCs|st|�StSr(rGrHrrr�
skipUnless�srJcCs
d|_|S)NT)�__unittest_expecting_failure__)rArrrr�srcs4t|t�r t�fdd�|D��St|t�o2t|��S)Nc3s|]}t|��VqdSr()�_is_subtype)�.0r$��basetyperr�	<genexpr>�sz_is_subtype.<locals>.<genexpr>)r;�tuple�allr<�
issubclass)�expectedrOrrNrrL�s
rLc@seZdZdd�Zdd�ZdS)�_BaseTestCaseContextcCs
||_dSr()r")rr"rrrr�sz_BaseTestCaseContext.__init__cCs |j�|j|�}|j�|��dSr()r"�_formatMessage�msg�failureException)r�standardMsgrWrrr�
_raiseFailure�sz"_BaseTestCaseContext._raiseFailureN)rrr
rrZrrrrrU�srUc@seZdZddd�Zdd�ZdS)�_AssertRaisesBaseContextNcCs@t�||�||_||_|dk	r*t�|�}||_d|_d|_dSr()	rUrrTr"�re�compile�expected_regex�obj_namerW)rrTr"r^rrrr�s
z!_AssertRaisesBaseContext.__init__c	Cs�z�t|j|j�s"td||jf��|sV|�dd�|_|rNtdtt|��f��|W�TS|^}}z|j	|_
Wntk
r�t|�|_
YnX|�|||�W5QRXW5d}XdS)Nz%s() arg 1 must be %srWz3%r is an invalid keyword argument for this function)
rLrT�
_base_type�	TypeError�_base_type_strr1rW�next�iterrr_�AttributeErrorr)r�namer-r.Zcallable_objrrr�handle�s(��z_AssertRaisesBaseContext.handle)N)rrr
rrgrrrrr[�s

r[c@s$eZdZeZdZdd�Zdd�ZdS)�_AssertRaisesContextz-an exception type or tuple of exception typescCs|Sr(r�rrrr�	__enter__�sz_AssertRaisesContext.__enter__cCs�|dkrbz|jj}Wntk
r2t|j�}YnX|jrP|�d�||j��ql|�d�|��n
t�|�t	||j�s|dS|�
d�|_|jdkr�dS|j}|�
t|��s�|�d�|jt|���dS)Nz{} not raised by {}z
{} not raisedFT�"{}" does not match "{}")rTrrerr_rZ�format�	traceback�clear_framesrS�with_tracebackZ	exceptionr^�search�pattern)r�exc_type�	exc_value�tb�exc_namer^rrr�__exit__�s.
�

�z_AssertRaisesContext.__exit__N)rrr
�
BaseExceptionr`rbrjrvrrrrrh�srhc@s$eZdZeZdZdd�Zdd�ZdS)�_AssertWarnsContextz(a warning type or tuple of warning typescCsRttj���D]}t|dd�ri|_qtjdd�|_|j�	�|_t�
d|j�|S)N�__warningregistry__T)�record�always)�listr �modules�values�getattrry�warnings�catch_warnings�warnings_managerrj�simplefilterrT)r�vrrrrj�sz_AssertWarnsContext.__enter__cCs|j�|||�|dk	rdSz|jj}Wntk
rFt|j�}YnXd}|jD]Z}|j}t||j�sjqR|dkrv|}|j	dk	r�|j	�
t|��s�qR||_|j|_|j
|_
dS|dk	r�|�d�|j	jt|���|jr�|�d�||j��n|�d�|��dS)Nrkz{} not triggered by {}z{} not triggered)r�rvrTrrerr��messager;r^rpZwarning�filename�linenorZrlrqr_)rrrrsrtruZfirst_matching�m�wrrrrvs@

��
�z_AssertWarnsContext.__exit__N)rrr
�Warningr`rbrjrvrrrrrx�srx�_LoggingWatcher�records�outputc@s$eZdZdd�Zdd�Zdd�ZdS)�_CapturingHandlercCstj�|�tgg�|_dSr()�logging�Handlerrr��watcherrirrrr3sz_CapturingHandler.__init__cCsdSr(rrirrr�flush7sz_CapturingHandler.flushcCs*|jj�|�|�|�}|jj�|�dSr()r�r�rrlr�)rrzrWrrr�emit:s
z_CapturingHandler.emitN)rrr
rr�r�rrrrr�.sr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_AssertLogsContextz"%(levelname)s:%(name)s:%(message)scCs:t�||�||_|r(tj�||�|_ntj|_d|_dSr()	rUr�logger_namer�Z_nameToLevel�get�level�INFOrW)rr"r�r�rrrrFsz_AssertLogsContext.__init__cCs�t|jtj�r|j}|_nt�|j�}|_t�|j�}t�}|�	|�|j
|_
|jdd�|_|j
|_|j|_|g|_|�|j
�d|_|j
S)NF)r;r�r�ZLogger�loggerZ	getLoggerZ	Formatter�LOGGING_FORMATr�ZsetFormatterr��handlers�old_handlersr��	old_level�	propagate�
old_propagate�setLevel)rr�Z	formatterZhandlerrrrrjOs
z_AssertLogsContext.__enter__cCs`|j|j_|j|j_|j�|j�|dk	r.dSt|jj	�dkr\|�
d�t�
|j�|jj��dS)NFrz-no logs of level {} or higher triggered on {})r�r�r�r�r�r�r��lenr�r�rZrlr�ZgetLevelNamer�rf)rrrrsrtrrrrv`s


��z_AssertLogsContext.__exit__N)rrr
r�rrjrvrrrrr�As	r�c@seZdZdd�ZdS)�_OrderedChainMapccs8t�}|jD]&}|D]}||kr|�|�|VqqdSr()�set�maps�add)r�seen�mapping�krrr�__iter__ns

z_OrderedChainMap.__iter__N)rrr
r�rrrrr�msr�c@seZdZeZdZdZdZdZgZ	d�dd�Z
dd	�Zd
d�Zde_
ed
d��Zdd�Zdd�Zedd��Zedd��Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zejefd)d*��Z d+d,�Z!d-d.�Z"d/d0�Z#d1d2�Z$d3d4�Z%d5d6�Z&d7d8�Z'd�d:d;�Z(d<d=�Z)ed>d?��Z*d@dA�Z+dBdC�Z,dDdE�Z-d�dFdG�Z.d�dHdI�Z/d�dJdK�Z0dLdM�Z1dNdO�Z2dPdQ�Z3d�dRdS�Z4dTdU�Z5d�dVdW�Z6d�dXdY�Z7d�dZd[�Z8d�d\d]�Z9d�d^d_�Z:d�d`da�Z;dbdc�Z<d�ddde�Z=d�dfdg�Z>d�dhdi�Z?d�djdk�Z@d�dldm�ZAd�dndo�ZBd�dpdq�ZCd�drds�ZDd�dtdu�ZEd�dvdw�ZFd�dxdy�ZGd�dzd{�ZHd�d|d}�ZId�d~d�ZJd�d�d��ZKd�d�d��ZLd�d�d��ZMd�d�d��ZNd�d�d��ZOd�d��ZPd�d��ZQd�d�d��ZRd�d�d��ZSd�d��ZTeTe7�ZUZVeTe8�ZWZXeTe9�ZYZZeTe:�Z[Z\eTe0�Z]Z^eTe2�Z_eTe/�Z`eTeP�ZaeTeR�ZbeTeS�Zcd9S)��TestCaseTi�iF�runTestcCs�||_d|_d|_zt||�}Wn.tk
rN|dkrJtd|j|f��Yn
X|j|_g|_d|_	i|_
|�td�|�t
d�|�td�|�td�|�td�|�td�dS)	NzNo testr�zno such test method in %s: %s�assertDictEqual�assertListEqual�assertTupleEqual�assertSetEqual�assertMultiLineEqual)�_testMethodName�_outcome�_testMethodDocrre�
ValueError�	__class__�__doc__�	_cleanups�_subtest�_type_equality_funcs�addTypeEqualityFunc�dictr|rQr��	frozensetr)rZ
methodName�
testMethodrrrr�s(�zTestCase.__init__cCs||j|<dSr()r�)rZtypeobjr,rrrr��s
zTestCase.addTypeEqualityFunccOs�t|�dkr|^}}}nV|s&td��nHd|krZ|�d�}|^}}ddl}|jdtdd�ntdt|�d��t|�}|j�|||f�dS)	N�z>descriptor 'addCleanup' of 'TestCase' object needs an argumentr,rz4Passing 'function' as keyword argument is deprecated)�
stacklevelz:addCleanup expected at least 1 positional argument, got %dr)	r�rar1r��warn�DeprecationWarningrQr�r)r-r.rr,r�rrr�
addCleanup�s"

�
�zTestCase.addCleanupz%($self, function, /, *args, **kwargs)cOs|j�|||f�dSr()�_class_cleanupsr)�clsr,r-r.rrr�addClassCleanup�szTestCase.addClassCleanupcCsdSr(rrirrr�setUp�szTestCase.setUpcCsdSr(rrirrr�tearDown�szTestCase.tearDowncCsdSr(r�r�rrr�
setUpClass�szTestCase.setUpClasscCsdSr(rr�rrr�
tearDownClassszTestCase.tearDownClasscCsdS)Nrrrirrr�countTestCasesszTestCase.countTestCasescCst��Sr()rZ
TestResultrirrr�defaultTestResult	szTestCase.defaultTestResultcCs$|j}|r |���d�d��SdS�N�
r)r��strip�split�r�docrrr�shortDescriptionszTestCase.shortDescriptioncCsdt|j�|jfS)Nz%s.%s�rr�r�rirrr�idszTestCase.idcCs t|�t|�k	rtS|j|jkSr()r<�NotImplementedr��r�otherrrr�__eq__szTestCase.__eq__cCstt|�|jf�Sr()�hashr<r�rirrr�__hash__ szTestCase.__hash__cCsd|jt|j�fS�Nz%s (%s))r�rr�rirrr�__str__#szTestCase.__str__cCsdt|j�|jfS)Nz<%s testMethod=%s>r�rirrr�__repr__&s�zTestCase.__repr__cCs<t|dd�}|dk	r |||�nt�dtd�|�|�dS)N�addSkipz4TestResult has no addSkip method, skips not reportedr�)rr�r��RuntimeWarning�
addSuccess)rrr"r9r�rrr�_addSkip*s�zTestCase._addSkipc	ks�|jdks|jjsdVdS|j}|dkr4t|�}n|j�|�}t|||�|_zX|jj|jdd��dVW5QRX|jjs�|jj	}|dk	r�|j
r�t�n|jjr�t�W5||_XdS)NT�r#)
r�rr�r��params�	new_child�_SubTestr%rrZfailfastrr)rrWr��parentZ
params_maprrrr�subTest3s$
zTestCase.subTestcCs`|D]V\}}t|t�r(|�|j||�q|dk	rt|d|j�rN|�||�q|�||�qdSr0)r;r�rr"rSrX�
addFailureZaddError)rrr�testr!rrr�_feedErrorsToResultRs
zTestCase._feedErrorsToResultcCsDz
|j}Wn*tk
r4t�dt�|�|�YnX|||�dS)Nz@TestResult has no addExpectedFailure method, reporting as passes)�addExpectedFailurerer�r�r�r�)rrr!r�rrr�_addExpectedFailure\s
�zTestCase._addExpectedFailurecCshz
|j}WnPtk
rZt�dt�z
td�Wn$tk
rT|�|t���YnXYn
X||�dS)NzCTestResult has no addUnexpectedSuccess method, reporting as failure)	�addUnexpectedSuccessrer�r�r�rr�r r!)rrr�rrr�_addUnexpectedSuccessfs
�
zTestCase._addUnexpectedSuccesscCs|��dSr()r�rirrr�
_callSetUpuszTestCase._callSetUpcCs
|�dSr(r)r�methodrrr�_callTestMethodxszTestCase._callTestMethodcCs|��dSr()r�rirrr�
_callTearDown{szTestCase._callTearDowncOs|||�dSr(r�rr,r-r.rrr�_callCleanup~szTestCase._callCleanupNc

Cs|}|dkr.|��}t|dd�}|dk	r.|�|�|�t||j�}t|jdd�s^t|dd�r�z,t|jdd�pxt|dd�}|�|||�W5|�|�XdSt|dd�}t|dd�}|p�|}t|�}	z�|	|_|	�|��|�
�W5QRX|	j�r@||	_|	j|dd	��|�|�W5QRXd|	_|	�|��|��W5QRX|��|	jD]\}}|�|||��qN|�||	j�|	j�r�|�r�|	j
�r�|�||	j
�n
|�|�n
|�|�|W�S|�|�|dk�r�t|dd�}
|
dk	�r�|
�|	j�	�d|	_
d|_XdS)
N�startTestRunr?Fr@rCrK�stopTestRunTr�)r�rZ	startTestr�r�ZstopTestr�rr�clearrr�r%r�rrr�r��
doCleanupsrr�r�r�r�)
rrZorig_resultr�r�Zskip_whyZexpecting_failure_methodZexpecting_failure_classr�outcomer�r�r9rrr�run�st

�
���




zTestCase.runc	CsR|jp
t�}|jrL|j��\}}}|�|��|j|f|�|�W5QRXq|jSr()r�rr�r1r%r�r)rr�r,r-r.rrrr��szTestCase.doCleanupsc
Csdg|_|jr`|j��\}}}z|||�Wqtk
r\}z|j�t���W5d}~XYqXqdSr()ZtearDown_exceptionsr�r1r2rr r!)r�r,r-r.r4rrr�doClassCleanups�szTestCase.doClassCleanupscOs|j||�Sr()r�)rr-�kwdsrrr�__call__�szTestCase.__call__cCsF|��t||j��|��|jrB|j�d�\}}}|||�qdS)N���)r�rr�r�r�r1r�rrr�debug�szTestCase.debugcCst|��dSr(r6)rr9rrr�skipTest�szTestCase.skipTestcCs|�|��dSr()rX)rrWrrr�fail�sz
TestCase.failcCs&|r"|�|dt|��}|�|��dS)Nz%s is not false�rVrrX�r�exprrWrrr�assertFalse�szTestCase.assertFalsecCs&|s"|�|dt|��}|�|��dS)Nz%s is not truerrrrr�
assertTrue�szTestCase.assertTruecCsV|js|p|S|dkr|Szd||fWStk
rPdt|�t|�fYSXdS)Nz%s : %s)�longMessage�UnicodeDecodeErrorr)rrWrYrrrrV�s
zTestCase._formatMessagecOs(t||�}z|�d||�W�Sd}XdS)N�assertRaises�rhrg)r�expected_exceptionr-r.�contextrrrr
s
zTestCase.assertRaisescOst||�}|�d||�S)N�assertWarns�rxrg)r�expected_warningr-r.r
rrrr5s
zTestCase.assertWarnscCst|||�Sr()r�)rr�r�rrr�
assertLogsTszTestCase.assertLogscCsFt|�t|�kr@|j�t|��}|dk	r@t|t�r<t||�}|S|jSr()r<r�r�r;rr�_baseAssertEqual)r�first�secondZasserterrrr�_getAssertEqualityFuncjs

zTestCase._getAssertEqualityFunccCs0||ks,dt||�}|�||�}|�|��dS)N�%s != %s)rrVrX)rrrrWrYrrrr�szTestCase._baseAssertEqualcCs|�||�}||||d�dS)N)rW)r)rrrrWZassertion_funcrrr�assertEqual�szTestCase.assertEqualcCs2||ks.|�|dt|�t|�f�}|�|��dS)Nz%s == %sr)rrrrWrrr�assertNotEqual�s
�zTestCase.assertNotEqualcCs�||krdS|dk	r$|dk	r$td��t||�}|dk	rf||krDdSdt|�t|�t|�t|�f}n:|dkrrd}t||�dkr�dSdt|�t|�|t|�f}|�||�}|�|��dS)N� specify delta or places not bothz(%s != %s within %s delta (%s difference)�rz)%s != %s within %r places (%s difference)�ra�absr�roundrVrX�rrrZplacesrWZdelta�diffrYrrr�assertAlmostEqual�s4��zTestCase.assertAlmostEqualcCs�|dk	r|dk	rtd��t||�}|dk	rb||ks@||kr@dSdt|�t|�t|�t|�f}n<|dkrnd}||ks�t||�dkr�dSdt|�t|�|f}|�||�}|�|��dS)Nrz(%s == %s within %s delta (%s difference)rrz%s == %s within %r placesrrrrr�assertNotAlmostEqual�s,��zTestCase.assertNotAlmostEqualcCs�|dk	rP|j}t||�s.|�d|t|�f��t||�sT|�d|t|�f��nd}d}zt|�}Wn ttfk
r�d|}YnX|dkr�zt|�}Wn ttfk
r�d|}YnX|dk�r�||kr�dSd|��ft||�}t	t
||��D]�}	z||	}
Wn4tttfk
�r<|d|	|f7}Y�q�YnXz||	}Wn4tttfk
�r~|d|	|f7}Y�q�YnX|
|kr�|d	|	ft|
|�7}�q�q�||k�r�|dk�r�t|�t|�k�r�dS||k�r<|d
|||f7}z|d|t||�f7}Wn,tttfk
�r8|d||f7}YnXnh||k�r�|d
|||f7}z|d|t||�f7}Wn,tttfk
�r�|d||f7}YnX|}dd�
t�t�|���t�|�����}
|�||
�}|�||�}|�|�dS)NzFirst sequence is not a %s: %szSecond sequence is not a %s: %sZsequencez(First %s has no length.    Non-sequence?z)Second %s has no length.    Non-sequence?z%ss differ: %s != %s
z(
Unable to index element %d of first %s
z)
Unable to index element %d of second %s
z#
First differing element %d:
%s
%s
z+
First %s contains %d additional elements.
zFirst extra element %d:
%s
z'Unable to index element %d of first %s
z,
Second %s contains %d additional elements.
z(Unable to index element %d of second %s
r�)rr;rXrr�ra�NotImplementedError�
capitalizer�range�min�
IndexErrorr<�join�difflib�ndiff�pprint�pformat�
splitlines�_truncateMessagerVr)rZseq1Zseq2rW�seq_typeZ
seq_type_nameZ	differingZlen1Zlen2�iZitem1Zitem2rY�diffMsgrrr�assertSequenceEqual�s�

�

��
�

������

��
�

��
���zTestCase.assertSequenceEqualcCs2|j}|dkst|�|kr"||S|tt|�Sr()�maxDiffr��DIFF_OMITTED)rr�rZmax_diffrrrr-NszTestCase._truncateMessagecCs|j|||td�dS�N)r.)r1r|)rZlist1Zlist2rWrrrr�Ts
zTestCase.assertListEqualcCs|j|||td�dSr4)r1rQ)rZtuple1Ztuple2rWrrrr�`s	zTestCase.assertTupleEqualc

Cs`z|�|�}Wn^tk
r>}z|�d|�W5d}~XYn0tk
rl}z|�d|�W5d}~XYnXz|�|�}Wn^tk
r�}z|�d|�W5d}~XYn0tk
r�}z|�d|�W5d}~XYnX|s�|s�dSg}|�r|�d�|D]}|�t|���q|�r@|�d�|D]}|�t|���q*d�|�}	|�|�||	��dS)Nz/invalid type when attempting set difference: %sz2first argument does not support set difference: %sz3second argument does not support set difference: %sz*Items in the first set but not the second:z*Items in the second set but not the first:r�)�
differencerarrer�reprr'rV)
rZset1Zset2rWZdifference1r$Zdifference2�lines�itemrYrrrr�ks2
  


zTestCase.assertSetEqualcCs2||kr.dt|�t|�f}|�|�||��dS)Nz%s not found in %s�rrrV�r�memberZ	containerrWrYrrr�assertIn�s
�zTestCase.assertIncCs2||kr.dt|�t|�f}|�|�||��dS)Nz%s unexpectedly found in %sr9r:rrr�assertNotIn�s
�zTestCase.assertNotIncCs2||k	r.dt|�t|�f}|�|�||��dS)Nz%s is not %sr9�rZexpr1Zexpr2rWrYrrr�assertIs�s
�zTestCase.assertIscCs,||kr(dt|�f}|�|�||��dS)Nzunexpectedly identical: %sr9r>rrr�assertIsNot�szTestCase.assertIsNotc	Cs~|�|td�|�|td�||krzdt||�}dd�t�t�|���t�|�����}|�	||�}|�
|�||��dS)Nz"First argument is not a dictionaryz#Second argument is not a dictionaryrr�)�assertIsInstancer�rr'r(r)r*r+r,r-rrV)rZd1Zd2rWrYrrrrr��s
�zTestCase.assertDictEqualc		Cs�t�dt�g}g}|��D]L\}}||kr8|�|�q|||kr|�dt|�t|�t||�f�q|sv|svdSd}|r�dd�dd�|D��}|r�|r�|d7}|d	d�|�7}|�|�||��dS)
Nz&assertDictContainsSubset is deprecatedz%s, expected: %s, actual: %srCzMissing: %s�,css|]}t|�VqdSr()r)rMr�rrrrP�sz4TestCase.assertDictContainsSubset.<locals>.<genexpr>z; zMismatched values: %s)	r�r�r��itemsrrr'rrV)	rZsubsetZ
dictionaryrWZmissingZ
mismatched�key�valuerYrrr�assertDictContainsSubset�s4�
���
z!TestCase.assertDictContainsSubsetc
Cs�t|�t|�}}zt�|�}t�|�}Wntk
rHt||�}YnX||krVdSt||�}|r�d}dd�|D�}d�|�}	|�||	�}|�||�}|�	|�dS)NzElement counts were not equal:
cSsg|]}d|�qS)z First has %d, Second has %d:  %rr)rMrrrr�
<listcomp>�sz-TestCase.assertCountEqual.<locals>.<listcomp>r�)
r|�collections�Counterrarrr'r-rVr)
rrrrWZ	first_seqZ
second_seqZdifferencesrYr7r0rrr�assertCountEqual�s 


zTestCase.assertCountEqualcCs�|�|td�|�|td�||kr�t|�|jks@t|�|jkrN|�|||�|jdd�}|jdd�}t|�dkr�|�d�|kr�|dg}|dg}dt||�}dd	�t	�
||��}|�||�}|�|�
||��dS)
NzFirst argument is not a stringzSecond argument is not a stringT)�keependsrz
r�rrC)rArr��_diffThresholdrr,r�rr'r(r)r-rrV)rrrrWZ
firstlinesZsecondlinesrYrrrrr��s �

zTestCase.assertMultiLineEqualcCs2||ks.dt|�t|�f}|�|�||��dS)Nz%s not less than %sr9�r�a�brWrYrrr�
assertLessszTestCase.assertLesscCs2||ks.dt|�t|�f}|�|�||��dS)Nz%s not less than or equal to %sr9rMrrr�assertLessEqualszTestCase.assertLessEqualcCs2||ks.dt|�t|�f}|�|�||��dS)Nz%s not greater than %sr9rMrrr�
assertGreaterszTestCase.assertGreatercCs2||ks.dt|�t|�f}|�|�||��dS)Nz"%s not greater than or equal to %sr9rMrrr�assertGreaterEqual szTestCase.assertGreaterEqualcCs,|dk	r(dt|�f}|�|�||��dS)Nz%s is not Noner9�rr)rWrYrrr�assertIsNone&szTestCase.assertIsNonecCs"|dkrd}|�|�||��dS)Nzunexpectedly None)rrVrTrrr�assertIsNotNone,szTestCase.assertIsNotNonecCs0t||�s,dt|�|f}|�|�||��dS)Nz%s is not an instance of %r�r;rrrV�rr)r�rWrYrrrrA2s
zTestCase.assertIsInstancecCs0t||�r,dt|�|f}|�|�||��dS)Nz%s is an instance of %rrWrXrrr�assertNotIsInstance9s
zTestCase.assertNotIsInstancecOst|||�}|�d||�S)N�assertRaisesRegexr)rrr^r-r.r
rrrrZ?s
zTestCase.assertRaisesRegexcOst|||�}|�d||�S)N�assertWarnsRegexr)rrr^r-r.r
rrrr[OszTestCase.assertWarnsRegexcCsJt|ttf�rt�|�}|�|�sFd|j|f}|�||�}|�|��dS)Nz&Regex didn't match: %r not found in %r)	r;r�bytesr\r]rprqrVrX)r�textr^rWrYrrr�assertRegexbs

�zTestCase.assertRegexcCs`t|ttf�rt�|�}|�|�}|r\d||��|���|j|f}|�	||�}|�
|��dS)Nz"Regex matched: %r matches %r in %r)r;rr\r\r]rp�start�endrqrVrX)rr]Zunexpected_regexrW�matchrYrrr�assertNotRegexns

�zTestCase.assertNotRegexcs�fdd�}|S)Ncs t�d��j�td��||�S)NzPlease use {0} instead.r�)r�r�rlrr�r7��
original_funcrr�deprecated_func~s
�z,TestCase._deprecate.<locals>.deprecated_funcr)rdrerrcr�
_deprecate}szTestCase._deprecate)r�)N)N)N)N)NN)N)N)N)NNN)NNN)NN)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)drrr
�AssertionErrorrXrr2rLZ_classSetupFailedr�rr�r��__text_signature__�classmethodr�r�r�r�r�r�r�r�r�r�r�r�r�r�r&r'�_subtest_msg_sentinelr�r�r�r�r�r�r�r�r�r�r�r�rrrrrrVr
rrrrrrr r!r1r-r�r�r�r<r=r?r@r�rFrJr�rPrQrRrSrUrVrArYrZr[r^rbrfZfailUnlessEqualZassertEqualsZfailIfEqualZassertNotEqualsZfailUnlessAlmostEqualZassertAlmostEqualsZfailIfAlmostEqualZassertNotAlmostEqualsZ
failUnlessZassert_ZfailUnlessRaisesZfailIfZassertRaisesRegexpZassertRegexpMatchesZassertNotRegexpMatchesrrrrr�ws�!
 


	


E

	


!



	�
-�
#
c


+






 










	r�csfeZdZd�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Z�Z
S)�FunctionTestCaseNcs*tt|���||_||_||_||_dSr()�superrkr�
_setUpFunc�
_tearDownFunc�	_testFunc�_description)rZtestFuncr�r�Zdescription�r�rrr�s
zFunctionTestCase.__init__cCs|jdk	r|��dSr()rmrirrrr��s
zFunctionTestCase.setUpcCs|jdk	r|��dSr()rnrirrrr��s
zFunctionTestCase.tearDowncCs|��dSr()rorirrrr��szFunctionTestCase.runTestcCs|jjSr()rorrirrrr��szFunctionTestCase.idcCs@t||j�stS|j|jko>|j|jko>|j|jko>|j|jkSr()r;r�r�rmrnrorpr�rrrr��s
�
�
�zFunctionTestCase.__eq__cCstt|�|j|j|j|jf�Sr()r�r<rmrnrorprirrrr��s�zFunctionTestCase.__hash__cCsdt|j�|jjfSr�)rr�rorrirrrr��s
�zFunctionTestCase.__str__cCsdt|j�|jfS)Nz<%s tec=%s>)rr�rorirrrr��s
�zFunctionTestCase.__repr__cCs2|jdk	r|jS|jj}|r.|�d�d��p0dSr�)rpror�r�r�r�rrrr��s
z!FunctionTestCase.shortDescription)NNN)rrr
rr�r�r�r�r�r�r�r�r��
__classcell__rrrqrrk�s		rkcsDeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z�Z	S)
r�cs(t���||_||_||_|j|_dSr()rlr�_messager"r�rX)rr"r�r�rqrrr�s

z_SubTest.__init__cCstd��dS)Nzsubtests cannot be run directly)r"rirrrr��sz_SubTest.runTestcCs^g}|jtk	r |�d�|j��|jrPd�dd�|j��D��}|�d�|��d�|�p\dS)Nz[{}]z, css|]\}}d�||�VqdS)z{}={!r}N)rl)rMr�r�rrrrP�s�z+_SubTest._subDescription.<locals>.<genexpr>z({})� z(<subtest>))rsrjrrlr�r'rC)r�partsZparams_descrrr�_subDescription�s

�z_SubTest._subDescriptioncCsd�|j��|���S�Nz{} {})rlr"r�rvrirrrr��sz_SubTest.idcCs
|j��Sr()r"r�rirrrr��sz_SubTest.shortDescriptioncCsd�|j|���Srw)rlr"rvrirrrr��sz_SubTest.__str__)
rrr
rr�rvr�r�r�rrrrrqrr��sr�)3r r=r(r�r*r\r�rHr&rmrDrCr�utilrrrrrZ
__unittest�objectrjr3r2r	rrrr*r+r/r5rFrIrJrrLrUr[rhrx�
namedtupler�r�r�r��ChainMapr�r�rkr�rrrr�<module>sb(	*%5�,
$:PK��[a!n�}}!__pycache__/result.cpython-38.pycnu�[���U

e5d�@s\dZddlZddlZddlZddlmZddlmZdZdd�Z	d	Z
d
ZGdd�de�Z
dS)
zTest result object�N�)�util��wrapsTcst���fdd��}|S)Ncs$t|dd�r|���|f|�|�S)N�failfastF)�getattr�stop)�self�args�kw��method��'/usr/lib64/python3.8/unittest/result.py�inner
szfailfast.<locals>.innerr)r
rrrrrsrz
Stdout:
%sz
Stderr:
%sc@s�eZdZdZdZdZdZd.dd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zedd��Zedd��Zdd�Zdd�Zdd�Zdd�Zed d!��Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�ZdS)/�
TestResulta�Holder for test result information.

    Test results are automatically managed by the TestCase and TestSuite
    classes, and do not need to be explicitly manipulated by writers of tests.

    Each instance holds the total number of tests run, and collections of
    failures and errors that occurred among those test runs. The collections
    contain tuples of (testcase, exceptioninfo), where exceptioninfo is the
    formatted traceback of the error that occurred.
    NFcCsbd|_g|_g|_d|_g|_g|_g|_d|_d|_d|_	d|_
d|_tj
|_tj|_d|_dS)NFr)r�failures�errors�testsRun�skipped�expectedFailures�unexpectedSuccesses�
shouldStop�buffer�	tb_locals�_stdout_buffer�_stderr_buffer�sys�stdout�_original_stdout�stderr�_original_stderr�
_mirrorOutput)r	�streamZdescriptions�	verbosityrrr�__init__&szTestResult.__init__cCsdS)z#Called by TestRunner after test runNr�r	rrr�printErrors7szTestResult.printErrorscCs |jd7_d|_|��dS)z-Called when the given test is about to be runrFN)rr"�_setupStdout�r	�testrrr�	startTest:szTestResult.startTestcCs8|jr4|jdkr$t��|_t��|_|jt_|jt_dS)N)rr�io�StringIOrrrr r&rrrr(@s


zTestResult._setupStdoutcCsdS)zpCalled once before any tests are executed.

        See startTest for a method called before each test.
        Nrr&rrr�startTestRunHszTestResult.startTestRuncCs|��d|_dS)z'Called when the given test has been runFN)�_restoreStdoutr"r)rrr�stopTestNszTestResult.stopTestcCs�|jr�|jrltj��}tj��}|rF|�d�s6|d7}|j�t	|�|rl|�d�s\|d7}|j
�t|�|jt_|j
t_|j�
d�|j��|j�
d�|j��dS)N�
r)rr"rr�getvaluer �endswithr�write�STDOUT_LINEr!�STDERR_LINEr�seek�truncater)r	�output�errorrrrr/Ss$




zTestResult._restoreStdoutcCsdS)zmCalled once after all tests are executed.

        See stopTest for a method called after each test.
        Nrr&rrr�stopTestRunhszTestResult.stopTestRuncCs"|j�||�||�f�d|_dS)zmCalled when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info().
        TN)r�append�_exc_info_to_stringr"�r	r*�errrrr�addErrornszTestResult.addErrorcCs"|j�||�||�f�d|_dS)zdCalled when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info().TN)rr<r=r"r>rrr�
addFailurevszTestResult.addFailurecCsZ|dk	rVt|dd�r|��t|d|j�r4|j}n|j}|�||�||�f�d|_dS)z�Called at the end of a subtest.
        'err' is None if the subtest ended successfully, otherwise it's a
        tuple of values as returned by sys.exc_info().
        NrFrT)	rr�
issubclass�failureExceptionrrr<r=r")r	r*Zsubtestr?rrrr�
addSubTest}szTestResult.addSubTestcCsdS)z-Called when a test has completed successfullyNrr)rrr�
addSuccess�szTestResult.addSuccesscCs|j�||f�dS)zCalled when a test is skipped.N)rr<)r	r*�reasonrrr�addSkip�szTestResult.addSkipcCs|j�||�||�f�dS)z/Called when an expected failure/error occurred.N)rr<r=r>rrr�addExpectedFailure�s�zTestResult.addExpectedFailurecCs|j�|�dS)z5Called when a test was expected to fail, but succeed.N)rr<r)rrr�addUnexpectedSuccess�szTestResult.addUnexpectedSuccesscCs>t|j�t|j�kodkno<t|d�p<t|j�dkS)z/Tells whether or not this result was a success.rr)�lenrr�hasattrrr&rrr�
wasSuccessful�s$�zTestResult.wasSuccessfulcCs
d|_dS)z+Indicates that the tests should be aborted.TN)rr&rrrr�szTestResult.stopcCs�|\}}}|r |�|�r |j}q
||jkr6|�|�}nd}tj|||||jd�}t|���}|j	r�t
j��}	t
j
��}
|	r�|	�d�s�|	d7}	|�t|	�|
r�|
�d�s�|
d7}
|�t|
�d�|�S)z>Converts a sys.exc_info()-style tuple of values into a string.N)�limit�capture_localsr1�)�_is_relevant_tb_level�tb_nextrC�_count_relevant_tb_levels�	traceback�TracebackExceptionr�list�formatrrrr2r r3r<r5r6�join)r	r?r*�exctype�value�tb�lengthZtb_eZmsgLinesr9r:rrrr=�s4

�



zTestResult._exc_info_to_stringcCsd|jjkS)N�
__unittest)�tb_frame�	f_globals)r	rZrrrrP�sz TestResult._is_relevant_tb_levelcCs&d}|r"|�|�s"|d7}|j}q|S)Nrr)rPrQ)r	rZr[rrrrR�s
z$TestResult._count_relevant_tb_levelscCs&dt�|j�|jt|j�t|j�fS)Nz!<%s run=%i errors=%i failures=%i>)rZstrclass�	__class__rrJrrr&rrr�__repr__�s
��zTestResult.__repr__)NNN)�__name__�
__module__�__qualname__�__doc__Z_previousTestClassZ_testRunEnteredZ_moduleSetUpFailedr%r'r+r(r.r0r/r;rr@rArDrErGrHrIrLrr=rPrRr`rrrrrs8




	r)rdr,rrSrOr�	functoolsrr\rr5r6�objectrrrrr�<module>sPK��[�{��%__pycache__/main.cpython-38.opt-2.pycnu�[���U

e5d�+�@spddlZddlZddlZddlmZmZddlmZdZdZ	dZ
dd	�Zd
d�Zdd
�Z
Gdd�de�ZeZdS)�N�)�loader�runner)�installHandlerTaExamples:
  %(prog)s test_module               - run tests from test_module
  %(prog)s module.TestClass          - run tests from module.TestClass
  %(prog)s module.Class.test_method  - run specified test method
  %(prog)s path/to/test_file.py      - run tests from test_file.py
aFExamples:
  %(prog)s                           - run default set of tests
  %(prog)s MyTestSuite               - run suite 'MyTestSuite'
  %(prog)s MyTestCase.testSomething  - run MyTestCase.testSomething
  %(prog)s MyTestCase                - run all 'test*' test methods
                                       in MyTestCase
cCsxtj�|�rt|���d�rttj�|�rXtj�|t���}tj�|�sP|�tj	�rT|S|}|dd��
dd��
dd�S|S)Nz.py����\�.�/)�os�path�isfile�lower�endswith�isabs�relpath�getcwd�
startswith�pardir�replace)�nameZrel_path�r�%/usr/lib64/python3.8/unittest/main.py�
_convert_namesrcCsdd�|D�S)NcSsg|]}t|��qSr)r)�.0rrrr�
<listcomp>.sz"_convert_names.<locals>.<listcomp>r)�namesrrr�_convert_names-srcCsd|krd|}|S)N�*z*%s*r)�patternrrr�_convert_select_pattern1src@s�eZdZdZdZdZZZZZ	Z
dZddddej
ddddddfdd�dd�Zdd	d
�Zdd�Zd
d�Zddd�Zdd�Zdd�Zdd�Zdd�Zddd�Zdd�ZdS) �TestProgramNr�__main__TF)�	tb_localscCs�t|t�r<t|�|_|�d�dd�D]}
t|j|
�|_q&n||_|dkrPtj}||_||_	|	|_
||_|
|_||_
|dkr�tjs�d|_n||_||_||_||_tj�|d�|_|�|�|��dS)Nrr�defaultr)�
isinstance�str�
__import__�module�split�getattr�sys�argv�exit�failfast�
catchbreak�	verbosity�bufferr"�warnoptions�warnings�defaultTest�
testRunner�
testLoaderr
r�basename�progName�	parseArgs�runTests)�selfr'r3r+r4r5r,r/r-r.r0r2r"�partrrr�__init__As,


zTestProgram.__init__cCs4|rt|�|jdkr|��|��t�d�dS)N�)�print�_discovery_parser�_initArgParsers�_print_helpr*r,)r:�msgrrr�	usageExitgs
zTestProgram.usageExitcOsZ|jdkr6t|j���ttd|ji�|j��n t|j���ttd|ji�dS)N�prog)	r'r>�_main_parserZformat_help�
MAIN_EXAMPLESr7r?�
print_help�MODULE_EXAMPLES)r:�args�kwargsrrrrAos
zTestProgram._print_helpcCs�|��|jdkrpt|�dkrD|d��dkrD|�|dd��dS|j�|dd�|�|js�|�g�dSn|j�|dd�|�|jr�t|j�|_	t
dkr�d|_n6|jdkr�d|_	n$t|jt
�r�|jf|_	nt|j�|_	|��dS)Nr�discoverr=r!)r@r'�lenr
�
_do_discoveryrE�
parse_args�testsr�	testNames�__name__r3r$r%�list�createTests)r:r+rrrr8xs(


zTestProgram.parseArgscCst|jr|j|j_|r@|dkr"|jn|�}|�|j|j|j�|_n0|jdkr\|j�|j	�|_n|j�
|j|j	�|_dS�N)�testNamePatternsr5rK�startr�top�testrPZloadTestsFromModuler'ZloadTestsFromNames)r:�from_discovery�LoaderrrrrrS�s


�zTestProgram.createTestscCs$|��}|�|�|_|�|�|_dSrT)�_getParentArgParser�_getMainArgParserrE�_getDiscoveryArgParserr?)r:Z
parent_parserrrrr@�szTestProgram._initArgParserscCs�tjdd�}|jddddddd	�|jd
ddddd
d	�|jddddd�|jdkrn|jdddddd�d|_|jdkr�|jdddddd�d|_|jdkr�|jdddddd�d|_|jdkr�|jdd d!td"d#�g|_|S)$NF)Zadd_helpz-vz	--verboser/Zstore_constr=zVerbose output)�dest�actionZconst�helpz-qz--quietrzQuiet outputz--localsr"�
store_truez"Show local variables in tracebacks)r^r_r`z-fz
--failfastr-zStop on first fail or errorz-cz--catchr.z'Catch Ctrl-C and display results so farz-bz--bufferr0z%Buffer stdout and stderr during testsz-krU�appendz.Only run tests which match the given substring)r^r_�typer`)�argparse�ArgumentParser�add_argumentr-r.r0rUr)r:�parserrrrr[�sR
�
��

�

�

�
�zTestProgram._getParentArgParsercCs2tj|gd�}|j|_|j|_|jdddd�|S)N��parentsrOrz?a list of any number of test modules, classes and test methods.)�nargsr`)rdrer7rDrArGrf)r:�parentrgrrrr\�s�zTestProgram._getMainArgParsercCsztj|gd�}d|j|_d|_|jddddd�|jd	d
ddd�|jd
dddd�dD]}|j|dtjtjd�qZ|S)Nrhz%s discoverzcFor test discovery all test modules must be importable from the top level directory of the project.z-sz--start-directoryrVz*Directory to start discovery ('.' default))r^r`z-pz	--patternrz+Pattern to match tests ('test*.py' default)z-tz--top-level-directoryrWz<Top level directory of project (defaults to start directory))rVrrW�?)rjr#r`)rdrer7rDZepilogrfZSUPPRESS)r:rkrg�argrrrr]�s$
�
�
��z"TestProgram._getDiscoveryArgParsercCsLd|_d|_d|_|dk	r:|jdkr,|��|j�||�|jd|d�dS)Nrztest*.pyT)rYrZ)rVrrWr?r@rNrS)r:r+rZrrrrM�s
zTestProgram._do_discoveryc	Cs�|jrt�|jdkrtj|_t|jt�r�zVz"|j|j|j|j	|j
|jd�}Wn.tk
r||j|j|j|j	|j
d�}YnXWq�tk
r�|��}Yq�Xn|j}|�
|j�|_|jr�t�|j���dS)N)r/r-r0r2r")r/r-r0r2)r.rr4rZTextTestRunnerr$rcr/r-r0r2r"�	TypeError�runrX�resultr,r*Z
wasSuccessful)r:r4rrrr9�s2
�
�zTestProgram.runTests)N)FN)N)rQ�
__module__�__qualname__r'r/r-r.r0r7r2rUr?rZdefaultTestLoaderr<rCrAr8rSr@r[r\r]rMr9rrrrr 7s4��&
	
#

r )r*rdr
�rrZsignalsrZ
__unittestrFrHrrr�objectr �mainrrrr�<module>s	]PK��[�����%__pycache__/case.cpython-38.opt-1.pycnu�[���U

e5d���@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZmZmZmZmZdZe�ZdZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�ZGdd�de�Zdd�ZgZdd�Zdd�Z dd�Z!dd�Z"dd�Z#dd�Z$dd�Z%Gd d!�d!�Z&Gd"d#�d#e&�Z'Gd$d%�d%e'�Z(Gd&d'�d'e'�Z)e�*d(d)d*g�Z+Gd+d,�d,ej,�Z-Gd-d.�d.e&�Z.Gd/d0�d0ej/�Z0Gd1d2�d2e�Z1Gd3d4�d4e1�Z2Gd5d6�d6e1�Z3dS)7zTest case implementation�N�)�result)�strclass�	safe_repr�_count_diff_all_purpose�_count_diff_hashable�_common_shorten_reprTz@
Diff is %s characters long. Set self.maxDiff to None to see it.c@seZdZdZdS)�SkipTestz�
    Raise this exception in a test to skip it.

    Usually you can use TestCase.skipTest() or one of the skipping decorators
    instead of raising this directly.
    N��__name__�
__module__�__qualname__�__doc__�rr�%/usr/lib64/python3.8/unittest/case.pyr	sr	c@seZdZdZdS)�_ShouldStopz
    The test should stop.
    Nr
rrrrr"src@seZdZdZdS)�_UnexpectedSuccessz7
    The test was supposed to fail, but it didn't!
    Nr
rrrrr'src@s&eZdZddd�Zejddd��ZdS)	�_OutcomeNcCs4d|_||_t|d�|_d|_g|_d|_g|_dS)NF�
addSubTestT)�expecting_failurer�hasattr�result_supports_subtests�success�skipped�expectedFailure�errors)�selfrrrr�__init__.sz_Outcome.__init__Fc
cs�|j}d|_z�z
dVWn�tk
r.�Yn�tk
rh}zd|_|j�|t|�f�W5d}~XYnjtk
rzYnXt��}|j	r�||_
nd|_|j�||f�d}YnX|jr�|jr�|j�|df�W5|jo�||_XdS)NTF)
r�KeyboardInterruptr	r�append�strr�sys�exc_inforrrr)r�	test_case�isTestZold_success�er"rrr�testPartExecutor7s*
$
z_Outcome.testPartExecutor)N)F)rrr
r�
contextlib�contextmanagerr&rrrrr-s
	rcCs|S�Nr)�objrrr�_idUsr+cOst�|||f�dS)znSame as addCleanup, except the cleanup items are called even if
    setUpModule fails (unlike tearDownModule).N)�_module_cleanupsr)�function�args�kwargsrrr�addModuleCleanupZsr0c
Csdg}trTt��\}}}z|||�Wqtk
rP}z|�|�W5d}~XYqXq|r`|d�dS)zWExecute all module cleanup functions. Normally called for you after
    tearDownModule.Nr)r,�pop�	Exceptionr)�
exceptionsr-r.r/�excrrr�doModuleCleanups`sr5cs,�fdd�}t�tj�r(�}d�||�S|S)z&
    Unconditionally skip a test.
    cs4t|t�s$t�|��fdd��}|}d|_�|_|S)Ncst���dSr)�r	�r.r/��reasonrr�skip_wrappervsz-skip.<locals>.decorator.<locals>.skip_wrapperT)�
isinstance�type�	functools�wraps�__unittest_skip__�__unittest_skip_why__)�	test_itemr:r8rr�	decoratorts
zskip.<locals>.decorator�)r;�types�FunctionType)r9rBrArr8r�skipps
rFcCs|rt|�StS)z/
    Skip a test if the condition is true.
    �rFr+�Z	conditionr9rrr�skipIf�srIcCs|st|�StS)z3
    Skip a test unless the condition is true.
    rGrHrrr�
skipUnless�srJcCs
d|_|S)NT)�__unittest_expecting_failure__)rArrrr�srcs4t|t�r t�fdd�|D��St|t�o2t|��S)Nc3s|]}t|��VqdSr))�_is_subtype)�.0r%��basetyperr�	<genexpr>�sz_is_subtype.<locals>.<genexpr>)r;�tuple�allr<�
issubclass)�expectedrOrrNrrL�s
rLc@seZdZdd�Zdd�ZdS)�_BaseTestCaseContextcCs
||_dSr))r#)rr#rrrr�sz_BaseTestCaseContext.__init__cCs |j�|j|�}|j�|��dSr))r#�_formatMessage�msg�failureException)r�standardMsgrWrrr�
_raiseFailure�sz"_BaseTestCaseContext._raiseFailureN)rrr
rrZrrrrrU�srUc@seZdZddd�Zdd�ZdS)�_AssertRaisesBaseContextNcCs@t�||�||_||_|dk	r*t�|�}||_d|_d|_dSr))	rUrrTr#�re�compile�expected_regex�obj_namerW)rrTr#r^rrrr�s
z!_AssertRaisesBaseContext.__init__c	Cs�z�t|j|j�s"td||jf��|sV|�dd�|_|rNtdtt|��f��|W�TS|^}}z|j	|_
Wntk
r�t|�|_
YnX|�|||�W5QRXW5d}XdS)z�
        If args is empty, assertRaises/Warns is being used as a
        context manager, so check for a 'msg' kwarg and return self.
        If args is not empty, call a callable passing positional and keyword
        arguments.
        Nz%s() arg 1 must be %srWz3%r is an invalid keyword argument for this function)
rLrT�
_base_type�	TypeError�_base_type_strr1rW�next�iterrr_�AttributeErrorr )r�namer.r/Zcallable_objrrr�handle�s(��z_AssertRaisesBaseContext.handle)N)rrr
rrgrrrrr[�s

r[c@s(eZdZdZeZdZdd�Zdd�ZdS)�_AssertRaisesContextzCA context manager used to implement TestCase.assertRaises* methods.z-an exception type or tuple of exception typescCs|Sr)r�rrrr�	__enter__�sz_AssertRaisesContext.__enter__cCs�|dkrbz|jj}Wntk
r2t|j�}YnX|jrP|�d�||j��ql|�d�|��n
t�|�t	||j�s|dS|�
d�|_|jdkr�dS|j}|�
t|��s�|�d�|jt|���dS)Nz{} not raised by {}z
{} not raisedFT�"{}" does not match "{}")rTrrer r_rZ�format�	traceback�clear_framesrS�with_tracebackZ	exceptionr^�search�pattern)r�exc_type�	exc_value�tb�exc_namer^rrr�__exit__�s.
�

�z_AssertRaisesContext.__exit__N)	rrr
r�
BaseExceptionr`rbrjrvrrrrrh�s
rhc@s(eZdZdZeZdZdd�Zdd�ZdS)�_AssertWarnsContextzBA context manager used to implement TestCase.assertWarns* methods.z(a warning type or tuple of warning typescCsRttj���D]}t|dd�ri|_qtjdd�|_|j�	�|_t�
d|j�|S)N�__warningregistry__T)�record�always)�listr!�modules�values�getattrry�warnings�catch_warnings�warnings_managerrj�simplefilterrT)r�vrrrrj�sz_AssertWarnsContext.__enter__cCs|j�|||�|dk	rdSz|jj}Wntk
rFt|j�}YnXd}|jD]Z}|j}t||j�sjqR|dkrv|}|j	dk	r�|j	�
t|��s�qR||_|j|_|j
|_
dS|dk	r�|�d�|j	jt|���|jr�|�d�||j��n|�d�|��dS)Nrkz{} not triggered by {}z{} not triggered)r�rvrTrrer r��messager;r^rpZwarning�filename�linenorZrlrqr_)rrrrsrtruZfirst_matching�m�wrrrrvs@

��
�z_AssertWarnsContext.__exit__N)	rrr
r�Warningr`rbrjrvrrrrrx�s
rx�_LoggingWatcher�records�outputc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_CapturingHandlerzM
    A logging handler capturing all (raw and formatted) logging output.
    cCstj�|�tgg�|_dSr))�logging�Handlerrr��watcherrirrrr3sz_CapturingHandler.__init__cCsdSr)rrirrr�flush7sz_CapturingHandler.flushcCs*|jj�|�|�|�}|jj�|�dSr))r�r�rrlr�)rrzrWrrr�emit:s
z_CapturingHandler.emitN)rrr
rrr�r�rrrrr�.sr�c@s,eZdZdZdZdd�Zdd�Zdd�Zd	S)
�_AssertLogsContextz:A context manager used to implement TestCase.assertLogs().z"%(levelname)s:%(name)s:%(message)scCs:t�||�||_|r(tj�||�|_ntj|_d|_dSr))	rUr�logger_namer�Z_nameToLevel�get�level�INFOrW)rr#r�r�rrrrFsz_AssertLogsContext.__init__cCs�t|jtj�r|j}|_nt�|j�}|_t�|j�}t�}|�	|�|j
|_
|jdd�|_|j
|_|j|_|g|_|�|j
�d|_|j
S)NF)r;r�r�ZLogger�loggerZ	getLoggerZ	Formatter�LOGGING_FORMATr�ZsetFormatterr��handlers�old_handlersr��	old_level�	propagate�
old_propagate�setLevel)rr�Z	formatterZhandlerrrrrjOs
z_AssertLogsContext.__enter__cCs`|j|j_|j|j_|j�|j�|dk	r.dSt|jj	�dkr\|�
d�t�
|j�|jj��dS)NFrz-no logs of level {} or higher triggered on {})r�r�r�r�r�r�r��lenr�r�rZrlr�ZgetLevelNamer�rf)rrrrsrtrrrrv`s


��z_AssertLogsContext.__exit__N)rrr
rr�rrjrvrrrrr�As
	r�c@seZdZdd�ZdS)�_OrderedChainMapccs8t�}|jD]&}|D]}||kr|�|�|VqqdSr))�set�maps�add)r�seen�mapping�krrr�__iter__ns

z_OrderedChainMap.__iter__N)rrr
r�rrrrr�msr�c@seZdZdZeZdZdZdZdZ	gZ
d�dd�Zd	d
�Zdd�Z
d
e
_edd��Zdd�Zdd�Zedd��Zedd��Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zeje fd*d+��Z!d,d-�Z"d.d/�Z#d0d1�Z$d2d3�Z%d4d5�Z&d6d7�Z'd8d9�Z(d�d;d<�Z)d=d>�Z*ed?d@��Z+dAdB�Z,dCdD�Z-dEdF�Z.d�dGdH�Z/d�dIdJ�Z0d�dKdL�Z1dMdN�Z2dOdP�Z3dQdR�Z4d�dSdT�Z5dUdV�Z6d�dWdX�Z7d�dYdZ�Z8d�d[d\�Z9d�d]d^�Z:d�d_d`�Z;d�dadb�Z<dcdd�Z=d�dedf�Z>d�dgdh�Z?d�didj�Z@d�dkdl�ZAd�dmdn�ZBd�dodp�ZCd�dqdr�ZDd�dsdt�ZEd�dudv�ZFd�dwdx�ZGd�dydz�ZHd�d{d|�ZId�d}d~�ZJd�dd��ZKd�d�d��ZLd�d�d��ZMd�d�d��ZNd�d�d��ZOd�d�d��ZPd�d��ZQd�d��ZRd�d�d��ZSd�d�d��ZTd�d��ZUeUe8�ZVZWeUe9�ZXZYeUe:�ZZZ[eUe;�Z\Z]eUe1�Z^Z_eUe3�Z`eUe0�ZaeUeQ�ZbeUeS�ZceUeT�Zdd:S)��TestCaseaWA class whose instances are single test cases.

    By default, the test code itself should be placed in a method named
    'runTest'.

    If the fixture may be used for many test cases, create as
    many test methods as are needed. When instantiating such a TestCase
    subclass, specify in the constructor arguments the name of the test method
    that the instance is to execute.

    Test authors should subclass TestCase for their own tests. Construction
    and deconstruction of the test's environment ('fixture') can be
    implemented by overriding the 'setUp' and 'tearDown' methods respectively.

    If it is necessary to override the __init__ method, the base class
    __init__ method must always be called. It is important that subclasses
    should not change the signature of their __init__ method, since instances
    of the classes are instantiated automatically by parts of the framework
    in order to be run.

    When subclassing TestCase, you can set these attributes:
    * failureException: determines which exception will be raised when
        the instance's assertion methods fail; test methods raising this
        exception will be deemed to have 'failed' rather than 'errored'.
    * longMessage: determines whether long messages (including repr of
        objects used in assert methods) will be printed on failure in *addition*
        to any explicit message passed.
    * maxDiff: sets the maximum length of a diff in failure messages
        by assert methods using difflib. It is looked up as an instance
        attribute so can be configured by individual tests if required.
    Ti�iF�runTestcCs�||_d|_d|_zt||�}Wn.tk
rN|dkrJtd|j|f��Yn
X|j|_g|_d|_	i|_
|�td�|�t
d�|�td�|�td�|�td�|�td	�dS)
z�Create an instance of the class that will use the named test
           method when executed. Raises a ValueError if the instance does
           not have a method with the specified name.
        NzNo testr�zno such test method in %s: %s�assertDictEqual�assertListEqual�assertTupleEqual�assertSetEqual�assertMultiLineEqual)�_testMethodName�_outcome�_testMethodDocrre�
ValueError�	__class__r�	_cleanups�_subtest�_type_equality_funcs�addTypeEqualityFunc�dictr|rQr��	frozensetr )rZ
methodName�
testMethodrrrr�s(�zTestCase.__init__cCs||j|<dS)a[Add a type specific assertEqual style function to compare a type.

        This method is for use by TestCase subclasses that need to register
        their own type equality functions to provide nicer error messages.

        Args:
            typeobj: The data type to call this function on when both values
                    are of the same type in assertEqual().
            function: The callable taking two arguments and an optional
                    msg= argument that raises self.failureException with a
                    useful error message when the two arguments are not equal.
        N)r�)rZtypeobjr-rrrr��s
zTestCase.addTypeEqualityFunccOs�t|�dkr|^}}}nV|s&td��nHd|krZ|�d�}|^}}ddl}|jdtdd�ntdt|�d	��t|�}|j�|||f�dS)
aAdd a function, with arguments, to be called when the test is
        completed. Functions added are called on a LIFO basis and are
        called after tearDown on test failure or success.

        Cleanup items are called even if setUp fails (unlike tearDown).�z>descriptor 'addCleanup' of 'TestCase' object needs an argumentr-rNz4Passing 'function' as keyword argument is deprecated)�
stacklevelz:addCleanup expected at least 1 positional argument, got %dr)	r�rar1r��warn�DeprecationWarningrQr�r)r.r/rr-r�rrr�
addCleanup�s"

�
�zTestCase.addCleanupz%($self, function, /, *args, **kwargs)cOs|j�|||f�dS)zpSame as addCleanup, except the cleanup items are called even if
        setUpClass fails (unlike tearDownClass).N)�_class_cleanupsr)�clsr-r.r/rrr�addClassCleanup�szTestCase.addClassCleanupcCsdS)zAHook method for setting up the test fixture before exercising it.Nrrirrr�setUp�szTestCase.setUpcCsdS)zAHook method for deconstructing the test fixture after testing it.Nrrirrr�tearDown�szTestCase.tearDowncCsdS)zKHook method for setting up class fixture before running tests in the class.Nr�r�rrr�
setUpClass�szTestCase.setUpClasscCsdS)zVHook method for deconstructing the class fixture after running all tests in the class.Nrr�rrr�
tearDownClassszTestCase.tearDownClasscCsdS)Nrrrirrr�countTestCasesszTestCase.countTestCasescCst��Sr))rZ
TestResultrirrr�defaultTestResult	szTestCase.defaultTestResultcCs$|j}|r |���d�d��SdS)z�Returns a one-line description of the test, or None if no
        description has been provided.

        The default implementation of this method returns the first line of
        the specified test method's docstring.
        �
rN)r��strip�split�r�docrrr�shortDescriptionszTestCase.shortDescriptioncCsdt|j�|jfS)Nz%s.%s�rr�r�rirrr�idszTestCase.idcCs t|�t|�k	rtS|j|jkSr))r<�NotImplementedr��r�otherrrr�__eq__szTestCase.__eq__cCstt|�|jf�Sr))�hashr<r�rirrr�__hash__ szTestCase.__hash__cCsd|jt|j�fS�Nz%s (%s))r�rr�rirrr�__str__#szTestCase.__str__cCsdt|j�|jfS)Nz<%s testMethod=%s>r�rirrr�__repr__&s�zTestCase.__repr__cCs<t|dd�}|dk	r |||�nt�dtd�|�|�dS)N�addSkipz4TestResult has no addSkip method, skips not reportedr�)rr�r��RuntimeWarning�
addSuccess)rrr#r9r�rrr�_addSkip*s�zTestCase._addSkipc	ks�|jdks|jjsdVdS|j}|dkr4t|�}n|j�|�}t|||�|_zX|jj|jdd��dVW5QRX|jjs�|jj	}|dk	r�|j
r�t�n|jjr�t�W5||_XdS)aPReturn a context manager that will return the enclosed block
        of code in a subtest identified by the optional message and
        keyword parameters.  A failure in the subtest marks the test
        case as failed but resumes execution at the end of the enclosed
        block, allowing further test code to be executed.
        NT�r$)
r�rr�r��params�	new_child�_SubTestr&rrZfailfastrr)rrWr��parentZ
params_maprrrr�subTest3s$
zTestCase.subTestcCs`|D]V\}}t|t�r(|�|j||�q|dk	rt|d|j�rN|�||�q|�||�qdS)Nr)r;r�rr#rSrX�
addFailureZaddError)rrr�testr"rrr�_feedErrorsToResultRs
zTestCase._feedErrorsToResultcCsDz
|j}Wn*tk
r4t�dt�|�|�YnX|||�dS)Nz@TestResult has no addExpectedFailure method, reporting as passes)�addExpectedFailurerer�r�r�r�)rrr"r�rrr�_addExpectedFailure\s
�zTestCase._addExpectedFailurecCshz
|j}WnPtk
rZt�dt�z
td�Wn$tk
rT|�|t���YnXYn
X||�dS)NzCTestResult has no addUnexpectedSuccess method, reporting as failure)	�addUnexpectedSuccessrer�r�r�rr�r!r")rrr�rrr�_addUnexpectedSuccessfs
�
zTestCase._addUnexpectedSuccesscCs|��dSr))r�rirrr�
_callSetUpuszTestCase._callSetUpcCs
|�dSr)r)r�methodrrr�_callTestMethodxszTestCase._callTestMethodcCs|��dSr))r�rirrr�
_callTearDown{szTestCase._callTearDowncOs|||�dSr)r�rr-r.r/rrr�_callCleanup~szTestCase._callCleanupNc

Cs|}|dkr.|��}t|dd�}|dk	r.|�|�|�t||j�}t|jdd�s^t|dd�r�z,t|jdd�pxt|dd�}|�|||�W5|�|�XdSt|dd�}t|dd�}|p�|}t|�}	z�|	|_|	�|��|�
�W5QRX|	j�r@||	_|	j|dd	��|�|�W5QRXd|	_|	�|��|��W5QRX|��|	jD]\}}|�|||��qN|�||	j�|	j�r�|�r�|	j
�r�|�||	j
�n
|�|�n
|�|�|W�S|�|�|dk�r�t|dd�}
|
dk	�r�|
�|	j�	�d|	_
d|_XdS)
N�startTestRunr?Fr@rCrK�stopTestRunTr�)r�rZ	startTestr�r�ZstopTestr�rr�clearrr�r&r�rrr�r��
doCleanupsrr�r�r�r�)
rrZorig_resultr�r�Zskip_whyZexpecting_failure_methodZexpecting_failure_classr�outcomer�r�r9rrr�run�st

�
���




zTestCase.runc	CsR|jp
t�}|jrL|j��\}}}|�|��|j|f|�|�W5QRXq|jS)zNExecute all cleanup functions. Normally called for you after
        tearDown.)r�rr�r1r&r�r)rr�r-r.r/rrrr��szTestCase.doCleanupsc
Csdg|_|jr`|j��\}}}z|||�Wqtk
r\}z|j�t���W5d}~XYqXqdS)zYExecute all class cleanup functions. Normally called for you after
        tearDownClass.N)ZtearDown_exceptionsr�r1r2rr!r")r�r-r.r/r4rrr�doClassCleanups�szTestCase.doClassCleanupscOs|j||�Sr))r�)rr.�kwdsrrr�__call__�szTestCase.__call__cCsF|��t||j��|��|jrB|j�d�\}}}|||�qdS)z6Run the test without collecting errors in a TestResult���N)r�rr�r�r�r1r�rrr�debug�szTestCase.debugcCst|��dS)zSkip this test.Nr6)rr9rrr�skipTest�szTestCase.skipTestcCs|�|��dS)z)Fail immediately, with the given message.N)rX)rrWrrr�fail�sz
TestCase.failcCs&|r"|�|dt|��}|�|��dS)z#Check that the expression is false.z%s is not falseN�rVrrX�r�exprrWrrr�assertFalse�szTestCase.assertFalsecCs&|s"|�|dt|��}|�|��dS)z"Check that the expression is true.z%s is not trueNrrrrr�
assertTrue�szTestCase.assertTruecCsV|js|p|S|dkr|Szd||fWStk
rPdt|�t|�fYSXdS)a�Honour the longMessage attribute when generating failure messages.
        If longMessage is False this means:
        * Use only an explicit message if it is provided
        * Otherwise use the standard message for the assert

        If longMessage is True:
        * Use the standard message
        * If an explicit message is provided, plus ' : ' and the explicit message
        Nz%s : %s)�longMessage�UnicodeDecodeErrorr)rrWrYrrrrV�s
zTestCase._formatMessagecOs(t||�}z|�d||�W�Sd}XdS)a=Fail unless an exception of class expected_exception is raised
           by the callable when invoked with specified positional and
           keyword arguments. If a different type of exception is
           raised, it will not be caught, and the test case will be
           deemed to have suffered an error, exactly as for an
           unexpected exception.

           If called with the callable and arguments omitted, will return a
           context object used like this::

                with self.assertRaises(SomeException):
                    do_something()

           An optional keyword argument 'msg' can be provided when assertRaises
           is used as a context object.

           The context manager keeps a reference to the exception as
           the 'exception' attribute. This allows you to inspect the
           exception after the assertion::

               with self.assertRaises(SomeException) as cm:
                   do_something()
               the_exception = cm.exception
               self.assertEqual(the_exception.error_code, 3)
        N�assertRaises�rhrg)r�expected_exceptionr.r/�contextrrrrs
zTestCase.assertRaisescOst||�}|�d||�S)a�Fail unless a warning of class warnClass is triggered
           by the callable when invoked with specified positional and
           keyword arguments.  If a different type of warning is
           triggered, it will not be handled: depending on the other
           warning filtering rules in effect, it might be silenced, printed
           out, or raised as an exception.

           If called with the callable and arguments omitted, will return a
           context object used like this::

                with self.assertWarns(SomeWarning):
                    do_something()

           An optional keyword argument 'msg' can be provided when assertWarns
           is used as a context object.

           The context manager keeps a reference to the first matching
           warning as the 'warning' attribute; similarly, the 'filename'
           and 'lineno' attributes give you information about the line
           of Python code from which the warning was triggered.
           This allows you to inspect the warning after the assertion::

               with self.assertWarns(SomeWarning) as cm:
                   do_something()
               the_warning = cm.warning
               self.assertEqual(the_warning.some_attribute, 147)
        �assertWarns�rxrg)r�expected_warningr.r/rrrrr5s
zTestCase.assertWarnscCst|||�S)a�Fail unless a log message of level *level* or higher is emitted
        on *logger_name* or its children.  If omitted, *level* defaults to
        INFO and *logger* defaults to the root logger.

        This method must be used as a context manager, and will yield
        a recording object with two attributes: `output` and `records`.
        At the end of the context manager, the `output` attribute will
        be a list of the matching formatted log messages and the
        `records` attribute will be a list of the corresponding LogRecord
        objects.

        Example::

            with self.assertLogs('foo', level='INFO') as cm:
                logging.getLogger('foo').info('first message')
                logging.getLogger('foo.bar').error('second message')
            self.assertEqual(cm.output, ['INFO:foo:first message',
                                         'ERROR:foo.bar:second message'])
        )r�)rr�r�rrr�
assertLogsTszTestCase.assertLogscCsFt|�t|�kr@|j�t|��}|dk	r@t|t�r<t||�}|S|jS)aGet a detailed comparison function for the types of the two args.

        Returns: A callable accepting (first, second, msg=None) that will
        raise a failure exception if first != second with a useful human
        readable error message for those types.
        N)r<r�r�r;r r�_baseAssertEqual)r�first�secondZasserterrrr�_getAssertEqualityFuncjs

zTestCase._getAssertEqualityFunccCs0||ks,dt||�}|�||�}|�|��dS)z:The default assertEqual implementation, not type specific.�%s != %sN)rrVrX)rrrrWrYrrrr�szTestCase._baseAssertEqualcCs|�||�}||||d�dS)z[Fail if the two objects are unequal as determined by the '=='
           operator.
        )rWN)r)rrrrWZassertion_funcrrr�assertEqual�szTestCase.assertEqualcCs2||ks.|�|dt|�t|�f�}|�|��dS)zYFail if the two objects are equal as determined by the '!='
           operator.
        z%s == %sNr)rrrrWrrr�assertNotEqual�s
�zTestCase.assertNotEqualcCs�||krdS|dk	r$|dk	r$td��t||�}|dk	rf||krDdSdt|�t|�t|�t|�f}n:|dkrrd}t||�dkr�dSdt|�t|�|t|�f}|�||�}|�|��dS)a'Fail if the two objects are unequal as determined by their
           difference rounded to the given number of decimal places
           (default 7) and comparing to zero, or by comparing that the
           difference between the two objects is more than the given
           delta.

           Note that decimal places (from zero) are usually not the same
           as significant digits (measured from the most significant digit).

           If the two objects compare equal then they will automatically
           compare almost equal.
        N� specify delta or places not bothz(%s != %s within %s delta (%s difference)�rz)%s != %s within %r places (%s difference)�ra�absr�roundrVrX�rrrZplacesrWZdelta�diffrYrrr�assertAlmostEqual�s4��zTestCase.assertAlmostEqualcCs�|dk	r|dk	rtd��t||�}|dk	rb||ks@||kr@dSdt|�t|�t|�t|�f}n<|dkrnd}||ks�t||�dkr�dSdt|�t|�|f}|�||�}|�|��dS)a�Fail if the two objects are equal as determined by their
           difference rounded to the given number of decimal places
           (default 7) and comparing to zero, or by comparing that the
           difference between the two objects is less than the given delta.

           Note that decimal places (from zero) are usually not the same
           as significant digits (measured from the most significant digit).

           Objects that are equal automatically fail.
        Nrz(%s == %s within %s delta (%s difference)rrz%s == %s within %r placesrrrrr�assertNotAlmostEqual�s,��zTestCase.assertNotAlmostEqualcCs�|dk	rP|j}t||�s.|�d|t|�f��t||�sT|�d|t|�f��nd}d}zt|�}Wn ttfk
r�d|}YnX|dkr�zt|�}Wn ttfk
r�d|}YnX|dk�r�||kr�dSd|��ft||�}t	t
||��D]�}	z||	}
Wn4tttfk
�r<|d|	|f7}Y�q�YnXz||	}Wn4tttfk
�r~|d	|	|f7}Y�q�YnX|
|kr�|d
|	ft|
|�7}�q�q�||k�r�|dk�r�t|�t|�k�r�dS||k�r<|d|||f7}z|d|t||�f7}Wn,tttfk
�r8|d
||f7}YnXnh||k�r�|d|||f7}z|d|t||�f7}Wn,tttfk
�r�|d||f7}YnX|}dd�
t�t�|���t�|�����}
|�||
�}|�||�}|�|�dS)aAAn equality assertion for ordered sequences (like lists and tuples).

        For the purposes of this function, a valid ordered sequence type is one
        which can be indexed, has a length, and has an equality operator.

        Args:
            seq1: The first sequence to compare.
            seq2: The second sequence to compare.
            seq_type: The expected datatype of the sequences, or None if no
                    datatype should be enforced.
            msg: Optional message to use on failure instead of a list of
                    differences.
        NzFirst sequence is not a %s: %szSecond sequence is not a %s: %sZsequencez(First %s has no length.    Non-sequence?z)Second %s has no length.    Non-sequence?z%ss differ: %s != %s
z(
Unable to index element %d of first %s
z)
Unable to index element %d of second %s
z#
First differing element %d:
%s
%s
z+
First %s contains %d additional elements.
zFirst extra element %d:
%s
z'Unable to index element %d of first %s
z,
Second %s contains %d additional elements.
z(Unable to index element %d of second %s
r�)rr;rXrr�ra�NotImplementedError�
capitalizer�range�min�
IndexErrorr<�join�difflib�ndiff�pprint�pformat�
splitlines�_truncateMessagerVr)rZseq1Zseq2rW�seq_typeZ
seq_type_nameZ	differingZlen1Zlen2�iZitem1Zitem2rY�diffMsgrrr�assertSequenceEqual�s�

�

��
�

������

��
�

��
���zTestCase.assertSequenceEqualcCs2|j}|dkst|�|kr"||S|tt|�Sr))�maxDiffr��DIFF_OMITTED)rr�rZmax_diffrrrr+NszTestCase._truncateMessagecCs|j|||td�dS)aA list-specific equality assertion.

        Args:
            list1: The first list to compare.
            list2: The second list to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.

        �r,N)r/r|)rZlist1Zlist2rWrrrr�Ts
zTestCase.assertListEqualcCs|j|||td�dS)aA tuple-specific equality assertion.

        Args:
            tuple1: The first tuple to compare.
            tuple2: The second tuple to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.
        r2N)r/rQ)rZtuple1Ztuple2rWrrrr�`s	zTestCase.assertTupleEqualc

Cs`z|�|�}Wn^tk
r>}z|�d|�W5d}~XYn0tk
rl}z|�d|�W5d}~XYnXz|�|�}Wn^tk
r�}z|�d|�W5d}~XYn0tk
r�}z|�d|�W5d}~XYnX|s�|s�dSg}|�r|�d�|D]}|�t|���q|�r@|�d�|D]}|�t|���q*d�|�}	|�|�||	��dS)a�A set-specific equality assertion.

        Args:
            set1: The first set to compare.
            set2: The second set to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.

        assertSetEqual uses ducktyping to support different types of sets, and
        is optimized for sets specifically (parameters must support a
        difference method).
        z/invalid type when attempting set difference: %sNz2first argument does not support set difference: %sz3second argument does not support set difference: %sz*Items in the first set but not the second:z*Items in the second set but not the first:r�)�
differencerarrer�reprr%rV)
rZset1Zset2rWZdifference1r%Zdifference2�lines�itemrYrrrr�ks2
  


zTestCase.assertSetEqualcCs2||kr.dt|�t|�f}|�|�||��dS)zDJust like self.assertTrue(a in b), but with a nicer default message.z%s not found in %sN�rrrV�r�memberZ	containerrWrYrrr�assertIn�s
�zTestCase.assertIncCs2||kr.dt|�t|�f}|�|�||��dS)zHJust like self.assertTrue(a not in b), but with a nicer default message.z%s unexpectedly found in %sNr7r8rrr�assertNotIn�s
�zTestCase.assertNotIncCs2||k	r.dt|�t|�f}|�|�||��dS)zDJust like self.assertTrue(a is b), but with a nicer default message.z%s is not %sNr7�rZexpr1Zexpr2rWrYrrr�assertIs�s
�zTestCase.assertIscCs,||kr(dt|�f}|�|�||��dS)zHJust like self.assertTrue(a is not b), but with a nicer default message.zunexpectedly identical: %sNr7r<rrr�assertIsNot�szTestCase.assertIsNotc	Cs~|�|td�|�|td�||krzdt||�}dd�t�t�|���t�|�����}|�	||�}|�
|�||��dS)Nz"First argument is not a dictionaryz#Second argument is not a dictionaryrr�)�assertIsInstancer�rr%r&r'r(r)r*r+rrV)rZd1Zd2rWrYrrrrr��s
�zTestCase.assertDictEqualc		Cs�t�dt�g}g}|��D]L\}}||kr8|�|�q|||kr|�dt|�t|�t||�f�q|sv|svdSd}|r�dd�dd�|D��}|r�|r�|d	7}|d
d�|�7}|�|�||��dS)z2Checks whether dictionary is a superset of subset.z&assertDictContainsSubset is deprecatedz%s, expected: %s, actual: %sNrCzMissing: %s�,css|]}t|�VqdSr))r)rMr�rrrrP�sz4TestCase.assertDictContainsSubset.<locals>.<genexpr>z; zMismatched values: %s)	r�r�r��itemsrrr%rrV)	rZsubsetZ
dictionaryrWZmissingZ
mismatched�key�valuerYrrr�assertDictContainsSubset�s4�
���
z!TestCase.assertDictContainsSubsetc
Cs�t|�t|�}}zt�|�}t�|�}Wntk
rHt||�}YnX||krVdSt||�}|r�d}dd�|D�}d�|�}	|�||	�}|�||�}|�	|�dS)a[Asserts that two iterables have the same elements, the same number of
        times, without regard to order.

            self.assertEqual(Counter(list(first)),
                             Counter(list(second)))

         Example:
            - [0, 1, 1] and [1, 0, 1] compare equal.
            - [0, 0, 1] and [0, 1] compare unequal.

        NzElement counts were not equal:
cSsg|]}d|�qS)z First has %d, Second has %d:  %rr)rMrrrr�
<listcomp>�sz-TestCase.assertCountEqual.<locals>.<listcomp>r�)
r|�collections�Counterrarrr%r+rVr)
rrrrWZ	first_seqZ
second_seqZdifferencesrYr5r.rrr�assertCountEqual�s 


zTestCase.assertCountEqualcCs�|�|td�|�|td�||kr�t|�|jks@t|�|jkrN|�|||�|jdd�}|jdd�}t|�dkr�|�d�|kr�|dg}|dg}dt||�}dd	�t	�
||��}|�||�}|�|�
||��d
S)z-Assert that two multi-line strings are equal.zFirst argument is not a stringzSecond argument is not a stringT)�keependsrz
r�rrCN)r?r r��_diffThresholdrr*r�rr%r&r'r+rrV)rrrrWZ
firstlinesZsecondlinesrYrrrrr��s �

zTestCase.assertMultiLineEqualcCs2||ks.dt|�t|�f}|�|�||��dS)zCJust like self.assertTrue(a < b), but with a nicer default message.z%s not less than %sNr7�r�a�brWrYrrr�
assertLessszTestCase.assertLesscCs2||ks.dt|�t|�f}|�|�||��dS)zDJust like self.assertTrue(a <= b), but with a nicer default message.z%s not less than or equal to %sNr7rKrrr�assertLessEqualszTestCase.assertLessEqualcCs2||ks.dt|�t|�f}|�|�||��dS)zCJust like self.assertTrue(a > b), but with a nicer default message.z%s not greater than %sNr7rKrrr�
assertGreaterszTestCase.assertGreatercCs2||ks.dt|�t|�f}|�|�||��dS)zDJust like self.assertTrue(a >= b), but with a nicer default message.z"%s not greater than or equal to %sNr7rKrrr�assertGreaterEqual szTestCase.assertGreaterEqualcCs,|dk	r(dt|�f}|�|�||��dS)zCSame as self.assertTrue(obj is None), with a nicer default message.Nz%s is not Noner7�rr*rWrYrrr�assertIsNone&szTestCase.assertIsNonecCs"|dkrd}|�|�||��dS)z(Included for symmetry with assertIsNone.Nzunexpectedly None)rrVrRrrr�assertIsNotNone,szTestCase.assertIsNotNonecCs0t||�s,dt|�|f}|�|�||��dS)zTSame as self.assertTrue(isinstance(obj, cls)), with a nicer
        default message.z%s is not an instance of %rN�r;rrrV�rr*r�rWrYrrrr?2s
zTestCase.assertIsInstancecCs0t||�r,dt|�|f}|�|�||��dS)z,Included for symmetry with assertIsInstance.z%s is an instance of %rNrUrVrrr�assertNotIsInstance9s
zTestCase.assertNotIsInstancecOst|||�}|�d||�S)aAsserts that the message in a raised exception matches a regex.

        Args:
            expected_exception: Exception class expected to be raised.
            expected_regex: Regex (re.Pattern object or string) expected
                    to be found in error message.
            args: Function to be called and extra positional args.
            kwargs: Extra kwargs.
            msg: Optional message used in case of failure. Can only be used
                    when assertRaisesRegex is used as a context manager.
        �assertRaisesRegexr	)rr
r^r.r/rrrrrX?s
zTestCase.assertRaisesRegexcOst|||�}|�d||�S)a�Asserts that the message in a triggered warning matches a regexp.
        Basic functioning is similar to assertWarns() with the addition
        that only warnings whose messages also match the regular expression
        are considered successful matches.

        Args:
            expected_warning: Warning class expected to be triggered.
            expected_regex: Regex (re.Pattern object or string) expected
                    to be found in error message.
            args: Function to be called and extra positional args.
            kwargs: Extra kwargs.
            msg: Optional message used in case of failure. Can only be used
                    when assertWarnsRegex is used as a context manager.
        �assertWarnsRegexr
)rrr^r.r/rrrrrYOszTestCase.assertWarnsRegexcCsJt|ttf�rt�|�}|�|�sFd|j|f}|�||�}|�|��dS)z=Fail the test unless the text matches the regular expression.z&Regex didn't match: %r not found in %rN)	r;r �bytesr\r]rprqrVrX)r�textr^rWrYrrr�assertRegexbs

�zTestCase.assertRegexcCs`t|ttf�rt�|�}|�|�}|r\d||��|���|j|f}|�	||�}|�
|��dS)z9Fail the test if the text matches the regular expression.z"Regex matched: %r matches %r in %rN)r;r rZr\r]rp�start�endrqrVrX)rr[Zunexpected_regexrW�matchrYrrr�assertNotRegexns

�zTestCase.assertNotRegexcs�fdd�}|S)Ncs t�d��j�td��||�S)NzPlease use {0} instead.r�)r�r�rlrr�r7��
original_funcrr�deprecated_func~s
�z,TestCase._deprecate.<locals>.deprecated_funcr)rbrcrrar�
_deprecate}szTestCase._deprecate)r�)N)N)N)N)NN)N)N)N)NNN)NNN)NN)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)errr
r�AssertionErrorrXrr0rJZ_classSetupFailedr�rr�r��__text_signature__�classmethodr�r�r�r�r�r�r�r�r�r�r�r�r�r�r'r(�_subtest_msg_sentinelr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrVrrrrrrrrrr/r+r�r�r�r:r;r=r>r�rDrHr�rNrOrPrQrSrTr?rWrXrYr\r`rdZfailUnlessEqualZassertEqualsZfailIfEqualZassertNotEqualsZfailUnlessAlmostEqualZassertAlmostEqualsZfailIfAlmostEqualZassertNotAlmostEqualsZ
failUnlessZassert_ZfailUnlessRaisesZfailIfZassertRaisesRegexpZassertRegexpMatchesZassertNotRegexpMatchesrrrrr�ws� 
 


	


E

	


!



	�
-�
#
c


+






 










	r�csjeZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
�ZS)�FunctionTestCaseaIA test case that wraps a test function.

    This is useful for slipping pre-existing test functions into the
    unittest framework. Optionally, set-up and tidy-up functions can be
    supplied. As with TestCase, the tidy-up ('tearDown') function will
    always be called if the set-up ('setUp') function ran successfully.
    Ncs*tt|���||_||_||_||_dSr))�superrir�
_setUpFunc�
_tearDownFunc�	_testFunc�_description)rZtestFuncr�r�Zdescription�r�rrr�s
zFunctionTestCase.__init__cCs|jdk	r|��dSr))rkrirrrr��s
zFunctionTestCase.setUpcCs|jdk	r|��dSr))rlrirrrr��s
zFunctionTestCase.tearDowncCs|��dSr))rmrirrrr��szFunctionTestCase.runTestcCs|jjSr))rmrrirrrr��szFunctionTestCase.idcCs@t||j�stS|j|jko>|j|jko>|j|jko>|j|jkSr))r;r�r�rkrlrmrnr�rrrr��s
�
�
�zFunctionTestCase.__eq__cCstt|�|j|j|j|jf�Sr))r�r<rkrlrmrnrirrrr��s�zFunctionTestCase.__hash__cCsdt|j�|jjfSr�)rr�rmrrirrrr��s
�zFunctionTestCase.__str__cCsdt|j�|jfS)Nz<%s tec=%s>)rr�rmrirrrr��s
�zFunctionTestCase.__repr__cCs2|jdk	r|jS|jj}|r.|�d�d��p0dS)Nr�r)rnrmrr�r�r�rrrr��s
z!FunctionTestCase.shortDescription)NNN)rrr
rrr�r�r�r�r�r�r�r�r��
__classcell__rrrorri�s	ricsDeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z�Z	S)
r�cs(t���||_||_||_|j|_dSr))rjr�_messager#r�rX)rr#r�r�rorrr�s

z_SubTest.__init__cCstd��dS)Nzsubtests cannot be run directly)r rirrrr��sz_SubTest.runTestcCs^g}|jtk	r |�d�|j��|jrPd�dd�|j��D��}|�d�|��d�|�p\dS)Nz[{}]z, css|]\}}d�||�VqdS)z{}={!r}N)rl)rMr�r�rrrrP�s�z+_SubTest._subDescription.<locals>.<genexpr>z({})� z(<subtest>))rqrhrrlr�r%rA)r�partsZparams_descrrr�_subDescription�s

�z_SubTest._subDescriptioncCsd�|j��|���S�Nz{} {})rlr#r�rtrirrrr��sz_SubTest.idcCs
|j��S)zlReturns a one-line description of the subtest, or None if no
        description has been provided.
        )r#r�rirrrr��sz_SubTest.shortDescriptioncCsd�|j|���Sru)rlr#rtrirrrr��sz_SubTest.__str__)
rrr
rr�rtr�r�r�rprrrorr��sr�)4rr!r=r&r�r(r\r�rFr'rmrDrCr�utilrrrrrZ
__unittest�objectrhr1r2r	rrrr+r,r0r5rFrIrJrrLrUr[rhrx�
namedtupler�r�r�r��ChainMapr�r�rir�rrrr�<module>sd(	*%5�,
$:PK��[l�k�+__pycache__/async_case.cpython-38.opt-1.pycnu�[���U

e5d��@s0ddlZddlZddlmZGdd�de�ZdS)�N�)�TestCasecs�eZdZd�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zd �fdd�	Z�ZS)!�IsolatedAsyncioTestCase�runTestcst��|�d|_d|_dS�N)�super�__init__�_asyncioTestLoop�_asyncioCallsQueue)�selfZ
methodName��	__class__��+/usr/lib64/python3.8/unittest/async_case.pyr"sz IsolatedAsyncioTestCase.__init__c�sdSrr�rrrr�
asyncSetUp'sz"IsolatedAsyncioTestCase.asyncSetUpc�sdSrrrrrr�
asyncTearDown*sz%IsolatedAsyncioTestCase.asyncTearDowncOs|j|f|�|�dSr)Z
addCleanup)r�func�args�kwargsrrr�addAsyncCleanup-s
z'IsolatedAsyncioTestCase.addAsyncCleanupcCs|��|�|j�dSr)ZsetUp�
_callAsyncrrrrr�
_callSetUp<sz"IsolatedAsyncioTestCase._callSetUpcCs|�|�dSr��_callMaybeAsync)r�methodrrr�_callTestMethod@sz'IsolatedAsyncioTestCase._callTestMethodcCs|�|j�|��dSr)rrZtearDownrrrr�
_callTearDownCsz%IsolatedAsyncioTestCase._callTearDowncOs|j|f|�|�dSrr)rZfunctionrrrrr�_callCleanupGsz$IsolatedAsyncioTestCase._callCleanupcOs0|||�}|j��}|j�||f�|j�|�Sr)r	�
create_futurer
�
put_nowait�run_until_complete�rrrr�ret�futrrrrJs

z"IsolatedAsyncioTestCase._callAsynccOsB|||�}t�|�r:|j��}|j�||f�|j�|�S|SdSr)�inspectZisawaitabler	rr
r r!r"rrrrRs


z'IsolatedAsyncioTestCase._callMaybeAsyncc
�s�t��|_}|�d�|��IdH}|��|dkr:dS|\}}z |IdH}|��s`|�|�Wqttfk
r|�Yqt	tj
fk
r�}z|��s�|�|�W5d}~XYqXqdSr)�asyncioZQueuer
Z
set_result�getZ	task_done�	cancelled�
SystemExit�KeyboardInterrupt�
BaseExceptionZCancelledErrorZ
set_exception)rr$ZqueueZqueryZ	awaitabler#Zexrrr�_asyncioLoopRunner\s 

z*IsolatedAsyncioTestCase._asyncioLoopRunnercCsJt��}t�|�|�d�||_|��}|�|�|��|_|�	|�dS)NT)
r&Znew_event_loop�set_event_loopZ	set_debugr	rZcreate_taskr,Z_asyncioCallsTaskr!)r�loopr$rrr�_setupAsyncioLoopos

z)IsolatedAsyncioTestCase._setupAsyncioLoopc	Cs�|j}d|_|j�d�|�|j���z�t�|�}|s@W�vdS|D]}|�	�qD|�tj
||dd���|D]0}|��r|qn|��dk	rn|�
d|��|d��qn|�|���W5t�d�|��XdS)NT)r.Zreturn_exceptionsz(unhandled exception during test shutdown)�message�	exception�task)r	r
r r!�joinr&r-�closeZ	all_tasksZcancelZgatherr(r1Zcall_exception_handlerZshutdown_asyncgens)rr.Z	to_cancelr2rrr�_tearDownAsyncioLoopys2

��

z,IsolatedAsyncioTestCase._tearDownAsyncioLoopNcs(|��zt��|�W�S|��XdSr)r/r5r�run)r�resultrrrr6�szIsolatedAsyncioTestCase.run)r)N)�__name__�
__module__�__qualname__rrrrrrrrrrr,r/r5r6�
__classcell__rrrrrs

"r)r&r%Zcaserrrrrr�<module>sPK��[-:p_8_8'__pycache__/loader.cpython-38.opt-1.pycnu�[���U

e5d�X�@sdZddlZddlZddlZddlZddlZddlZddlZddlmZm	Z	ddl
mZmZm
Z
dZe�dej�ZGdd	�d	ej�Zd
d�Zdd
�Zdd�Zdd�Zdd�ZGdd�de�Ze�Zddd�Ze
jdfdd�Zde
jejfdd�Z de
jejfdd�Z!dS) zLoading unittests.�N)�fnmatch�fnmatchcase�)�case�suite�utilTz[_a-z]\w*\.py$cs,eZdZdZ�fdd�Z�fdd�Z�ZS)�_FailedTestNcs||_tt|��|�dS�N)�
_exception�superr�__init__)�selfZmethod_name�	exception��	__class__��'/usr/lib64/python3.8/unittest/loader.pyrsz_FailedTest.__init__cs*|�jkrtt���|�S�fdd�}|S)Ncs
�j�dSr	)r
r�r
rr�testFailure!sz,_FailedTest.__getattr__.<locals>.testFailure)�_testMethodNamerr�__getattr__)r
�namerrrrrs
z_FailedTest.__getattr__)�__name__�
__module__�__qualname__rrr�
__classcell__rrrrrsrcCs"d|t��f}t|t|�||�S)Nz#Failed to import test module: %s
%s)�	traceback�
format_exc�_make_failed_test�ImportError)r�
suiteClass�messagerrr�_make_failed_import_test&s
�r"cCsdt��f}t||||�S)NzFailed to call load_tests:
%s)rrr)rrr r!rrr�_make_failed_load_tests+s�r#cCst||�}||f�|fSr	)r)�
methodnamerr r!�testrrrr0s
rcCs<t�t|��dd��}||i}tdtjf|�}|||�f�S)NcSsdSr	rrrrr�testSkipped5sz'_make_skipped_test.<locals>.testSkippedZ
ModuleSkipped)r�skip�str�type�TestCase)r$rr r&�attrsZ	TestClassrrr�_make_skipped_test4s

r,cCs*|���d�r|dd�Stj�|�dS)Nz	$py.classi����r)�lower�endswith�os�path�splitext)r0rrr�_jython_aware_splitext<sr2cs�eZdZdZdZeej�ZdZ	e
jZdZ
�fdd�Zdd�Zdd�d	d
�Zd!dd�Zd"d
d�Zdd�Zd#dd�Zdd�Zdd�Zdd�Zdd�Zd$dd�Zd%dd �Z�ZS)&�
TestLoaderz�
    This class is responsible for loading tests according to various criteria
    and returning them wrapped in a TestSuite
    r%Ncs tt|���g|_t�|_dSr	)rr3r�errors�set�_loading_packagesrrrrrMszTestLoader.__init__cCsFt|tj�rtd��|�|�}|s2t|d�r2dg}|�t||��}|S)z;Return a suite of all test cases contained in testCaseClasszYTest cases should not be derived from TestSuite. Maybe you meant to derive from TestCase?ZrunTest)�
issubclassr�	TestSuite�	TypeError�getTestCaseNames�hasattrr �map)r
�
testCaseClassZ
testCaseNamesZloaded_suiterrr�loadTestsFromTestCaseTs
z TestLoader.loadTestsFromTestCase��patternc

Os:t|�dksd|kr,t�dt�|�dd�t|�dkrRt|�d}td�|���t|�dkrxt|�d}td�|���g}t|�D]4}t	||�}t
|t�r�t|t
j�r�|�|�|��q�t	|dd�}	|�|�}|	dk	�r6z|	|||�WStk
�r4}
z,t|j|
|j�\}}|j�|�|WY�Sd}
~
XYnX|S)	z>Return a suite of all test cases contained in the given modulerZuse_load_testsz(use_load_tests is deprecated and ignoredNrzCloadTestsFromModule() takes 1 positional argument but {} were givenz=loadTestsFromModule() got an unexpected keyword argument '{}'�
load_tests)�len�warnings�warn�DeprecationWarning�popr9�format�sorted�dir�getattr�
isinstancer)r7rr*�appendr>r �	Exceptionr#rr4)
r
�moduler@�argsZkwsZ	complaint�testsr�objrA�e�
error_case�
error_messagerrr�loadTestsFromModulebs<�


�zTestLoader.loadTestsFromModulecCsX|�d�}d\}}|dkr�|dd�}|r�zd�|�}t|�}Wq�Wq&tk
r�|��}t||j�\}}|s�|j�|�|YSYq&Xq&|dd�}|}	|D]�}
z|	t	|	|
�}}	Wq�t
k
�rN}zvt	|	dd�dk	�r|dk	�r|j�|�|WY�DSt|
||jdt�
�f�\}}|j�|�|WY�
SW5d}~XYq�Xq�t|	tj��rj|�|	�St|	t��r�t|	tj��r�|�|	�St|	tj��r�t|t��r�t|tj��r�|d}||�}
tt	|
|�tj��s�|�|
g�Snt|	tj��r�|	St|	��rH|	�}t|tj��r|St|tj��r6|�|g�Std|	|f��ntd	|	��dS)
aSReturn a suite of all test cases given a string specifier.

        The name may resolve either to a module, a test case class, a
        test method within a test case class, or a callable object which
        returns a TestCase or TestSuite instance.

        The method optionally resolves the names relative to a given module.
        �.)NNNr�__path__zFailed to access attribute:
%s���z"calling %s returned %s, not a testz$don't know how to make test from: %s)�split�join�
__import__rrFr"r r4rLrJ�AttributeErrorrrrrK�types�
ModuleTyperUr)r7rr*r>�FunctionTyperr8�callabler9)r
rrN�partsrSrTZ
parts_copy�module_nameZnext_attributerQ�part�parentrR�instr%rrr�loadTestsFromName�s�	

����$

�
�
�zTestLoader.loadTestsFromNamecs��fdd�|D�}��|�S)z�Return a suite of all test cases found using the given sequence
        of string specifiers. See 'loadTestsFromName()'.
        csg|]}��|���qSr)rf)�.0r�rNr
rr�
<listcomp>�sz1TestLoader.loadTestsFromNames.<locals>.<listcomp>)r )r
�namesrNZsuitesrrhr�loadTestsFromNames�szTestLoader.loadTestsFromNamescs>��fdd�}tt|t����}�jr:|jt��j�d�|S)zLReturn a sorted sequence of method names found within testCaseClass
        csZ|��j�sdSt�|�}t|�s&dSd�j�j|f��jdkpXt�fdd��jD��S)NFz%s.%s.%sc3s|]}t�|�VqdSr	)r)rgr@�ZfullNamerr�	<genexpr>�szKTestLoader.getTestCaseNames.<locals>.shouldIncludeMethod.<locals>.<genexpr>)�
startswith�testMethodPrefixrJr`rr�testNamePatterns�any)�attrnameZtestFunc�r
r=rlr�shouldIncludeMethod�s
�
�z8TestLoader.getTestCaseNames.<locals>.shouldIncludeMethod)�key)�list�filterrI�sortTestMethodsUsing�sort�	functools�
cmp_to_key)r
r=rtZtestFnNamesrrsrr:�s
zTestLoader.getTestCaseNames�test*.pycCsJd}|dkr|jdk	r|j}n|dkr.d}|}tj�|�}|tjkrRtj�d|�||_d}d}g}tj�tj�|��r�tj�|�}||kr�tj�tj�|d��}�npzt	|�Wnt
k
r�d}Y�nJXtj|}|�d�d}	ztj�tj�
|j��}Wn�tk
�r�z
|j}
Wntk
�r8d}
YnX|
�r�|
jdk�r�|
jdk	�r�d}|jD]P}|�s||�|��s|�qb|�|j�dtjj��d|_|�|j||dd���qbn*|jtjk�r�td�d�ntd	�|��d�YnX|�r|�s|�|	�|_tj�|�ntj�|�|�r*t
d
|��|�s@t|�||��}|� |�S)a%Find and return all test modules from the specified start
        directory, recursing into subdirectories to find them and return all
        tests found within them. Only test files that match the pattern will
        be loaded. (Using shell style pattern matching.)

        All test modules must be importable from the top level of the project.
        If the start directory is not the top level directory then the top
        level directory must be specified separately.

        If a test package name (directory with '__init__.py') matches the
        pattern then the package will be checked for a 'load_tests' function. If
        this exists then it will be called with (loader, tests, pattern) unless
        the package has already had load_tests called from the same discovery
        invocation, in which case the package module object is not scanned for
        tests - this ensures that when a package uses discover to further
        discover child tests that infinite recursion does not happen.

        If load_tests exists then discovery does *not* recurse into the package,
        load_tests is responsible for loading all tests in the package.

        The pattern is deliberately not stored as a loader attribute so that
        packages can continue discovery themselves. top_level_dir is stored so
        load_tests does not need to pass this argument in to loader.discover().

        Paths are sorted before being imported to ensure reproducible execution
        order even on filesystems with non-alphabetical ordering like ext3/4.
        FNTr�__init__.pyrV)�	namespacez2Can not use builtin modules as dotted module namesz$don't know how to discover from {!r}z%Start directory is not importable: %r)!�_top_level_dirr/r0�abspath�sys�insert�isdir�isfilerZr[r�modulesrY�dirname�__file__r\�__spec__�loader�submodule_search_locationsrWrnr�replace�sep�extend�_find_tests�builtin_module_namesr9rG� _get_directory_containing_module�removervr )r
�	start_dirr@Z
top_level_dirZset_implicit_topZis_not_importable�is_namespacerPZ
the_moduleZtop_part�specr0rrr�discover�s�

�


�
���
������zTestLoader.discovercCsRtj|}tj�|j�}tj�|����d�rBtj�	tj�	|��Stj�	|�SdS)Nr})
r�r�r/r0r�r��basenamer-rnr�)r
rbrN�	full_pathrrrr�`s

z+TestLoader._get_directory_containing_modulecCsB||jkrdSttj�|��}tj�||j�}|�tjjd�}|S)NrV)rr2r/r0�normpath�relpathr�r�)r
r0Z_relpathrrrr�_get_name_from_pathls
zTestLoader._get_name_from_pathcCst|�tj|Sr	)r[r�r�)r
rrrr�_get_module_from_namexsz TestLoader._get_module_from_namecCs
t||�Sr	)r)r
r0r�r@rrr�_match_path|szTestLoader._match_pathFc

cs�|�|�}|dkrD||jkrD|�|||�\}}|dk	r<|V|sDdStt�|��}|D]t}tj�||�}	|�|	||�\}}|dk	r�|V|rV|�|	�}|j�|�z|�
|	||�EdHW5|j�	|�XqVdS)z/Used by discovery. Yields test suites it loads.rVN)r�r6�_find_test_pathrHr/�listdirr0rZ�add�discardr�)
r
r�r@r~rrPZshould_recurse�pathsr0r�rrrr��s6
��
zTestLoader._find_testsc
Csttj�|�}tj�|��rVt�|�s(dS|�|||�s:dS|�|�}z|�|�}Wnht	j
k
r�}zt|||j�dfWY�Sd}~XYn�t
||j�\}}	|j�|	�|dfYSXtj�t|d|��}
ttj�|
��}ttj�|��}|��|��k�r@tj�|�}
ttj�|��}tj�|�}d}t|||
|f��|j||d�dfS�ntj�|��rl|�s�tj�tj�|d���s�dSd}d}|�|�}z|�|�}Wnjt	j
k
�r�}zt|||j�dfWY�Sd}~XYn�t
||j�\}}	|j�|	�|dfYSXt|dd�}|j�|�z0|j||d�}|dk	�rP|dfW�S|d	fW�S|j�|�XndSdS)
z�Used by discovery.

        Loads tests from a single file, or a directories' __init__.py when
        passed the directory.

        Returns a tuple (None_or_tests_from_file, should_recurse).
        )NFFNr�zW%r module incorrectly imported from %r. Expected %r. Is this module globally installed?r?r}rAT)r/r0r�r��VALID_MODULE_NAME�matchr�r�r�rZSkipTestr,r r"r4rLr�rJr2�realpathr-r�rrUr�rZr6r�r�)r
r�r@r~r�rrNrRrSrTZmod_filer�Zfullpath_noextZ
module_dirZmod_nameZexpected_dir�msgrArP�packagerrrr��s|

&
�
�
�
�
���
&
�
zTestLoader._find_test_path)N)N)r|N)F)F)rrr�__doc__ro�staticmethodr�
three_way_cmprxrprr8r rrr>rUrfrkr:r�r�r�r�r�r�r�rrrrrr3Bs&
(
N

n
"r3cCs&t�}||_||_||_|r"||_|Sr	)r3rxrorpr )�prefix�	sortUsingr rpr�rrr�_makeLoader�sr�cCst|||d��|�S)N)rp)r�r:)r=r�r�rprrrr:�sr:r%cCst|||��|�Sr	)r�r>)r=r�r�r rrr�	makeSuite�s�r�cCst|||��|�Sr	)r�rU)rNr�r�r rrr�
findTestCasess�r�)NN)"r�r/�rer�rr]rzrCrr�rrrZ
__unittest�compile�
IGNORECASEr�r*rr"r#rr,r2�objectr3ZdefaultTestLoaderr�r�r:r8r�r�rrrr�<module>s</
	�
�PK��[�f�YY%__pycache__/async_case.cpython-38.pycnu�[���U

e5d��@s0ddlZddlZddlmZGdd�de�ZdS)�N�)�TestCasecs�eZdZd�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zd �fdd�	Z�ZS)!�IsolatedAsyncioTestCase�runTestcst��|�d|_d|_dS�N)�super�__init__�_asyncioTestLoop�_asyncioCallsQueue)�selfZ
methodName��	__class__��+/usr/lib64/python3.8/unittest/async_case.pyr"sz IsolatedAsyncioTestCase.__init__c�sdSrr�rrrr�
asyncSetUp'sz"IsolatedAsyncioTestCase.asyncSetUpc�sdSrrrrrr�
asyncTearDown*sz%IsolatedAsyncioTestCase.asyncTearDowncOs|j|f|�|�dSr)Z
addCleanup)r�func�args�kwargsrrr�addAsyncCleanup-s
z'IsolatedAsyncioTestCase.addAsyncCleanupcCs|��|�|j�dSr)ZsetUp�
_callAsyncrrrrr�
_callSetUp<sz"IsolatedAsyncioTestCase._callSetUpcCs|�|�dSr��_callMaybeAsync)r�methodrrr�_callTestMethod@sz'IsolatedAsyncioTestCase._callTestMethodcCs|�|j�|��dSr)rrZtearDownrrrr�
_callTearDownCsz%IsolatedAsyncioTestCase._callTearDowncOs|j|f|�|�dSrr)rZfunctionrrrrr�_callCleanupGsz$IsolatedAsyncioTestCase._callCleanupcOsL|jdk	st�|||�}t�|�s&t�|j��}|j�||f�|j�|�Sr�r	�AssertionError�inspectZisawaitable�
create_futurer
�
put_nowait�run_until_complete�rrrr�ret�futrrrrJs

z"IsolatedAsyncioTestCase._callAsynccOsP|jdk	st�|||�}t�|�rH|j��}|j�||f�|j�|�S|SdSrrr%rrrrRs


z'IsolatedAsyncioTestCase._callMaybeAsyncc
�s�t��|_}|�d�|��IdH}|��|dkr:dS|\}}z |IdH}|��s`|�|�Wqttfk
r|�Yqt	tj
fk
r�}z|��s�|�|�W5d}~XYqXqdSr)�asyncioZQueuer
Z
set_result�getZ	task_done�	cancelled�
SystemExit�KeyboardInterrupt�
BaseExceptionZCancelledErrorZ
set_exception)rr'ZqueueZqueryZ	awaitabler&Zexrrr�_asyncioLoopRunner\s 

z*IsolatedAsyncioTestCase._asyncioLoopRunnercCsX|jdkst�t��}t�|�|�d�||_|��}|�|�|��|_	|�
|�dS)NT)r	r r(Znew_event_loop�set_event_loopZ	set_debugr"Zcreate_taskr.Z_asyncioCallsTaskr$)r�loopr'rrr�_setupAsyncioLoopos

z)IsolatedAsyncioTestCase._setupAsyncioLoopc	Cs�|jdk	st�|j}d|_|j�d�|�|j���z�t�	|�}|sNW�vdS|D]}|�
�qR|�tj||dd���|D]0}|��r�q||�
�dk	r||�d|�
�|d��q||�|���W5t�d�|��XdS)NT)r0Zreturn_exceptionsz(unhandled exception during test shutdown)�message�	exception�task)r	r r
r#r$�joinr(r/�closeZ	all_tasksZcancelZgatherr*r3Zcall_exception_handlerZshutdown_asyncgens)rr0Z	to_cancelr4rrr�_tearDownAsyncioLoopys4

��

z,IsolatedAsyncioTestCase._tearDownAsyncioLoopNcs(|��zt��|�W�S|��XdSr)r1r7r�run)r�resultrrrr8�szIsolatedAsyncioTestCase.run)r)N)�__name__�
__module__�__qualname__rrrrrrrrrrr.r1r7r8�
__classcell__rrrrrs

"r)r(r!Zcaserrrrrr�<module>sPK��[�V)��-�-'__pycache__/loader.cpython-38.opt-2.pycnu�[���U

e5d�X�@sddlZddlZddlZddlZddlZddlZddlZddlmZmZddl	m
Z
mZmZdZ
e�dej�ZGdd�de
j�Zd	d
�Zdd�Zd
d�Zdd�Zdd�ZGdd�de�Ze�Zddd�Zejdfdd�Zdejejfdd�Zdejejfdd�Z dS)�N)�fnmatch�fnmatchcase�)�case�suite�utilTz[_a-z]\w*\.py$cs,eZdZdZ�fdd�Z�fdd�Z�ZS)�_FailedTestNcs||_tt|��|�dS�N)�
_exception�superr�__init__)�selfZmethod_name�	exception��	__class__��'/usr/lib64/python3.8/unittest/loader.pyrsz_FailedTest.__init__cs*|�jkrtt���|�S�fdd�}|S)Ncs
�j�dSr	)r
r�r
rr�testFailure!sz,_FailedTest.__getattr__.<locals>.testFailure)�_testMethodNamerr�__getattr__)r
�namerrrrrs
z_FailedTest.__getattr__)�__name__�
__module__�__qualname__rrr�
__classcell__rrrrrsrcCs"d|t��f}t|t|�||�S)Nz#Failed to import test module: %s
%s)�	traceback�
format_exc�_make_failed_test�ImportError)r�
suiteClass�messagerrr�_make_failed_import_test&s
�r"cCsdt��f}t||||�S)NzFailed to call load_tests:
%s)rrr)rrr r!rrr�_make_failed_load_tests+s�r#cCst||�}||f�|fSr	)r)�
methodnamerr r!�testrrrr0s
rcCs<t�t|��dd��}||i}tdtjf|�}|||�f�S)NcSsdSr	rrrrr�testSkipped5sz'_make_skipped_test.<locals>.testSkippedZ
ModuleSkipped)r�skip�str�type�TestCase)r$rr r&�attrsZ	TestClassrrr�_make_skipped_test4s

r,cCs*|���d�r|dd�Stj�|�dS)Nz	$py.classi����r)�lower�endswith�os�path�splitext)r0rrr�_jython_aware_splitext<sr2cs�eZdZdZeej�ZdZe	j
ZdZ�fdd�Z
dd�Zdd�dd	�Zd d
d�Zd!dd
�Zdd�Zd"dd�Zdd�Zdd�Zdd�Zdd�Zd#dd�Zd$dd�Z�ZS)%�
TestLoaderr%Ncs tt|���g|_t�|_dSr	)rr3r�errors�set�_loading_packagesrrrrrMszTestLoader.__init__cCsFt|tj�rtd��|�|�}|s2t|d�r2dg}|�t||��}|S)NzYTest cases should not be derived from TestSuite. Maybe you meant to derive from TestCase?ZrunTest)�
issubclassr�	TestSuite�	TypeError�getTestCaseNames�hasattrr �map)r
�
testCaseClassZ
testCaseNamesZloaded_suiterrr�loadTestsFromTestCaseTs
z TestLoader.loadTestsFromTestCase��patternc

Os:t|�dksd|kr,t�dt�|�dd�t|�dkrRt|�d}td�|���t|�dkrxt|�d}td�|���g}t|�D]4}t	||�}t
|t�r�t|t
j�r�|�|�|��q�t	|dd�}	|�|�}|	dk	�r6z|	|||�WStk
�r4}
z,t|j|
|j�\}}|j�|�|WY�Sd}
~
XYnX|S)NrZuse_load_testsz(use_load_tests is deprecated and ignoredrzCloadTestsFromModule() takes 1 positional argument but {} were givenz=loadTestsFromModule() got an unexpected keyword argument '{}'�
load_tests)�len�warnings�warn�DeprecationWarning�popr9�format�sorted�dir�getattr�
isinstancer)r7rr*�appendr>r �	Exceptionr#rr4)
r
�moduler@�argsZkwsZ	complaint�testsr�objrA�e�
error_case�
error_messagerrr�loadTestsFromModulebs<�


�zTestLoader.loadTestsFromModulecCsX|�d�}d\}}|dkr�|dd�}|r�zd�|�}t|�}Wq�Wq&tk
r�|��}t||j�\}}|s�|j�|�|YSYq&Xq&|dd�}|}	|D]�}
z|	t	|	|
�}}	Wq�t
k
�rN}zvt	|	dd�dk	�r|dk	�r|j�|�|WY�DSt|
||jdt�
�f�\}}|j�|�|WY�
SW5d}~XYq�Xq�t|	tj��rj|�|	�St|	t��r�t|	tj��r�|�|	�St|	tj��r�t|t��r�t|tj��r�|d}||�}
tt	|
|�tj��s�|�|
g�Snt|	tj��r�|	St|	��rH|	�}t|tj��r|St|tj��r6|�|g�Std|	|f��ntd|	��dS)	N�.)NNr�__path__zFailed to access attribute:
%s���z"calling %s returned %s, not a testz$don't know how to make test from: %s)�split�join�
__import__rrFr"r r4rLrJ�AttributeErrorrrrrK�types�
ModuleTyperUr)r7rr*r>�FunctionTyperr8�callabler9)r
rrN�partsrSrTZ
parts_copy�module_nameZnext_attributerQ�part�parentrR�instr%rrr�loadTestsFromName�s�	

����$

�
�
�zTestLoader.loadTestsFromNamecs��fdd�|D�}��|�S)Ncsg|]}��|���qSr)rf)�.0r�rNr
rr�
<listcomp>�sz1TestLoader.loadTestsFromNames.<locals>.<listcomp>)r )r
�namesrNZsuitesrrhr�loadTestsFromNames�szTestLoader.loadTestsFromNamescs>��fdd�}tt|t����}�jr:|jt��j�d�|S)NcsZ|��j�sdSt�|�}t|�s&dSd�j�j|f��jdkpXt�fdd��jD��S)NFz%s.%s.%sc3s|]}t�|�VqdSr	)r)rgr@�ZfullNamerr�	<genexpr>�szKTestLoader.getTestCaseNames.<locals>.shouldIncludeMethod.<locals>.<genexpr>)�
startswith�testMethodPrefixrJr`rr�testNamePatterns�any)�attrnameZtestFunc�r
r=rlr�shouldIncludeMethod�s
�
�z8TestLoader.getTestCaseNames.<locals>.shouldIncludeMethod)�key)�list�filterrI�sortTestMethodsUsing�sort�	functools�
cmp_to_key)r
r=rtZtestFnNamesrrsrr:�s
zTestLoader.getTestCaseNames�test*.pycCsJd}|dkr|jdk	r|j}n|dkr.d}|}tj�|�}|tjkrRtj�d|�||_d}d}g}tj�tj�|��r�tj�|�}||kr�tj�tj�|d��}�npzt	|�Wnt
k
r�d}Y�nJXtj|}|�d�d}	ztj�tj�
|j��}Wn�tk
�r�z
|j}
Wntk
�r8d}
YnX|
�r�|
jdk�r�|
jdk	�r�d}|jD]P}|�s||�|��s|�qb|�|j�dtjj��d|_|�|j||dd���qbn*|jtjk�r�td�d�ntd�|��d�YnX|�r|�s|�|	�|_tj�|�ntj�|�|�r*t
d	|��|�s@t|�||��}|� |�S)
NFTr�__init__.pyrV)�	namespacez2Can not use builtin modules as dotted module namesz$don't know how to discover from {!r}z%Start directory is not importable: %r)!�_top_level_dirr/r0�abspath�sys�insert�isdir�isfilerZr[r�modulesrY�dirname�__file__r\�__spec__�loader�submodule_search_locationsrWrnr�replace�sep�extend�_find_tests�builtin_module_namesr9rG� _get_directory_containing_module�removervr )r
�	start_dirr@Z
top_level_dirZset_implicit_topZis_not_importable�is_namespacerPZ
the_moduleZtop_part�specr0rrr�discover�s�

�


�
���
������zTestLoader.discovercCsRtj|}tj�|j�}tj�|����d�rBtj�	tj�	|��Stj�	|�SdS)Nr})
r�r�r/r0r�r��basenamer-rnr�)r
rbrN�	full_pathrrrr�`s

z+TestLoader._get_directory_containing_modulecCsB||jkrdSttj�|��}tj�||j�}|�tjjd�}|S�NrV)rr2r/r0�normpath�relpathr�r�)r
r0Z_relpathrrrr�_get_name_from_pathls
zTestLoader._get_name_from_pathcCst|�tj|Sr	)r[r�r�)r
rrrr�_get_module_from_namexsz TestLoader._get_module_from_namecCs
t||�Sr	)r)r
r0r�r@rrr�_match_path|szTestLoader._match_pathFc

cs�|�|�}|dkrD||jkrD|�|||�\}}|dk	r<|V|sDdStt�|��}|D]t}tj�||�}	|�|	||�\}}|dk	r�|V|rV|�|	�}|j�|�z|�
|	||�EdHW5|j�	|�XqVdSr�)r�r6�_find_test_pathrHr/�listdirr0rZ�add�discardr�)
r
r�r@r~rrPZshould_recurse�pathsr0r�rrrr��s6
��
zTestLoader._find_testsc
Csttj�|�}tj�|��rVt�|�s(dS|�|||�s:dS|�|�}z|�|�}Wnht	j
k
r�}zt|||j�dfWY�Sd}~XYn�t
||j�\}}	|j�|	�|dfYSXtj�t|d|��}
ttj�|
��}ttj�|��}|��|��k�r@tj�|�}
ttj�|��}tj�|�}d}t|||
|f��|j||d�dfS�ntj�|��rl|�s�tj�tj�|d���s�dSd}d}|�|�}z|�|�}Wnjt	j
k
�r�}zt|||j�dfWY�Sd}~XYn�t
||j�\}}	|j�|	�|dfYSXt|dd�}|j�|�z0|j||d�}|dk	�rP|dfW�S|dfW�S|j�|�XndSdS)	N)NFFr�zW%r module incorrectly imported from %r. Expected %r. Is this module globally installed?r?r}rAT)r/r0r�r��VALID_MODULE_NAME�matchr�r�r�rZSkipTestr,r r"r4rLr�rJr2�realpathr-r�rrUr�rZr6r�r�)r
r�r@r~r�rrNrRrSrTZmod_filer�Zfullpath_noextZ
module_dirZmod_nameZexpected_dir�msgrArP�packagerrrr��s|

&
�
�
�
�
���
&
�
zTestLoader._find_test_path)N)N)r|N)F)F)rrrro�staticmethodr�
three_way_cmprxrprr8r rrr>rUrfrkr:r�r�r�r�r�r�r�rrrrrr3Bs$
(
N

n
"r3cCs&t�}||_||_||_|r"||_|Sr	)r3rxrorpr )�prefix�	sortUsingr rpr�rrr�_makeLoader�sr�cCst|||d��|�S)N)rp)r�r:)r=r�r�rprrrr:�sr:r%cCst|||��|�Sr	)r�r>)r=r�r�r rrr�	makeSuite�s�r�cCst|||��|�Sr	)r�rU)rNr�r�r rrr�
findTestCasess�r�)NN)!r/�rer�rr]rzrCrr�rrrZ
__unittest�compile�
IGNORECASEr�r*rr"r#rr,r2�objectr3ZdefaultTestLoaderr�r�r:r8r�r�rrrr�<module>s:/
	�
�PK��[jr�&6�6�__pycache__/case.cpython-38.pycnu�[���U

e5d���@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZmZmZmZmZdZe�ZdZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�ZGdd�de�Zdd�ZgZdd�Zdd�Z dd�Z!dd�Z"dd�Z#dd�Z$dd�Z%Gd d!�d!�Z&Gd"d#�d#e&�Z'Gd$d%�d%e'�Z(Gd&d'�d'e'�Z)e�*d(d)d*g�Z+Gd+d,�d,ej,�Z-Gd-d.�d.e&�Z.Gd/d0�d0ej/�Z0Gd1d2�d2e�Z1Gd3d4�d4e1�Z2Gd5d6�d6e1�Z3dS)7zTest case implementation�N�)�result)�strclass�	safe_repr�_count_diff_all_purpose�_count_diff_hashable�_common_shorten_reprTz@
Diff is %s characters long. Set self.maxDiff to None to see it.c@seZdZdZdS)�SkipTestz�
    Raise this exception in a test to skip it.

    Usually you can use TestCase.skipTest() or one of the skipping decorators
    instead of raising this directly.
    N��__name__�
__module__�__qualname__�__doc__�rr�%/usr/lib64/python3.8/unittest/case.pyr	sr	c@seZdZdZdS)�_ShouldStopz
    The test should stop.
    Nr
rrrrr"src@seZdZdZdS)�_UnexpectedSuccessz7
    The test was supposed to fail, but it didn't!
    Nr
rrrrr'src@s&eZdZddd�Zejddd��ZdS)	�_OutcomeNcCs4d|_||_t|d�|_d|_g|_d|_g|_dS)NF�
addSubTestT)�expecting_failurer�hasattr�result_supports_subtests�success�skipped�expectedFailure�errors)�selfrrrr�__init__.sz_Outcome.__init__Fc
cs�|j}d|_z�z
dVWn�tk
r.�Yn�tk
rh}zd|_|j�|t|�f�W5d}~XYnjtk
rzYnXt��}|j	r�||_
nd|_|j�||f�d}YnX|jr�|jr�|j�|df�W5|jo�||_XdS)NTF)
r�KeyboardInterruptr	r�append�strr�sys�exc_inforrrr)r�	test_case�isTestZold_success�er"rrr�testPartExecutor7s*
$
z_Outcome.testPartExecutor)N)F)rrr
r�
contextlib�contextmanagerr&rrrrr-s
	rcCs|S�Nr)�objrrr�_idUsr+cOst�|||f�dS)znSame as addCleanup, except the cleanup items are called even if
    setUpModule fails (unlike tearDownModule).N)�_module_cleanupsr)�function�args�kwargsrrr�addModuleCleanupZsr0c
Csdg}trTt��\}}}z|||�Wqtk
rP}z|�|�W5d}~XYqXq|r`|d�dS)zWExecute all module cleanup functions. Normally called for you after
    tearDownModule.Nr)r,�pop�	Exceptionr)�
exceptionsr-r.r/�excrrr�doModuleCleanups`sr5cs,�fdd�}t�tj�r(�}d�||�S|S)z&
    Unconditionally skip a test.
    cs4t|t�s$t�|��fdd��}|}d|_�|_|S)Ncst���dSr)�r	�r.r/��reasonrr�skip_wrappervsz-skip.<locals>.decorator.<locals>.skip_wrapperT)�
isinstance�type�	functools�wraps�__unittest_skip__�__unittest_skip_why__)�	test_itemr:r8rr�	decoratorts
zskip.<locals>.decorator�)r;�types�FunctionType)r9rBrArr8r�skipps
rFcCs|rt|�StS)z/
    Skip a test if the condition is true.
    �rFr+�Z	conditionr9rrr�skipIf�srIcCs|st|�StS)z3
    Skip a test unless the condition is true.
    rGrHrrr�
skipUnless�srJcCs
d|_|S)NT)�__unittest_expecting_failure__)rArrrr�srcs4t|t�r t�fdd�|D��St|t�o2t|��S)Nc3s|]}t|��VqdSr))�_is_subtype)�.0r%��basetyperr�	<genexpr>�sz_is_subtype.<locals>.<genexpr>)r;�tuple�allr<�
issubclass)�expectedrOrrNrrL�s
rLc@seZdZdd�Zdd�ZdS)�_BaseTestCaseContextcCs
||_dSr))r#)rr#rrrr�sz_BaseTestCaseContext.__init__cCs |j�|j|�}|j�|��dSr))r#�_formatMessage�msg�failureException)r�standardMsgrWrrr�
_raiseFailure�sz"_BaseTestCaseContext._raiseFailureN)rrr
rrZrrrrrU�srUc@seZdZddd�Zdd�ZdS)�_AssertRaisesBaseContextNcCs@t�||�||_||_|dk	r*t�|�}||_d|_d|_dSr))	rUrrTr#�re�compile�expected_regex�obj_namerW)rrTr#r^rrrr�s
z!_AssertRaisesBaseContext.__init__c	Cs�z�t|j|j�s"td||jf��|sV|�dd�|_|rNtdtt|��f��|W�TS|^}}z|j	|_
Wntk
r�t|�|_
YnX|�|||�W5QRXW5d}XdS)z�
        If args is empty, assertRaises/Warns is being used as a
        context manager, so check for a 'msg' kwarg and return self.
        If args is not empty, call a callable passing positional and keyword
        arguments.
        Nz%s() arg 1 must be %srWz3%r is an invalid keyword argument for this function)
rLrT�
_base_type�	TypeError�_base_type_strr1rW�next�iterrr_�AttributeErrorr )r�namer.r/Zcallable_objrrr�handle�s(��z_AssertRaisesBaseContext.handle)N)rrr
rrgrrrrr[�s

r[c@s(eZdZdZeZdZdd�Zdd�ZdS)�_AssertRaisesContextzCA context manager used to implement TestCase.assertRaises* methods.z-an exception type or tuple of exception typescCs|Sr)r�rrrr�	__enter__�sz_AssertRaisesContext.__enter__cCs�|dkrbz|jj}Wntk
r2t|j�}YnX|jrP|�d�||j��ql|�d�|��n
t�|�t	||j�s|dS|�
d�|_|jdkr�dS|j}|�
t|��s�|�d�|jt|���dS)Nz{} not raised by {}z
{} not raisedFT�"{}" does not match "{}")rTrrer r_rZ�format�	traceback�clear_framesrS�with_tracebackZ	exceptionr^�search�pattern)r�exc_type�	exc_value�tb�exc_namer^rrr�__exit__�s.
�

�z_AssertRaisesContext.__exit__N)	rrr
r�
BaseExceptionr`rbrjrvrrrrrh�s
rhc@s(eZdZdZeZdZdd�Zdd�ZdS)�_AssertWarnsContextzBA context manager used to implement TestCase.assertWarns* methods.z(a warning type or tuple of warning typescCsRttj���D]}t|dd�ri|_qtjdd�|_|j�	�|_t�
d|j�|S)N�__warningregistry__T)�record�always)�listr!�modules�values�getattrry�warnings�catch_warnings�warnings_managerrj�simplefilterrT)r�vrrrrj�sz_AssertWarnsContext.__enter__cCs|j�|||�|dk	rdSz|jj}Wntk
rFt|j�}YnXd}|jD]Z}|j}t||j�sjqR|dkrv|}|j	dk	r�|j	�
t|��s�qR||_|j|_|j
|_
dS|dk	r�|�d�|j	jt|���|jr�|�d�||j��n|�d�|��dS)Nrkz{} not triggered by {}z{} not triggered)r�rvrTrrer r��messager;r^rpZwarning�filename�linenorZrlrqr_)rrrrsrtruZfirst_matching�m�wrrrrvs@

��
�z_AssertWarnsContext.__exit__N)	rrr
r�Warningr`rbrjrvrrrrrx�s
rx�_LoggingWatcher�records�outputc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_CapturingHandlerzM
    A logging handler capturing all (raw and formatted) logging output.
    cCstj�|�tgg�|_dSr))�logging�Handlerrr��watcherrirrrr3sz_CapturingHandler.__init__cCsdSr)rrirrr�flush7sz_CapturingHandler.flushcCs*|jj�|�|�|�}|jj�|�dSr))r�r�rrlr�)rrzrWrrr�emit:s
z_CapturingHandler.emitN)rrr
rrr�r�rrrrr�.sr�c@s,eZdZdZdZdd�Zdd�Zdd�Zd	S)
�_AssertLogsContextz:A context manager used to implement TestCase.assertLogs().z"%(levelname)s:%(name)s:%(message)scCs:t�||�||_|r(tj�||�|_ntj|_d|_dSr))	rUr�logger_namer�Z_nameToLevel�get�level�INFOrW)rr#r�r�rrrrFsz_AssertLogsContext.__init__cCs�t|jtj�r|j}|_nt�|j�}|_t�|j�}t�}|�	|�|j
|_
|jdd�|_|j
|_|j|_|g|_|�|j
�d|_|j
S)NF)r;r�r�ZLogger�loggerZ	getLoggerZ	Formatter�LOGGING_FORMATr�ZsetFormatterr��handlers�old_handlersr��	old_level�	propagate�
old_propagate�setLevel)rr�Z	formatterZhandlerrrrrjOs
z_AssertLogsContext.__enter__cCs`|j|j_|j|j_|j�|j�|dk	r.dSt|jj	�dkr\|�
d�t�
|j�|jj��dS)NFrz-no logs of level {} or higher triggered on {})r�r�r�r�r�r�r��lenr�r�rZrlr�ZgetLevelNamer�rf)rrrrsrtrrrrv`s


��z_AssertLogsContext.__exit__N)rrr
rr�rrjrvrrrrr�As
	r�c@seZdZdd�ZdS)�_OrderedChainMapccs8t�}|jD]&}|D]}||kr|�|�|VqqdSr))�set�maps�add)r�seen�mapping�krrr�__iter__ns

z_OrderedChainMap.__iter__N)rrr
r�rrrrr�msr�c@seZdZdZeZdZdZdZdZ	gZ
d�dd�Zd	d
�Zdd�Z
d
e
_edd��Zdd�Zdd�Zedd��Zedd��Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zeje fd*d+��Z!d,d-�Z"d.d/�Z#d0d1�Z$d2d3�Z%d4d5�Z&d6d7�Z'd8d9�Z(d�d;d<�Z)d=d>�Z*ed?d@��Z+dAdB�Z,dCdD�Z-dEdF�Z.d�dGdH�Z/d�dIdJ�Z0d�dKdL�Z1dMdN�Z2dOdP�Z3dQdR�Z4d�dSdT�Z5dUdV�Z6d�dWdX�Z7d�dYdZ�Z8d�d[d\�Z9d�d]d^�Z:d�d_d`�Z;d�dadb�Z<dcdd�Z=d�dedf�Z>d�dgdh�Z?d�didj�Z@d�dkdl�ZAd�dmdn�ZBd�dodp�ZCd�dqdr�ZDd�dsdt�ZEd�dudv�ZFd�dwdx�ZGd�dydz�ZHd�d{d|�ZId�d}d~�ZJd�dd��ZKd�d�d��ZLd�d�d��ZMd�d�d��ZNd�d�d��ZOd�d�d��ZPd�d��ZQd�d��ZRd�d�d��ZSd�d�d��ZTd�d��ZUeUe8�ZVZWeUe9�ZXZYeUe:�ZZZ[eUe;�Z\Z]eUe1�Z^Z_eUe3�Z`eUe0�ZaeUeQ�ZbeUeS�ZceUeT�Zdd:S)��TestCaseaWA class whose instances are single test cases.

    By default, the test code itself should be placed in a method named
    'runTest'.

    If the fixture may be used for many test cases, create as
    many test methods as are needed. When instantiating such a TestCase
    subclass, specify in the constructor arguments the name of the test method
    that the instance is to execute.

    Test authors should subclass TestCase for their own tests. Construction
    and deconstruction of the test's environment ('fixture') can be
    implemented by overriding the 'setUp' and 'tearDown' methods respectively.

    If it is necessary to override the __init__ method, the base class
    __init__ method must always be called. It is important that subclasses
    should not change the signature of their __init__ method, since instances
    of the classes are instantiated automatically by parts of the framework
    in order to be run.

    When subclassing TestCase, you can set these attributes:
    * failureException: determines which exception will be raised when
        the instance's assertion methods fail; test methods raising this
        exception will be deemed to have 'failed' rather than 'errored'.
    * longMessage: determines whether long messages (including repr of
        objects used in assert methods) will be printed on failure in *addition*
        to any explicit message passed.
    * maxDiff: sets the maximum length of a diff in failure messages
        by assert methods using difflib. It is looked up as an instance
        attribute so can be configured by individual tests if required.
    Ti�iF�runTestcCs�||_d|_d|_zt||�}Wn.tk
rN|dkrJtd|j|f��Yn
X|j|_g|_d|_	i|_
|�td�|�t
d�|�td�|�td�|�td�|�td	�dS)
z�Create an instance of the class that will use the named test
           method when executed. Raises a ValueError if the instance does
           not have a method with the specified name.
        NzNo testr�zno such test method in %s: %s�assertDictEqual�assertListEqual�assertTupleEqual�assertSetEqual�assertMultiLineEqual)�_testMethodName�_outcome�_testMethodDocrre�
ValueError�	__class__r�	_cleanups�_subtest�_type_equality_funcs�addTypeEqualityFunc�dictr|rQr��	frozensetr )rZ
methodName�
testMethodrrrr�s(�zTestCase.__init__cCs||j|<dS)a[Add a type specific assertEqual style function to compare a type.

        This method is for use by TestCase subclasses that need to register
        their own type equality functions to provide nicer error messages.

        Args:
            typeobj: The data type to call this function on when both values
                    are of the same type in assertEqual().
            function: The callable taking two arguments and an optional
                    msg= argument that raises self.failureException with a
                    useful error message when the two arguments are not equal.
        N)r�)rZtypeobjr-rrrr��s
zTestCase.addTypeEqualityFunccOs�t|�dkr|^}}}nV|s&td��nHd|krZ|�d�}|^}}ddl}|jdtdd�ntdt|�d	��t|�}|j�|||f�dS)
aAdd a function, with arguments, to be called when the test is
        completed. Functions added are called on a LIFO basis and are
        called after tearDown on test failure or success.

        Cleanup items are called even if setUp fails (unlike tearDown).�z>descriptor 'addCleanup' of 'TestCase' object needs an argumentr-rNz4Passing 'function' as keyword argument is deprecated)�
stacklevelz:addCleanup expected at least 1 positional argument, got %dr)	r�rar1r��warn�DeprecationWarningrQr�r)r.r/rr-r�rrr�
addCleanup�s"

�
�zTestCase.addCleanupz%($self, function, /, *args, **kwargs)cOs|j�|||f�dS)zpSame as addCleanup, except the cleanup items are called even if
        setUpClass fails (unlike tearDownClass).N)�_class_cleanupsr)�clsr-r.r/rrr�addClassCleanup�szTestCase.addClassCleanupcCsdS)zAHook method for setting up the test fixture before exercising it.Nrrirrr�setUp�szTestCase.setUpcCsdS)zAHook method for deconstructing the test fixture after testing it.Nrrirrr�tearDown�szTestCase.tearDowncCsdS)zKHook method for setting up class fixture before running tests in the class.Nr�r�rrr�
setUpClass�szTestCase.setUpClasscCsdS)zVHook method for deconstructing the class fixture after running all tests in the class.Nrr�rrr�
tearDownClassszTestCase.tearDownClasscCsdS)Nrrrirrr�countTestCasesszTestCase.countTestCasescCst��Sr))rZ
TestResultrirrr�defaultTestResult	szTestCase.defaultTestResultcCs$|j}|r |���d�d��SdS)z�Returns a one-line description of the test, or None if no
        description has been provided.

        The default implementation of this method returns the first line of
        the specified test method's docstring.
        �
rN)r��strip�split�r�docrrr�shortDescriptionszTestCase.shortDescriptioncCsdt|j�|jfS)Nz%s.%s�rr�r�rirrr�idszTestCase.idcCs t|�t|�k	rtS|j|jkSr))r<�NotImplementedr��r�otherrrr�__eq__szTestCase.__eq__cCstt|�|jf�Sr))�hashr<r�rirrr�__hash__ szTestCase.__hash__cCsd|jt|j�fS�Nz%s (%s))r�rr�rirrr�__str__#szTestCase.__str__cCsdt|j�|jfS)Nz<%s testMethod=%s>r�rirrr�__repr__&s�zTestCase.__repr__cCs<t|dd�}|dk	r |||�nt�dtd�|�|�dS)N�addSkipz4TestResult has no addSkip method, skips not reportedr�)rr�r��RuntimeWarning�
addSuccess)rrr#r9r�rrr�_addSkip*s�zTestCase._addSkipc	ks�|jdks|jjsdVdS|j}|dkr4t|�}n|j�|�}t|||�|_zX|jj|jdd��dVW5QRX|jjs�|jj	}|dk	r�|j
r�t�n|jjr�t�W5||_XdS)aPReturn a context manager that will return the enclosed block
        of code in a subtest identified by the optional message and
        keyword parameters.  A failure in the subtest marks the test
        case as failed but resumes execution at the end of the enclosed
        block, allowing further test code to be executed.
        NT�r$)
r�rr�r��params�	new_child�_SubTestr&rrZfailfastrr)rrWr��parentZ
params_maprrrr�subTest3s$
zTestCase.subTestcCs`|D]V\}}t|t�r(|�|j||�q|dk	rt|d|j�rN|�||�q|�||�qdS)Nr)r;r�rr#rSrX�
addFailureZaddError)rrr�testr"rrr�_feedErrorsToResultRs
zTestCase._feedErrorsToResultcCsDz
|j}Wn*tk
r4t�dt�|�|�YnX|||�dS)Nz@TestResult has no addExpectedFailure method, reporting as passes)�addExpectedFailurerer�r�r�r�)rrr"r�rrr�_addExpectedFailure\s
�zTestCase._addExpectedFailurecCshz
|j}WnPtk
rZt�dt�z
td�Wn$tk
rT|�|t���YnXYn
X||�dS)NzCTestResult has no addUnexpectedSuccess method, reporting as failure)	�addUnexpectedSuccessrer�r�r�rr�r!r")rrr�rrr�_addUnexpectedSuccessfs
�
zTestCase._addUnexpectedSuccesscCs|��dSr))r�rirrr�
_callSetUpuszTestCase._callSetUpcCs
|�dSr)r)r�methodrrr�_callTestMethodxszTestCase._callTestMethodcCs|��dSr))r�rirrr�
_callTearDown{szTestCase._callTearDowncOs|||�dSr)r�rr-r.r/rrr�_callCleanup~szTestCase._callCleanupNc

Cs|}|dkr.|��}t|dd�}|dk	r.|�|�|�t||j�}t|jdd�s^t|dd�r�z,t|jdd�pxt|dd�}|�|||�W5|�|�XdSt|dd�}t|dd�}|p�|}t|�}	z�|	|_|	�|��|�
�W5QRX|	j�r@||	_|	j|dd	��|�|�W5QRXd|	_|	�|��|��W5QRX|��|	jD]\}}|�|||��qN|�||	j�|	j�r�|�r�|	j
�r�|�||	j
�n
|�|�n
|�|�|W�S|�|�|dk�r�t|dd�}
|
dk	�r�|
�|	j�	�d|	_
d|_XdS)
N�startTestRunr?Fr@rCrK�stopTestRunTr�)r�rZ	startTestr�r�ZstopTestr�rr�clearrr�r&r�rrr�r��
doCleanupsrr�r�r�r�)
rrZorig_resultr�r�Zskip_whyZexpecting_failure_methodZexpecting_failure_classr�outcomer�r�r9rrr�run�st

�
���




zTestCase.runc	CsR|jp
t�}|jrL|j��\}}}|�|��|j|f|�|�W5QRXq|jS)zNExecute all cleanup functions. Normally called for you after
        tearDown.)r�rr�r1r&r�r)rr�r-r.r/rrrr��szTestCase.doCleanupsc
Csdg|_|jr`|j��\}}}z|||�Wqtk
r\}z|j�t���W5d}~XYqXqdS)zYExecute all class cleanup functions. Normally called for you after
        tearDownClass.N)ZtearDown_exceptionsr�r1r2rr!r")r�r-r.r/r4rrr�doClassCleanups�szTestCase.doClassCleanupscOs|j||�Sr))r�)rr.�kwdsrrr�__call__�szTestCase.__call__cCsF|��t||j��|��|jrB|j�d�\}}}|||�qdS)z6Run the test without collecting errors in a TestResult���N)r�rr�r�r�r1r�rrr�debug�szTestCase.debugcCst|��dS)zSkip this test.Nr6)rr9rrr�skipTest�szTestCase.skipTestcCs|�|��dS)z)Fail immediately, with the given message.N)rX)rrWrrr�fail�sz
TestCase.failcCs&|r"|�|dt|��}|�|��dS)z#Check that the expression is false.z%s is not falseN�rVrrX�r�exprrWrrr�assertFalse�szTestCase.assertFalsecCs&|s"|�|dt|��}|�|��dS)z"Check that the expression is true.z%s is not trueNrrrrr�
assertTrue�szTestCase.assertTruecCsV|js|p|S|dkr|Szd||fWStk
rPdt|�t|�fYSXdS)a�Honour the longMessage attribute when generating failure messages.
        If longMessage is False this means:
        * Use only an explicit message if it is provided
        * Otherwise use the standard message for the assert

        If longMessage is True:
        * Use the standard message
        * If an explicit message is provided, plus ' : ' and the explicit message
        Nz%s : %s)�longMessage�UnicodeDecodeErrorr)rrWrYrrrrV�s
zTestCase._formatMessagecOs(t||�}z|�d||�W�Sd}XdS)a=Fail unless an exception of class expected_exception is raised
           by the callable when invoked with specified positional and
           keyword arguments. If a different type of exception is
           raised, it will not be caught, and the test case will be
           deemed to have suffered an error, exactly as for an
           unexpected exception.

           If called with the callable and arguments omitted, will return a
           context object used like this::

                with self.assertRaises(SomeException):
                    do_something()

           An optional keyword argument 'msg' can be provided when assertRaises
           is used as a context object.

           The context manager keeps a reference to the exception as
           the 'exception' attribute. This allows you to inspect the
           exception after the assertion::

               with self.assertRaises(SomeException) as cm:
                   do_something()
               the_exception = cm.exception
               self.assertEqual(the_exception.error_code, 3)
        N�assertRaises�rhrg)r�expected_exceptionr.r/�contextrrrrs
zTestCase.assertRaisescOst||�}|�d||�S)a�Fail unless a warning of class warnClass is triggered
           by the callable when invoked with specified positional and
           keyword arguments.  If a different type of warning is
           triggered, it will not be handled: depending on the other
           warning filtering rules in effect, it might be silenced, printed
           out, or raised as an exception.

           If called with the callable and arguments omitted, will return a
           context object used like this::

                with self.assertWarns(SomeWarning):
                    do_something()

           An optional keyword argument 'msg' can be provided when assertWarns
           is used as a context object.

           The context manager keeps a reference to the first matching
           warning as the 'warning' attribute; similarly, the 'filename'
           and 'lineno' attributes give you information about the line
           of Python code from which the warning was triggered.
           This allows you to inspect the warning after the assertion::

               with self.assertWarns(SomeWarning) as cm:
                   do_something()
               the_warning = cm.warning
               self.assertEqual(the_warning.some_attribute, 147)
        �assertWarns�rxrg)r�expected_warningr.r/rrrrr5s
zTestCase.assertWarnscCst|||�S)a�Fail unless a log message of level *level* or higher is emitted
        on *logger_name* or its children.  If omitted, *level* defaults to
        INFO and *logger* defaults to the root logger.

        This method must be used as a context manager, and will yield
        a recording object with two attributes: `output` and `records`.
        At the end of the context manager, the `output` attribute will
        be a list of the matching formatted log messages and the
        `records` attribute will be a list of the corresponding LogRecord
        objects.

        Example::

            with self.assertLogs('foo', level='INFO') as cm:
                logging.getLogger('foo').info('first message')
                logging.getLogger('foo.bar').error('second message')
            self.assertEqual(cm.output, ['INFO:foo:first message',
                                         'ERROR:foo.bar:second message'])
        )r�)rr�r�rrr�
assertLogsTszTestCase.assertLogscCsFt|�t|�kr@|j�t|��}|dk	r@t|t�r<t||�}|S|jS)aGet a detailed comparison function for the types of the two args.

        Returns: A callable accepting (first, second, msg=None) that will
        raise a failure exception if first != second with a useful human
        readable error message for those types.
        N)r<r�r�r;r r�_baseAssertEqual)r�first�secondZasserterrrr�_getAssertEqualityFuncjs

zTestCase._getAssertEqualityFunccCs0||ks,dt||�}|�||�}|�|��dS)z:The default assertEqual implementation, not type specific.�%s != %sN)rrVrX)rrrrWrYrrrr�szTestCase._baseAssertEqualcCs|�||�}||||d�dS)z[Fail if the two objects are unequal as determined by the '=='
           operator.
        )rWN)r)rrrrWZassertion_funcrrr�assertEqual�szTestCase.assertEqualcCs2||ks.|�|dt|�t|�f�}|�|��dS)zYFail if the two objects are equal as determined by the '!='
           operator.
        z%s == %sNr)rrrrWrrr�assertNotEqual�s
�zTestCase.assertNotEqualcCs�||krdS|dk	r$|dk	r$td��t||�}|dk	rf||krDdSdt|�t|�t|�t|�f}n:|dkrrd}t||�dkr�dSdt|�t|�|t|�f}|�||�}|�|��dS)a'Fail if the two objects are unequal as determined by their
           difference rounded to the given number of decimal places
           (default 7) and comparing to zero, or by comparing that the
           difference between the two objects is more than the given
           delta.

           Note that decimal places (from zero) are usually not the same
           as significant digits (measured from the most significant digit).

           If the two objects compare equal then they will automatically
           compare almost equal.
        N� specify delta or places not bothz(%s != %s within %s delta (%s difference)�rz)%s != %s within %r places (%s difference)�ra�absr�roundrVrX�rrrZplacesrWZdelta�diffrYrrr�assertAlmostEqual�s4��zTestCase.assertAlmostEqualcCs�|dk	r|dk	rtd��t||�}|dk	rb||ks@||kr@dSdt|�t|�t|�t|�f}n<|dkrnd}||ks�t||�dkr�dSdt|�t|�|f}|�||�}|�|��dS)a�Fail if the two objects are equal as determined by their
           difference rounded to the given number of decimal places
           (default 7) and comparing to zero, or by comparing that the
           difference between the two objects is less than the given delta.

           Note that decimal places (from zero) are usually not the same
           as significant digits (measured from the most significant digit).

           Objects that are equal automatically fail.
        Nrz(%s == %s within %s delta (%s difference)rrz%s == %s within %r placesrrrrr�assertNotAlmostEqual�s,��zTestCase.assertNotAlmostEqualcCs�|dk	rP|j}t||�s.|�d|t|�f��t||�sT|�d|t|�f��nd}d}zt|�}Wn ttfk
r�d|}YnX|dkr�zt|�}Wn ttfk
r�d|}YnX|dk�r�||kr�dSd|��ft||�}t	t
||��D]�}	z||	}
Wn4tttfk
�r<|d|	|f7}Y�q�YnXz||	}Wn4tttfk
�r~|d	|	|f7}Y�q�YnX|
|kr�|d
|	ft|
|�7}�q�q�||k�r�|dk�r�t|�t|�k�r�dS||k�r<|d|||f7}z|d|t||�f7}Wn,tttfk
�r8|d
||f7}YnXnh||k�r�|d|||f7}z|d|t||�f7}Wn,tttfk
�r�|d||f7}YnX|}dd�
t�t�|���t�|�����}
|�||
�}|�||�}|�|�dS)aAAn equality assertion for ordered sequences (like lists and tuples).

        For the purposes of this function, a valid ordered sequence type is one
        which can be indexed, has a length, and has an equality operator.

        Args:
            seq1: The first sequence to compare.
            seq2: The second sequence to compare.
            seq_type: The expected datatype of the sequences, or None if no
                    datatype should be enforced.
            msg: Optional message to use on failure instead of a list of
                    differences.
        NzFirst sequence is not a %s: %szSecond sequence is not a %s: %sZsequencez(First %s has no length.    Non-sequence?z)Second %s has no length.    Non-sequence?z%ss differ: %s != %s
z(
Unable to index element %d of first %s
z)
Unable to index element %d of second %s
z#
First differing element %d:
%s
%s
z+
First %s contains %d additional elements.
zFirst extra element %d:
%s
z'Unable to index element %d of first %s
z,
Second %s contains %d additional elements.
z(Unable to index element %d of second %s
r�)rr;rXrr�ra�NotImplementedError�
capitalizer�range�min�
IndexErrorr<�join�difflib�ndiff�pprint�pformat�
splitlines�_truncateMessagerVr)rZseq1Zseq2rW�seq_typeZ
seq_type_nameZ	differingZlen1Zlen2�iZitem1Zitem2rY�diffMsgrrr�assertSequenceEqual�s�

�

��
�

������

��
�

��
���zTestCase.assertSequenceEqualcCs2|j}|dkst|�|kr"||S|tt|�Sr))�maxDiffr��DIFF_OMITTED)rr�rZmax_diffrrrr+NszTestCase._truncateMessagecCs|j|||td�dS)aA list-specific equality assertion.

        Args:
            list1: The first list to compare.
            list2: The second list to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.

        �r,N)r/r|)rZlist1Zlist2rWrrrr�Ts
zTestCase.assertListEqualcCs|j|||td�dS)aA tuple-specific equality assertion.

        Args:
            tuple1: The first tuple to compare.
            tuple2: The second tuple to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.
        r2N)r/rQ)rZtuple1Ztuple2rWrrrr�`s	zTestCase.assertTupleEqualc

Cs`z|�|�}Wn^tk
r>}z|�d|�W5d}~XYn0tk
rl}z|�d|�W5d}~XYnXz|�|�}Wn^tk
r�}z|�d|�W5d}~XYn0tk
r�}z|�d|�W5d}~XYnX|s�|s�dSg}|�r|�d�|D]}|�t|���q|�r@|�d�|D]}|�t|���q*d�|�}	|�|�||	��dS)a�A set-specific equality assertion.

        Args:
            set1: The first set to compare.
            set2: The second set to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.

        assertSetEqual uses ducktyping to support different types of sets, and
        is optimized for sets specifically (parameters must support a
        difference method).
        z/invalid type when attempting set difference: %sNz2first argument does not support set difference: %sz3second argument does not support set difference: %sz*Items in the first set but not the second:z*Items in the second set but not the first:r�)�
differencerarrer�reprr%rV)
rZset1Zset2rWZdifference1r%Zdifference2�lines�itemrYrrrr�ks2
  


zTestCase.assertSetEqualcCs2||kr.dt|�t|�f}|�|�||��dS)zDJust like self.assertTrue(a in b), but with a nicer default message.z%s not found in %sN�rrrV�r�memberZ	containerrWrYrrr�assertIn�s
�zTestCase.assertIncCs2||kr.dt|�t|�f}|�|�||��dS)zHJust like self.assertTrue(a not in b), but with a nicer default message.z%s unexpectedly found in %sNr7r8rrr�assertNotIn�s
�zTestCase.assertNotIncCs2||k	r.dt|�t|�f}|�|�||��dS)zDJust like self.assertTrue(a is b), but with a nicer default message.z%s is not %sNr7�rZexpr1Zexpr2rWrYrrr�assertIs�s
�zTestCase.assertIscCs,||kr(dt|�f}|�|�||��dS)zHJust like self.assertTrue(a is not b), but with a nicer default message.zunexpectedly identical: %sNr7r<rrr�assertIsNot�szTestCase.assertIsNotc	Cs~|�|td�|�|td�||krzdt||�}dd�t�t�|���t�|�����}|�	||�}|�
|�||��dS)Nz"First argument is not a dictionaryz#Second argument is not a dictionaryrr�)�assertIsInstancer�rr%r&r'r(r)r*r+rrV)rZd1Zd2rWrYrrrrr��s
�zTestCase.assertDictEqualc		Cs�t�dt�g}g}|��D]L\}}||kr8|�|�q|||kr|�dt|�t|�t||�f�q|sv|svdSd}|r�dd�dd�|D��}|r�|r�|d	7}|d
d�|�7}|�|�||��dS)z2Checks whether dictionary is a superset of subset.z&assertDictContainsSubset is deprecatedz%s, expected: %s, actual: %sNrCzMissing: %s�,css|]}t|�VqdSr))r)rMr�rrrrP�sz4TestCase.assertDictContainsSubset.<locals>.<genexpr>z; zMismatched values: %s)	r�r�r��itemsrrr%rrV)	rZsubsetZ
dictionaryrWZmissingZ
mismatched�key�valuerYrrr�assertDictContainsSubset�s4�
���
z!TestCase.assertDictContainsSubsetc
Cs�t|�t|�}}zt�|�}t�|�}Wntk
rHt||�}YnX||krVdSt||�}|r�d}dd�|D�}d�|�}	|�||	�}|�||�}|�	|�dS)a[Asserts that two iterables have the same elements, the same number of
        times, without regard to order.

            self.assertEqual(Counter(list(first)),
                             Counter(list(second)))

         Example:
            - [0, 1, 1] and [1, 0, 1] compare equal.
            - [0, 0, 1] and [0, 1] compare unequal.

        NzElement counts were not equal:
cSsg|]}d|�qS)z First has %d, Second has %d:  %rr)rMrrrr�
<listcomp>�sz-TestCase.assertCountEqual.<locals>.<listcomp>r�)
r|�collections�Counterrarrr%r+rVr)
rrrrWZ	first_seqZ
second_seqZdifferencesrYr5r.rrr�assertCountEqual�s 


zTestCase.assertCountEqualcCs�|�|td�|�|td�||kr�t|�|jks@t|�|jkrN|�|||�|jdd�}|jdd�}t|�dkr�|�d�|kr�|dg}|dg}dt||�}dd	�t	�
||��}|�||�}|�|�
||��d
S)z-Assert that two multi-line strings are equal.zFirst argument is not a stringzSecond argument is not a stringT)�keependsrz
r�rrCN)r?r r��_diffThresholdrr*r�rr%r&r'r+rrV)rrrrWZ
firstlinesZsecondlinesrYrrrrr��s �

zTestCase.assertMultiLineEqualcCs2||ks.dt|�t|�f}|�|�||��dS)zCJust like self.assertTrue(a < b), but with a nicer default message.z%s not less than %sNr7�r�a�brWrYrrr�
assertLessszTestCase.assertLesscCs2||ks.dt|�t|�f}|�|�||��dS)zDJust like self.assertTrue(a <= b), but with a nicer default message.z%s not less than or equal to %sNr7rKrrr�assertLessEqualszTestCase.assertLessEqualcCs2||ks.dt|�t|�f}|�|�||��dS)zCJust like self.assertTrue(a > b), but with a nicer default message.z%s not greater than %sNr7rKrrr�
assertGreaterszTestCase.assertGreatercCs2||ks.dt|�t|�f}|�|�||��dS)zDJust like self.assertTrue(a >= b), but with a nicer default message.z"%s not greater than or equal to %sNr7rKrrr�assertGreaterEqual szTestCase.assertGreaterEqualcCs,|dk	r(dt|�f}|�|�||��dS)zCSame as self.assertTrue(obj is None), with a nicer default message.Nz%s is not Noner7�rr*rWrYrrr�assertIsNone&szTestCase.assertIsNonecCs"|dkrd}|�|�||��dS)z(Included for symmetry with assertIsNone.Nzunexpectedly None)rrVrRrrr�assertIsNotNone,szTestCase.assertIsNotNonecCs0t||�s,dt|�|f}|�|�||��dS)zTSame as self.assertTrue(isinstance(obj, cls)), with a nicer
        default message.z%s is not an instance of %rN�r;rrrV�rr*r�rWrYrrrr?2s
zTestCase.assertIsInstancecCs0t||�r,dt|�|f}|�|�||��dS)z,Included for symmetry with assertIsInstance.z%s is an instance of %rNrUrVrrr�assertNotIsInstance9s
zTestCase.assertNotIsInstancecOst|||�}|�d||�S)aAsserts that the message in a raised exception matches a regex.

        Args:
            expected_exception: Exception class expected to be raised.
            expected_regex: Regex (re.Pattern object or string) expected
                    to be found in error message.
            args: Function to be called and extra positional args.
            kwargs: Extra kwargs.
            msg: Optional message used in case of failure. Can only be used
                    when assertRaisesRegex is used as a context manager.
        �assertRaisesRegexr	)rr
r^r.r/rrrrrX?s
zTestCase.assertRaisesRegexcOst|||�}|�d||�S)a�Asserts that the message in a triggered warning matches a regexp.
        Basic functioning is similar to assertWarns() with the addition
        that only warnings whose messages also match the regular expression
        are considered successful matches.

        Args:
            expected_warning: Warning class expected to be triggered.
            expected_regex: Regex (re.Pattern object or string) expected
                    to be found in error message.
            args: Function to be called and extra positional args.
            kwargs: Extra kwargs.
            msg: Optional message used in case of failure. Can only be used
                    when assertWarnsRegex is used as a context manager.
        �assertWarnsRegexr
)rrr^r.r/rrrrrYOszTestCase.assertWarnsRegexcCsVt|ttf�r$|std��t�|�}|�|�sRd|j|f}|�||�}|�	|��dS)z=Fail the test unless the text matches the regular expression.z!expected_regex must not be empty.z&Regex didn't match: %r not found in %rN)
r;r �bytes�AssertionErrorr\r]rprqrVrX)r�textr^rWrYrrr�assertRegexbs

�zTestCase.assertRegexcCs`t|ttf�rt�|�}|�|�}|r\d||��|���|j|f}|�	||�}|�
|��dS)z9Fail the test if the text matches the regular expression.z"Regex matched: %r matches %r in %rN)r;r rZr\r]rp�start�endrqrVrX)rr\Zunexpected_regexrW�matchrYrrr�assertNotRegexns

�zTestCase.assertNotRegexcs�fdd�}|S)Ncs t�d��j�td��||�S)NzPlease use {0} instead.r�)r�r�rlrr�r7��
original_funcrr�deprecated_func~s
�z,TestCase._deprecate.<locals>.deprecated_funcr)rcrdrrbr�
_deprecate}szTestCase._deprecate)r�)N)N)N)N)NN)N)N)N)NNN)NNN)NN)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)errr
rr[rXrr0rJZ_classSetupFailedr�rr�r��__text_signature__�classmethodr�r�r�r�r�r�r�r�r�r�r�r�r�r�r'r(�_subtest_msg_sentinelr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrVrrrrrrrrrr/r+r�r�r�r:r;r=r>r�rDrHr�rNrOrPrQrSrTr?rWrXrYr]rareZfailUnlessEqualZassertEqualsZfailIfEqualZassertNotEqualsZfailUnlessAlmostEqualZassertAlmostEqualsZfailIfAlmostEqualZassertNotAlmostEqualsZ
failUnlessZassert_ZfailUnlessRaisesZfailIfZassertRaisesRegexpZassertRegexpMatchesZassertNotRegexpMatchesrrrrr�ws� 
 


	


E

	


!



	�
-�
#
c


+






 










	r�csjeZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
�ZS)�FunctionTestCaseaIA test case that wraps a test function.

    This is useful for slipping pre-existing test functions into the
    unittest framework. Optionally, set-up and tidy-up functions can be
    supplied. As with TestCase, the tidy-up ('tearDown') function will
    always be called if the set-up ('setUp') function ran successfully.
    Ncs*tt|���||_||_||_||_dSr))�superrir�
_setUpFunc�
_tearDownFunc�	_testFunc�_description)rZtestFuncr�r�Zdescription�r�rrr�s
zFunctionTestCase.__init__cCs|jdk	r|��dSr))rkrirrrr��s
zFunctionTestCase.setUpcCs|jdk	r|��dSr))rlrirrrr��s
zFunctionTestCase.tearDowncCs|��dSr))rmrirrrr��szFunctionTestCase.runTestcCs|jjSr))rmrrirrrr��szFunctionTestCase.idcCs@t||j�stS|j|jko>|j|jko>|j|jko>|j|jkSr))r;r�r�rkrlrmrnr�rrrr��s
�
�
�zFunctionTestCase.__eq__cCstt|�|j|j|j|jf�Sr))r�r<rkrlrmrnrirrrr��s�zFunctionTestCase.__hash__cCsdt|j�|jjfSr�)rr�rmrrirrrr��s
�zFunctionTestCase.__str__cCsdt|j�|jfS)Nz<%s tec=%s>)rr�rmrirrrr��s
�zFunctionTestCase.__repr__cCs2|jdk	r|jS|jj}|r.|�d�d��p0dS)Nr�r)rnrmrr�r�r�rrrr��s
z!FunctionTestCase.shortDescription)NNN)rrr
rrr�r�r�r�r�r�r�r�r��
__classcell__rrrorri�s	ricsDeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z�Z	S)
r�cs(t���||_||_||_|j|_dSr))rjr�_messager#r�rX)rr#r�r�rorrr�s

z_SubTest.__init__cCstd��dS)Nzsubtests cannot be run directly)r rirrrr��sz_SubTest.runTestcCs^g}|jtk	r |�d�|j��|jrPd�dd�|j��D��}|�d�|��d�|�p\dS)Nz[{}]z, css|]\}}d�||�VqdS)z{}={!r}N)rl)rMr�r�rrrrP�s�z+_SubTest._subDescription.<locals>.<genexpr>z({})� z(<subtest>))rqrhrrlr�r%rA)r�partsZparams_descrrr�_subDescription�s

�z_SubTest._subDescriptioncCsd�|j��|���S�Nz{} {})rlr#r�rtrirrrr��sz_SubTest.idcCs
|j��S)zlReturns a one-line description of the subtest, or None if no
        description has been provided.
        )r#r�rirrrr��sz_SubTest.shortDescriptioncCsd�|j|���Sru)rlr#rtrirrrr��sz_SubTest.__str__)
rrr
rr�rtr�r�r�rprrrorr��sr�)4rr!r=r&r�r(r\r�rFr'rmrDrCr�utilrrrrrZ
__unittest�objectrhr1r2r	rrrr+r,r0r5rFrIrJrrLrUr[rhrx�
namedtupler�r�r�r��ChainMapr�r�rir�rrrr�<module>sd(	*%5�,
$:PK��[4')6OO'__pycache__/result.cpython-38.opt-2.pycnu�[���U

e5d�@sXddlZddlZddlZddlmZddlmZdZdd�ZdZ	d	Z
Gd
d�de�ZdS)�N�)�util��wrapsTcst���fdd��}|S)Ncs$t|dd�r|���|f|�|�S)N�failfastF)�getattr�stop)�self�args�kw��method��'/usr/lib64/python3.8/unittest/result.py�inner
szfailfast.<locals>.innerr)r
rrrrrsrz
Stdout:
%sz
Stderr:
%sc@s�eZdZdZdZdZd-dd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
edd��Zedd��Zdd�Zdd�Zdd�Zdd�Zedd ��Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�ZdS).�
TestResultNFcCsbd|_g|_g|_d|_g|_g|_g|_d|_d|_d|_	d|_
d|_tj
|_tj|_d|_dS)NFr)r�failures�errors�testsRun�skipped�expectedFailures�unexpectedSuccesses�
shouldStop�buffer�	tb_locals�_stdout_buffer�_stderr_buffer�sys�stdout�_original_stdout�stderr�_original_stderr�
_mirrorOutput)r	�streamZdescriptions�	verbosityrrr�__init__&szTestResult.__init__cCsdS�Nr�r	rrr�printErrors7szTestResult.printErrorscCs |jd7_d|_|��dS)NrF)rr"�_setupStdout�r	�testrrr�	startTest:szTestResult.startTestcCs8|jr4|jdkr$t��|_t��|_|jt_|jt_dSr&)rr�io�StringIOrrrr r'rrrr)@s


zTestResult._setupStdoutcCsdSr&rr'rrr�startTestRunHszTestResult.startTestRuncCs|��d|_dS)NF)�_restoreStdoutr"r*rrr�stopTestNszTestResult.stopTestcCs�|jr�|jrltj��}tj��}|rF|�d�s6|d7}|j�t	|�|rl|�d�s\|d7}|j
�t|�|jt_|j
t_|j�
d�|j��|j�
d�|j��dS)N�
r)rr"rr�getvaluer �endswithr�write�STDOUT_LINEr!�STDERR_LINEr�seek�truncater)r	�output�errorrrrr0Ss$




zTestResult._restoreStdoutcCsdSr&rr'rrr�stopTestRunhszTestResult.stopTestRuncCs"|j�||�||�f�d|_dS�NT)r�append�_exc_info_to_stringr"�r	r+�errrrr�addErrornszTestResult.addErrorcCs"|j�||�||�f�d|_dSr=)rr>r?r"r@rrr�
addFailurevszTestResult.addFailurecCsZ|dk	rVt|dd�r|��t|d|j�r4|j}n|j}|�||�||�f�d|_dS)NrFrT)	rr�
issubclass�failureExceptionrrr>r?r")r	r+ZsubtestrArrrr�
addSubTest}szTestResult.addSubTestcCsdSr&rr*rrr�
addSuccess�szTestResult.addSuccesscCs|j�||f�dSr&)rr>)r	r+�reasonrrr�addSkip�szTestResult.addSkipcCs|j�||�||�f�dSr&)rr>r?r@rrr�addExpectedFailure�s�zTestResult.addExpectedFailurecCs|j�|�dSr&)rr>r*rrr�addUnexpectedSuccess�szTestResult.addUnexpectedSuccesscCs>t|j�t|j�kodkno<t|d�p<t|j�dkS)Nrr)�lenrr�hasattrrr'rrr�
wasSuccessful�s$�zTestResult.wasSuccessfulcCs
d|_dSr=)rr'rrrr�szTestResult.stopcCs�|\}}}|r |�|�r |j}q
||jkr6|�|�}nd}tj|||||jd�}t|���}|j	r�t
j��}	t
j
��}
|	r�|	�d�s�|	d7}	|�t|	�|
r�|
�d�s�|
d7}
|�t|
�d�|�S)N)�limit�capture_localsr2�)�_is_relevant_tb_level�tb_nextrE�_count_relevant_tb_levels�	traceback�TracebackExceptionr�list�formatrrrr3r r4r>r6r7�join)r	rAr+�exctype�value�tb�lengthZtb_eZmsgLinesr:r;rrrr?�s4

�



zTestResult._exc_info_to_stringcCsd|jjkS)N�
__unittest)�tb_frame�	f_globals)r	r\rrrrR�sz TestResult._is_relevant_tb_levelcCs&d}|r"|�|�s"|d7}|j}q|S)Nrr)rRrS)r	r\r]rrrrT�s
z$TestResult._count_relevant_tb_levelscCs&dt�|j�|jt|j�t|j�fS)Nz!<%s run=%i errors=%i failures=%i>)rZstrclass�	__class__rrLrrr'rrr�__repr__�s
��zTestResult.__repr__)NNN)�__name__�
__module__�__qualname__Z_previousTestClassZ_testRunEnteredZ_moduleSetUpFailedr%r(r,r)r/r1r0r<rrBrCrFrGrIrJrKrNrr?rRrTrbrrrrrs6



	r)
r-rrUrQr�	functoolsrr^rr6r7�objectrrrrr�<module>sPK��[��.z�&�& __pycache__/suite.cpython-38.pycnu�[���U

e5d2�@s|dZddlZddlmZddlmZdZdd�ZGd	d
�d
e�ZGdd�de�Z	Gdd
�d
e�Z
dd�ZGdd�de�ZdS)�	TestSuite�N�)�case)�utilTcCst||dd��}|�dS)NcSsdS�N�rrr�&/usr/lib64/python3.8/unittest/suite.py�<lambda>�z!_call_if_exists.<locals>.<lambda>)�getattr)�parent�attr�funcrrr�_call_if_existssrc@sneZdZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�
BaseTestSuitezNA simple test suite that doesn't provide class or module shared fixtures.
    TrcCsg|_d|_|�|�dS�Nr)�_tests�_removed_tests�addTests)�self�testsrrr�__init__szBaseTestSuite.__init__cCsdt�|j�t|�fS)Nz
<%s tests=%s>)r�strclass�	__class__�list�rrrr�__repr__szBaseTestSuite.__repr__cCs t||j�stSt|�t|�kSr)�
isinstancer�NotImplementedr)r�otherrrr�__eq__szBaseTestSuite.__eq__cCs
t|j�Sr)�iterrrrrr�__iter__"szBaseTestSuite.__iter__cCs$|j}|D]}|r
||��7}q
|Sr)r�countTestCases)rZcases�testrrrr#%s
zBaseTestSuite.countTestCasescCsLt|�std�t|����t|t�r<t|tjt	f�r<td��|j
�|�dS)Nz{} is not callablezNTestCases and TestSuites must be instantiated before passing them to addTest())�callable�	TypeError�format�reprr�type�
issubclassrZTestCaserr�append�rr$rrr�addTest,s�zBaseTestSuite.addTestcCs*t|t�rtd��|D]}|�|�qdS)Nz0tests must be an iterable of tests, not a string)r�strr&r-)rrr$rrrr6s
zBaseTestSuite.addTestscCs8t|�D]*\}}|jrq4||�|jr|�|�q|Sr)�	enumerate�
shouldStop�_cleanup�_removeTestAtIndex)r�result�indexr$rrr�run<szBaseTestSuite.runcCsNz|j|}Wntk
r"Yn(Xt|d�r@|j|��7_d|j|<dS)z2Stop holding a reference to the TestCase at index.r#N)rr&�hasattrrr#)rr4r$rrrr2Es
z BaseTestSuite._removeTestAtIndexcOs|j||�Sr�r5)r�args�kwdsrrr�__call__SszBaseTestSuite.__call__cCs|D]}|��qdS)�7Run the tests without collecting errors in a TestResultN)�debugr,rrrr<VszBaseTestSuite.debugN)r)�__name__�
__module__�__qualname__�__doc__r1rrr r"r#r-rr5r2r:r<rrrrrs

	rc@s^eZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zddd�Z	ddd�Z
dd�Zdd�Zd
S)ra�A test suite is a composite test consisting of a number of TestCases.

    For use, create an instance of TestSuite, then add test case instances.
    When all tests have been added, the suite can be passed to a test
    runner, such as TextTestRunner. It will run the individual test cases
    in the order in which they were added, aggregating the results. When
    subclassing, do not forget to call the base class constructor.
    FcCs�d}t|dd�dkrd|_}t|�D]�\}}|jr8q�t|�r�|�||�|�||�|�||�|j|_	t|jdd�s&t|dd�r�q&|s�||�n|�
�|jr&|�|�q&|r�|�d|�|�
|�d|_|S)NF�_testRunEnteredT�_classSetupFailed�_moduleSetUpFailed)rrAr/r0�_isnotsuite�_tearDownPreviousClass�_handleModuleFixture�_handleClassSetUpr�_previousTestClassr<r1r2�_handleModuleTearDown)rr3r<ZtopLevelr4r$rrrr5fs2

�

z
TestSuite.runcCst�}|�|d�dS)r;TN)�_DebugResultr5)rr<rrrr<�szTestSuite.debugc	Cs2t|dd�}|j}||krdS|jr(dSt|dd�r8dSz
d|_Wntk
rVYnXt|dd�}|dk	�r.t|d�z^z
|�WnNt
k
r�}z0t|t�r��d|_t
�|�}|�	||d|�W5d}~XYnXW5t|d�|jdk�r,|��t|j�dk�r,|jD]}|j	||d	d||d
��qXdS)NrH�__unittest_skip__F�
setUpClass�_setupStdout�_restoreStdoutTrr��info)rrrCrBr&r�doClassCleanups�len�tearDown_exceptions�"_createClassOrModuleLevelException�	ExceptionrrJrr)	rr$r3�
previousClass�currentClassrL�exc�	className�errrrG�sL





�

�zTestSuite._handleClassSetUpcCs"d}t|dd�}|dk	r|j}|S)NrH)rr>)rr3�previousModulerVrrr�_get_previous_module�s
zTestSuite._get_previous_modulec	
Cs|�|�}|jj}||krdS|�|�d|_ztj|}Wntk
rRYdSXt|dd�}|dk	�rt	|d�z�z
|�Wn�t
k
�r}zfzt��Wn2t
k
r�}z|�
||d|�W5d}~XYnXt|t�r�d|_|�
||d|�W5d}~XYnXW5t	|d�XdS)NF�setUpModulerMrNT)r\rr>rIrC�sys�modules�KeyErrorrrrUr�doModuleCleanupsrTrrJ)	rr$r3r[Z
currentModule�moduler]rZrXrrrrF�s>




�
�zTestSuite._handleModuleFixtureNcCs$|�d|�d�}|�||||�dS)Nz (�))�_addClassOrModuleLevelException)rr3rXZmethod_namerrP�	errorNamerrrrT�sz,TestSuite._createClassOrModuleLevelExceptioncCs^t|�}t|dd�}|dk	r8t|tj�r8||t|��n"|sN|�|t���n|�||�dS)N�addSkip)	�_ErrorHolderrrrZSkipTestr.ZaddErrorr^�exc_info)rr3Z	exceptionrerP�errorrfrrrrd�sz)TestSuite._addClassOrModuleLevelExceptioncCs|�|�}|dkrdS|jr dSztj|}Wntk
rDYdSXt|dd�}|dk	�rt|d�zNz
|�Wn>t	k
r�}z t|t�r��|�
||d|�W5d}~XYnXW5t|d�zt��Wn4t	k
�r}z|�
||d|�W5d}~XYnXXdS)N�tearDownModulerMrN)
r\rCr^r_r`rrrrarUrTrrJ)rr3r[rbrjrZrrrrI�s:




�
�zTestSuite._handleModuleTearDownc	Cst|dd�}|j}||krdSt|dd�r.dSt|dd�r>dSt|dd�rNdSt|dd�}|dk	�rt|d�zXz
|�WnHt	k
r�}z*t
|t�r��t�|�}|�||d|�W5d}~XYnXW5t|d�|��t|j�d	k�r|jD]&}t�|�}|j||d
d||d�q�XdS)NrHrBFrCrK�
tearDownClassrMrNrrrO)rrrrQrRrSrrrTrUrrJ)	rr$r3rVrWrkrXrYrZrrrrEsB




�


�z TestSuite._tearDownPreviousClass)F)N)N)
r=r>r?r@r5r<rGr\rFrTrdrIrErrrrr\s	
!($�
�
 c@sTeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�ZdS)rgz�
    Placeholder for a TestCase inside a result. As far as a TestResult
    is concerned, this looks exactly like a unit test. Used to insert
    arbitrary errors into a test suite run.
    NcCs
||_dSr��description)rrmrrrrBsz_ErrorHolder.__init__cCs|jSrrlrrrr�idEsz_ErrorHolder.idcCsdSrrrrrr�shortDescriptionHsz_ErrorHolder.shortDescriptioncCsd|jfS)Nz<ErrorHolder description=%r>rlrrrrrKsz_ErrorHolder.__repr__cCs|��Sr)rnrrrr�__str__Nsz_ErrorHolder.__str__cCsdSrr�rr3rrrr5Qsz_ErrorHolder.runcCs
|�|�Srr7rqrrrr:Vsz_ErrorHolder.__call__cCsdSrrrrrrr#Ysz_ErrorHolder.countTestCases)
r=r>r?r@ZfailureExceptionrrnrorrpr5r:r#rrrrrg6s	rgcCs(zt|�Wntk
r"YdSXdS)z?A crude way to tell apart testcases and suites with duck-typingTF)r!r&)r$rrrrD\s
rDc@seZdZdZdZdZdZdS)rJzCUsed by the TestSuite to hold previous class when running in debug.NF)r=r>r?r@rHrCr0rrrrrJesrJ)
r@r^�rrZ
__unittestr�objectrrrgrDrJrrrr�<module>sL[&	PK��[2B�Z�"�"&__pycache__/suite.cpython-38.opt-2.pycnu�[���U

e5d2�@sxddlZddlmZddlmZdZdd�ZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�Z	dd�Z
Gdd�de�ZdS)�N�)�case)�utilTcCst||dd��}|�dS)NcSsdS�N�rrr�&/usr/lib64/python3.8/unittest/suite.py�<lambda>�z!_call_if_exists.<locals>.<lambda>)�getattr)�parent�attr�funcrrr�_call_if_existssrc@sjeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�
BaseTestSuiteTrcCsg|_d|_|�|�dS�Nr)�_tests�_removed_tests�addTests)�self�testsrrr�__init__szBaseTestSuite.__init__cCsdt�|j�t|�fS)Nz
<%s tests=%s>)r�strclass�	__class__�list�rrrr�__repr__szBaseTestSuite.__repr__cCs t||j�stSt|�t|�kSr)�
isinstancer�NotImplementedr)r�otherrrr�__eq__szBaseTestSuite.__eq__cCs
t|j�Sr)�iterrrrrr�__iter__"szBaseTestSuite.__iter__cCs$|j}|D]}|r
||��7}q
|Sr)r�countTestCases)rZcases�testrrrr"%s
zBaseTestSuite.countTestCasescCsLt|�std�t|����t|t�r<t|tjt	f�r<td��|j
�|�dS)Nz{} is not callablezNTestCases and TestSuites must be instantiated before passing them to addTest())�callable�	TypeError�format�reprr�type�
issubclassrZTestCase�	TestSuiter�append�rr#rrr�addTest,s�zBaseTestSuite.addTestcCs*t|t�rtd��|D]}|�|�qdS)Nz0tests must be an iterable of tests, not a string)r�strr%r-)rrr#rrrr6s
zBaseTestSuite.addTestscCs8t|�D]*\}}|jrq4||�|jr|�|�q|Sr)�	enumerate�
shouldStop�_cleanup�_removeTestAtIndex)r�result�indexr#rrr�run<szBaseTestSuite.runcCsNz|j|}Wntk
r"Yn(Xt|d�r@|j|��7_d|j|<dS)Nr")rr%�hasattrrr")rr4r#rrrr2Es
z BaseTestSuite._removeTestAtIndexcOs|j||�Sr�r5)r�args�kwdsrrr�__call__SszBaseTestSuite.__call__cCs|D]}|��qdSr)�debugr,rrrr;VszBaseTestSuite.debugN)r)�__name__�
__module__�__qualname__r1rrrr!r"r-rr5r2r:r;rrrrrs

	rc@sZeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
d�Zddd�Z	dd�Z
dd�ZdS)r*FcCs�d}t|dd�dkrd|_}t|�D]�\}}|jr8q�t|�r�|�||�|�||�|�||�|j|_	t|jdd�s&t|dd�r�q&|s�||�n|�
�|jr&|�|�q&|r�|�d|�|�
|�d|_|S)NF�_testRunEnteredT�_classSetupFailed�_moduleSetUpFailed)r
r?r/r0�_isnotsuite�_tearDownPreviousClass�_handleModuleFixture�_handleClassSetUpr�_previousTestClassr;r1r2�_handleModuleTearDown)rr3r;ZtopLevelr4r#rrrr5fs2

�

z
TestSuite.runcCst�}|�|d�dS)NT)�_DebugResultr5)rr;rrrr;�szTestSuite.debugc	Cs2t|dd�}|j}||krdS|jr(dSt|dd�r8dSz
d|_Wntk
rVYnXt|dd�}|dk	�r.t|d�z^z
|�WnNt
k
r�}z0t|t�r��d|_t
�|�}|�	||d|�W5d}~XYnXW5t|d�|jdk�r,|��t|j�dk�r,|jD]}|j	||d	d||d
��qXdS)NrF�__unittest_skip__F�
setUpClass�_setupStdout�_restoreStdoutTrr��info)r
rrAr@r%r�doClassCleanups�len�tearDown_exceptions�"_createClassOrModuleLevelException�	ExceptionrrHrr)	rr#r3�
previousClass�currentClassrJ�exc�	className�errrrE�sL





�

�zTestSuite._handleClassSetUpcCs"d}t|dd�}|dk	r|j}|S)NrF)r
r=)rr3�previousModulerTrrr�_get_previous_module�s
zTestSuite._get_previous_modulec	
Cs|�|�}|jj}||krdS|�|�d|_ztj|}Wntk
rRYdSXt|dd�}|dk	�rt	|d�z�z
|�Wn�t
k
�r}zfzt��Wn2t
k
r�}z|�
||d|�W5d}~XYnXt|t�r�d|_|�
||d|�W5d}~XYnXW5t	|d�XdS)NF�setUpModulerKrLT)rZrr=rGrA�sys�modules�KeyErrorr
rrSr�doModuleCleanupsrRrrH)	rr#r3rYZ
currentModule�moduler[rXrVrrrrD�s>




�
�zTestSuite._handleModuleFixtureNcCs$|�d|�d�}|�||||�dS)Nz (�))�_addClassOrModuleLevelException)rr3rVZmethod_namerrN�	errorNamerrrrR�sz,TestSuite._createClassOrModuleLevelExceptioncCs^t|�}t|dd�}|dk	r8t|tj�r8||t|��n"|sN|�|t���n|�||�dS)N�addSkip)	�_ErrorHolderr
rrZSkipTestr.ZaddErrorr\�exc_info)rr3Z	exceptionrcrN�errorrdrrrrb�sz)TestSuite._addClassOrModuleLevelExceptioncCs|�|�}|dkrdS|jr dSztj|}Wntk
rDYdSXt|dd�}|dk	�rt|d�zNz
|�Wn>t	k
r�}z t|t�r��|�
||d|�W5d}~XYnXW5t|d�zt��Wn4t	k
�r}z|�
||d|�W5d}~XYnXXdS)N�tearDownModulerKrL)
rZrAr\r]r^r
rrr_rSrRrrH)rr3rYr`rhrXrrrrG�s:




�
�zTestSuite._handleModuleTearDownc	Cst|dd�}|j}||krdSt|dd�r.dSt|dd�r>dSt|dd�rNdSt|dd�}|dk	�rt|d�zXz
|�WnHt	k
r�}z*t
|t�r��t�|�}|�||d|�W5d}~XYnXW5t|d�|��t|j�d	k�r|jD]&}t�|�}|j||d
d||d�q�XdS)NrFr@FrArI�
tearDownClassrKrLrrrM)r
rrrOrPrQrrrRrSrrH)	rr#r3rTrUrirVrWrXrrrrCsB




�


�z TestSuite._tearDownPreviousClass)F)N)N)r<r=r>r5r;rErZrDrRrbrGrCrrrrr*\s

!($�
�
 r*c@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)reNcCs
||_dSr��description)rrkrrrrBsz_ErrorHolder.__init__cCs|jSrrjrrrr�idEsz_ErrorHolder.idcCsdSrrrrrr�shortDescriptionHsz_ErrorHolder.shortDescriptioncCsd|jfS)Nz<ErrorHolder description=%r>rjrrrrrKsz_ErrorHolder.__repr__cCs|��Sr)rlrrrr�__str__Nsz_ErrorHolder.__str__cCsdSrr�rr3rrrr5Qsz_ErrorHolder.runcCs
|�|�Srr7rorrrr:Vsz_ErrorHolder.__call__cCsdSrrrrrrr"Ysz_ErrorHolder.countTestCases)r<r=r>ZfailureExceptionrrlrmrrnr5r:r"rrrrre6s
recCs(zt|�Wntk
r"YdSXdS)NTF)r r%)r#rrrrB\s
rBc@seZdZdZdZdZdS)rHNF)r<r=r>rFrAr0rrrrrHesrH)r\�rrZ
__unittestr�objectrr*rerBrHrrrr�<module>sL[&	PK��[�1��)__pycache__/__main__.cpython-38.opt-1.pycnu�[���U

e5d��@s`dZddlZejd�d�rBddlZej�ej�Zedejd<[dZ	ddl
m
Z
e
dd�dS)	zMain entry point�Nz__main__.pyz -m unittestT�)�main)�module)�__doc__�sys�argv�endswithZos.path�os�path�basename�
executableZ
__unittestr�r
r
�)/usr/lib64/python3.8/unittest/__main__.py�<module>sPK��[�l%�88%__pycache__/util.cpython-38.opt-2.pycnu�[���U

e5d_�@s�ddlmZmZddlmZdZdZdZdZdZ	dZ
eeee
ee	Zdd�Zd	d
�Z
ddd
�Zdd�Zdd�Zdd�Zdd�Zedd�Zdd�Zdd�ZdS)�)�
namedtuple�Counter)�commonprefixT�P��cCsBt|�||}|tkr>d|d|�||t|�|d�f}|S)Nz%s[%d chars]%s)�len�_PLACEHOLDER_LEN)�s�	prefixlenZ	suffixlen�skip�r
�%/usr/lib64/python3.8/unittest/util.py�_shortens&rcs�ttt|��}ttt|��}|tkr(|St|��t���t|�tt}|t	krxt
�t|��t��fdd�|D��St
�tt	��t��fdd�|D��S)Nc3s|]}�|�d�VqdS�Nr
��.0r
��prefixrr
r�	<genexpr>'sz'_common_shorten_repr.<locals>.<genexpr>c3s&|]}�t|�d�tt�VqdSr)r�
_MIN_DIFF_LEN�_MIN_END_LENrrr
rr*s�)�tuple�map�	safe_repr�maxr�_MAX_LENGTHr�_MIN_BEGIN_LENr	�_MIN_COMMON_LENr)�args�maxlenZ
common_lenr
rr�_common_shorten_reprs ��r!FcCsPzt|�}Wntk
r*t�|�}YnX|r<t|�tkr@|S|dt�dS)Nz [truncated]...)�repr�	Exception�object�__repr__rr)�objZshort�resultr
r
rr-srcCsd|j|jfS)Nz%s.%s)�
__module__�__qualname__)�clsr
r
r�strclass6sr+cCsd}}g}g}z�||}||}||krT|�|�|d7}|||kr�|d7}q<nv||kr�|�|�|d7}|||kr�|d7}qnnD|d7}z|||kr�|d7}q�W5|d7}|||kr�|d7}q�XWqtk
�r|�||d��|�||d��Y�qYqXq||fS�Nr�)�append�
IndexError�extend)�expected�actual�i�j�missingZ
unexpected�e�ar
r
r�sorted_list_difference9s8

r8cCsHg}|r@|��}z|�|�Wqtk
r<|�|�YqXq||fSr)�pop�remove�
ValueErrorr.)r1r2r5�itemr
r
r�unorderable_list_differencebsr=cCs||k||kSrr
)�x�yr
r
r�
three_way_cmpssr@ZMismatchzactual expected valuecCs,t|�t|�}}t|�t|�}}t�}g}t|�D]�\}}	|	|krHq6d}
}t||�D] }|||	krZ|
d7}
|||<qZt|�D] \}}
|
|	kr�|d7}|||<q�|
|kr6t|
||	�}|�|�q6t|�D]X\}}	|	|kr�q�d}t||�D] }|||	kr�|d7}|||<q�td||	�}|�|�q�|Sr,)�listrr$�	enumerate�range�	_Mismatchr.)r2r1r
�t�m�nZNULLr'r3�elem�cnt_s�cnt_tr4Z
other_elem�diffr
r
r�_count_diff_all_purposeys<


rLc	Cs�t|�t|�}}g}|��D]2\}}|�|d�}||krt|||�}|�|�q|��D]&\}}||krZtd||�}|�|�qZ|S)Nr)r�items�getrDr.)	r2r1r
rEr'rHrIrJrKr
r
r�_count_diff_hashable�srON)F)�collectionsrrZos.pathrZ
__unittestrr	rrrrrr!rr+r8r=r@rDrLrOr
r
r
r�<module>s0
���
	)
#PK��[�1��#__pycache__/__main__.cpython-38.pycnu�[���U

e5d��@s`dZddlZejd�d�rBddlZej�ej�Zedejd<[dZ	ddl
m
Z
e
dd�dS)	zMain entry point�Nz__main__.pyz -m unittestT�)�main)�module)�__doc__�sys�argv�endswithZos.path�os�path�basename�
executableZ
__unittestr�r
r
�)/usr/lib64/python3.8/unittest/__main__.py�<module>sPK��[P�<��(__pycache__/signals.cpython-38.opt-1.pycnu�[���U

e5dc	�@sbddlZddlZddlmZdZGdd�de�Ze��Zdd�Z	dd	�Z
dad
d�Zddd
�Z
dS)�N)�wrapsTc@seZdZdd�Zdd�ZdS)�_InterruptHandlercCsNd|_||_t|t�rD|tjkr(tj}n|tjkr<dd�}ntd��||_	dS)NFcSsdS�N�)Z
unused_signumZunused_framerr�(/usr/lib64/python3.8/unittest/signals.py�default_handlersz3_InterruptHandler.__init__.<locals>.default_handlerzYexpected SIGINT signal handler to be signal.SIG_IGN, signal.SIG_DFL, or a callable object)
�called�original_handler�
isinstance�int�signal�SIG_DFL�default_int_handler�SIG_IGN�	TypeErrorr)�selfrrrr�__init__
s



z_InterruptHandler.__init__cCsRt�tj�}||k	r |�||�|jr2|�||�d|_t��D]}|��q@dS)NT)r�	getsignal�SIGINTrr�_results�keys�stop)rZsignum�frameZinstalled_handler�resultrrr�__call__sz_InterruptHandler.__call__N)�__name__�
__module__�__qualname__rrrrrrr	srcCsdt|<dS)N�)r�rrrr�registerResult*sr cCstt�|d��Sr)�boolr�poprrrr�removeResult-sr#cCs.tdkr*t�tj�}t|�at�tjt�dSr)�_interrupt_handlerrrrr)rrrr�installHandler1sr%cs<�dk	r t���fdd��}|Stdk	r8t�tjtj�dS)Nc
s6t�tj�}t�z�||�W�St�tj|�XdSr)rrr�
removeHandler)�args�kwargs�initial��methodrr�inner;s
zremoveHandler.<locals>.inner)rr$rrr	)r+r,rr*rr&9sr&)N)r�weakref�	functoolsrZ
__unittest�objectr�WeakKeyDictionaryrr r#r$r%r&rrrr�<module>s PK��[���vpp%__pycache__/main.cpython-38.opt-1.pycnu�[���U

e5d�+�@stdZddlZddlZddlZddlmZmZddlmZdZ	dZ
dZd	d
�Zdd�Z
d
d�ZGdd�de�ZeZdS)zUnittest main program�N�)�loader�runner)�installHandlerTaExamples:
  %(prog)s test_module               - run tests from test_module
  %(prog)s module.TestClass          - run tests from module.TestClass
  %(prog)s module.Class.test_method  - run specified test method
  %(prog)s path/to/test_file.py      - run tests from test_file.py
aFExamples:
  %(prog)s                           - run default set of tests
  %(prog)s MyTestSuite               - run suite 'MyTestSuite'
  %(prog)s MyTestCase.testSomething  - run MyTestCase.testSomething
  %(prog)s MyTestCase                - run all 'test*' test methods
                                       in MyTestCase
cCsxtj�|�rt|���d�rttj�|�rXtj�|t���}tj�|�sP|�tj	�rT|S|}|dd��
dd��
dd�S|S)Nz.py����\�.�/)�os�path�isfile�lower�endswith�isabs�relpath�getcwd�
startswith�pardir�replace)�nameZrel_path�r�%/usr/lib64/python3.8/unittest/main.py�
_convert_namesrcCsdd�|D�S)NcSsg|]}t|��qSr)r)�.0rrrr�
<listcomp>.sz"_convert_names.<locals>.<listcomp>r)�namesrrr�_convert_names-srcCsd|krd|}|S)N�*z*%s*r)�patternrrr�_convert_select_pattern1src@s�eZdZdZdZdZdZZZZ	Z
ZdZdddde
jddddddfdd�dd	�Zdd
d�Zdd
�Zdd�Zddd�Zdd�Zdd�Zdd�Zdd�Zd dd�Zdd�ZdS)!�TestProgramzA command-line program that runs a set of tests; this is primarily
       for making test modules conveniently executable.
    Nr�__main__TF)�	tb_localscCs�t|t�r<t|�|_|�d�dd�D]}
t|j|
�|_q&n||_|dkrPtj}||_||_	|	|_
||_|
|_||_
|dkr�tjs�d|_n||_||_||_||_tj�|d�|_|�|�|��dS)Nrr�defaultr)�
isinstance�str�
__import__�module�split�getattr�sys�argv�exit�failfast�
catchbreak�	verbosity�bufferr"�warnoptions�warnings�defaultTest�
testRunner�
testLoaderr
r�basename�progName�	parseArgs�runTests)�selfr'r3r+r4r5r,r/r-r.r0r2r"�partrrr�__init__As,


zTestProgram.__init__cCs4|rt|�|jdkr|��|��t�d�dS)N�)�print�_discovery_parser�_initArgParsers�_print_helpr*r,)r:�msgrrr�	usageExitgs
zTestProgram.usageExitcOsZ|jdkr6t|j���ttd|ji�|j��n t|j���ttd|ji�dS)N�prog)	r'r>�_main_parserZformat_help�
MAIN_EXAMPLESr7r?�
print_help�MODULE_EXAMPLES)r:�args�kwargsrrrrAos
zTestProgram._print_helpcCs�|��|jdkrpt|�dkrD|d��dkrD|�|dd��dS|j�|dd�|�|js�|�g�dSn|j�|dd�|�|jr�t|j�|_	t
dkr�d|_n6|jdkr�d|_	n$t|jt
�r�|jf|_	nt|j�|_	|��dS)Nr�discoverr=r!)r@r'�lenr
�
_do_discoveryrE�
parse_args�testsr�	testNames�__name__r3r$r%�list�createTests)r:r+rrrr8xs(


zTestProgram.parseArgscCst|jr|j|j_|r@|dkr"|jn|�}|�|j|j|j�|_n0|jdkr\|j�|j	�|_n|j�
|j|j	�|_dS�N)�testNamePatternsr5rK�startr�top�testrPZloadTestsFromModuler'ZloadTestsFromNames)r:�from_discovery�LoaderrrrrrS�s


�zTestProgram.createTestscCs$|��}|�|�|_|�|�|_dSrT)�_getParentArgParser�_getMainArgParserrE�_getDiscoveryArgParserr?)r:Z
parent_parserrrrr@�szTestProgram._initArgParserscCs�tjdd�}|jddddddd	�|jd
ddddd
d	�|jddddd�|jdkrn|jdddddd�d|_|jdkr�|jdddddd�d|_|jdkr�|jdddddd�d|_|jdkr�|jdd d!td"d#�g|_|S)$NF)Zadd_helpz-vz	--verboser/Zstore_constr=zVerbose output)�dest�actionZconst�helpz-qz--quietrzQuiet outputz--localsr"�
store_truez"Show local variables in tracebacks)r^r_r`z-fz
--failfastr-zStop on first fail or errorz-cz--catchr.z'Catch Ctrl-C and display results so farz-bz--bufferr0z%Buffer stdout and stderr during testsz-krU�appendz.Only run tests which match the given substring)r^r_�typer`)�argparse�ArgumentParser�add_argumentr-r.r0rUr)r:�parserrrrr[�sR
�
��

�

�

�
�zTestProgram._getParentArgParsercCs2tj|gd�}|j|_|j|_|jdddd�|S)N��parentsrOrz?a list of any number of test modules, classes and test methods.)�nargsr`)rdrer7rDrArGrf)r:�parentrgrrrr\�s�zTestProgram._getMainArgParsercCsztj|gd�}d|j|_d|_|jddddd�|jd	d
ddd�|jd
dddd�dD]}|j|dtjtjd�qZ|S)Nrhz%s discoverzcFor test discovery all test modules must be importable from the top level directory of the project.z-sz--start-directoryrVz*Directory to start discovery ('.' default))r^r`z-pz	--patternrz+Pattern to match tests ('test*.py' default)z-tz--top-level-directoryrWz<Top level directory of project (defaults to start directory))rVrrW�?)rjr#r`)rdrer7rDZepilogrfZSUPPRESS)r:rkrg�argrrrr]�s$
�
�
��z"TestProgram._getDiscoveryArgParsercCsLd|_d|_d|_|dk	r:|jdkr,|��|j�||�|jd|d�dS)Nrztest*.pyT)rYrZ)rVrrWr?r@rNrS)r:r+rZrrrrM�s
zTestProgram._do_discoveryc	Cs�|jrt�|jdkrtj|_t|jt�r�zVz"|j|j|j|j	|j
|jd�}Wn.tk
r||j|j|j|j	|j
d�}YnXWq�tk
r�|��}Yq�Xn|j}|�
|j�|_|jr�t�|j���dS)N)r/r-r0r2r")r/r-r0r2)r.rr4rZTextTestRunnerr$rcr/r-r0r2r"�	TypeError�runrX�resultr,r*Z
wasSuccessful)r:r4rrrr9�s2
�
�zTestProgram.runTests)N)FN)N)rQ�
__module__�__qualname__�__doc__r'r/r-r.r0r7r2rUr?rZdefaultTestLoaderr<rCrAr8rSr@r[r\r]rMr9rrrrr 7s6��&
	
#

r )rsr*rdr
�rrZsignalsrZ
__unittestrFrHrrr�objectr �mainrrrr�<module>s	]PK��[���58.8.__pycache__/mock.cpython-38.pycnu�[���U

e5d��@s�dZdZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZddl
mZddlmZmZdd�ee�D�Zd	ZeZd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zd�dd�Zdd�Zdd�Zdd�Z dd �Z!d�d!d"�Z"d#d$�Z#d%d&�Z$d'd(�Z%Gd)d*�d*e&�Z'Gd+d,�d,e&�Z(e(�Z)e)j*Z*e)j+Z,e)j-Z.d-d.d/d0d1d2d3d4hZ/d5d6�Z0Gd7d8�d8e1�Z2d9d:�Z3Gd;d<�d<e&�Z4Gd=d>�d>e&�Z5Gd?d@�d@e5�Z6dAdB�Z7GdCdD�dDe5�Z8GdEdF�dFe8e6�Z9dGdH�Z:dIdJ�Z;GdKdL�dLe&�Z<dMdN�Z=e*dddddfdOdP�Z>d�dQdR�Z?e*dddddfdSdT�Z@GdUdV�dVe&�ZAdWdX�ZBdYdZ�ZCe>e@_&eAe@_De?e@_EeCe@_Fd[e@_Gd\ZHd]ZId^�Jd_d`�eI�K�D��ZLd^�Jdad`�eI�K�D��ZMdbdcdddedfdgdhdidjdkdldmdndodpdqdrdshZNdtdu�ZOdvd�d^�JeHeIeLeMg��K�D�ZPdwdxdyhZQdzhZReQeRBZSePeNBZTeTeSBZUd{d|d}d~dd�d�d�hZVd�d��d�d��d�d��d�d��d��ZWeXeXeXeXd�dddd�d�d	d�dd��
ZYd�d��ZZd�d��Z[d�d��Z\d�d��Z]eZe[e\e]d��Z^d�d��Z_Gd�d��d�e5�Z`Gd�d��d�e`e6�ZaGd�d��d�e`�ZbGd�d��d�e`e9�ZcGd�d��d�e5�ZdGd�d��d�e5�ZeGd�d��d�eeebe9�ZfGd�d��d�e&�Zgeg�Zhd�d��ZiGd�d��d�ej�Zkekdd��Zld�d�d��Zmd�d��ZnGd�d��d�e&�Zoepem�epehjq�fZrdasd�d��Ztd�d�d��ZuGd�d��d�e9�Zvd�d��ZwGd�d��d��ZxdS)�)�Mock�	MagicMock�patch�sentinel�DEFAULT�ANY�call�create_autospec�	AsyncMock�
FILTER_DIR�NonCallableMock�NonCallableMagicMock�	mock_open�PropertyMock�sealz1.0�N)�CodeType�
ModuleType�
MethodType)�	safe_repr)�wraps�partialcCsh|]}|�d�s|�qS��_��
startswith)�.0�name�r�%/usr/lib64/python3.8/unittest/mock.py�	<setcomp>(s
rTcCs>t|�rt|t�sdSt|d�r*t|d�}t�|�p<t�|�S)NF�__func__)	�_is_instance_mock�
isinstancer	�hasattr�getattr�asyncio�iscoroutinefunction�inspectZisawaitable��objrrr�
_is_async_obj0s


r*cCst|dd�rt�|�SdSdS)N�__code__F)r$r%r&��funcrrr�_is_async_func8s
r.cCstt|�t�S�N)�
issubclass�typerr(rrrr!?sr!cCst|t�pt|t�ot|t�Sr/)r"�
BaseExceptionr1r0r(rrr�
_is_exceptionEs
�r3cCs"t|t�rt|d�r|jS|SdS�N�mock)r"�
FunctionTypesr#r5r(rrr�
_extract_mockLsr7cCs�t|t�r|s|j}d}n,t|t�sFz
|j}Wntk
rDYdSX|rVt|d�}n|}z|t�|�fWSt	k
r�YdSXdS)z�
    Given an arbitrary, possibly callable object, try to create a suitable
    signature object.
    Return a (reduced func, signature) tuple, or None.
    TN)
r"r1�__init__r6�__call__�AttributeErrorrr'�	signature�
ValueError)r-Zas_instanceZeat_selfZsig_funcrrr�_get_signature_objectUs

r=FcsNt|||���dkrdS�\}��fdd�}t||�|t|�_�t|�_dS)Ncs�j||�dSr/��bind��self�args�kwargs��sigrr�checksigwsz"_check_signature.<locals>.checksig)r=�_copy_func_detailsr1�_mock_check_sig�
__signature__)r-r5�	skipfirst�instancerFrrDr�_check_signaturers

rLc	Cs:dD]0}zt||t||��Wqtk
r2YqXqdS)N)�__name__�__doc__�__text_signature__�
__module__�__defaults__�__kwdefaults__)�setattrr$r:)r-�funcopy�	attributerrrrG~s
rGcCs@t|t�rdSt|tttf�r(t|j�St|dd�dk	r<dSdS)NTr9F)r"r1�staticmethod�classmethodr�	_callabler r$r(rrrrX�s

rXcCst|�ttfkSr/)r1�list�tupler(rrr�_is_list�sr[cCsFt|t�st|dd�dk	S|f|jD]}|j�d�dk	r&dSq&dS)ztGiven an object, return True if the object is callable.
    For classes, return True if instances would be callable.r9NTF)r"r1r$�__mro__�__dict__�get)r)�baserrr�_instance_callable�s
r`cs�t|t�}t|||�}|dkr"|S|\}��fdd�}t||�|j}|��sRd}||d�}d|}	t|	|�||}
t|
|��|
S)Ncs�j||�dSr/r>�rBrCrDrrrF�sz _set_signature.<locals>.checksigrT)Z
_checksig_r5zYdef %s(*args, **kwargs):
    _checksig_(*args, **kwargs)
    return mock(*args, **kwargs))r"r1r=rGrM�isidentifier�exec�_setup_func)r5�originalrKrJ�resultr-rFr�context�srcrTrrDr�_set_signature�s$


�
rics���_�fdd�}�fdd�}�fdd�}�fdd�}�fd	d
�}�fdd�}�fd
d�}	��fdd�}
d�_d�_d�_t��_t��_t��_�j�_�j	�_	�j
�_
|�_|�_|�_
|	�_|
�_|�_|�_|�_|�_��_dS)Ncs�j||�Sr/)�assert_called_withra�r5rrrj�sz'_setup_func.<locals>.assert_called_withcs�j||�Sr/)�
assert_calledrarkrrrl�sz"_setup_func.<locals>.assert_calledcs�j||�Sr/)�assert_not_calledrarkrrrm�sz&_setup_func.<locals>.assert_not_calledcs�j||�Sr/)�assert_called_oncerarkrrrn�sz'_setup_func.<locals>.assert_called_oncecs�j||�Sr/)�assert_called_once_withrarkrrro�sz,_setup_func.<locals>.assert_called_once_withcs�j||�Sr/)�assert_has_callsrarkrrrp�sz%_setup_func.<locals>.assert_has_callscs�j||�Sr/)�assert_any_callrarkrrrq�sz$_setup_func.<locals>.assert_any_callcs:t��_t��_����j}t|�r6|�k	r6|��dSr/)�	_CallList�method_calls�
mock_calls�
reset_mock�return_valuer!)�ret�rTr5rrru�sz_setup_func.<locals>.reset_mockFr)r5�called�
call_count�	call_argsrr�call_args_listrsrtrv�side_effect�_mock_childrenrjrorprqrurlrmrnrI�_mock_delegate)rTr5rErjrlrmrnrorprqrurrxrrd�s8rdcsJtjj�_d�_d�_t��_�fdd�}dD]}t�|t||��q.dS)Nrcst�j|�||�Sr/)r$r5)�attrrBrCrkrr�wrapper�sz"_setup_async_mock.<locals>.wrapper)�assert_awaited�assert_awaited_once�assert_awaited_with�assert_awaited_once_with�assert_any_await�assert_has_awaits�assert_not_awaited)	r%�
coroutines�
_is_coroutine�await_count�
await_argsrr�await_args_listrSr)r5r�rUrrkr�_setup_async_mock�s
r�cCsd|dd�|kS)N�__%s__����r�rrrr�	_is_magicsr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_SentinelObjectz!A unique, named, sentinel object.cCs
||_dSr/r��rArrrrr8sz_SentinelObject.__init__cCs
d|jS�Nzsentinel.%sr��rArrr�__repr__sz_SentinelObject.__repr__cCs
d|jSr�r�r�rrr�
__reduce__sz_SentinelObject.__reduce__N)rMrP�__qualname__rNr8r�r�rrrrr�sr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�	_SentinelzAAccess attributes to return a named object, usable as a sentinel.cCs
i|_dSr/)�
_sentinelsr�rrrr8#sz_Sentinel.__init__cCs|dkrt�|j�|t|��S)N�	__bases__)r:r��
setdefaultr�r�rrr�__getattr__&sz_Sentinel.__getattr__cCsdS)Nrrr�rrrr�,sz_Sentinel.__reduce__N)rMrPr�rNr8r�r�rrrrr�!sr�rv�_mock_return_valuer}�_mock_side_effect�_mock_parent�_mock_new_parent�
_mock_name�_mock_new_namecCs8t�|�d|}||fdd�}||fdd�}t||�S)NZ_mock_cSs"|j}|dkrt||�St||�Sr/)rr$)rAr�	_the_namerErrr�_getAs
z"_delegating_property.<locals>._getcSs*|j}|dkr||j|<nt|||�dSr/)rr]rS)rA�valuerr�rErrr�_setFsz"_delegating_property.<locals>._set)�_allowed_names�add�property)rr�r�r�rrr�_delegating_property>s

r�c@seZdZdd�Zdd�ZdS)rrcCslt|t�st�||�St|�}t|�}||kr2dStd||d�D]"}||||�}||krDdSqDdS)NFr�T)r"rY�__contains__�len�range)rAr�Z	len_valueZlen_self�iZsub_listrrrr�Ss
z_CallList.__contains__cCst�t|��Sr/)�pprintZpformatrYr�rrrr�asz_CallList.__repr__N)rMrPr�r�r�rrrrrrQsrrcCs|t|�}t|�sdS|js4|js4|jdk	s4|jdk	r8dS|}|dk	rX||krPdS|j}q<|rh||_||_|rx||_||_dS)NFT)r7r!r�r�r�r�)�parentr�r�new_name�_parentrrr�_check_and_set_parentes*��r�c@seZdZdd�Zdd�ZdS)�	_MockItercCst|�|_dSr/)�iterr))rAr)rrrr8�sz_MockIter.__init__cCs
t|j�Sr/)�nextr)r�rrr�__next__�sz_MockIter.__next__N)rMrPr�r8r�rrrrr��sr�c@seZdZeZdZdd�ZdS)�BaseNcOsdSr/rr@rrrr8�sz
Base.__init__)rMrPr�rr�r�r8rrrrr��sr�c@sdeZdZdZdd�ZdLdd�Zd	d
�ZdMdd�ZdNd
d�Zdd�Z	dd�Z
dZee	e
e�Z
edd��Zed�Zed�Zed�Zed�Zed�Zdd�Zdd�Zeee�ZdOddd�d d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Z dPd3d4�Z!d5d6�Z"d7d8�Z#d9d:�Z$d;d<�Z%d=d>�Z&d?d@�Z'dAdB�Z(dQdCdD�Z)dEdF�Z*dGdH�Z+dRdJdK�Z,dS)Srz A non-callable version of `Mock`c	Os�|f}t|t�s^t�tj�}|j|f|�|�j}dd�|��D�}|r^t	||d�r^t
|f}t|j|d|j
i�}tt|��|�}|S)NcSsg|]}|�d�r|�qS��specr�r�argrrr�
<listcomp>�s
�z+NonCallableMock.__new__.<locals>.<listcomp>rrN)r0r	r'r;rr8Zbind_partialZ	arguments�keysr*�AsyncMockMixinr1rMrN�_safe_super�__new__)	�clsrB�kw�basesrEZ
bound_argsZspec_arg�newrKrrrr��s
�zNonCallableMock.__new__N�FcKs�|dkr|}|j}
||
d<||
d<||
d<||
d<d|
d<|dk	rJ|}d}|
dkrZ|dk	}
|�|||	|
�i|
d<||
d	<d|
d
<d|
d<d|
d<d
|
d<t�|
d<t�|
d<t�|
d<||
d<|r�|jf|�tt|��||||||�dS)Nr�r�r�r�F�_mock_sealedTr~�_mock_wrapsrZ_mock_calledZ_mock_call_argsrZ_mock_call_countZ_mock_call_args_listZ_mock_mock_callsrs�_mock_unsafe)r]�_mock_add_specrr�configure_mockr�rr8)rAr�rr�spec_setr��_spec_state�	_new_name�_new_parent�_spec_as_instance�	_eat_selfZunsaferCr]rrrr8�sD



�zNonCallableMock.__init__cCs0t|�}d|_d|_d|_d|_t|||�dS)z�
        Attach a mock as an attribute of this one, replacing its name and
        parent. Calls to the attached mock will be recorded in the
        `method_calls` and `mock_calls` attributes of this one.Nr�)r7r�r�r�r�rS)rAr5rUZ
inner_mockrrr�attach_mock�szNonCallableMock.attach_mockcCs|�||�dS�z�Add a spec to a mock. `spec` can either be an object or a
        list of strings. Only attributes on the `spec` can be fetched as
        attributes from the mock.

        If `spec_set` is True then only attributes on the spec can be set.N)r��rAr�r�rrr�
mock_add_spec�szNonCallableMock.mock_add_speccCs�d}d}g}t|�D] }t�t||d��r|�|�q|dk	r~t|�s~t|t�rV|}nt|�}t|||�}	|	ot|	d}t|�}|j	}
||
d<||
d<||
d<||
d<||
d<dS)Nr��_spec_class�	_spec_set�_spec_signature�
_mock_methods�_spec_asyncs)
�dirr%r&r$�appendr[r"r1r=r])rAr�r�r�r�r�r�r�r��resr]rrrr��s,
�zNonCallableMock._mock_add_speccCs8|j}|jdk	r|jj}|tkr4|j|dd�}||_|S)N�()�r�r�)r�rrvr�_get_child_mock)rArwrrrZ__get_return_values
�z"NonCallableMock.__get_return_valuecCs,|jdk	r||j_n||_t||dd�dS)Nr�)rrvr�r�)rAr�rrrZ__set_return_values

z"NonCallableMock.__set_return_valuez1The value to be returned when the mock is called.cCs|jdkrt|�S|jSr/)r�r1r�rrr�	__class__!s
zNonCallableMock.__class__ryrzr{r|rtcCsN|j}|dkr|jS|j}|dk	rJt|�sJt|t�sJt|�sJt|�}||_|Sr/)rr�r}�callabler"r�r3)rA�	delegatedZsfrrrZ__get_side_effect.s��z!NonCallableMock.__get_side_effectcCs(t|�}|j}|dkr||_n||_dSr/)�	_try_iterrr�r})rAr�r�rrrZ__set_side_effect9s
z!NonCallableMock.__set_side_effect)rvr}cCs�|dkrg}t|�|krdS|�t|��d|_d|_d|_t�|_t�|_t�|_|r^t	|_
|rhd|_|j�
�D]"}t|t�sr|tkr�qr|�|�qr|j
}t|�r�||k	r�|�|�dS)z-Restore the mock object to its initial state.NFr)�idr�ryr{rzrrrtr|rsrr�r�r~�valuesr"�
_SpecState�_deletedrur!)rAZvisitedrvr}�childrwrrrruDs,zNonCallableMock.reset_mockcKsXt|��dd�d�D]>\}}|�d�}|��}|}|D]}t||�}q6t|||�qdS)aZSet attributes on the mock through keyword arguments.

        Attributes plus return values and side effects can be set on child
        mocks using standard dot notation and unpacking a dictionary in the
        method call:

        >>> attrs = {'method.return_value': 3, 'other.side_effect': KeyError}
        >>> mock.configure_mock(**attrs)cSs|d�d�S)Nr�.)�count)�entryrrr�<lambda>o�z0NonCallableMock.configure_mock.<locals>.<lambda>)�keyr�N)�sorted�items�split�popr$rS)rArCr��valrB�finalr)r�rrrr�bs	�
zNonCallableMock.configure_mockcCs�|dkrt|��n:|jdk	r<||jks.|tkrLtd|��nt|�rLt|��|jsd|�d�rdtd��|j�|�}|tkr�t|��np|dkr�d}|j	dk	r�t
|j	|�}|j|||||d�}||j|<n.t|t
�r�t|j|j|j|j|j�}||j|<|S)N>r�r�zMock object has no attribute %r)�assertZassretz1Attributes cannot start with 'assert' or 'assret')r�rrr�r�)r:r��_all_magicsr�r�rr~r^r�r�r$r�r"r�rr�r�rKr�r)rArrfrrrrr�xsF




�
�
zNonCallableMock.__getattr__cCs�|jg}|j}|}d}|dgkr$d}|dk	rZ|}|�|j|�d}|jdkrRd}|j}q$tt|��}|jpnd}t|�dkr�|ddkr�|d7}||d<d�|�S)Nr�r�r�r5r�)r�z().r)r�r�r�rY�reversedr�r��join)rAZ
_name_listr�Zlast�dotZ_firstrrr�_extract_mock_name�s(


z"NonCallableMock._extract_mock_namecCs^|��}d}|dkrd|}d}|jdk	rDd}|jr8d}||jj}dt|�j||t|�fS)Nr�)r5zmock.z name=%rz spec=%rz spec_set=%rz<%s%s%s id='%s'>)r�r�r�rMr1r�)rArZname_stringZspec_stringrrrr��s 
�zNonCallableMock.__repr__cCsvtst�|�S|jpg}tt|��}t|j�}dd�|j�	�D�}dd�|D�}dd�|D�}t
t||||��S)z8Filter the output of `dir(mock)` to only useful members.cSsg|]\}}|tk	r|�qSr)r�)rZm_nameZm_valuerrrr��s�z+NonCallableMock.__dir__.<locals>.<listcomp>cSsg|]}|�d�s|�qSrr�r�errrr��s
cSs"g|]}|�d�rt|�r|�qSr)rr�rrrrr��s
�)r
�object�__dir__r�r�r1rYr]r~r�r��set)rAZextrasZ	from_typeZ	from_dictZfrom_child_mocksrrrr�s


�zNonCallableMock.__dir__csT|tkrt��||�S�jrH�jdk	rH|�jkrH|�jkrHtd|��n�|tkrbd|}t|��n�|tkr�jdk	r�|�jkr�td|��t	|�s�t
t��|t||��|���fdd�}n(t
�|d|�t
t��||�|�j|<n,|dkr�|�_dSt
�|||��r|�j|<�j�rFt�|��sF����d|��}td|����t��||�S)Nz!Mock object has no attribute '%s'z.Attempting to set unsupported magic method %r.cs��f|�|�Sr/r�rBr��rerArrr��r�z-NonCallableMock.__setattr__.<locals>.<lambda>r�r�zCannot set )r�r�__setattr__r�r�r]r:�_unsupported_magicsr�r!rSr1�_get_methodr�r~r�r�r#r�)rArr��msg�	mock_namerrrr�s<��

zNonCallableMock.__setattr__cCs�|tkr2|t|�jkr2tt|�|�||jkr2dS|j�|t�}||jkr\tt|��	|�n|t
krlt|��|tk	r||j|=t
|j|<dSr/)r�r1r]�delattrr~r^�_missingr�r�__delattr__r�r:)rArr)rrrrs

zNonCallableMock.__delattr__cCs|jpd}t|||�Sr4)r��_format_call_signature�rArBrCrrrr�_format_mock_call_signatures
z+NonCallableMock._format_mock_call_signaturercCs.d}|�||�}|j}|j|�}||||fS)Nz.expected %s not found.
Expected: %s
Actual: %s)rr{)rArBrC�action�message�expected_stringr{Z
actual_stringrrr�_format_mock_failure_messages

z,NonCallableMock._format_mock_failure_messagecCsj|s
|jSd}|�dd��d�}|j}|D]:}|�|�}|dksJt|t�rPqfq*t|�}|j}|j}q*|S)aH
        * If call objects are asserted against a method/function like obj.meth1
        then there could be no name for the call object to lookup. Hence just
        return the spec_signature of the method/function being asserted against.
        * If the name is not empty then remove () and split by '.' to get
        list of names to iterate through the children until a potential
        match is found. A child mock is created only during attribute access
        so if we get a _SpecState then no attributes of the spec were accessed
        and can be safely exited.
        Nr�r�r�)r��replacer�r~r^r"r�r7)rArrE�namesZchildrenr�rrr�_get_call_signature_from_name's
z-NonCallableMock._get_call_signature_from_namec
Cs�t|t�r&t|�dkr&|�|d�}n|j}|dk	r�t|�dkrNd}|\}}n
|\}}}z||j||�fWStk
r�}z|�d�WY�Sd}~XYq�Xn|SdS)a
        Given a call (or simply an (args, kwargs) tuple), return a
        comparison key suitable for matching with other calls.
        This is a best effort method which relies on the spec's signature,
        if available, or falls back on the arguments themselves.
        r�rNr�)r"rZr�rr�r?�	TypeError�with_traceback)rA�_callrErrBrCrrrr�
_call_matcherHs

"zNonCallableMock._call_matchercCs0|jdkr,d|jpd|j|��f}t|��dS)z/assert that the mock was never called.
        rz9Expected '%s' to not have been called. Called %s times.%sr5N�rzr��_calls_repr�AssertionError�rAr
rrrrmbs
��z!NonCallableMock.assert_not_calledcCs$|jdkr d|jpd}t|��dS)z6assert that the mock was called at least once
        rz"Expected '%s' to have been called.r5N)rzr�rr rrrrlls

�zNonCallableMock.assert_calledcCs0|jdks,d|jpd|j|��f}t|��dS)z3assert that the mock was called only once.
        r�z:Expected '%s' to have been called once. Called %s times.%sr5Nrr rrrrnts
��z"NonCallableMock.assert_called_oncecs��jdkr.�����}d}d||f}t|�����fdd�}����f�}���j�}||kr~t|t�rn|nd}t|��|�dS)z�assert that the last call was made with the specified arguments.

        Raises an AssertionError if the args and keyword args passed in are
        different to the last call to the mock.Nznot called.z0expected call not found.
Expected: %s
Actual: %scs�����}|Sr/�r�r
�rBrCrArr�_error_message�sz:NonCallableMock.assert_called_with.<locals>._error_message)r{rrrr"�	Exception)rArBrC�expected�actualZ
error_messager$�causerr#rrj~s
�z"NonCallableMock.assert_called_withcOs8|jdks,d|jpd|j|��f}t|��|j||�S)ziassert that the mock was called exactly once and that that call was
        with the specified arguments.r�z3Expected '%s' to be called once. Called %s times.%sr5)rzr�rrrj�rArBrCr
rrrro�s
��z'NonCallableMock.assert_called_once_withc		s�fdd�|D�}tdd�|D�d�}t�fdd��jD��}|s�||kr�|dkrXd}nd�d	d�|D��}t|�d
t|���jdd��d
����|�dSt|�}g}|D]2}z|�|�Wq�t	k
r�|�
|�Yq�Xq�|�rtd�jp�dt|�|f�|�dS)a�assert the mock has been called with the specified calls.
        The `mock_calls` list is checked for the calls.

        If `any_order` is False (the default) then the calls must be
        sequential. There can be extra calls before or after the
        specified calls.

        If `any_order` is True then the calls can be in any order, but
        they must all appear in `mock_calls`.csg|]}��|��qSr�r�r�cr�rrr��sz4NonCallableMock.assert_has_calls.<locals>.<listcomp>css|]}t|t�r|VqdSr/�r"r%rrrr�	<genexpr>�s
z3NonCallableMock.assert_has_calls.<locals>.<genexpr>Nc3s|]}��|�VqdSr/r*r+r�rrr.�szCalls not found.z+Error processing expected calls.
Errors: {}cSsg|]}t|t�r|nd�qSr/r-rrrrr��s��
Expected: ZActual)�prefixr�z@%r does not contain all of %r in its call list, found %r insteadr5)
r�rrrt�formatrr�rstriprY�remover<r�r�rZ)	rA�calls�	any_orderr&r(Z	all_calls�problem�	not_found�kallrr�rrp�sH
��"������z NonCallableMock.assert_has_callscsZ��||f�}�fdd��jD�}||krVt|t�r8|nd}��||�}td|�|�dS)z�assert the mock has been called with the specified arguments.

        The assert passes if the mock has *ever* been called, unlike
        `assert_called_with` and `assert_called_once_with` that only pass if
        the call is the most recent one.csg|]}��|��qSrr*r+r�rrr��sz3NonCallableMock.assert_any_call.<locals>.<listcomp>Nz%s call not found)rr|r"r%rr�rArBrCr&r'r(rrr�rrq�s��zNonCallableMock.assert_any_callcKs�|�d�}||jdkr"tf|�St|�}t|t�rB|tkrBt}nbt|t�rp|tksd|j	rj||j	krjt}q�t}n4t|t
�s�t|t�r�t}q�t|t�r�t
}n
|jd}|jr�d|kr�d|dnd}|��|}t|��|f|�S)aPCreate the child mocks for attributes and return value.
        By default child mocks will be the same type as the parent.
        Subclasses of Mock may want to override this to customize the way
        child mocks are made.

        For non-callable mocks the callable variant will be used (rather than
        any custom subclass).r�r�r�rr�r�)r^r]r	r1r0r�_async_method_magicsr��_all_sync_magicsr��
CallableMixinrrrr\r�r�r:)rAr�r��_type�klassrUrrrrr��s2


��



zNonCallableMock._get_child_mock�CallscCs"|js
dSd|�dt|j��d�S)z�Renders self.mock_calls as a string.

        Example: "
Calls: [call(1), call(2)]."

        If self.mock_calls is empty, an empty string is returned. The
        output will be truncated if very long.
        r��
z: r�)rtr)rAr0rrrrszNonCallableMock._calls_repr)NNNNNNr�NFNF)F)FF)N)r)F)r?)-rMrPr�rNr�r8r�r�r�Z"_NonCallableMock__get_return_valueZ"_NonCallableMock__set_return_valueZ"_NonCallableMock__return_value_docr�rvr�r�ryrzr{r|rtZ!_NonCallableMock__get_side_effectZ!_NonCallableMock__set_side_effectr}rur�r�r�r�rrrrrrrrmrlrnrjrorprqr�rrrrrr�sp�
-
	�

�

''
!


-'rcCsL|dkr|St|�r|St|�r$|Sz
t|�WStk
rF|YSXdSr/)r3rXr�rr(rrrr�s
r�c
@sReZdZddedddddddf
dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)r<Nr�c	Ks6||jd<tt|�j|||||||	|
f|�||_dS)Nr�)r]r�r<r8r})rAr�r}rvrrr�r�r�r�r�rCrrrr8#s

��zCallableMixin.__init__cOsdSr/rr@rrrrH/szCallableMixin._mock_check_sigcOs$|j||�|j||�|j||�Sr/)rH�_increment_mock_call�
_mock_callr@rrrr94szCallableMixin.__call__cOs|j||�Sr/)�_execute_mock_callr@rrrrB<szCallableMixin._mock_callcOsd|_|jd7_t||fdd�}||_|j�|�|jdk	}|j}|j}|dk}|j	�td||f��|j
}|dk	r�|r�|j�t|||f��|jdk	}|r�|jd|}t|||f�}	|j	�|	�|jr�|r�d}
nd}
|jdk}|j|
|}|j
}qpdS)NTr���twor�r�r�)ryrz�_Callr{r|r�r�r�r�rtr�rs)rArBrCrZdo_method_callsZmethod_call_nameZmock_call_nameZ	is_a_callr�Zthis_mock_callr�rrrrA?s4


z"CallableMixin._increment_mock_callcOs||j}|dk	rPt|�r|�n(t|�s:t|�}t|�rD|�n
|||�}|tk	rP|S|jtk	r`|jS|jdk	rv|j||�S|jSr/)r}r3rXr�rr�rvr�)rArBrC�effectrfrrrrCms 


z CallableMixin._execute_mock_call)
rMrPr�rr8rHr9rBrArCrrrrr<!s�
.r<c@seZdZdZdS)ra�	
    Create a new `Mock` object. `Mock` takes several optional arguments
    that specify the behaviour of the Mock object:

    * `spec`: This can be either a list of strings or an existing object (a
      class or instance) that acts as the specification for the mock object. If
      you pass in an object then a list of strings is formed by calling dir on
      the object (excluding unsupported magic attributes and methods). Accessing
      any attribute not in this list will raise an `AttributeError`.

      If `spec` is an object (rather than a list of strings) then
      `mock.__class__` returns the class of the spec object. This allows mocks
      to pass `isinstance` tests.

    * `spec_set`: A stricter variant of `spec`. If used, attempting to *set*
      or get an attribute on the mock that isn't on the object passed as
      `spec_set` will raise an `AttributeError`.

    * `side_effect`: A function to be called whenever the Mock is called. See
      the `side_effect` attribute. Useful for raising exceptions or
      dynamically changing return values. The function is called with the same
      arguments as the mock, and unless it returns `DEFAULT`, the return
      value of this function is used as the return value.

      If `side_effect` is an iterable then each call to the mock will return
      the next value from the iterable. If any of the members of the iterable
      are exceptions they will be raised instead of returned.

    * `return_value`: The value returned when the mock is called. By default
      this is a new Mock (created on first access). See the
      `return_value` attribute.

    * `wraps`: Item for the mock object to wrap. If `wraps` is not None then
      calling the Mock will pass the call through to the wrapped object
      (returning the real result). Attribute access on the mock will return a
      Mock object that wraps the corresponding attribute of the wrapped object
      (so attempting to access an attribute that doesn't exist will raise an
      `AttributeError`).

      If the mock has an explicit `return_value` set then calls are not passed
      to the wrapped object and the `return_value` is returned instead.

    * `name`: If the mock has a name then it will be used in the repr of the
      mock. This can be useful for debugging. The name is propagated to child
      mocks.

    Mocks can also be called with arbitrary keyword arguments. These will be
    used to set attributes on the mock after it is created.
    N�rMrPr�rNrrrrr�srcCs8zt||�WStk
r2t|�t||�YSXdSr/)r$r:�
__import__)�thing�comp�import_pathrrr�_dot_lookup�s
rMcCsB|�d�}|�d�}t|�}|D]}|d|7}t|||�}q |S)Nr�rz.%s)r�r�rIrM)�targetZ
componentsrLrJrKrrr�	_importer�s

rOc@szeZdZdZgZdd�Zdd�Zdd�Zdd	�Ze	j
d
d��Zdd
�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS)�_patchNc

Csn|dk	r(|tk	rtd��|dk	r(td��||_||_||_||_||_||_d|_||_	||_
|	|_g|_dS)Nz,Cannot use 'new' and 'new_callable' togetherz1Cannot use 'autospec' and 'new_callable' togetherF)
rr<�getterrUr��new_callabler��createZ	has_localr��autospecrC�additional_patchers)
rArQrUr�r�rSr�rTrRrCrrrr8�s(��z_patch.__init__c
CsHt|j|j|j|j|j|j|j|j|j	�	}|j
|_
dd�|jD�|_|S)NcSsg|]}|���qSr)�copy)r�prrrr��sz_patch.copy.<locals>.<listcomp>)rPrQrUr�r�rSr�rTrRrC�attribute_namerU)rA�patcherrrrrV�s ��z_patch.copycCs2t|t�r|�|�St�|�r(|�|�S|�|�Sr/)r"r1�decorate_classr'r&�decorate_async_callable�decorate_callable�rAr-rrrr9�s




z_patch.__call__cCsNt|�D]@}|�tj�sqt||�}t|d�s0q|��}t||||��q|S�Nr9)r�rr�TEST_PREFIXr$r#rVrS)rAr>r��
attr_valuerYrrrrZs

z_patch.decorate_classc	csrg}t���\}|jD]8}|�|�}|jdk	r8|�|�q|jtkr|�|�q|t	|�7}||fVW5QRXdSr/)
�
contextlib�	ExitStack�	patchings�
enter_contextrX�updater�rr�rZ)rA�patchedrB�keywargs�
extra_args�
exit_stack�patchingr�rrr�decoration_helpers




z_patch.decoration_helpercs>t�d�r�j����St�����fdd����g�_�S)Nrcc
s4���||��\}}�||�W5QR�SQRXdSr/�rk�rBrgZnewargsZnewkeywargs�r-rfrArrrf(s�z)_patch.decorate_callable.<locals>.patched�r#rcr�rr]rrnrr\"s
z_patch.decorate_callablecs>t�d�r�j����St�����fdd����g�_�S)Nrcc
�s:���||��"\}}�||�IdHW5QR�SQRXdSr/rlrmrnrrrf9s�z/_patch.decorate_async_callable.<locals>.patchedror]rrnrr[3s
z_patch.decorate_async_callablec	Cs�|��}|j}t}d}z|j|}Wn$ttfk
rHt||t�}YnXd}|tkrft|t	�rfd|_
|j
s�|tkr�td||f��||fS)NFTz!%s does not have the attribute %r)rQrUrr]r:�KeyErrorr$�	_builtinsr"rrS)rArNrre�localrrr�get_originalDs 
�z_patch.get_originalcCs�|j|j|j}}}|j|j}}|j}|��|_|dkr@d}|dkrLd}|dkrXd}|dk	rp|dk	rptd��|dk	s�|dk	r�|dkr�td��|�	�\}}|t
k�r||dk�r|d}	|dkr�|}|dkr�|}d}n&|dk	r�|dkr�|}d}n|dkr�|}|dk	�s|dk	�r.|t
k�rtd��t|t��r.d}	|dk�rHt
|��rHt}
nt}
i}|dk	�r`|}
n^|dk	�st|dk	�r�|}|dk	�r�|}t|��r�d|k}
n
t|�}
t
|��r�t}
n
|
�r�t}
|dk	�r�||d	<|dk	�r�||d
<t|
t��rt|
t��r|j�r|j|d<|�|�|
f|�}|	�r�t|��r�|}|dk	�rB|}t|��sZt|��sZt}
|�d�|
f|dd
�|��|_nl|dk	�r�|t
k	�r�td��|t
k�r�td��t|�}|dk�r�|}t|f||jd�|��}n|�r�td��|}||_||_t� �|_!zrt"|j|j|�|j#dk	�rpi}|jt
k�r:|||j#<|j$D](}|j!�%|�}|jt
k�r@|�|��q@|WS|WS|j&t'�(���s��YnXdS)zPerform the patch.FNzCan't specify spec and autospec)TNz6Can't provide explicit spec_set *and* spec or autospecTz!Can't use 'spec' with create=Truer9r�r�rr�r�zBautospec creates the mock for you. Can't specify autospec and new.z%Can't use 'autospec' with create=True)r��_namez.Can't pass kwargs to a mock we aren't creating))r�r�r�rTrCrRrQrNrrsrr"r1r*r	rr[r�rr0rrUrer!r`r�rv�boolr�
temp_original�is_localrarb�_exit_stackrSrXrUrd�__exit__�sys�exc_info)rAr�r�r�rTrCrRrerrZinherit�Klass�_kwargsZ	this_specZnot_callableZnew_attrrhrjr�rrr�	__enter__\s�
�








��




�
�


�

��


z_patch.__enter__cGs�|jr$|jtk	r$t|j|j|j�n>t|j|j�|jsbt|j|j�rP|jdkrbt|j|j|j�|`|`|`|j	}|`	|j
|�S)zUndo the patch.)rNrPrQ�__annotations__rR)rwrvrrSrNrUrrSr#rxry)rAr{rirrrry�s�z_patch.__exit__cCs|��}|j�|�|S)z-Activate a patch, returning any created mock.)r~�_active_patchesr�)rArfrrr�start�sz_patch.startcCs6z|j�|�Wntk
r&YdSX|�ddd�S)zStop an active patch.N)r�r3r<ryr�rrr�stop�s
z_patch.stop)rMrPr�rXr�r8rVr9rZra�contextmanagerrkr\r[rsr~ryr�r�rrrrrP�s 

rPc	sPz��dd�\�}Wn&ttfk
r:td�f��YnX�fdd�}||fS)Nr�r�z.Need a valid target to patch. You supplied: %rcst��Sr/�rOr�rNrrr�r�z_get_target.<locals>.<lambda>)�rsplitrr<)rNrUrQrr�r�_get_target
s�r�c

s>t��tkrt��d����fdd�}	t|	||||||||�	S)a
    patch the named member (`attribute`) on an object (`target`) with a mock
    object.

    `patch.object` can be used as a decorator, class decorator or a context
    manager. Arguments `new`, `spec`, `create`, `spec_set`,
    `autospec` and `new_callable` have the same meaning as for `patch`. Like
    `patch`, `patch.object` takes arbitrary keyword arguments for configuring
    the mock object it creates.

    When used as a class decorator `patch.object` honours `patch.TEST_PREFIX`
    for choosing which methods to wrap.
    z3 must be the actual object to be patched, not a strcs�Sr/rrr�rrr�*r�z_patch_object.<locals>.<lambda>)r1�strrrP)
rNrUr�r�rSr�rTrRrCrQrr�r�
_patch_objects ��r�c
s�t��tkr�fdd�}n�fdd�}|s2td��t|���}|d\}	}
t||	|
|||||i�	}|	|_|dd�D]2\}	}
t||	|
|||||i�	}|	|_|j�|�qt|S)a�Perform multiple patches in a single call. It takes the object to be
    patched (either as an object or a string to fetch the object by importing)
    and keyword arguments for the patches::

        with patch.multiple(settings, FIRST_PATCH='one', SECOND_PATCH='two'):
            ...

    Use `DEFAULT` as the value if you want `patch.multiple` to create
    mocks for you. In this case the created mocks are passed into a decorated
    function by keyword, and a dictionary is returned when `patch.multiple` is
    used as a context manager.

    `patch.multiple` can be used as a decorator, class decorator or a context
    manager. The arguments `spec`, `spec_set`, `create`,
    `autospec` and `new_callable` have the same meaning as for `patch`. These
    arguments will be applied to *all* patches done by `patch.multiple`.

    When used as a class decorator `patch.multiple` honours `patch.TEST_PREFIX`
    for choosing which methods to wrap.
    cst��Sr/r�rr�rrr�Hr�z!_patch_multiple.<locals>.<lambda>cs�Sr/rrr�rrr�Jr�z=Must supply at least one keyword argument with patch.multiplerr�N)	r1r�r<rYr�rPrXrUr�)
rNr�rSr�rTrRrCrQr�rUr�rYZthis_patcherrr�r�_patch_multiple1sH���r�c

Ks$t|�\}}	t||	|||||||�	S)a7
    `patch` acts as a function decorator, class decorator or a context
    manager. Inside the body of the function or with statement, the `target`
    is patched with a `new` object. When the function/with statement exits
    the patch is undone.

    If `new` is omitted, then the target is replaced with an
    `AsyncMock if the patched object is an async function or a
    `MagicMock` otherwise. If `patch` is used as a decorator and `new` is
    omitted, the created mock is passed in as an extra argument to the
    decorated function. If `patch` is used as a context manager the created
    mock is returned by the context manager.

    `target` should be a string in the form `'package.module.ClassName'`. The
    `target` is imported and the specified object replaced with the `new`
    object, so the `target` must be importable from the environment you are
    calling `patch` from. The target is imported when the decorated function
    is executed, not at decoration time.

    The `spec` and `spec_set` keyword arguments are passed to the `MagicMock`
    if patch is creating one for you.

    In addition you can pass `spec=True` or `spec_set=True`, which causes
    patch to pass in the object being mocked as the spec/spec_set object.

    `new_callable` allows you to specify a different class, or callable object,
    that will be called to create the `new` object. By default `AsyncMock` is
    used for async functions and `MagicMock` for the rest.

    A more powerful form of `spec` is `autospec`. If you set `autospec=True`
    then the mock will be created with a spec from the object being replaced.
    All attributes of the mock will also have the spec of the corresponding
    attribute of the object being replaced. Methods and functions being
    mocked will have their arguments checked and will raise a `TypeError` if
    they are called with the wrong signature. For mocks replacing a class,
    their return value (the 'instance') will have the same spec as the class.

    Instead of `autospec=True` you can pass `autospec=some_object` to use an
    arbitrary object as the spec instead of the one being replaced.

    By default `patch` will fail to replace attributes that don't exist. If
    you pass in `create=True`, and the attribute doesn't exist, patch will
    create the attribute for you when the patched function is called, and
    delete it again afterwards. This is useful for writing tests against
    attributes that your production code creates at runtime. It is off by
    default because it can be dangerous. With it switched on you can write
    passing tests against APIs that don't actually exist!

    Patch can be used as a `TestCase` class decorator. It works by
    decorating each test method in the class. This reduces the boilerplate
    code when your test methods share a common patchings set. `patch` finds
    tests by looking for method names that start with `patch.TEST_PREFIX`.
    By default this is `test`, which matches the way `unittest` finds tests.
    You can specify an alternative prefix by setting `patch.TEST_PREFIX`.

    Patch can be used as a context manager, with the with statement. Here the
    patching applies to the indented block after the with statement. If you
    use "as" then the patched object will be bound to the name after the
    "as"; very useful if `patch` is creating a mock object for you.

    `patch` takes arbitrary keyword arguments. These will be passed to
    the `Mock` (or `new_callable`) on construction.

    `patch.dict(...)`, `patch.multiple(...)` and `patch.object(...)` are
    available for alternate use-cases.
    )r�rP)
rNr�r�rSr�rTrRrCrQrUrrrrbsF�rc@sReZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
eZe
ZdS)�_patch_dicta#
    Patch a dictionary, or dictionary like object, and restore the dictionary
    to its original state after the test.

    `in_dict` can be a dictionary or a mapping like container. If it is a
    mapping then it must at least support getting, setting and deleting items
    plus iterating over keys.

    `in_dict` can also be a string specifying the name of the dictionary, which
    will then be fetched by importing it.

    `values` can be a dictionary of values to set in the dictionary. `values`
    can also be an iterable of `(key, value)` pairs.

    If `clear` is True then the dictionary will be cleared before the new
    values are set.

    `patch.dict` can also be called with arbitrary keyword arguments to set
    values in the dictionary::

        with patch.dict('sys.modules', mymodule=Mock(), other_module=Mock()):
            ...

    `patch.dict` can be used as a context manager, decorator or class
    decorator. When used as a class decorator `patch.dict` honours
    `patch.TEST_PREFIX` for choosing which methods to wrap.
    rFcKs,||_t|�|_|j�|�||_d|_dSr/)�in_dict�dictr�re�clear�	_original)rAr�r�r�rCrrrr8�s

z_patch_dict.__init__cs.t�t�r����St����fdd��}|S)Ncs&���z�||�W�S���XdSr/)r��
_unpatch_dictr��frArr�_inner�sz$_patch_dict.__call__.<locals>._inner)r"r1rZr)rAr�r�rr�rr9�s


z_patch_dict.__call__cCsXt|�D]J}t||�}|�tj�rt|d�rt|j|j|j	�}||�}t
|||�q|Sr^)r�r$rrr_r#r�r�r�r�rS)rAr>r�r`Z	decoratorZ	decoratedrrrrZ�s
�z_patch_dict.decorate_classcCs|��|jS)zPatch the dict.)r�r�r�rrrr~�sz_patch_dict.__enter__cCs�|j}t|jt�rt|j�|_|j}|j}z|��}Wn.tk
rdi}|D]}||||<qNYnX||_|rxt	|�z|�
|�Wn*tk
r�|D]}||||<q�YnXdSr/)r�r"r�r�rOr�rVr:r��_clear_dictre)rAr�r�r�rer�rrrr��s&z_patch_dict._patch_dictcCsR|j}|j}t|�z|�|�Wn*tk
rL|D]}||||<q6YnXdSr/)r�r�r�rer:)rAr�rer�rrrr�sz_patch_dict._unpatch_dictcGs|��dS)zUnpatch the dict.F)r�)rArBrrrrysz_patch_dict.__exit__N)rF)
rMrPr�rNr8r9rZr~r�r�ryr�r�rrrrr��s
	
r�cCs>z|��Wn,tk
r8t|�}|D]
}||=q(YnXdSr/)r�r:rY)r�r�r�rrrr�&sr�cCsttj�D]}|��q
dS)z7Stop all active patches. LIFO to unroll nested patches.N)r�rPr�r�)rrrr�_patch_stopall/sr�Ztestz�lt le gt ge eq ne getitem setitem delitem len contains iter hash str sizeof enter exit divmod rdivmod neg pos abs invert complex int float index round trunc floor ceil bool next fspath aiter zHadd sub mul matmul div floordiv mod lshift rshift and xor or pow truediv� ccs|]}d|VqdS)zi%sNr�r�nrrrr.Nsr.ccs|]}d|VqdS)zr%sNrr�rrrr.Os�__get__�__set__�
__delete__�__reversed__�__missing__r��
__reduce_ex__Z__getinitargs__�__getnewargs__�__getstate__�__setstate__�
__getformat__Z
__setformat__r�r�__subclasses__�
__format__�__getnewargs_ex__cs�fdd�}||_|S)z:Turns a callable object (like a mock) into a real functioncs�|f|�|�Sr/r�rArBr�r,rr�method`sz_get_method.<locals>.method)rM)rr-r�rr,rr	^sr	cCsh|]}d|�qS)r�r)rr�rrrrfs�
__aenter__�	__aexit__�	__anext__�	__aiter__r�rr8r��__prepare__�__instancecheck__�__subclasscheck__�__del__cCs
t�|�Sr/)r�__hash__r�rrrr�|r�r�cCs
t�|�Sr/)r�__str__r�rrrr�}r�cCs
t�|�Sr/)r�
__sizeof__r�rrrr�~r�cCs"t|�j�d|���dt|���S)N�/)r1rMr�r�r�rrrr�r�)r�r�r��
__fspath__r�y�?g�?)
�__lt__�__gt__�__le__�__ge__�__int__r��__len__ry�__complex__�	__float__�__bool__�	__index__r�cs�fdd�}|S)Ncs$�jj}|tk	r|S�|kr dStS�NT)�__eq__r�r�NotImplemented)�other�ret_valr�rrr��sz_get_eq.<locals>.__eq__r)rAr�rr�r�_get_eq�sr�cs�fdd�}|S)Ncs �jjtk	rtS�|krdStS�NF)�__ne__r�rr�)r�r�rrr��s
z_get_ne.<locals>.__ne__r)rAr�rr�r�_get_ne�sr�cs�fdd�}|S)Ncs �jj}|tkrtg�St|�Sr/)�__iter__r�rr��r�r�rrr��sz_get_iter.<locals>.__iter__r)rAr�rr�r�	_get_iter�sr�cs�fdd�}|S)Ncs(�jj}|tkrttg��Stt|��Sr/)r�r�r�_AsyncIteratorr�r�r�rrr��sz"_get_async_iter.<locals>.__aiter__r)rAr�rr�r�_get_async_iter�sr�)r�r�r�r�cCsbt�|t�}|tk	r||_dSt�|�}|dk	rB||�}||_dSt�|�}|dk	r^||�|_dSr/)�_return_valuesr^rrv�_calculate_return_value�_side_effect_methodsr})r5r�rZfixedZreturn_calculatorrvZ
side_effectorrrr�_set_return_value�s

r�c@seZdZdd�Zdd�ZdS)�
MagicMixincOs&|��tt|�j||�|��dSr/)�_mock_set_magicsr�r�r8r�rrrr8�szMagicMixin.__init__cCs�ttB}|}t|dd�dk	rX|�|j�}t�}||}|D]}|t|�jkr:t||�q:|tt|�j�}t|�}|D]}t	||t
||��qvdS)Nr�)�_magicsr:r$�intersectionr�rr1r]rrS�
MagicProxy)rAZorig_magicsZthese_magicsZ
remove_magicsr�r=rrrr��szMagicMixin._mock_set_magicsN)rMrPr�r8r�rrrrr��sr�c@seZdZdZddd�ZdS)rz-A version of `MagicMock` that isn't callable.FcCs|�||�|��dSr��r�r�r�rrrr��sz"NonCallableMagicMock.mock_add_specN)F�rMrPr�rNr�rrrrr�src@seZdZdd�ZdS)�AsyncMagicMixincOs&|��tt|�j||�|��dSr/)r�r�r�r8r�rrrr8�szAsyncMagicMixin.__init__N�rMrPr�r8rrrrr��sr�c@seZdZdZddd�ZdS)ra�
    MagicMock is a subclass of Mock with default implementations
    of most of the magic methods. You can use MagicMock without having to
    configure the magic methods yourself.

    If you use the `spec` or `spec_set` arguments then *only* magic
    methods that exist in the spec will be created.

    Attributes and the return value of a `MagicMock` will also be `MagicMocks`.
    FcCs|�||�|��dSr�r�r�rrrr�szMagicMock.mock_add_specN)Fr�rrrrrs
rc@s&eZdZdd�Zdd�Zddd�ZdS)	r�cCs||_||_dSr/�rr�)rArr�rrrr8szMagicProxy.__init__cCs8|j}|j}|j|||d�}t|||�t|||�|S)N)rr�r�)rr�r�rSr�)rAr�r��mrrr�create_mocks�zMagicProxy.create_mockNcCs|��Sr/)r�)rAr)r=rrrr�(szMagicProxy.__get__)N)rMrPr�r8r�r�rrrrr�s	r�cs�eZdZed�Zed�Zed�Z�fdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
ddd�Zdd�Z�fdd�Z�ZS)r�r�r�r�cs\t�j||�tjj|jd<d|jd<d|jd<t�|jd<ttd�}t	j
|_||jd<dS)Nr�rZ_mock_await_countZ_mock_await_argsZ_mock_await_args_list�r�r+)�superr8r%r�r�r]rrrrr'ZCO_COROUTINE�co_flags)rArBrC�	code_mock�r�rrr81s


zAsyncMockMixin.__init__c�st||fdd�}|jd7_||_|j�|�|j}|dk	r�t|�rL|�nbt|�s�zt|�}Wnt	k
rxt
�YnXt|�r�|�n&t�|�r�|||�IdH}n
|||�}|t
k	r�|S|jt
k	r�|jS|jdk	r�t�|j�r�|j||�IdHS|j||�S|jS)NTrDr�)rFr�r�r�r�r}r3rXr��
StopIteration�StopAsyncIterationr%r&rr�rvr�)rArBrCrrGrfrrrrCAs6




z!AsyncMockMixin._execute_mock_callcCs(|jdkr$d|jpd�d�}t|��dS)zA
        Assert that the mock was awaited at least once.
        r�	Expected r5z to have been awaited.N�r�r�rr rrrr�is
zAsyncMockMixin.assert_awaitedcCs0|jdks,d|jpd�d|j�d�}t|��dS)z@
        Assert that the mock was awaited exactly once.
        r�r�r5�$ to have been awaited once. Awaited � times.Nr�r rrrr�qs
z"AsyncMockMixin.assert_awaited_oncecsz�jdkr&�����}td|�d������fdd�}����f�}���j�}||krvt|t�rf|nd}t|��|�dS)zN
        Assert that the last await was with the specified arguments.
        NzExpected await: z
Not awaitedcs�j��dd�}|S)N�await)rr!r"r#rrr$�sz:AsyncMockMixin.assert_awaited_with.<locals>._error_message)r�rrrr"r%)rArBrCr&r$r'r(rr#rr�zs
z"AsyncMockMixin.assert_awaited_withcOs8|jdks,d|jpd�d|j�d�}t|��|j||�S)zi
        Assert that the mock was awaited exactly once and with the specified
        arguments.
        r�r�r5r�r�)r�r�rr�r)rrrr��s
z'AsyncMockMixin.assert_awaited_once_withcsZ��||f�}�fdd��jD�}||krVt|t�r8|nd}��||�}td|�|�dS)zU
        Assert the mock has ever been awaited with the specified arguments.
        csg|]}��|��qSrr*r+r�rrr��sz3AsyncMockMixin.assert_any_await.<locals>.<listcomp>Nz%s await not found)rr�r"r%rrr9rr�rr��s��zAsyncMockMixin.assert_any_awaitFc		s��fdd�|D�}tdd�|D�d�}t�fdd��jD��}|s�||kr�|dkrXd}nd�d	d�|D��}t|�d
t|��d�j���|�dSt|�}g}|D]2}z|�|�Wq�tk
r�|�|�Yq�Xq�|r�tdt	|�f�|�dS)
a�
        Assert the mock has been awaited with the specified calls.
        The :attr:`await_args_list` list is checked for the awaits.

        If `any_order` is False (the default) then the awaits must be
        sequential. There can be extra calls before or after the
        specified awaits.

        If `any_order` is True then the awaits can be in any order, but
        they must all appear in :attr:`await_args_list`.
        csg|]}��|��qSrr*r+r�rrr��sz4AsyncMockMixin.assert_has_awaits.<locals>.<listcomp>css|]}t|t�r|VqdSr/r-rrrrr.�s
z3AsyncMockMixin.assert_has_awaits.<locals>.<genexpr>Nc3s|]}��|�VqdSr/r*r+r�rrr.�szAwaits not found.z,Error processing expected awaits.
Errors: {}cSsg|]}t|t�r|nd�qSr/r-rrrrr��s�r/z	
Actual: z%r not all found in await list)
r�rrr�r1rrYr3r<r�rZ)	rAr4r5r&r(Z
all_awaitsr6r7r8rr�rr��s>������z AsyncMockMixin.assert_has_awaitscCs0|jdkr,d|jpd�d|j�d�}t|��dS)z9
        Assert that the mock was never awaited.
        rr�r5z# to not have been awaited. Awaited r�Nr�r rrrr��s
z!AsyncMockMixin.assert_not_awaitedcs&t�j||�d|_d|_t�|_dS)z0
        See :func:`.Mock.reset_mock()`
        rN)r�rur�r�rrr�r@r�rrru�szAsyncMockMixin.reset_mock)F)rMrPr�r�r�r�r�r8rCr�r�r�r�r�r�r�ru�
__classcell__rrr�rr�,s(	
,	r�c@seZdZdZdS)r	aa
    Enhance :class:`Mock` with features allowing to mock
    an async function.

    The :class:`AsyncMock` object will behave so the object is
    recognized as an async function, and the result of a call is an awaitable:

    >>> mock = AsyncMock()
    >>> asyncio.iscoroutinefunction(mock)
    True
    >>> inspect.isawaitable(mock())
    True


    The result of ``mock()`` is an async function which will have the outcome
    of ``side_effect`` or ``return_value``:

    - if ``side_effect`` is a function, the async function will return the
      result of that function,
    - if ``side_effect`` is an exception, the async function will raise the
      exception,
    - if ``side_effect`` is an iterable, the async function will return the
      next value of the iterable, however, if the sequence of result is
      exhausted, ``StopIteration`` is raised immediately,
    - if ``side_effect`` is not defined, the async function will return the
      value defined by ``return_value``, hence, by default, the async function
      returns a new :class:`AsyncMock` object.

    If the outcome of ``side_effect`` or ``return_value`` is an async function,
    the mock async function obtained when the mock object is called will be this
    async function itself (and not an async function returning an async
    function).

    The test author can also specify a wrapped object with ``wraps``. In this
    case, the :class:`Mock` object behavior is the same as with an
    :class:`.Mock` object: the wrapped object may have methods
    defined as async function functions.

    Based on Martin Richard's asynctest project.
    NrHrrrrr	�sr	c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_ANYz2A helper object that compares equal to everything.cCsdSr�r�rAr�rrrr�	sz_ANY.__eq__cCsdSr�rr�rrrr�	sz_ANY.__ne__cCsdS)Nz<ANY>rr�rrrr�	sz
_ANY.__repr__N)rMrPr�rNr�r�r�rrrrr�	sr�cCs`d|}d}d�dd�|D��}d�dd�|��D��}|r@|}|rX|rP|d7}||7}||S)Nz%s(%%s)r�z, cSsg|]}t|��qSr)�reprr�rrrr�!	sz*_format_call_signature.<locals>.<listcomp>cSsg|]\}}d||f�qS)z%s=%rr)rr�r�rrrr�"	s)r�r�)rrBrCrZformatted_argsZargs_stringZ
kwargs_stringrrrr	s
�rc@s�eZdZdZd!dd�Zd"d	d
�Zdd�ZejZd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zedd��Zedd��Zdd�Zdd �ZdS)#rFa�
    A tuple for holding the results of a call to a mock, either in the form
    `(args, kwargs)` or `(name, args, kwargs)`.

    If args or kwargs are empty then a call tuple will compare equal to
    a tuple without those values. This makes comparisons less verbose::

        _Call(('name', (), {})) == ('name',)
        _Call(('name', (1,), {})) == ('name', (1,))
        _Call(((), {'a': 'b'})) == ({'a': 'b'},)

    The `_Call` object provides a useful shortcut for comparing with call::

        _Call(((1, 2), {'a': 3})) == call(1, 2, a=3)
        _Call(('foo', (1, 2), {'a': 3})) == call.foo(1, 2, a=3)

    If the _Call has no name then it will match any name.
    rr�NFTcCs�d}i}t|�}|dkr$|\}}}nr|dkrd|\}	}
t|	t�rX|	}t|
t�rR|
}qb|
}q�|	|
}}n2|dkr�|\}t|t�r�|}nt|t�r�|}n|}|r�t�|||f�St�||||f�S)Nr�r�r�)r�r"r�rZr�)r�r�rr�rE�	from_kallrBrC�_len�first�secondrrrr�C	s.



z
_Call.__new__cCs||_||_||_dSr/)r�r��_mock_from_kall)rAr�rr�rEr�rrrr8c	sz_Call.__init__cCsh|tkrdSzt|�}Wntk
r.YdSXd}t|�dkrJ|\}}n
|\}}}t|dd�r|t|dd�r||j|jkr|dSd}|dkr�di}}n�|dkr�|\}}}n�|d	kr�|\}	t|	t�r�|	}i}n"t|	t�r�|	}di}}nd}|	}nV|dk�r@|\}
}t|
t��r4|
}t|t��r(|i}}n
d|}}n
|
|}}ndS|�rX||k�rXdS||f||fkS)
NTFr�r�r�rrr�r�)rr�rr$r�r"rZr�)rAr�Z	len_otherZ	self_nameZ	self_argsZself_kwargsZ
other_nameZ
other_argsZother_kwargsr�r�r�rrrr�j	sR


�


z_Call.__eq__cOs<|jdkrtd||fdd�S|jd}t|j||f||d�S)Nr�r�r�r��r�rFrrrrr9�	s

z_Call.__call__cCs2|jdkrt|dd�Sd|j|f}t||dd�S)NF)rr�z%s.%s)rr�r�r�)rAr�rrrrr��	s
z_Call.__getattr__cCs|tjkrt�t�||�Sr/)rZr]r:�__getattribute__)rAr�rrrr��	s
z_Call.__getattribute__cOs|�d�||�S)Nr��r�r@rrrr��	sz_Call.countcOs|�d�||�S)N�indexr�r@rrrr��	sz_Call.indexcCs(t|�dkr|\}}n
|\}}}||fS)Nr�)r�rrrr�_get_call_arguments�	s

z_Call._get_call_argumentscCs|��dS�Nr�r�r�rrrrB�	sz
_Call.argscCs|��dS)Nr�r�r�rrrrC�	sz_Call.kwargscCs||js&|jpd}|�d�r"d|}|St|�dkr@d}|\}}n0|\}}}|sTd}n|�d�shd|}nd|}t|||�S)Nrr�zcall%sr�zcall.%s)r�r�rr�r)rArrBrCrrrr��	s





z_Call.__repr__cCs4g}|}|dk	r(|jr |�|�|j}qtt|��S)z�For a call object that represents multiple calls, `call_list`
        returns a list of all the intermediate calls as well as the
        final call.N)r�r�r�rrr�)rAZvalsrJrrr�	call_list�	s
z_Call.call_list)rr�NFT)rNNFT)rMrPr�rNr�r8r�rr�r9r�r�r�r�r�r�rBrCr�r�rrrrrF0	s*�
 �
7

rF)r�c	Kslt|�rt|�}t|t�}t|�}d|i}|r8d|i}n|dkrDi}|rT|rTd|d<|�|�t}	t�|�rri}n8|r�|r�td��t	}	n"t
|�s�t}	n|r�|r�t|�s�t}	|�
d|�}|}
|dkr�d}
|	f|||
|d	�|��}t|t��rt||�}|�rt|�nt||||�|dk	�r,|�s,||j|<|�rV|�sVd
|k�rVt||dd|d�|_t|�D�]}t|��rr�q^zt||�}
Wntk
�r�Y�q^YnXd|
i}|�r�d|
i}t|
t��s�t|
||||�}||j|<np|}t|t��r�|j}t|||�}||d
<t�|
��rt	}nt}|f||||d�|��}||j|<t|
||d�t|t��r^t|||��q^|S)aICreate a mock object using another object as a spec. Attributes on the
    mock will use the corresponding attribute on the `spec` object as their
    spec.

    Functions or methods being mocked will have their arguments checked
    to check that they are called with the correct signature.

    If `spec_set` is True then attempting to set attributes that don't exist
    on the spec object will raise an `AttributeError`.

    If a class is used as a spec then the return value of the mock (the
    instance of the class) will have the same spec. You can use a class as the
    spec for an instance object by passing `instance=True`. The returned mock
    will only be callable if instances of the mock are callable.

    `create_autospec` also takes arbitrary keyword arguments that are passed to
    the constructor of the created mock.r�r�NTr�zJInstance can not be True when create_autospec is mocking an async functionrr�)r�r�r�rrvr�)rKrtr�r�)r�rr�r�)rJ)r[r1r"r.rerr'Zisdatadescriptor�RuntimeErrorr	rXrr`r�r6rir�rLr~rrvr�r�r$r:r�r5�
_must_skipr%r&rS)r�r�rKr�rtrC�is_typeZ
is_async_funcr}r|r�r5r�rer�r�rJZchild_klassrrrr�	s�




��


�

��
rcCsxt|t�s$|t|di�krdS|j}|jD]H}|j�|t�}|tkrFq*t|tt	f�rZdSt|t
�rl|SdSq*|S)z[
    Return whether we should skip the first argument on spec's `entry`
    attribute.
    r]F)r"r1r$r�r\r]r^rrVrWr6)r�r�r�r>rfrrrr�w
s


r�c@seZdZddd�ZdS)r�FNcCs(||_||_||_||_||_||_dSr/)r��idsr�r�rKr)rAr�r�r�rr�rKrrrr8�
sz_SpecState.__init__)FNNNFr�rrrrr��
s
�r�cCs"t|t�rt�|�St�|�SdSr/)r"�bytes�io�BytesIO�StringIO)�	read_datarrr�
_to_stream�
s

rr�cs&t��}|dg���fdd�}��fdd�}��fdd����fdd	����fd
d�}tdkr�ddl}ttt|j���tt|j����a|dkr�t	d
t
d�}t	td����j_d�j
_d�j_d�j_d�j_|�j_���d<�d�j_|�j_��j_|�j_����fdd�}||_�|_|S)a�
    A helper function to create a mock to replace the use of `open`. It works
    for `open` called directly or used as a context manager.

    The `mock` argument is the mock object to configure. If `None` (the
    default) then a `MagicMock` will be created for you, with the API limited
    to methods or attributes available on standard file handles.

    `read_data` is a string for the `read`, `readline` and `readlines` of the
    file handle to return.  This is an empty string by default.
    Ncs$�jjdk	r�jjS�dj||�Sr�)�	readlinesrvra��_state�handlerr�_readlines_side_effect�
sz)mock_open.<locals>._readlines_side_effectcs$�jjdk	r�jjS�dj||�Sr�)�readrvrarrr�_read_side_effect�
sz$mock_open.<locals>._read_side_effectc?s$��EdH�dj||�VqdSr�)�readlinera)�_iter_side_effectrrr�_readline_side_effect�
sz(mock_open.<locals>._readline_side_effectc3s0�jjdk	r�jjVq�dD]
}|Vq dSr�)rrv)�linerrrr
�
sz$mock_open.<locals>._iter_side_effectcs �jjdk	r�jjSt�d�Sr�)rrvr�rrrr�_next_side_effect�
sz$mock_open.<locals>._next_side_effectr�open)rr�r�r�cs6t���d<�jj�dkr2���d<�d�j_tS)Nrr�)rrr}rra)rrrrrr�
reset_data�
s

zmock_open.<locals>.reset_data)r�	file_spec�_iorYrr��
TextIOWrapper�unionrrrr~rv�writer
rrr}r�r�)r5rZ
_read_datar	rrrrr)r
rrrrrr
�
s8"

r
c@s*eZdZdZdd�Zd	dd�Zdd�ZdS)
raW
    A mock intended to be used as a property, or other descriptor, on a class.
    `PropertyMock` provides `__get__` and `__set__` methods so you can specify
    a return value when it is fetched.

    Fetching a `PropertyMock` instance from an object calls the mock, with
    no args. Setting it calls the mock with the value being set.
    cKs
tf|�Sr/)r)rArCrrrr�szPropertyMock._get_child_mockNcCs|�Sr/r)rAr)Zobj_typerrrr�szPropertyMock.__get__cCs||�dSr/r)rAr)r�rrrr�
szPropertyMock.__set__)N)rMrPr�rNr�r�r�rrrrr�
s
rc	Cs^d|_t|�D]J}zt||�}Wntk
r8YqYnXt|t�sFq|j|krt|�qdS)a�Disable the automatic generation of child mocks.

    Given an input Mock, seals it to ensure no further mocks will be generated
    when accessing an attribute that was not already defined.

    The operation recursively seals the mock passed in, meaning that
    the mock itself, any mocks generated by accessing one of its attributes,
    and all assigned mocks without a name or spec will be sealed.
    TN)r�r�r$r:r"rr�r)r5r�r�rrrrs



rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	r�z8
    Wraps an iterator in an asynchronous iterator.
    cCs&||_ttd�}tj|_||jd<dS)Nr�r+)�iteratorrrr'ZCO_ITERABLE_COROUTINEr�r])rArr�rrrr8+s
z_AsyncIterator.__init__cCs|Sr/rr�rrrr�1sz_AsyncIterator.__aiter__c�s*zt|j�WStk
r YnXt�dSr/)r�rr�r�r�rrrr�4s
z_AsyncIterator.__anext__N)rMrPr�rNr8r�r�rrrrr�'sr�)F)F)NFNNN)FFNN)Nr�)y�__all__�__version__r%rarr'r�rz�builtins�typesrrrZ
unittest.utilr�	functoolsrrr�rqr
r�r�r*r.r!r3r7r=rLrGrXr[r`rirdr�r�rr�r�rr�MISSINGr
ZDELETEDr�r�r�rYrrr�r�r�rr�r<rrMrOrPr�r�r�rr�r�r�r�ZmultipleZstopallr_Z
magic_methodsZnumericsr�r�Zinplace�rightZ
_non_defaultsr	r�r:Z_sync_async_magicsZ
_async_magicsr;r�rr�r�r�r�r�r�r�r�r�r�rr�rr�r�r	r�rrrZrFrrr�r�r1r�r6rrr
rrr�rrrr�<module>s~	



1�	h4<�
�
2�
Mw	���	�
���
	
	�	8+B
�
�
NPK��[)����mock.pynu�[���# mock.py
# Test tools for mocking and patching.
# Maintained by Michael Foord
# Backport for other versions of Python available from
# https://pypi.org/project/mock

__all__ = (
    'Mock',
    'MagicMock',
    'patch',
    'sentinel',
    'DEFAULT',
    'ANY',
    'call',
    'create_autospec',
    'AsyncMock',
    'FILTER_DIR',
    'NonCallableMock',
    'NonCallableMagicMock',
    'mock_open',
    'PropertyMock',
    'seal',
)


__version__ = '1.0'

import asyncio
import contextlib
import io
import inspect
import pprint
import sys
import builtins
from types import CodeType, ModuleType, MethodType
from unittest.util import safe_repr
from functools import wraps, partial


_builtins = {name for name in dir(builtins) if not name.startswith('_')}

FILTER_DIR = True

# Workaround for issue #12370
# Without this, the __class__ properties wouldn't be set correctly
_safe_super = super

def _is_async_obj(obj):
    if _is_instance_mock(obj) and not isinstance(obj, AsyncMock):
        return False
    if hasattr(obj, '__func__'):
        obj = getattr(obj, '__func__')
    return asyncio.iscoroutinefunction(obj) or inspect.isawaitable(obj)


def _is_async_func(func):
    if getattr(func, '__code__', None):
        return asyncio.iscoroutinefunction(func)
    else:
        return False


def _is_instance_mock(obj):
    # can't use isinstance on Mock objects because they override __class__
    # The base class for all mocks is NonCallableMock
    return issubclass(type(obj), NonCallableMock)


def _is_exception(obj):
    return (
        isinstance(obj, BaseException) or
        isinstance(obj, type) and issubclass(obj, BaseException)
    )


def _extract_mock(obj):
    # Autospecced functions will return a FunctionType with "mock" attribute
    # which is the actual mock object that needs to be used.
    if isinstance(obj, FunctionTypes) and hasattr(obj, 'mock'):
        return obj.mock
    else:
        return obj


def _get_signature_object(func, as_instance, eat_self):
    """
    Given an arbitrary, possibly callable object, try to create a suitable
    signature object.
    Return a (reduced func, signature) tuple, or None.
    """
    if isinstance(func, type) and not as_instance:
        # If it's a type and should be modelled as a type, use __init__.
        func = func.__init__
        # Skip the `self` argument in __init__
        eat_self = True
    elif not isinstance(func, FunctionTypes):
        # If we really want to model an instance of the passed type,
        # __call__ should be looked up, not __init__.
        try:
            func = func.__call__
        except AttributeError:
            return None
    if eat_self:
        sig_func = partial(func, None)
    else:
        sig_func = func
    try:
        return func, inspect.signature(sig_func)
    except ValueError:
        # Certain callable types are not supported by inspect.signature()
        return None


def _check_signature(func, mock, skipfirst, instance=False):
    sig = _get_signature_object(func, instance, skipfirst)
    if sig is None:
        return
    func, sig = sig
    def checksig(self, /, *args, **kwargs):
        sig.bind(*args, **kwargs)
    _copy_func_details(func, checksig)
    type(mock)._mock_check_sig = checksig
    type(mock).__signature__ = sig


def _copy_func_details(func, funcopy):
    # we explicitly don't copy func.__dict__ into this copy as it would
    # expose original attributes that should be mocked
    for attribute in (
        '__name__', '__doc__', '__text_signature__',
        '__module__', '__defaults__', '__kwdefaults__',
    ):
        try:
            setattr(funcopy, attribute, getattr(func, attribute))
        except AttributeError:
            pass


def _callable(obj):
    if isinstance(obj, type):
        return True
    if isinstance(obj, (staticmethod, classmethod, MethodType)):
        return _callable(obj.__func__)
    if getattr(obj, '__call__', None) is not None:
        return True
    return False


def _is_list(obj):
    # checks for list or tuples
    # XXXX badly named!
    return type(obj) in (list, tuple)


def _instance_callable(obj):
    """Given an object, return True if the object is callable.
    For classes, return True if instances would be callable."""
    if not isinstance(obj, type):
        # already an instance
        return getattr(obj, '__call__', None) is not None

    # *could* be broken by a class overriding __mro__ or __dict__ via
    # a metaclass
    for base in (obj,) + obj.__mro__:
        if base.__dict__.get('__call__') is not None:
            return True
    return False


def _set_signature(mock, original, instance=False):
    # creates a function with signature (*args, **kwargs) that delegates to a
    # mock. It still does signature checking by calling a lambda with the same
    # signature as the original.

    skipfirst = isinstance(original, type)
    result = _get_signature_object(original, instance, skipfirst)
    if result is None:
        return mock
    func, sig = result
    def checksig(*args, **kwargs):
        sig.bind(*args, **kwargs)
    _copy_func_details(func, checksig)

    name = original.__name__
    if not name.isidentifier():
        name = 'funcopy'
    context = {'_checksig_': checksig, 'mock': mock}
    src = """def %s(*args, **kwargs):
    _checksig_(*args, **kwargs)
    return mock(*args, **kwargs)""" % name
    exec (src, context)
    funcopy = context[name]
    _setup_func(funcopy, mock, sig)
    return funcopy


def _setup_func(funcopy, mock, sig):
    funcopy.mock = mock

    def assert_called_with(*args, **kwargs):
        return mock.assert_called_with(*args, **kwargs)
    def assert_called(*args, **kwargs):
        return mock.assert_called(*args, **kwargs)
    def assert_not_called(*args, **kwargs):
        return mock.assert_not_called(*args, **kwargs)
    def assert_called_once(*args, **kwargs):
        return mock.assert_called_once(*args, **kwargs)
    def assert_called_once_with(*args, **kwargs):
        return mock.assert_called_once_with(*args, **kwargs)
    def assert_has_calls(*args, **kwargs):
        return mock.assert_has_calls(*args, **kwargs)
    def assert_any_call(*args, **kwargs):
        return mock.assert_any_call(*args, **kwargs)
    def reset_mock():
        funcopy.method_calls = _CallList()
        funcopy.mock_calls = _CallList()
        mock.reset_mock()
        ret = funcopy.return_value
        if _is_instance_mock(ret) and not ret is mock:
            ret.reset_mock()

    funcopy.called = False
    funcopy.call_count = 0
    funcopy.call_args = None
    funcopy.call_args_list = _CallList()
    funcopy.method_calls = _CallList()
    funcopy.mock_calls = _CallList()

    funcopy.return_value = mock.return_value
    funcopy.side_effect = mock.side_effect
    funcopy._mock_children = mock._mock_children

    funcopy.assert_called_with = assert_called_with
    funcopy.assert_called_once_with = assert_called_once_with
    funcopy.assert_has_calls = assert_has_calls
    funcopy.assert_any_call = assert_any_call
    funcopy.reset_mock = reset_mock
    funcopy.assert_called = assert_called
    funcopy.assert_not_called = assert_not_called
    funcopy.assert_called_once = assert_called_once
    funcopy.__signature__ = sig

    mock._mock_delegate = funcopy


def _setup_async_mock(mock):
    mock._is_coroutine = asyncio.coroutines._is_coroutine
    mock.await_count = 0
    mock.await_args = None
    mock.await_args_list = _CallList()

    # Mock is not configured yet so the attributes are set
    # to a function and then the corresponding mock helper function
    # is called when the helper is accessed similar to _setup_func.
    def wrapper(attr, /, *args, **kwargs):
        return getattr(mock.mock, attr)(*args, **kwargs)

    for attribute in ('assert_awaited',
                      'assert_awaited_once',
                      'assert_awaited_with',
                      'assert_awaited_once_with',
                      'assert_any_await',
                      'assert_has_awaits',
                      'assert_not_awaited'):

        # setattr(mock, attribute, wrapper) causes late binding
        # hence attribute will always be the last value in the loop
        # Use partial(wrapper, attribute) to ensure the attribute is bound
        # correctly.
        setattr(mock, attribute, partial(wrapper, attribute))


def _is_magic(name):
    return '__%s__' % name[2:-2] == name


class _SentinelObject(object):
    "A unique, named, sentinel object."
    def __init__(self, name):
        self.name = name

    def __repr__(self):
        return 'sentinel.%s' % self.name

    def __reduce__(self):
        return 'sentinel.%s' % self.name


class _Sentinel(object):
    """Access attributes to return a named object, usable as a sentinel."""
    def __init__(self):
        self._sentinels = {}

    def __getattr__(self, name):
        if name == '__bases__':
            # Without this help(unittest.mock) raises an exception
            raise AttributeError
        return self._sentinels.setdefault(name, _SentinelObject(name))

    def __reduce__(self):
        return 'sentinel'


sentinel = _Sentinel()

DEFAULT = sentinel.DEFAULT
_missing = sentinel.MISSING
_deleted = sentinel.DELETED


_allowed_names = {
    'return_value', '_mock_return_value', 'side_effect',
    '_mock_side_effect', '_mock_parent', '_mock_new_parent',
    '_mock_name', '_mock_new_name'
}


def _delegating_property(name):
    _allowed_names.add(name)
    _the_name = '_mock_' + name
    def _get(self, name=name, _the_name=_the_name):
        sig = self._mock_delegate
        if sig is None:
            return getattr(self, _the_name)
        return getattr(sig, name)
    def _set(self, value, name=name, _the_name=_the_name):
        sig = self._mock_delegate
        if sig is None:
            self.__dict__[_the_name] = value
        else:
            setattr(sig, name, value)

    return property(_get, _set)



class _CallList(list):

    def __contains__(self, value):
        if not isinstance(value, list):
            return list.__contains__(self, value)
        len_value = len(value)
        len_self = len(self)
        if len_value > len_self:
            return False

        for i in range(0, len_self - len_value + 1):
            sub_list = self[i:i+len_value]
            if sub_list == value:
                return True
        return False

    def __repr__(self):
        return pprint.pformat(list(self))


def _check_and_set_parent(parent, value, name, new_name):
    value = _extract_mock(value)

    if not _is_instance_mock(value):
        return False
    if ((value._mock_name or value._mock_new_name) or
        (value._mock_parent is not None) or
        (value._mock_new_parent is not None)):
        return False

    _parent = parent
    while _parent is not None:
        # setting a mock (value) as a child or return value of itself
        # should not modify the mock
        if _parent is value:
            return False
        _parent = _parent._mock_new_parent

    if new_name:
        value._mock_new_parent = parent
        value._mock_new_name = new_name
    if name:
        value._mock_parent = parent
        value._mock_name = name
    return True

# Internal class to identify if we wrapped an iterator object or not.
class _MockIter(object):
    def __init__(self, obj):
        self.obj = iter(obj)
    def __next__(self):
        return next(self.obj)

class Base(object):
    _mock_return_value = DEFAULT
    _mock_side_effect = None
    def __init__(self, /, *args, **kwargs):
        pass



class NonCallableMock(Base):
    """A non-callable version of `Mock`"""

    def __new__(cls, /, *args, **kw):
        # every instance has its own class
        # so we can create magic methods on the
        # class without stomping on other mocks
        bases = (cls,)
        if not issubclass(cls, AsyncMock):
            # Check if spec is an async object or function
            sig = inspect.signature(NonCallableMock.__init__)
            bound_args = sig.bind_partial(cls, *args, **kw).arguments
            spec_arg = [
                arg for arg in bound_args.keys()
                if arg.startswith('spec')
            ]
            if spec_arg:
                # what if spec_set is different than spec?
                if _is_async_obj(bound_args[spec_arg[0]]):
                    bases = (AsyncMockMixin, cls,)
        new = type(cls.__name__, bases, {'__doc__': cls.__doc__})
        instance = _safe_super(NonCallableMock, cls).__new__(new)
        return instance


    def __init__(
            self, spec=None, wraps=None, name=None, spec_set=None,
            parent=None, _spec_state=None, _new_name='', _new_parent=None,
            _spec_as_instance=False, _eat_self=None, unsafe=False, **kwargs
        ):
        if _new_parent is None:
            _new_parent = parent

        __dict__ = self.__dict__
        __dict__['_mock_parent'] = parent
        __dict__['_mock_name'] = name
        __dict__['_mock_new_name'] = _new_name
        __dict__['_mock_new_parent'] = _new_parent
        __dict__['_mock_sealed'] = False

        if spec_set is not None:
            spec = spec_set
            spec_set = True
        if _eat_self is None:
            _eat_self = parent is not None

        self._mock_add_spec(spec, spec_set, _spec_as_instance, _eat_self)

        __dict__['_mock_children'] = {}
        __dict__['_mock_wraps'] = wraps
        __dict__['_mock_delegate'] = None

        __dict__['_mock_called'] = False
        __dict__['_mock_call_args'] = None
        __dict__['_mock_call_count'] = 0
        __dict__['_mock_call_args_list'] = _CallList()
        __dict__['_mock_mock_calls'] = _CallList()

        __dict__['method_calls'] = _CallList()
        __dict__['_mock_unsafe'] = unsafe

        if kwargs:
            self.configure_mock(**kwargs)

        _safe_super(NonCallableMock, self).__init__(
            spec, wraps, name, spec_set, parent,
            _spec_state
        )


    def attach_mock(self, mock, attribute):
        """
        Attach a mock as an attribute of this one, replacing its name and
        parent. Calls to the attached mock will be recorded in the
        `method_calls` and `mock_calls` attributes of this one."""
        inner_mock = _extract_mock(mock)

        inner_mock._mock_parent = None
        inner_mock._mock_new_parent = None
        inner_mock._mock_name = ''
        inner_mock._mock_new_name = None

        setattr(self, attribute, mock)


    def mock_add_spec(self, spec, spec_set=False):
        """Add a spec to a mock. `spec` can either be an object or a
        list of strings. Only attributes on the `spec` can be fetched as
        attributes from the mock.

        If `spec_set` is True then only attributes on the spec can be set."""
        self._mock_add_spec(spec, spec_set)


    def _mock_add_spec(self, spec, spec_set, _spec_as_instance=False,
                       _eat_self=False):
        _spec_class = None
        _spec_signature = None
        _spec_asyncs = []

        for attr in dir(spec):
            if asyncio.iscoroutinefunction(getattr(spec, attr, None)):
                _spec_asyncs.append(attr)

        if spec is not None and not _is_list(spec):
            if isinstance(spec, type):
                _spec_class = spec
            else:
                _spec_class = type(spec)
            res = _get_signature_object(spec,
                                        _spec_as_instance, _eat_self)
            _spec_signature = res and res[1]

            spec = dir(spec)

        __dict__ = self.__dict__
        __dict__['_spec_class'] = _spec_class
        __dict__['_spec_set'] = spec_set
        __dict__['_spec_signature'] = _spec_signature
        __dict__['_mock_methods'] = spec
        __dict__['_spec_asyncs'] = _spec_asyncs

    def __get_return_value(self):
        ret = self._mock_return_value
        if self._mock_delegate is not None:
            ret = self._mock_delegate.return_value

        if ret is DEFAULT:
            ret = self._get_child_mock(
                _new_parent=self, _new_name='()'
            )
            self.return_value = ret
        return ret


    def __set_return_value(self, value):
        if self._mock_delegate is not None:
            self._mock_delegate.return_value = value
        else:
            self._mock_return_value = value
            _check_and_set_parent(self, value, None, '()')

    __return_value_doc = "The value to be returned when the mock is called."
    return_value = property(__get_return_value, __set_return_value,
                            __return_value_doc)


    @property
    def __class__(self):
        if self._spec_class is None:
            return type(self)
        return self._spec_class

    called = _delegating_property('called')
    call_count = _delegating_property('call_count')
    call_args = _delegating_property('call_args')
    call_args_list = _delegating_property('call_args_list')
    mock_calls = _delegating_property('mock_calls')


    def __get_side_effect(self):
        delegated = self._mock_delegate
        if delegated is None:
            return self._mock_side_effect
        sf = delegated.side_effect
        if (sf is not None and not callable(sf)
                and not isinstance(sf, _MockIter) and not _is_exception(sf)):
            sf = _MockIter(sf)
            delegated.side_effect = sf
        return sf

    def __set_side_effect(self, value):
        value = _try_iter(value)
        delegated = self._mock_delegate
        if delegated is None:
            self._mock_side_effect = value
        else:
            delegated.side_effect = value

    side_effect = property(__get_side_effect, __set_side_effect)


    def reset_mock(self,  visited=None,*, return_value=False, side_effect=False):
        "Restore the mock object to its initial state."
        if visited is None:
            visited = []
        if id(self) in visited:
            return
        visited.append(id(self))

        self.called = False
        self.call_args = None
        self.call_count = 0
        self.mock_calls = _CallList()
        self.call_args_list = _CallList()
        self.method_calls = _CallList()

        if return_value:
            self._mock_return_value = DEFAULT
        if side_effect:
            self._mock_side_effect = None

        for child in self._mock_children.values():
            if isinstance(child, _SpecState) or child is _deleted:
                continue
            child.reset_mock(visited)

        ret = self._mock_return_value
        if _is_instance_mock(ret) and ret is not self:
            ret.reset_mock(visited)


    def configure_mock(self, /, **kwargs):
        """Set attributes on the mock through keyword arguments.

        Attributes plus return values and side effects can be set on child
        mocks using standard dot notation and unpacking a dictionary in the
        method call:

        >>> attrs = {'method.return_value': 3, 'other.side_effect': KeyError}
        >>> mock.configure_mock(**attrs)"""
        for arg, val in sorted(kwargs.items(),
                               # we sort on the number of dots so that
                               # attributes are set before we set attributes on
                               # attributes
                               key=lambda entry: entry[0].count('.')):
            args = arg.split('.')
            final = args.pop()
            obj = self
            for entry in args:
                obj = getattr(obj, entry)
            setattr(obj, final, val)


    def __getattr__(self, name):
        if name in {'_mock_methods', '_mock_unsafe'}:
            raise AttributeError(name)
        elif self._mock_methods is not None:
            if name not in self._mock_methods or name in _all_magics:
                raise AttributeError("Mock object has no attribute %r" % name)
        elif _is_magic(name):
            raise AttributeError(name)
        if not self._mock_unsafe:
            if name.startswith(('assert', 'assret')):
                raise AttributeError("Attributes cannot start with 'assert' "
                                     "or 'assret'")

        result = self._mock_children.get(name)
        if result is _deleted:
            raise AttributeError(name)
        elif result is None:
            wraps = None
            if self._mock_wraps is not None:
                # XXXX should we get the attribute without triggering code
                # execution?
                wraps = getattr(self._mock_wraps, name)

            result = self._get_child_mock(
                parent=self, name=name, wraps=wraps, _new_name=name,
                _new_parent=self
            )
            self._mock_children[name]  = result

        elif isinstance(result, _SpecState):
            result = create_autospec(
                result.spec, result.spec_set, result.instance,
                result.parent, result.name
            )
            self._mock_children[name]  = result

        return result


    def _extract_mock_name(self):
        _name_list = [self._mock_new_name]
        _parent = self._mock_new_parent
        last = self

        dot = '.'
        if _name_list == ['()']:
            dot = ''

        while _parent is not None:
            last = _parent

            _name_list.append(_parent._mock_new_name + dot)
            dot = '.'
            if _parent._mock_new_name == '()':
                dot = ''

            _parent = _parent._mock_new_parent

        _name_list = list(reversed(_name_list))
        _first = last._mock_name or 'mock'
        if len(_name_list) > 1:
            if _name_list[1] not in ('()', '().'):
                _first += '.'
        _name_list[0] = _first
        return ''.join(_name_list)

    def __repr__(self):
        name = self._extract_mock_name()

        name_string = ''
        if name not in ('mock', 'mock.'):
            name_string = ' name=%r' % name

        spec_string = ''
        if self._spec_class is not None:
            spec_string = ' spec=%r'
            if self._spec_set:
                spec_string = ' spec_set=%r'
            spec_string = spec_string % self._spec_class.__name__
        return "<%s%s%s id='%s'>" % (
            type(self).__name__,
            name_string,
            spec_string,
            id(self)
        )


    def __dir__(self):
        """Filter the output of `dir(mock)` to only useful members."""
        if not FILTER_DIR:
            return object.__dir__(self)

        extras = self._mock_methods or []
        from_type = dir(type(self))
        from_dict = list(self.__dict__)
        from_child_mocks = [
            m_name for m_name, m_value in self._mock_children.items()
            if m_value is not _deleted]

        from_type = [e for e in from_type if not e.startswith('_')]
        from_dict = [e for e in from_dict if not e.startswith('_') or
                     _is_magic(e)]
        return sorted(set(extras + from_type + from_dict + from_child_mocks))


    def __setattr__(self, name, value):
        if name in _allowed_names:
            # property setters go through here
            return object.__setattr__(self, name, value)
        elif (self._spec_set and self._mock_methods is not None and
            name not in self._mock_methods and
            name not in self.__dict__):
            raise AttributeError("Mock object has no attribute '%s'" % name)
        elif name in _unsupported_magics:
            msg = 'Attempting to set unsupported magic method %r.' % name
            raise AttributeError(msg)
        elif name in _all_magics:
            if self._mock_methods is not None and name not in self._mock_methods:
                raise AttributeError("Mock object has no attribute '%s'" % name)

            if not _is_instance_mock(value):
                setattr(type(self), name, _get_method(name, value))
                original = value
                value = lambda *args, **kw: original(self, *args, **kw)
            else:
                # only set _new_name and not name so that mock_calls is tracked
                # but not method calls
                _check_and_set_parent(self, value, None, name)
                setattr(type(self), name, value)
                self._mock_children[name] = value
        elif name == '__class__':
            self._spec_class = value
            return
        else:
            if _check_and_set_parent(self, value, name, name):
                self._mock_children[name] = value

        if self._mock_sealed and not hasattr(self, name):
            mock_name = f'{self._extract_mock_name()}.{name}'
            raise AttributeError(f'Cannot set {mock_name}')

        return object.__setattr__(self, name, value)


    def __delattr__(self, name):
        if name in _all_magics and name in type(self).__dict__:
            delattr(type(self), name)
            if name not in self.__dict__:
                # for magic methods that are still MagicProxy objects and
                # not set on the instance itself
                return

        obj = self._mock_children.get(name, _missing)
        if name in self.__dict__:
            _safe_super(NonCallableMock, self).__delattr__(name)
        elif obj is _deleted:
            raise AttributeError(name)
        if obj is not _missing:
            del self._mock_children[name]
        self._mock_children[name] = _deleted


    def _format_mock_call_signature(self, args, kwargs):
        name = self._mock_name or 'mock'
        return _format_call_signature(name, args, kwargs)


    def _format_mock_failure_message(self, args, kwargs, action='call'):
        message = 'expected %s not found.\nExpected: %s\nActual: %s'
        expected_string = self._format_mock_call_signature(args, kwargs)
        call_args = self.call_args
        actual_string = self._format_mock_call_signature(*call_args)
        return message % (action, expected_string, actual_string)


    def _get_call_signature_from_name(self, name):
        """
        * If call objects are asserted against a method/function like obj.meth1
        then there could be no name for the call object to lookup. Hence just
        return the spec_signature of the method/function being asserted against.
        * If the name is not empty then remove () and split by '.' to get
        list of names to iterate through the children until a potential
        match is found. A child mock is created only during attribute access
        so if we get a _SpecState then no attributes of the spec were accessed
        and can be safely exited.
        """
        if not name:
            return self._spec_signature

        sig = None
        names = name.replace('()', '').split('.')
        children = self._mock_children

        for name in names:
            child = children.get(name)
            if child is None or isinstance(child, _SpecState):
                break
            else:
                # If an autospecced object is attached using attach_mock the
                # child would be a function with mock object as attribute from
                # which signature has to be derived.
                child = _extract_mock(child)
                children = child._mock_children
                sig = child._spec_signature

        return sig


    def _call_matcher(self, _call):
        """
        Given a call (or simply an (args, kwargs) tuple), return a
        comparison key suitable for matching with other calls.
        This is a best effort method which relies on the spec's signature,
        if available, or falls back on the arguments themselves.
        """

        if isinstance(_call, tuple) and len(_call) > 2:
            sig = self._get_call_signature_from_name(_call[0])
        else:
            sig = self._spec_signature

        if sig is not None:
            if len(_call) == 2:
                name = ''
                args, kwargs = _call
            else:
                name, args, kwargs = _call
            try:
                return name, sig.bind(*args, **kwargs)
            except TypeError as e:
                return e.with_traceback(None)
        else:
            return _call

    def assert_not_called(self):
        """assert that the mock was never called.
        """
        if self.call_count != 0:
            msg = ("Expected '%s' to not have been called. Called %s times.%s"
                   % (self._mock_name or 'mock',
                      self.call_count,
                      self._calls_repr()))
            raise AssertionError(msg)

    def assert_called(self):
        """assert that the mock was called at least once
        """
        if self.call_count == 0:
            msg = ("Expected '%s' to have been called." %
                   (self._mock_name or 'mock'))
            raise AssertionError(msg)

    def assert_called_once(self):
        """assert that the mock was called only once.
        """
        if not self.call_count == 1:
            msg = ("Expected '%s' to have been called once. Called %s times.%s"
                   % (self._mock_name or 'mock',
                      self.call_count,
                      self._calls_repr()))
            raise AssertionError(msg)

    def assert_called_with(self, /, *args, **kwargs):
        """assert that the last call was made with the specified arguments.

        Raises an AssertionError if the args and keyword args passed in are
        different to the last call to the mock."""
        if self.call_args is None:
            expected = self._format_mock_call_signature(args, kwargs)
            actual = 'not called.'
            error_message = ('expected call not found.\nExpected: %s\nActual: %s'
                    % (expected, actual))
            raise AssertionError(error_message)

        def _error_message():
            msg = self._format_mock_failure_message(args, kwargs)
            return msg
        expected = self._call_matcher((args, kwargs))
        actual = self._call_matcher(self.call_args)
        if expected != actual:
            cause = expected if isinstance(expected, Exception) else None
            raise AssertionError(_error_message()) from cause


    def assert_called_once_with(self, /, *args, **kwargs):
        """assert that the mock was called exactly once and that that call was
        with the specified arguments."""
        if not self.call_count == 1:
            msg = ("Expected '%s' to be called once. Called %s times.%s"
                   % (self._mock_name or 'mock',
                      self.call_count,
                      self._calls_repr()))
            raise AssertionError(msg)
        return self.assert_called_with(*args, **kwargs)


    def assert_has_calls(self, calls, any_order=False):
        """assert the mock has been called with the specified calls.
        The `mock_calls` list is checked for the calls.

        If `any_order` is False (the default) then the calls must be
        sequential. There can be extra calls before or after the
        specified calls.

        If `any_order` is True then the calls can be in any order, but
        they must all appear in `mock_calls`."""
        expected = [self._call_matcher(c) for c in calls]
        cause = next((e for e in expected if isinstance(e, Exception)), None)
        all_calls = _CallList(self._call_matcher(c) for c in self.mock_calls)
        if not any_order:
            if expected not in all_calls:
                if cause is None:
                    problem = 'Calls not found.'
                else:
                    problem = ('Error processing expected calls.\n'
                               'Errors: {}').format(
                                   [e if isinstance(e, Exception) else None
                                    for e in expected])
                raise AssertionError(
                    f'{problem}\n'
                    f'Expected: {_CallList(calls)}'
                    f'{self._calls_repr(prefix="Actual").rstrip(".")}'
                ) from cause
            return

        all_calls = list(all_calls)

        not_found = []
        for kall in expected:
            try:
                all_calls.remove(kall)
            except ValueError:
                not_found.append(kall)
        if not_found:
            raise AssertionError(
                '%r does not contain all of %r in its call list, '
                'found %r instead' % (self._mock_name or 'mock',
                                      tuple(not_found), all_calls)
            ) from cause


    def assert_any_call(self, /, *args, **kwargs):
        """assert the mock has been called with the specified arguments.

        The assert passes if the mock has *ever* been called, unlike
        `assert_called_with` and `assert_called_once_with` that only pass if
        the call is the most recent one."""
        expected = self._call_matcher((args, kwargs))
        actual = [self._call_matcher(c) for c in self.call_args_list]
        if expected not in actual:
            cause = expected if isinstance(expected, Exception) else None
            expected_string = self._format_mock_call_signature(args, kwargs)
            raise AssertionError(
                '%s call not found' % expected_string
            ) from cause


    def _get_child_mock(self, /, **kw):
        """Create the child mocks for attributes and return value.
        By default child mocks will be the same type as the parent.
        Subclasses of Mock may want to override this to customize the way
        child mocks are made.

        For non-callable mocks the callable variant will be used (rather than
        any custom subclass)."""
        _new_name = kw.get("_new_name")
        if _new_name in self.__dict__['_spec_asyncs']:
            return AsyncMock(**kw)

        _type = type(self)
        if issubclass(_type, MagicMock) and _new_name in _async_method_magics:
            # Any asynchronous magic becomes an AsyncMock
            klass = AsyncMock
        elif issubclass(_type, AsyncMockMixin):
            if (_new_name in _all_sync_magics or
                    self._mock_methods and _new_name in self._mock_methods):
                # Any synchronous method on AsyncMock becomes a MagicMock
                klass = MagicMock
            else:
                klass = AsyncMock
        elif not issubclass(_type, CallableMixin):
            if issubclass(_type, NonCallableMagicMock):
                klass = MagicMock
            elif issubclass(_type, NonCallableMock):
                klass = Mock
        else:
            klass = _type.__mro__[1]

        if self._mock_sealed:
            attribute = "." + kw["name"] if "name" in kw else "()"
            mock_name = self._extract_mock_name() + attribute
            raise AttributeError(mock_name)

        return klass(**kw)


    def _calls_repr(self, prefix="Calls"):
        """Renders self.mock_calls as a string.

        Example: "\nCalls: [call(1), call(2)]."

        If self.mock_calls is empty, an empty string is returned. The
        output will be truncated if very long.
        """
        if not self.mock_calls:
            return ""
        return f"\n{prefix}: {safe_repr(self.mock_calls)}."



def _try_iter(obj):
    if obj is None:
        return obj
    if _is_exception(obj):
        return obj
    if _callable(obj):
        return obj
    try:
        return iter(obj)
    except TypeError:
        # XXXX backwards compatibility
        # but this will blow up on first call - so maybe we should fail early?
        return obj


class CallableMixin(Base):

    def __init__(self, spec=None, side_effect=None, return_value=DEFAULT,
                 wraps=None, name=None, spec_set=None, parent=None,
                 _spec_state=None, _new_name='', _new_parent=None, **kwargs):
        self.__dict__['_mock_return_value'] = return_value
        _safe_super(CallableMixin, self).__init__(
            spec, wraps, name, spec_set, parent,
            _spec_state, _new_name, _new_parent, **kwargs
        )

        self.side_effect = side_effect


    def _mock_check_sig(self, /, *args, **kwargs):
        # stub method that can be replaced with one with a specific signature
        pass


    def __call__(self, /, *args, **kwargs):
        # can't use self in-case a function / method we are mocking uses self
        # in the signature
        self._mock_check_sig(*args, **kwargs)
        self._increment_mock_call(*args, **kwargs)
        return self._mock_call(*args, **kwargs)


    def _mock_call(self, /, *args, **kwargs):
        return self._execute_mock_call(*args, **kwargs)

    def _increment_mock_call(self, /, *args, **kwargs):
        self.called = True
        self.call_count += 1

        # handle call_args
        # needs to be set here so assertions on call arguments pass before
        # execution in the case of awaited calls
        _call = _Call((args, kwargs), two=True)
        self.call_args = _call
        self.call_args_list.append(_call)

        # initial stuff for method_calls:
        do_method_calls = self._mock_parent is not None
        method_call_name = self._mock_name

        # initial stuff for mock_calls:
        mock_call_name = self._mock_new_name
        is_a_call = mock_call_name == '()'
        self.mock_calls.append(_Call(('', args, kwargs)))

        # follow up the chain of mocks:
        _new_parent = self._mock_new_parent
        while _new_parent is not None:

            # handle method_calls:
            if do_method_calls:
                _new_parent.method_calls.append(_Call((method_call_name, args, kwargs)))
                do_method_calls = _new_parent._mock_parent is not None
                if do_method_calls:
                    method_call_name = _new_parent._mock_name + '.' + method_call_name

            # handle mock_calls:
            this_mock_call = _Call((mock_call_name, args, kwargs))
            _new_parent.mock_calls.append(this_mock_call)

            if _new_parent._mock_new_name:
                if is_a_call:
                    dot = ''
                else:
                    dot = '.'
                is_a_call = _new_parent._mock_new_name == '()'
                mock_call_name = _new_parent._mock_new_name + dot + mock_call_name

            # follow the parental chain:
            _new_parent = _new_parent._mock_new_parent

    def _execute_mock_call(self, /, *args, **kwargs):
        # separate from _increment_mock_call so that awaited functions are
        # executed separately from their call, also AsyncMock overrides this method

        effect = self.side_effect
        if effect is not None:
            if _is_exception(effect):
                raise effect
            elif not _callable(effect):
                result = next(effect)
                if _is_exception(result):
                    raise result
            else:
                result = effect(*args, **kwargs)

            if result is not DEFAULT:
                return result

        if self._mock_return_value is not DEFAULT:
            return self.return_value

        if self._mock_wraps is not None:
            return self._mock_wraps(*args, **kwargs)

        return self.return_value



class Mock(CallableMixin, NonCallableMock):
    """
    Create a new `Mock` object. `Mock` takes several optional arguments
    that specify the behaviour of the Mock object:

    * `spec`: This can be either a list of strings or an existing object (a
      class or instance) that acts as the specification for the mock object. If
      you pass in an object then a list of strings is formed by calling dir on
      the object (excluding unsupported magic attributes and methods). Accessing
      any attribute not in this list will raise an `AttributeError`.

      If `spec` is an object (rather than a list of strings) then
      `mock.__class__` returns the class of the spec object. This allows mocks
      to pass `isinstance` tests.

    * `spec_set`: A stricter variant of `spec`. If used, attempting to *set*
      or get an attribute on the mock that isn't on the object passed as
      `spec_set` will raise an `AttributeError`.

    * `side_effect`: A function to be called whenever the Mock is called. See
      the `side_effect` attribute. Useful for raising exceptions or
      dynamically changing return values. The function is called with the same
      arguments as the mock, and unless it returns `DEFAULT`, the return
      value of this function is used as the return value.

      If `side_effect` is an iterable then each call to the mock will return
      the next value from the iterable. If any of the members of the iterable
      are exceptions they will be raised instead of returned.

    * `return_value`: The value returned when the mock is called. By default
      this is a new Mock (created on first access). See the
      `return_value` attribute.

    * `wraps`: Item for the mock object to wrap. If `wraps` is not None then
      calling the Mock will pass the call through to the wrapped object
      (returning the real result). Attribute access on the mock will return a
      Mock object that wraps the corresponding attribute of the wrapped object
      (so attempting to access an attribute that doesn't exist will raise an
      `AttributeError`).

      If the mock has an explicit `return_value` set then calls are not passed
      to the wrapped object and the `return_value` is returned instead.

    * `name`: If the mock has a name then it will be used in the repr of the
      mock. This can be useful for debugging. The name is propagated to child
      mocks.

    Mocks can also be called with arbitrary keyword arguments. These will be
    used to set attributes on the mock after it is created.
    """


def _dot_lookup(thing, comp, import_path):
    try:
        return getattr(thing, comp)
    except AttributeError:
        __import__(import_path)
        return getattr(thing, comp)


def _importer(target):
    components = target.split('.')
    import_path = components.pop(0)
    thing = __import__(import_path)

    for comp in components:
        import_path += ".%s" % comp
        thing = _dot_lookup(thing, comp, import_path)
    return thing


class _patch(object):

    attribute_name = None
    _active_patches = []

    def __init__(
            self, getter, attribute, new, spec, create,
            spec_set, autospec, new_callable, kwargs
        ):
        if new_callable is not None:
            if new is not DEFAULT:
                raise ValueError(
                    "Cannot use 'new' and 'new_callable' together"
                )
            if autospec is not None:
                raise ValueError(
                    "Cannot use 'autospec' and 'new_callable' together"
                )

        self.getter = getter
        self.attribute = attribute
        self.new = new
        self.new_callable = new_callable
        self.spec = spec
        self.create = create
        self.has_local = False
        self.spec_set = spec_set
        self.autospec = autospec
        self.kwargs = kwargs
        self.additional_patchers = []


    def copy(self):
        patcher = _patch(
            self.getter, self.attribute, self.new, self.spec,
            self.create, self.spec_set,
            self.autospec, self.new_callable, self.kwargs
        )
        patcher.attribute_name = self.attribute_name
        patcher.additional_patchers = [
            p.copy() for p in self.additional_patchers
        ]
        return patcher


    def __call__(self, func):
        if isinstance(func, type):
            return self.decorate_class(func)
        if inspect.iscoroutinefunction(func):
            return self.decorate_async_callable(func)
        return self.decorate_callable(func)


    def decorate_class(self, klass):
        for attr in dir(klass):
            if not attr.startswith(patch.TEST_PREFIX):
                continue

            attr_value = getattr(klass, attr)
            if not hasattr(attr_value, "__call__"):
                continue

            patcher = self.copy()
            setattr(klass, attr, patcher(attr_value))
        return klass


    @contextlib.contextmanager
    def decoration_helper(self, patched, args, keywargs):
        extra_args = []
        with contextlib.ExitStack() as exit_stack:
            for patching in patched.patchings:
                arg = exit_stack.enter_context(patching)
                if patching.attribute_name is not None:
                    keywargs.update(arg)
                elif patching.new is DEFAULT:
                    extra_args.append(arg)

            args += tuple(extra_args)
            yield (args, keywargs)


    def decorate_callable(self, func):
        # NB. Keep the method in sync with decorate_async_callable()
        if hasattr(func, 'patchings'):
            func.patchings.append(self)
            return func

        @wraps(func)
        def patched(*args, **keywargs):
            with self.decoration_helper(patched,
                                        args,
                                        keywargs) as (newargs, newkeywargs):
                return func(*newargs, **newkeywargs)

        patched.patchings = [self]
        return patched


    def decorate_async_callable(self, func):
        # NB. Keep the method in sync with decorate_callable()
        if hasattr(func, 'patchings'):
            func.patchings.append(self)
            return func

        @wraps(func)
        async def patched(*args, **keywargs):
            with self.decoration_helper(patched,
                                        args,
                                        keywargs) as (newargs, newkeywargs):
                return await func(*newargs, **newkeywargs)

        patched.patchings = [self]
        return patched


    def get_original(self):
        target = self.getter()
        name = self.attribute

        original = DEFAULT
        local = False

        try:
            original = target.__dict__[name]
        except (AttributeError, KeyError):
            original = getattr(target, name, DEFAULT)
        else:
            local = True

        if name in _builtins and isinstance(target, ModuleType):
            self.create = True

        if not self.create and original is DEFAULT:
            raise AttributeError(
                "%s does not have the attribute %r" % (target, name)
            )
        return original, local


    def __enter__(self):
        """Perform the patch."""
        new, spec, spec_set = self.new, self.spec, self.spec_set
        autospec, kwargs = self.autospec, self.kwargs
        new_callable = self.new_callable
        self.target = self.getter()

        # normalise False to None
        if spec is False:
            spec = None
        if spec_set is False:
            spec_set = None
        if autospec is False:
            autospec = None

        if spec is not None and autospec is not None:
            raise TypeError("Can't specify spec and autospec")
        if ((spec is not None or autospec is not None) and
            spec_set not in (True, None)):
            raise TypeError("Can't provide explicit spec_set *and* spec or autospec")

        original, local = self.get_original()

        if new is DEFAULT and autospec is None:
            inherit = False
            if spec is True:
                # set spec to the object we are replacing
                spec = original
                if spec_set is True:
                    spec_set = original
                    spec = None
            elif spec is not None:
                if spec_set is True:
                    spec_set = spec
                    spec = None
            elif spec_set is True:
                spec_set = original

            if spec is not None or spec_set is not None:
                if original is DEFAULT:
                    raise TypeError("Can't use 'spec' with create=True")
                if isinstance(original, type):
                    # If we're patching out a class and there is a spec
                    inherit = True
            if spec is None and _is_async_obj(original):
                Klass = AsyncMock
            else:
                Klass = MagicMock
            _kwargs = {}
            if new_callable is not None:
                Klass = new_callable
            elif spec is not None or spec_set is not None:
                this_spec = spec
                if spec_set is not None:
                    this_spec = spec_set
                if _is_list(this_spec):
                    not_callable = '__call__' not in this_spec
                else:
                    not_callable = not callable(this_spec)
                if _is_async_obj(this_spec):
                    Klass = AsyncMock
                elif not_callable:
                    Klass = NonCallableMagicMock

            if spec is not None:
                _kwargs['spec'] = spec
            if spec_set is not None:
                _kwargs['spec_set'] = spec_set

            # add a name to mocks
            if (isinstance(Klass, type) and
                issubclass(Klass, NonCallableMock) and self.attribute):
                _kwargs['name'] = self.attribute

            _kwargs.update(kwargs)
            new = Klass(**_kwargs)

            if inherit and _is_instance_mock(new):
                # we can only tell if the instance should be callable if the
                # spec is not a list
                this_spec = spec
                if spec_set is not None:
                    this_spec = spec_set
                if (not _is_list(this_spec) and not
                    _instance_callable(this_spec)):
                    Klass = NonCallableMagicMock

                _kwargs.pop('name')
                new.return_value = Klass(_new_parent=new, _new_name='()',
                                         **_kwargs)
        elif autospec is not None:
            # spec is ignored, new *must* be default, spec_set is treated
            # as a boolean. Should we check spec is not None and that spec_set
            # is a bool?
            if new is not DEFAULT:
                raise TypeError(
                    "autospec creates the mock for you. Can't specify "
                    "autospec and new."
                )
            if original is DEFAULT:
                raise TypeError("Can't use 'autospec' with create=True")
            spec_set = bool(spec_set)
            if autospec is True:
                autospec = original

            new = create_autospec(autospec, spec_set=spec_set,
                                  _name=self.attribute, **kwargs)
        elif kwargs:
            # can't set keyword args when we aren't creating the mock
            # XXXX If new is a Mock we could call new.configure_mock(**kwargs)
            raise TypeError("Can't pass kwargs to a mock we aren't creating")

        new_attr = new

        self.temp_original = original
        self.is_local = local
        self._exit_stack = contextlib.ExitStack()
        try:
            setattr(self.target, self.attribute, new_attr)
            if self.attribute_name is not None:
                extra_args = {}
                if self.new is DEFAULT:
                    extra_args[self.attribute_name] =  new
                for patching in self.additional_patchers:
                    arg = self._exit_stack.enter_context(patching)
                    if patching.new is DEFAULT:
                        extra_args.update(arg)
                return extra_args

            return new
        except:
            if not self.__exit__(*sys.exc_info()):
                raise

    def __exit__(self, *exc_info):
        """Undo the patch."""
        if self.is_local and self.temp_original is not DEFAULT:
            setattr(self.target, self.attribute, self.temp_original)
        else:
            delattr(self.target, self.attribute)
            if not self.create and (not hasattr(self.target, self.attribute) or
                        self.attribute in ('__doc__', '__module__',
                                           '__defaults__', '__annotations__',
                                           '__kwdefaults__')):
                # needed for proxy objects like django settings
                setattr(self.target, self.attribute, self.temp_original)

        del self.temp_original
        del self.is_local
        del self.target
        exit_stack = self._exit_stack
        del self._exit_stack
        return exit_stack.__exit__(*exc_info)


    def start(self):
        """Activate a patch, returning any created mock."""
        result = self.__enter__()
        self._active_patches.append(self)
        return result


    def stop(self):
        """Stop an active patch."""
        try:
            self._active_patches.remove(self)
        except ValueError:
            # If the patch hasn't been started this will fail
            return None

        return self.__exit__(None, None, None)



def _get_target(target):
    try:
        target, attribute = target.rsplit('.', 1)
    except (TypeError, ValueError):
        raise TypeError("Need a valid target to patch. You supplied: %r" %
                        (target,))
    getter = lambda: _importer(target)
    return getter, attribute


def _patch_object(
        target, attribute, new=DEFAULT, spec=None,
        create=False, spec_set=None, autospec=None,
        new_callable=None, **kwargs
    ):
    """
    patch the named member (`attribute`) on an object (`target`) with a mock
    object.

    `patch.object` can be used as a decorator, class decorator or a context
    manager. Arguments `new`, `spec`, `create`, `spec_set`,
    `autospec` and `new_callable` have the same meaning as for `patch`. Like
    `patch`, `patch.object` takes arbitrary keyword arguments for configuring
    the mock object it creates.

    When used as a class decorator `patch.object` honours `patch.TEST_PREFIX`
    for choosing which methods to wrap.
    """
    if type(target) is str:
        raise TypeError(
            f"{target!r} must be the actual object to be patched, not a str"
        )
    getter = lambda: target
    return _patch(
        getter, attribute, new, spec, create,
        spec_set, autospec, new_callable, kwargs
    )


def _patch_multiple(target, spec=None, create=False, spec_set=None,
                    autospec=None, new_callable=None, **kwargs):
    """Perform multiple patches in a single call. It takes the object to be
    patched (either as an object or a string to fetch the object by importing)
    and keyword arguments for the patches::

        with patch.multiple(settings, FIRST_PATCH='one', SECOND_PATCH='two'):
            ...

    Use `DEFAULT` as the value if you want `patch.multiple` to create
    mocks for you. In this case the created mocks are passed into a decorated
    function by keyword, and a dictionary is returned when `patch.multiple` is
    used as a context manager.

    `patch.multiple` can be used as a decorator, class decorator or a context
    manager. The arguments `spec`, `spec_set`, `create`,
    `autospec` and `new_callable` have the same meaning as for `patch`. These
    arguments will be applied to *all* patches done by `patch.multiple`.

    When used as a class decorator `patch.multiple` honours `patch.TEST_PREFIX`
    for choosing which methods to wrap.
    """
    if type(target) is str:
        getter = lambda: _importer(target)
    else:
        getter = lambda: target

    if not kwargs:
        raise ValueError(
            'Must supply at least one keyword argument with patch.multiple'
        )
    # need to wrap in a list for python 3, where items is a view
    items = list(kwargs.items())
    attribute, new = items[0]
    patcher = _patch(
        getter, attribute, new, spec, create, spec_set,
        autospec, new_callable, {}
    )
    patcher.attribute_name = attribute
    for attribute, new in items[1:]:
        this_patcher = _patch(
            getter, attribute, new, spec, create, spec_set,
            autospec, new_callable, {}
        )
        this_patcher.attribute_name = attribute
        patcher.additional_patchers.append(this_patcher)
    return patcher


def patch(
        target, new=DEFAULT, spec=None, create=False,
        spec_set=None, autospec=None, new_callable=None, **kwargs
    ):
    """
    `patch` acts as a function decorator, class decorator or a context
    manager. Inside the body of the function or with statement, the `target`
    is patched with a `new` object. When the function/with statement exits
    the patch is undone.

    If `new` is omitted, then the target is replaced with an
    `AsyncMock if the patched object is an async function or a
    `MagicMock` otherwise. If `patch` is used as a decorator and `new` is
    omitted, the created mock is passed in as an extra argument to the
    decorated function. If `patch` is used as a context manager the created
    mock is returned by the context manager.

    `target` should be a string in the form `'package.module.ClassName'`. The
    `target` is imported and the specified object replaced with the `new`
    object, so the `target` must be importable from the environment you are
    calling `patch` from. The target is imported when the decorated function
    is executed, not at decoration time.

    The `spec` and `spec_set` keyword arguments are passed to the `MagicMock`
    if patch is creating one for you.

    In addition you can pass `spec=True` or `spec_set=True`, which causes
    patch to pass in the object being mocked as the spec/spec_set object.

    `new_callable` allows you to specify a different class, or callable object,
    that will be called to create the `new` object. By default `AsyncMock` is
    used for async functions and `MagicMock` for the rest.

    A more powerful form of `spec` is `autospec`. If you set `autospec=True`
    then the mock will be created with a spec from the object being replaced.
    All attributes of the mock will also have the spec of the corresponding
    attribute of the object being replaced. Methods and functions being
    mocked will have their arguments checked and will raise a `TypeError` if
    they are called with the wrong signature. For mocks replacing a class,
    their return value (the 'instance') will have the same spec as the class.

    Instead of `autospec=True` you can pass `autospec=some_object` to use an
    arbitrary object as the spec instead of the one being replaced.

    By default `patch` will fail to replace attributes that don't exist. If
    you pass in `create=True`, and the attribute doesn't exist, patch will
    create the attribute for you when the patched function is called, and
    delete it again afterwards. This is useful for writing tests against
    attributes that your production code creates at runtime. It is off by
    default because it can be dangerous. With it switched on you can write
    passing tests against APIs that don't actually exist!

    Patch can be used as a `TestCase` class decorator. It works by
    decorating each test method in the class. This reduces the boilerplate
    code when your test methods share a common patchings set. `patch` finds
    tests by looking for method names that start with `patch.TEST_PREFIX`.
    By default this is `test`, which matches the way `unittest` finds tests.
    You can specify an alternative prefix by setting `patch.TEST_PREFIX`.

    Patch can be used as a context manager, with the with statement. Here the
    patching applies to the indented block after the with statement. If you
    use "as" then the patched object will be bound to the name after the
    "as"; very useful if `patch` is creating a mock object for you.

    `patch` takes arbitrary keyword arguments. These will be passed to
    the `Mock` (or `new_callable`) on construction.

    `patch.dict(...)`, `patch.multiple(...)` and `patch.object(...)` are
    available for alternate use-cases.
    """
    getter, attribute = _get_target(target)
    return _patch(
        getter, attribute, new, spec, create,
        spec_set, autospec, new_callable, kwargs
    )


class _patch_dict(object):
    """
    Patch a dictionary, or dictionary like object, and restore the dictionary
    to its original state after the test.

    `in_dict` can be a dictionary or a mapping like container. If it is a
    mapping then it must at least support getting, setting and deleting items
    plus iterating over keys.

    `in_dict` can also be a string specifying the name of the dictionary, which
    will then be fetched by importing it.

    `values` can be a dictionary of values to set in the dictionary. `values`
    can also be an iterable of `(key, value)` pairs.

    If `clear` is True then the dictionary will be cleared before the new
    values are set.

    `patch.dict` can also be called with arbitrary keyword arguments to set
    values in the dictionary::

        with patch.dict('sys.modules', mymodule=Mock(), other_module=Mock()):
            ...

    `patch.dict` can be used as a context manager, decorator or class
    decorator. When used as a class decorator `patch.dict` honours
    `patch.TEST_PREFIX` for choosing which methods to wrap.
    """

    def __init__(self, in_dict, values=(), clear=False, **kwargs):
        self.in_dict = in_dict
        # support any argument supported by dict(...) constructor
        self.values = dict(values)
        self.values.update(kwargs)
        self.clear = clear
        self._original = None


    def __call__(self, f):
        if isinstance(f, type):
            return self.decorate_class(f)
        @wraps(f)
        def _inner(*args, **kw):
            self._patch_dict()
            try:
                return f(*args, **kw)
            finally:
                self._unpatch_dict()

        return _inner


    def decorate_class(self, klass):
        for attr in dir(klass):
            attr_value = getattr(klass, attr)
            if (attr.startswith(patch.TEST_PREFIX) and
                 hasattr(attr_value, "__call__")):
                decorator = _patch_dict(self.in_dict, self.values, self.clear)
                decorated = decorator(attr_value)
                setattr(klass, attr, decorated)
        return klass


    def __enter__(self):
        """Patch the dict."""
        self._patch_dict()
        return self.in_dict


    def _patch_dict(self):
        values = self.values
        if isinstance(self.in_dict, str):
            self.in_dict = _importer(self.in_dict)
        in_dict = self.in_dict
        clear = self.clear

        try:
            original = in_dict.copy()
        except AttributeError:
            # dict like object with no copy method
            # must support iteration over keys
            original = {}
            for key in in_dict:
                original[key] = in_dict[key]
        self._original = original

        if clear:
            _clear_dict(in_dict)

        try:
            in_dict.update(values)
        except AttributeError:
            # dict like object with no update method
            for key in values:
                in_dict[key] = values[key]


    def _unpatch_dict(self):
        in_dict = self.in_dict
        original = self._original

        _clear_dict(in_dict)

        try:
            in_dict.update(original)
        except AttributeError:
            for key in original:
                in_dict[key] = original[key]


    def __exit__(self, *args):
        """Unpatch the dict."""
        self._unpatch_dict()
        return False

    start = __enter__
    stop = __exit__


def _clear_dict(in_dict):
    try:
        in_dict.clear()
    except AttributeError:
        keys = list(in_dict)
        for key in keys:
            del in_dict[key]


def _patch_stopall():
    """Stop all active patches. LIFO to unroll nested patches."""
    for patch in reversed(_patch._active_patches):
        patch.stop()


patch.object = _patch_object
patch.dict = _patch_dict
patch.multiple = _patch_multiple
patch.stopall = _patch_stopall
patch.TEST_PREFIX = 'test'

magic_methods = (
    "lt le gt ge eq ne "
    "getitem setitem delitem "
    "len contains iter "
    "hash str sizeof "
    "enter exit "
    # we added divmod and rdivmod here instead of numerics
    # because there is no idivmod
    "divmod rdivmod neg pos abs invert "
    "complex int float index "
    "round trunc floor ceil "
    "bool next "
    "fspath "
    "aiter "
)

numerics = (
    "add sub mul matmul div floordiv mod lshift rshift and xor or pow truediv"
)
inplace = ' '.join('i%s' % n for n in numerics.split())
right = ' '.join('r%s' % n for n in numerics.split())

# not including __prepare__, __instancecheck__, __subclasscheck__
# (as they are metaclass methods)
# __del__ is not supported at all as it causes problems if it exists

_non_defaults = {
    '__get__', '__set__', '__delete__', '__reversed__', '__missing__',
    '__reduce__', '__reduce_ex__', '__getinitargs__', '__getnewargs__',
    '__getstate__', '__setstate__', '__getformat__', '__setformat__',
    '__repr__', '__dir__', '__subclasses__', '__format__',
    '__getnewargs_ex__',
}


def _get_method(name, func):
    "Turns a callable object (like a mock) into a real function"
    def method(self, /, *args, **kw):
        return func(self, *args, **kw)
    method.__name__ = name
    return method


_magics = {
    '__%s__' % method for method in
    ' '.join([magic_methods, numerics, inplace, right]).split()
}

# Magic methods used for async `with` statements
_async_method_magics = {"__aenter__", "__aexit__", "__anext__"}
# Magic methods that are only used with async calls but are synchronous functions themselves
_sync_async_magics = {"__aiter__"}
_async_magics = _async_method_magics | _sync_async_magics

_all_sync_magics = _magics | _non_defaults
_all_magics = _all_sync_magics | _async_magics

_unsupported_magics = {
    '__getattr__', '__setattr__',
    '__init__', '__new__', '__prepare__',
    '__instancecheck__', '__subclasscheck__',
    '__del__'
}

_calculate_return_value = {
    '__hash__': lambda self: object.__hash__(self),
    '__str__': lambda self: object.__str__(self),
    '__sizeof__': lambda self: object.__sizeof__(self),
    '__fspath__': lambda self: f"{type(self).__name__}/{self._extract_mock_name()}/{id(self)}",
}

_return_values = {
    '__lt__': NotImplemented,
    '__gt__': NotImplemented,
    '__le__': NotImplemented,
    '__ge__': NotImplemented,
    '__int__': 1,
    '__contains__': False,
    '__len__': 0,
    '__exit__': False,
    '__complex__': 1j,
    '__float__': 1.0,
    '__bool__': True,
    '__index__': 1,
    '__aexit__': False,
}


def _get_eq(self):
    def __eq__(other):
        ret_val = self.__eq__._mock_return_value
        if ret_val is not DEFAULT:
            return ret_val
        if self is other:
            return True
        return NotImplemented
    return __eq__

def _get_ne(self):
    def __ne__(other):
        if self.__ne__._mock_return_value is not DEFAULT:
            return DEFAULT
        if self is other:
            return False
        return NotImplemented
    return __ne__

def _get_iter(self):
    def __iter__():
        ret_val = self.__iter__._mock_return_value
        if ret_val is DEFAULT:
            return iter([])
        # if ret_val was already an iterator, then calling iter on it should
        # return the iterator unchanged
        return iter(ret_val)
    return __iter__

def _get_async_iter(self):
    def __aiter__():
        ret_val = self.__aiter__._mock_return_value
        if ret_val is DEFAULT:
            return _AsyncIterator(iter([]))
        return _AsyncIterator(iter(ret_val))
    return __aiter__

_side_effect_methods = {
    '__eq__': _get_eq,
    '__ne__': _get_ne,
    '__iter__': _get_iter,
    '__aiter__': _get_async_iter
}



def _set_return_value(mock, method, name):
    fixed = _return_values.get(name, DEFAULT)
    if fixed is not DEFAULT:
        method.return_value = fixed
        return

    return_calculator = _calculate_return_value.get(name)
    if return_calculator is not None:
        return_value = return_calculator(mock)
        method.return_value = return_value
        return

    side_effector = _side_effect_methods.get(name)
    if side_effector is not None:
        method.side_effect = side_effector(mock)



class MagicMixin(Base):
    def __init__(self, /, *args, **kw):
        self._mock_set_magics()  # make magic work for kwargs in init
        _safe_super(MagicMixin, self).__init__(*args, **kw)
        self._mock_set_magics()  # fix magic broken by upper level init


    def _mock_set_magics(self):
        orig_magics = _magics | _async_method_magics
        these_magics = orig_magics

        if getattr(self, "_mock_methods", None) is not None:
            these_magics = orig_magics.intersection(self._mock_methods)

            remove_magics = set()
            remove_magics = orig_magics - these_magics

            for entry in remove_magics:
                if entry in type(self).__dict__:
                    # remove unneeded magic methods
                    delattr(self, entry)

        # don't overwrite existing attributes if called a second time
        these_magics = these_magics - set(type(self).__dict__)

        _type = type(self)
        for entry in these_magics:
            setattr(_type, entry, MagicProxy(entry, self))



class NonCallableMagicMock(MagicMixin, NonCallableMock):
    """A version of `MagicMock` that isn't callable."""
    def mock_add_spec(self, spec, spec_set=False):
        """Add a spec to a mock. `spec` can either be an object or a
        list of strings. Only attributes on the `spec` can be fetched as
        attributes from the mock.

        If `spec_set` is True then only attributes on the spec can be set."""
        self._mock_add_spec(spec, spec_set)
        self._mock_set_magics()


class AsyncMagicMixin(MagicMixin):
    def __init__(self, /, *args, **kw):
        self._mock_set_magics()  # make magic work for kwargs in init
        _safe_super(AsyncMagicMixin, self).__init__(*args, **kw)
        self._mock_set_magics()  # fix magic broken by upper level init

class MagicMock(MagicMixin, Mock):
    """
    MagicMock is a subclass of Mock with default implementations
    of most of the magic methods. You can use MagicMock without having to
    configure the magic methods yourself.

    If you use the `spec` or `spec_set` arguments then *only* magic
    methods that exist in the spec will be created.

    Attributes and the return value of a `MagicMock` will also be `MagicMocks`.
    """
    def mock_add_spec(self, spec, spec_set=False):
        """Add a spec to a mock. `spec` can either be an object or a
        list of strings. Only attributes on the `spec` can be fetched as
        attributes from the mock.

        If `spec_set` is True then only attributes on the spec can be set."""
        self._mock_add_spec(spec, spec_set)
        self._mock_set_magics()



class MagicProxy(Base):
    def __init__(self, name, parent):
        self.name = name
        self.parent = parent

    def create_mock(self):
        entry = self.name
        parent = self.parent
        m = parent._get_child_mock(name=entry, _new_name=entry,
                                   _new_parent=parent)
        setattr(parent, entry, m)
        _set_return_value(parent, m, entry)
        return m

    def __get__(self, obj, _type=None):
        return self.create_mock()


class AsyncMockMixin(Base):
    await_count = _delegating_property('await_count')
    await_args = _delegating_property('await_args')
    await_args_list = _delegating_property('await_args_list')

    def __init__(self, /, *args, **kwargs):
        super().__init__(*args, **kwargs)
        # asyncio.iscoroutinefunction() checks _is_coroutine property to say if an
        # object is a coroutine. Without this check it looks to see if it is a
        # function/method, which in this case it is not (since it is an
        # AsyncMock).
        # It is set through __dict__ because when spec_set is True, this
        # attribute is likely undefined.
        self.__dict__['_is_coroutine'] = asyncio.coroutines._is_coroutine
        self.__dict__['_mock_await_count'] = 0
        self.__dict__['_mock_await_args'] = None
        self.__dict__['_mock_await_args_list'] = _CallList()
        code_mock = NonCallableMock(spec_set=CodeType)
        code_mock.co_flags = inspect.CO_COROUTINE
        self.__dict__['__code__'] = code_mock

    async def _execute_mock_call(self, /, *args, **kwargs):
        # This is nearly just like super(), except for sepcial handling
        # of coroutines

        _call = _Call((args, kwargs), two=True)
        self.await_count += 1
        self.await_args = _call
        self.await_args_list.append(_call)

        effect = self.side_effect
        if effect is not None:
            if _is_exception(effect):
                raise effect
            elif not _callable(effect):
                try:
                    result = next(effect)
                except StopIteration:
                    # It is impossible to propogate a StopIteration
                    # through coroutines because of PEP 479
                    raise StopAsyncIteration
                if _is_exception(result):
                    raise result
            elif asyncio.iscoroutinefunction(effect):
                result = await effect(*args, **kwargs)
            else:
                result = effect(*args, **kwargs)

            if result is not DEFAULT:
                return result

        if self._mock_return_value is not DEFAULT:
            return self.return_value

        if self._mock_wraps is not None:
            if asyncio.iscoroutinefunction(self._mock_wraps):
                return await self._mock_wraps(*args, **kwargs)
            return self._mock_wraps(*args, **kwargs)

        return self.return_value

    def assert_awaited(self):
        """
        Assert that the mock was awaited at least once.
        """
        if self.await_count == 0:
            msg = f"Expected {self._mock_name or 'mock'} to have been awaited."
            raise AssertionError(msg)

    def assert_awaited_once(self):
        """
        Assert that the mock was awaited exactly once.
        """
        if not self.await_count == 1:
            msg = (f"Expected {self._mock_name or 'mock'} to have been awaited once."
                   f" Awaited {self.await_count} times.")
            raise AssertionError(msg)

    def assert_awaited_with(self, /, *args, **kwargs):
        """
        Assert that the last await was with the specified arguments.
        """
        if self.await_args is None:
            expected = self._format_mock_call_signature(args, kwargs)
            raise AssertionError(f'Expected await: {expected}\nNot awaited')

        def _error_message():
            msg = self._format_mock_failure_message(args, kwargs, action='await')
            return msg

        expected = self._call_matcher((args, kwargs))
        actual = self._call_matcher(self.await_args)
        if expected != actual:
            cause = expected if isinstance(expected, Exception) else None
            raise AssertionError(_error_message()) from cause

    def assert_awaited_once_with(self, /, *args, **kwargs):
        """
        Assert that the mock was awaited exactly once and with the specified
        arguments.
        """
        if not self.await_count == 1:
            msg = (f"Expected {self._mock_name or 'mock'} to have been awaited once."
                   f" Awaited {self.await_count} times.")
            raise AssertionError(msg)
        return self.assert_awaited_with(*args, **kwargs)

    def assert_any_await(self, /, *args, **kwargs):
        """
        Assert the mock has ever been awaited with the specified arguments.
        """
        expected = self._call_matcher((args, kwargs))
        actual = [self._call_matcher(c) for c in self.await_args_list]
        if expected not in actual:
            cause = expected if isinstance(expected, Exception) else None
            expected_string = self._format_mock_call_signature(args, kwargs)
            raise AssertionError(
                '%s await not found' % expected_string
            ) from cause

    def assert_has_awaits(self, calls, any_order=False):
        """
        Assert the mock has been awaited with the specified calls.
        The :attr:`await_args_list` list is checked for the awaits.

        If `any_order` is False (the default) then the awaits must be
        sequential. There can be extra calls before or after the
        specified awaits.

        If `any_order` is True then the awaits can be in any order, but
        they must all appear in :attr:`await_args_list`.
        """
        expected = [self._call_matcher(c) for c in calls]
        cause = next((e for e in expected if isinstance(e, Exception)), None)
        all_awaits = _CallList(self._call_matcher(c) for c in self.await_args_list)
        if not any_order:
            if expected not in all_awaits:
                if cause is None:
                    problem = 'Awaits not found.'
                else:
                    problem = ('Error processing expected awaits.\n'
                               'Errors: {}').format(
                                   [e if isinstance(e, Exception) else None
                                    for e in expected])
                raise AssertionError(
                    f'{problem}\n'
                    f'Expected: {_CallList(calls)}\n'
                    f'Actual: {self.await_args_list}'
                ) from cause
            return

        all_awaits = list(all_awaits)

        not_found = []
        for kall in expected:
            try:
                all_awaits.remove(kall)
            except ValueError:
                not_found.append(kall)
        if not_found:
            raise AssertionError(
                '%r not all found in await list' % (tuple(not_found),)
            ) from cause

    def assert_not_awaited(self):
        """
        Assert that the mock was never awaited.
        """
        if self.await_count != 0:
            msg = (f"Expected {self._mock_name or 'mock'} to not have been awaited."
                   f" Awaited {self.await_count} times.")
            raise AssertionError(msg)

    def reset_mock(self, /, *args, **kwargs):
        """
        See :func:`.Mock.reset_mock()`
        """
        super().reset_mock(*args, **kwargs)
        self.await_count = 0
        self.await_args = None
        self.await_args_list = _CallList()


class AsyncMock(AsyncMockMixin, AsyncMagicMixin, Mock):
    """
    Enhance :class:`Mock` with features allowing to mock
    an async function.

    The :class:`AsyncMock` object will behave so the object is
    recognized as an async function, and the result of a call is an awaitable:

    >>> mock = AsyncMock()
    >>> asyncio.iscoroutinefunction(mock)
    True
    >>> inspect.isawaitable(mock())
    True


    The result of ``mock()`` is an async function which will have the outcome
    of ``side_effect`` or ``return_value``:

    - if ``side_effect`` is a function, the async function will return the
      result of that function,
    - if ``side_effect`` is an exception, the async function will raise the
      exception,
    - if ``side_effect`` is an iterable, the async function will return the
      next value of the iterable, however, if the sequence of result is
      exhausted, ``StopIteration`` is raised immediately,
    - if ``side_effect`` is not defined, the async function will return the
      value defined by ``return_value``, hence, by default, the async function
      returns a new :class:`AsyncMock` object.

    If the outcome of ``side_effect`` or ``return_value`` is an async function,
    the mock async function obtained when the mock object is called will be this
    async function itself (and not an async function returning an async
    function).

    The test author can also specify a wrapped object with ``wraps``. In this
    case, the :class:`Mock` object behavior is the same as with an
    :class:`.Mock` object: the wrapped object may have methods
    defined as async function functions.

    Based on Martin Richard's asynctest project.
    """


class _ANY(object):
    "A helper object that compares equal to everything."

    def __eq__(self, other):
        return True

    def __ne__(self, other):
        return False

    def __repr__(self):
        return '<ANY>'

ANY = _ANY()



def _format_call_signature(name, args, kwargs):
    message = '%s(%%s)' % name
    formatted_args = ''
    args_string = ', '.join([repr(arg) for arg in args])
    kwargs_string = ', '.join([
        '%s=%r' % (key, value) for key, value in kwargs.items()
    ])
    if args_string:
        formatted_args = args_string
    if kwargs_string:
        if formatted_args:
            formatted_args += ', '
        formatted_args += kwargs_string

    return message % formatted_args



class _Call(tuple):
    """
    A tuple for holding the results of a call to a mock, either in the form
    `(args, kwargs)` or `(name, args, kwargs)`.

    If args or kwargs are empty then a call tuple will compare equal to
    a tuple without those values. This makes comparisons less verbose::

        _Call(('name', (), {})) == ('name',)
        _Call(('name', (1,), {})) == ('name', (1,))
        _Call(((), {'a': 'b'})) == ({'a': 'b'},)

    The `_Call` object provides a useful shortcut for comparing with call::

        _Call(((1, 2), {'a': 3})) == call(1, 2, a=3)
        _Call(('foo', (1, 2), {'a': 3})) == call.foo(1, 2, a=3)

    If the _Call has no name then it will match any name.
    """
    def __new__(cls, value=(), name='', parent=None, two=False,
                from_kall=True):
        args = ()
        kwargs = {}
        _len = len(value)
        if _len == 3:
            name, args, kwargs = value
        elif _len == 2:
            first, second = value
            if isinstance(first, str):
                name = first
                if isinstance(second, tuple):
                    args = second
                else:
                    kwargs = second
            else:
                args, kwargs = first, second
        elif _len == 1:
            value, = value
            if isinstance(value, str):
                name = value
            elif isinstance(value, tuple):
                args = value
            else:
                kwargs = value

        if two:
            return tuple.__new__(cls, (args, kwargs))

        return tuple.__new__(cls, (name, args, kwargs))


    def __init__(self, value=(), name=None, parent=None, two=False,
                 from_kall=True):
        self._mock_name = name
        self._mock_parent = parent
        self._mock_from_kall = from_kall


    def __eq__(self, other):
        if other is ANY:
            return True
        try:
            len_other = len(other)
        except TypeError:
            return False

        self_name = ''
        if len(self) == 2:
            self_args, self_kwargs = self
        else:
            self_name, self_args, self_kwargs = self

        if (getattr(self, '_mock_parent', None) and getattr(other, '_mock_parent', None)
                and self._mock_parent != other._mock_parent):
            return False

        other_name = ''
        if len_other == 0:
            other_args, other_kwargs = (), {}
        elif len_other == 3:
            other_name, other_args, other_kwargs = other
        elif len_other == 1:
            value, = other
            if isinstance(value, tuple):
                other_args = value
                other_kwargs = {}
            elif isinstance(value, str):
                other_name = value
                other_args, other_kwargs = (), {}
            else:
                other_args = ()
                other_kwargs = value
        elif len_other == 2:
            # could be (name, args) or (name, kwargs) or (args, kwargs)
            first, second = other
            if isinstance(first, str):
                other_name = first
                if isinstance(second, tuple):
                    other_args, other_kwargs = second, {}
                else:
                    other_args, other_kwargs = (), second
            else:
                other_args, other_kwargs = first, second
        else:
            return False

        if self_name and other_name != self_name:
            return False

        # this order is important for ANY to work!
        return (other_args, other_kwargs) == (self_args, self_kwargs)


    __ne__ = object.__ne__


    def __call__(self, /, *args, **kwargs):
        if self._mock_name is None:
            return _Call(('', args, kwargs), name='()')

        name = self._mock_name + '()'
        return _Call((self._mock_name, args, kwargs), name=name, parent=self)


    def __getattr__(self, attr):
        if self._mock_name is None:
            return _Call(name=attr, from_kall=False)
        name = '%s.%s' % (self._mock_name, attr)
        return _Call(name=name, parent=self, from_kall=False)


    def __getattribute__(self, attr):
        if attr in tuple.__dict__:
            raise AttributeError
        return tuple.__getattribute__(self, attr)


    def count(self, /, *args, **kwargs):
        return self.__getattr__('count')(*args, **kwargs)

    def index(self, /, *args, **kwargs):
        return self.__getattr__('index')(*args, **kwargs)

    def _get_call_arguments(self):
        if len(self) == 2:
            args, kwargs = self
        else:
            name, args, kwargs = self

        return args, kwargs

    @property
    def args(self):
        return self._get_call_arguments()[0]

    @property
    def kwargs(self):
        return self._get_call_arguments()[1]

    def __repr__(self):
        if not self._mock_from_kall:
            name = self._mock_name or 'call'
            if name.startswith('()'):
                name = 'call%s' % name
            return name

        if len(self) == 2:
            name = 'call'
            args, kwargs = self
        else:
            name, args, kwargs = self
            if not name:
                name = 'call'
            elif not name.startswith('()'):
                name = 'call.%s' % name
            else:
                name = 'call%s' % name
        return _format_call_signature(name, args, kwargs)


    def call_list(self):
        """For a call object that represents multiple calls, `call_list`
        returns a list of all the intermediate calls as well as the
        final call."""
        vals = []
        thing = self
        while thing is not None:
            if thing._mock_from_kall:
                vals.append(thing)
            thing = thing._mock_parent
        return _CallList(reversed(vals))


call = _Call(from_kall=False)


def create_autospec(spec, spec_set=False, instance=False, _parent=None,
                    _name=None, **kwargs):
    """Create a mock object using another object as a spec. Attributes on the
    mock will use the corresponding attribute on the `spec` object as their
    spec.

    Functions or methods being mocked will have their arguments checked
    to check that they are called with the correct signature.

    If `spec_set` is True then attempting to set attributes that don't exist
    on the spec object will raise an `AttributeError`.

    If a class is used as a spec then the return value of the mock (the
    instance of the class) will have the same spec. You can use a class as the
    spec for an instance object by passing `instance=True`. The returned mock
    will only be callable if instances of the mock are callable.

    `create_autospec` also takes arbitrary keyword arguments that are passed to
    the constructor of the created mock."""
    if _is_list(spec):
        # can't pass a list instance to the mock constructor as it will be
        # interpreted as a list of strings
        spec = type(spec)

    is_type = isinstance(spec, type)
    is_async_func = _is_async_func(spec)
    _kwargs = {'spec': spec}
    if spec_set:
        _kwargs = {'spec_set': spec}
    elif spec is None:
        # None we mock with a normal mock without a spec
        _kwargs = {}
    if _kwargs and instance:
        _kwargs['_spec_as_instance'] = True

    _kwargs.update(kwargs)

    Klass = MagicMock
    if inspect.isdatadescriptor(spec):
        # descriptors don't have a spec
        # because we don't know what type they return
        _kwargs = {}
    elif is_async_func:
        if instance:
            raise RuntimeError("Instance can not be True when create_autospec "
                               "is mocking an async function")
        Klass = AsyncMock
    elif not _callable(spec):
        Klass = NonCallableMagicMock
    elif is_type and instance and not _instance_callable(spec):
        Klass = NonCallableMagicMock

    _name = _kwargs.pop('name', _name)

    _new_name = _name
    if _parent is None:
        # for a top level object no _new_name should be set
        _new_name = ''

    mock = Klass(parent=_parent, _new_parent=_parent, _new_name=_new_name,
                 name=_name, **_kwargs)

    if isinstance(spec, FunctionTypes):
        # should only happen at the top level because we don't
        # recurse for functions
        mock = _set_signature(mock, spec)
        if is_async_func:
            _setup_async_mock(mock)
    else:
        _check_signature(spec, mock, is_type, instance)

    if _parent is not None and not instance:
        _parent._mock_children[_name] = mock

    if is_type and not instance and 'return_value' not in kwargs:
        mock.return_value = create_autospec(spec, spec_set, instance=True,
                                            _name='()', _parent=mock)

    for entry in dir(spec):
        if _is_magic(entry):
            # MagicMock already does the useful magic methods for us
            continue

        # XXXX do we need a better way of getting attributes without
        # triggering code execution (?) Probably not - we need the actual
        # object to mock it so we would rather trigger a property than mock
        # the property descriptor. Likewise we want to mock out dynamically
        # provided attributes.
        # XXXX what about attributes that raise exceptions other than
        # AttributeError on being fetched?
        # we could be resilient against it, or catch and propagate the
        # exception when the attribute is fetched from the mock
        try:
            original = getattr(spec, entry)
        except AttributeError:
            continue

        kwargs = {'spec': original}
        if spec_set:
            kwargs = {'spec_set': original}

        if not isinstance(original, FunctionTypes):
            new = _SpecState(original, spec_set, mock, entry, instance)
            mock._mock_children[entry] = new
        else:
            parent = mock
            if isinstance(spec, FunctionTypes):
                parent = mock.mock

            skipfirst = _must_skip(spec, entry, is_type)
            kwargs['_eat_self'] = skipfirst
            if asyncio.iscoroutinefunction(original):
                child_klass = AsyncMock
            else:
                child_klass = MagicMock
            new = child_klass(parent=parent, name=entry, _new_name=entry,
                              _new_parent=parent,
                              **kwargs)
            mock._mock_children[entry] = new
            _check_signature(original, new, skipfirst=skipfirst)

        # so functions created with _set_signature become instance attributes,
        # *plus* their underlying mock exists in _mock_children of the parent
        # mock. Adding to _mock_children may be unnecessary where we are also
        # setting as an instance attribute?
        if isinstance(new, FunctionTypes):
            setattr(mock, entry, new)

    return mock


def _must_skip(spec, entry, is_type):
    """
    Return whether we should skip the first argument on spec's `entry`
    attribute.
    """
    if not isinstance(spec, type):
        if entry in getattr(spec, '__dict__', {}):
            # instance attribute - shouldn't skip
            return False
        spec = spec.__class__

    for klass in spec.__mro__:
        result = klass.__dict__.get(entry, DEFAULT)
        if result is DEFAULT:
            continue
        if isinstance(result, (staticmethod, classmethod)):
            return False
        elif isinstance(result, FunctionTypes):
            # Normal method => skip if looked up on type
            # (if looked up on instance, self is already skipped)
            return is_type
        else:
            return False

    # function is a dynamically provided attribute
    return is_type


class _SpecState(object):

    def __init__(self, spec, spec_set=False, parent=None,
                 name=None, ids=None, instance=False):
        self.spec = spec
        self.ids = ids
        self.spec_set = spec_set
        self.parent = parent
        self.instance = instance
        self.name = name


FunctionTypes = (
    # python function
    type(create_autospec),
    # instance method
    type(ANY.__eq__),
)


file_spec = None


def _to_stream(read_data):
    if isinstance(read_data, bytes):
        return io.BytesIO(read_data)
    else:
        return io.StringIO(read_data)


def mock_open(mock=None, read_data=''):
    """
    A helper function to create a mock to replace the use of `open`. It works
    for `open` called directly or used as a context manager.

    The `mock` argument is the mock object to configure. If `None` (the
    default) then a `MagicMock` will be created for you, with the API limited
    to methods or attributes available on standard file handles.

    `read_data` is a string for the `read`, `readline` and `readlines` of the
    file handle to return.  This is an empty string by default.
    """
    _read_data = _to_stream(read_data)
    _state = [_read_data, None]

    def _readlines_side_effect(*args, **kwargs):
        if handle.readlines.return_value is not None:
            return handle.readlines.return_value
        return _state[0].readlines(*args, **kwargs)

    def _read_side_effect(*args, **kwargs):
        if handle.read.return_value is not None:
            return handle.read.return_value
        return _state[0].read(*args, **kwargs)

    def _readline_side_effect(*args, **kwargs):
        yield from _iter_side_effect()
        while True:
            yield _state[0].readline(*args, **kwargs)

    def _iter_side_effect():
        if handle.readline.return_value is not None:
            while True:
                yield handle.readline.return_value
        for line in _state[0]:
            yield line

    def _next_side_effect():
        if handle.readline.return_value is not None:
            return handle.readline.return_value
        return next(_state[0])

    global file_spec
    if file_spec is None:
        import _io
        file_spec = list(set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO))))

    if mock is None:
        mock = MagicMock(name='open', spec=open)

    handle = MagicMock(spec=file_spec)
    handle.__enter__.return_value = handle

    handle.write.return_value = None
    handle.read.return_value = None
    handle.readline.return_value = None
    handle.readlines.return_value = None

    handle.read.side_effect = _read_side_effect
    _state[1] = _readline_side_effect()
    handle.readline.side_effect = _state[1]
    handle.readlines.side_effect = _readlines_side_effect
    handle.__iter__.side_effect = _iter_side_effect
    handle.__next__.side_effect = _next_side_effect

    def reset_data(*args, **kwargs):
        _state[0] = _to_stream(read_data)
        if handle.readline.side_effect == _state[1]:
            # Only reset the side effect if the user hasn't overridden it.
            _state[1] = _readline_side_effect()
            handle.readline.side_effect = _state[1]
        return DEFAULT

    mock.side_effect = reset_data
    mock.return_value = handle
    return mock


class PropertyMock(Mock):
    """
    A mock intended to be used as a property, or other descriptor, on a class.
    `PropertyMock` provides `__get__` and `__set__` methods so you can specify
    a return value when it is fetched.

    Fetching a `PropertyMock` instance from an object calls the mock, with
    no args. Setting it calls the mock with the value being set.
    """
    def _get_child_mock(self, /, **kwargs):
        return MagicMock(**kwargs)

    def __get__(self, obj, obj_type=None):
        return self()
    def __set__(self, obj, val):
        self(val)


def seal(mock):
    """Disable the automatic generation of child mocks.

    Given an input Mock, seals it to ensure no further mocks will be generated
    when accessing an attribute that was not already defined.

    The operation recursively seals the mock passed in, meaning that
    the mock itself, any mocks generated by accessing one of its attributes,
    and all assigned mocks without a name or spec will be sealed.
    """
    mock._mock_sealed = True
    for attr in dir(mock):
        try:
            m = getattr(mock, attr)
        except AttributeError:
            continue
        if not isinstance(m, NonCallableMock):
            continue
        if m._mock_new_parent is mock:
            seal(m)


class _AsyncIterator:
    """
    Wraps an iterator in an asynchronous iterator.
    """
    def __init__(self, iterator):
        self.iterator = iterator
        code_mock = NonCallableMock(spec_set=CodeType)
        code_mock.co_flags = inspect.CO_ITERABLE_COROUTINE
        self.__dict__['__code__'] = code_mock

    def __aiter__(self):
        return self

    async def __anext__(self):
        try:
            return next(self.iterator)
        except StopIteration:
            pass
        raise StopAsyncIteration
PK��[�b!%��__main__.pynu�[���"""Main entry point"""

import sys
if sys.argv[0].endswith("__main__.py"):
    import os.path
    # We change sys.argv[0] to make help message more useful
    # use executable without path, unquoted
    # (it's just a hint anyway)
    # (if you have spaces in your executable you get what you deserve!)
    executable = os.path.basename(sys.executable)
    sys.argv[0] = executable + " -m unittest"
    del os

__unittest = True

from .main import main

main(module=None)
PK��[����+�+main.pynu�[���"""Unittest main program"""

import sys
import argparse
import os

from . import loader, runner
from .signals import installHandler

__unittest = True

MAIN_EXAMPLES = """\
Examples:
  %(prog)s test_module               - run tests from test_module
  %(prog)s module.TestClass          - run tests from module.TestClass
  %(prog)s module.Class.test_method  - run specified test method
  %(prog)s path/to/test_file.py      - run tests from test_file.py
"""

MODULE_EXAMPLES = """\
Examples:
  %(prog)s                           - run default set of tests
  %(prog)s MyTestSuite               - run suite 'MyTestSuite'
  %(prog)s MyTestCase.testSomething  - run MyTestCase.testSomething
  %(prog)s MyTestCase                - run all 'test*' test methods
                                       in MyTestCase
"""

def _convert_name(name):
    # on Linux / Mac OS X 'foo.PY' is not importable, but on
    # Windows it is. Simpler to do a case insensitive match
    # a better check would be to check that the name is a
    # valid Python module name.
    if os.path.isfile(name) and name.lower().endswith('.py'):
        if os.path.isabs(name):
            rel_path = os.path.relpath(name, os.getcwd())
            if os.path.isabs(rel_path) or rel_path.startswith(os.pardir):
                return name
            name = rel_path
        # on Windows both '\' and '/' are used as path
        # separators. Better to replace both than rely on os.path.sep
        return name[:-3].replace('\\', '.').replace('/', '.')
    return name

def _convert_names(names):
    return [_convert_name(name) for name in names]


def _convert_select_pattern(pattern):
    if not '*' in pattern:
        pattern = '*%s*' % pattern
    return pattern


class TestProgram(object):
    """A command-line program that runs a set of tests; this is primarily
       for making test modules conveniently executable.
    """
    # defaults for testing
    module=None
    verbosity = 1
    failfast = catchbreak = buffer = progName = warnings = testNamePatterns = None
    _discovery_parser = None

    def __init__(self, module='__main__', defaultTest=None, argv=None,
                    testRunner=None, testLoader=loader.defaultTestLoader,
                    exit=True, verbosity=1, failfast=None, catchbreak=None,
                    buffer=None, warnings=None, *, tb_locals=False):
        if isinstance(module, str):
            self.module = __import__(module)
            for part in module.split('.')[1:]:
                self.module = getattr(self.module, part)
        else:
            self.module = module
        if argv is None:
            argv = sys.argv

        self.exit = exit
        self.failfast = failfast
        self.catchbreak = catchbreak
        self.verbosity = verbosity
        self.buffer = buffer
        self.tb_locals = tb_locals
        if warnings is None and not sys.warnoptions:
            # even if DeprecationWarnings are ignored by default
            # print them anyway unless other warnings settings are
            # specified by the warnings arg or the -W python flag
            self.warnings = 'default'
        else:
            # here self.warnings is set either to the value passed
            # to the warnings args or to None.
            # If the user didn't pass a value self.warnings will
            # be None. This means that the behavior is unchanged
            # and depends on the values passed to -W.
            self.warnings = warnings
        self.defaultTest = defaultTest
        self.testRunner = testRunner
        self.testLoader = testLoader
        self.progName = os.path.basename(argv[0])
        self.parseArgs(argv)
        self.runTests()

    def usageExit(self, msg=None):
        if msg:
            print(msg)
        if self._discovery_parser is None:
            self._initArgParsers()
        self._print_help()
        sys.exit(2)

    def _print_help(self, *args, **kwargs):
        if self.module is None:
            print(self._main_parser.format_help())
            print(MAIN_EXAMPLES % {'prog': self.progName})
            self._discovery_parser.print_help()
        else:
            print(self._main_parser.format_help())
            print(MODULE_EXAMPLES % {'prog': self.progName})

    def parseArgs(self, argv):
        self._initArgParsers()
        if self.module is None:
            if len(argv) > 1 and argv[1].lower() == 'discover':
                self._do_discovery(argv[2:])
                return
            self._main_parser.parse_args(argv[1:], self)
            if not self.tests:
                # this allows "python -m unittest -v" to still work for
                # test discovery.
                self._do_discovery([])
                return
        else:
            self._main_parser.parse_args(argv[1:], self)

        if self.tests:
            self.testNames = _convert_names(self.tests)
            if __name__ == '__main__':
                # to support python -m unittest ...
                self.module = None
        elif self.defaultTest is None:
            # createTests will load tests from self.module
            self.testNames = None
        elif isinstance(self.defaultTest, str):
            self.testNames = (self.defaultTest,)
        else:
            self.testNames = list(self.defaultTest)
        self.createTests()

    def createTests(self, from_discovery=False, Loader=None):
        if self.testNamePatterns:
            self.testLoader.testNamePatterns = self.testNamePatterns
        if from_discovery:
            loader = self.testLoader if Loader is None else Loader()
            self.test = loader.discover(self.start, self.pattern, self.top)
        elif self.testNames is None:
            self.test = self.testLoader.loadTestsFromModule(self.module)
        else:
            self.test = self.testLoader.loadTestsFromNames(self.testNames,
                                                           self.module)

    def _initArgParsers(self):
        parent_parser = self._getParentArgParser()
        self._main_parser = self._getMainArgParser(parent_parser)
        self._discovery_parser = self._getDiscoveryArgParser(parent_parser)

    def _getParentArgParser(self):
        parser = argparse.ArgumentParser(add_help=False)

        parser.add_argument('-v', '--verbose', dest='verbosity',
                            action='store_const', const=2,
                            help='Verbose output')
        parser.add_argument('-q', '--quiet', dest='verbosity',
                            action='store_const', const=0,
                            help='Quiet output')
        parser.add_argument('--locals', dest='tb_locals',
                            action='store_true',
                            help='Show local variables in tracebacks')
        if self.failfast is None:
            parser.add_argument('-f', '--failfast', dest='failfast',
                                action='store_true',
                                help='Stop on first fail or error')
            self.failfast = False
        if self.catchbreak is None:
            parser.add_argument('-c', '--catch', dest='catchbreak',
                                action='store_true',
                                help='Catch Ctrl-C and display results so far')
            self.catchbreak = False
        if self.buffer is None:
            parser.add_argument('-b', '--buffer', dest='buffer',
                                action='store_true',
                                help='Buffer stdout and stderr during tests')
            self.buffer = False
        if self.testNamePatterns is None:
            parser.add_argument('-k', dest='testNamePatterns',
                                action='append', type=_convert_select_pattern,
                                help='Only run tests which match the given substring')
            self.testNamePatterns = []

        return parser

    def _getMainArgParser(self, parent):
        parser = argparse.ArgumentParser(parents=[parent])
        parser.prog = self.progName
        parser.print_help = self._print_help

        parser.add_argument('tests', nargs='*',
                            help='a list of any number of test modules, '
                            'classes and test methods.')

        return parser

    def _getDiscoveryArgParser(self, parent):
        parser = argparse.ArgumentParser(parents=[parent])
        parser.prog = '%s discover' % self.progName
        parser.epilog = ('For test discovery all test modules must be '
                         'importable from the top level directory of the '
                         'project.')

        parser.add_argument('-s', '--start-directory', dest='start',
                            help="Directory to start discovery ('.' default)")
        parser.add_argument('-p', '--pattern', dest='pattern',
                            help="Pattern to match tests ('test*.py' default)")
        parser.add_argument('-t', '--top-level-directory', dest='top',
                            help='Top level directory of project (defaults to '
                                 'start directory)')
        for arg in ('start', 'pattern', 'top'):
            parser.add_argument(arg, nargs='?',
                                default=argparse.SUPPRESS,
                                help=argparse.SUPPRESS)

        return parser

    def _do_discovery(self, argv, Loader=None):
        self.start = '.'
        self.pattern = 'test*.py'
        self.top = None
        if argv is not None:
            # handle command line args for test discovery
            if self._discovery_parser is None:
                # for testing
                self._initArgParsers()
            self._discovery_parser.parse_args(argv, self)

        self.createTests(from_discovery=True, Loader=Loader)

    def runTests(self):
        if self.catchbreak:
            installHandler()
        if self.testRunner is None:
            self.testRunner = runner.TextTestRunner
        if isinstance(self.testRunner, type):
            try:
                try:
                    testRunner = self.testRunner(verbosity=self.verbosity,
                                                 failfast=self.failfast,
                                                 buffer=self.buffer,
                                                 warnings=self.warnings,
                                                 tb_locals=self.tb_locals)
                except TypeError:
                    # didn't accept the tb_locals argument
                    testRunner = self.testRunner(verbosity=self.verbosity,
                                                 failfast=self.failfast,
                                                 buffer=self.buffer,
                                                 warnings=self.warnings)
            except TypeError:
                # didn't accept the verbosity, buffer or failfast arguments
                testRunner = self.testRunner()
        else:
            # it is assumed to be a TestRunner instance
            testRunner = self.testRunner
        self.result = testRunner.run(self.test)
        if self.exit:
            sys.exit(not self.result.wasSuccessful())

main = TestProgram
PK��[����__init__.pynu�[���"""
Python unit testing framework, based on Erich Gamma's JUnit and Kent Beck's
Smalltalk testing framework (used with permission).

This module contains the core framework classes that form the basis of
specific test cases and suites (TestCase, TestSuite etc.), and also a
text-based utility class for running the tests and reporting the results
 (TextTestRunner).

Simple usage:

    import unittest

    class IntegerArithmeticTestCase(unittest.TestCase):
        def testAdd(self):  # test method names begin with 'test'
            self.assertEqual((1 + 2), 3)
            self.assertEqual(0 + 1, 1)
        def testMultiply(self):
            self.assertEqual((0 * 10), 0)
            self.assertEqual((5 * 8), 40)

    if __name__ == '__main__':
        unittest.main()

Further information is available in the bundled documentation, and from

  http://docs.python.org/library/unittest.html

Copyright (c) 1999-2003 Steve Purcell
Copyright (c) 2003-2010 Python Software Foundation
This module is free software, and you may redistribute it and/or modify
it under the same terms as Python itself, so long as this copyright message
and disclaimer are retained in their original form.

IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.

THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE.  THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
"""

__all__ = ['TestResult', 'TestCase', 'IsolatedAsyncioTestCase', 'TestSuite',
           'TextTestRunner', 'TestLoader', 'FunctionTestCase', 'main',
           'defaultTestLoader', 'SkipTest', 'skip', 'skipIf', 'skipUnless',
           'expectedFailure', 'TextTestResult', 'installHandler',
           'registerResult', 'removeResult', 'removeHandler',
           'addModuleCleanup']

# Expose obsolete functions for backwards compatibility
__all__.extend(['getTestCaseNames', 'makeSuite', 'findTestCases'])

__unittest = True

from .result import TestResult
from .async_case import IsolatedAsyncioTestCase
from .case import (addModuleCleanup, TestCase, FunctionTestCase, SkipTest, skip,
                   skipIf, skipUnless, expectedFailure)
from .suite import BaseTestSuite, TestSuite
from .loader import (TestLoader, defaultTestLoader, makeSuite, getTestCaseNames,
                     findTestCases)
from .main import TestProgram, main
from .runner import TextTestRunner, TextTestResult
from .signals import installHandler, registerResult, removeResult, removeHandler

# deprecated
_TextTestResult = TextTestResult

# There are no tests here, so don't try to run anything discovered from
# introspecting the symbols (e.g. FunctionTestCase). Instead, all our
# tests come from within unittest.test.
def load_tests(loader, tests, pattern):
    import os.path
    # top level directory cached on loader instance
    this_dir = os.path.dirname(__file__)
    return loader.discover(start_dir=this_dir, pattern=pattern)
PK��[V�q��
async_case.pynu�[���import asyncio
import inspect

from .case import TestCase



class IsolatedAsyncioTestCase(TestCase):
    # Names intentionally have a long prefix
    # to reduce a chance of clashing with user-defined attributes
    # from inherited test case
    #
    # The class doesn't call loop.run_until_complete(self.setUp()) and family
    # but uses a different approach:
    # 1. create a long-running task that reads self.setUp()
    #    awaitable from queue along with a future
    # 2. await the awaitable object passing in and set the result
    #    into the future object
    # 3. Outer code puts the awaitable and the future object into a queue
    #    with waiting for the future
    # The trick is necessary because every run_until_complete() call
    # creates a new task with embedded ContextVar context.
    # To share contextvars between setUp(), test and tearDown() we need to execute
    # them inside the same task.

    # Note: the test case modifies event loop policy if the policy was not instantiated
    # yet.
    # asyncio.get_event_loop_policy() creates a default policy on demand but never
    # returns None
    # I believe this is not an issue in user level tests but python itself for testing
    # should reset a policy in every test module
    # by calling asyncio.set_event_loop_policy(None) in tearDownModule()

    def __init__(self, methodName='runTest'):
        super().__init__(methodName)
        self._asyncioTestLoop = None
        self._asyncioCallsQueue = None

    async def asyncSetUp(self):
        pass

    async def asyncTearDown(self):
        pass

    def addAsyncCleanup(self, func, /, *args, **kwargs):
        # A trivial trampoline to addCleanup()
        # the function exists because it has a different semantics
        # and signature:
        # addCleanup() accepts regular functions
        # but addAsyncCleanup() accepts coroutines
        #
        # We intentionally don't add inspect.iscoroutinefunction() check
        # for func argument because there is no way
        # to check for async function reliably:
        # 1. It can be "async def func()" iself
        # 2. Class can implement "async def __call__()" method
        # 3. Regular "def func()" that returns awaitable object
        self.addCleanup(*(func, *args), **kwargs)

    def _callSetUp(self):
        self.setUp()
        self._callAsync(self.asyncSetUp)

    def _callTestMethod(self, method):
        self._callMaybeAsync(method)

    def _callTearDown(self):
        self._callAsync(self.asyncTearDown)
        self.tearDown()

    def _callCleanup(self, function, *args, **kwargs):
        self._callMaybeAsync(function, *args, **kwargs)

    def _callAsync(self, func, /, *args, **kwargs):
        assert self._asyncioTestLoop is not None
        ret = func(*args, **kwargs)
        assert inspect.isawaitable(ret)
        fut = self._asyncioTestLoop.create_future()
        self._asyncioCallsQueue.put_nowait((fut, ret))
        return self._asyncioTestLoop.run_until_complete(fut)

    def _callMaybeAsync(self, func, /, *args, **kwargs):
        assert self._asyncioTestLoop is not None
        ret = func(*args, **kwargs)
        if inspect.isawaitable(ret):
            fut = self._asyncioTestLoop.create_future()
            self._asyncioCallsQueue.put_nowait((fut, ret))
            return self._asyncioTestLoop.run_until_complete(fut)
        else:
            return ret

    async def _asyncioLoopRunner(self, fut):
        self._asyncioCallsQueue = queue = asyncio.Queue()
        fut.set_result(None)
        while True:
            query = await queue.get()
            queue.task_done()
            if query is None:
                return
            fut, awaitable = query
            try:
                ret = await awaitable
                if not fut.cancelled():
                    fut.set_result(ret)
            except (SystemExit, KeyboardInterrupt):
                raise
            except (BaseException, asyncio.CancelledError) as ex:
                if not fut.cancelled():
                    fut.set_exception(ex)

    def _setupAsyncioLoop(self):
        assert self._asyncioTestLoop is None
        loop = asyncio.new_event_loop()
        asyncio.set_event_loop(loop)
        loop.set_debug(True)
        self._asyncioTestLoop = loop
        fut = loop.create_future()
        self._asyncioCallsTask = loop.create_task(self._asyncioLoopRunner(fut))
        loop.run_until_complete(fut)

    def _tearDownAsyncioLoop(self):
        assert self._asyncioTestLoop is not None
        loop = self._asyncioTestLoop
        self._asyncioTestLoop = None
        self._asyncioCallsQueue.put_nowait(None)
        loop.run_until_complete(self._asyncioCallsQueue.join())

        try:
            # cancel all tasks
            to_cancel = asyncio.all_tasks(loop)
            if not to_cancel:
                return

            for task in to_cancel:
                task.cancel()

            loop.run_until_complete(
                asyncio.gather(*to_cancel, loop=loop, return_exceptions=True))

            for task in to_cancel:
                if task.cancelled():
                    continue
                if task.exception() is not None:
                    loop.call_exception_handler({
                        'message': 'unhandled exception during test shutdown',
                        'exception': task.exception(),
                        'task': task,
                    })
            # shutdown asyncgens
            loop.run_until_complete(loop.shutdown_asyncgens())
        finally:
            asyncio.set_event_loop(None)
            loop.close()

    def run(self, result=None):
        self._setupAsyncioLoop()
        try:
            return super().run(result)
        finally:
            self._tearDownAsyncioLoop()
PK��[[[$�	result.pynu�[���"""Test result object"""

import io
import sys
import traceback

from . import util
from functools import wraps

__unittest = True

def failfast(method):
    @wraps(method)
    def inner(self, *args, **kw):
        if getattr(self, 'failfast', False):
            self.stop()
        return method(self, *args, **kw)
    return inner

STDOUT_LINE = '\nStdout:\n%s'
STDERR_LINE = '\nStderr:\n%s'


class TestResult(object):
    """Holder for test result information.

    Test results are automatically managed by the TestCase and TestSuite
    classes, and do not need to be explicitly manipulated by writers of tests.

    Each instance holds the total number of tests run, and collections of
    failures and errors that occurred among those test runs. The collections
    contain tuples of (testcase, exceptioninfo), where exceptioninfo is the
    formatted traceback of the error that occurred.
    """
    _previousTestClass = None
    _testRunEntered = False
    _moduleSetUpFailed = False
    def __init__(self, stream=None, descriptions=None, verbosity=None):
        self.failfast = False
        self.failures = []
        self.errors = []
        self.testsRun = 0
        self.skipped = []
        self.expectedFailures = []
        self.unexpectedSuccesses = []
        self.shouldStop = False
        self.buffer = False
        self.tb_locals = False
        self._stdout_buffer = None
        self._stderr_buffer = None
        self._original_stdout = sys.stdout
        self._original_stderr = sys.stderr
        self._mirrorOutput = False

    def printErrors(self):
        "Called by TestRunner after test run"

    def startTest(self, test):
        "Called when the given test is about to be run"
        self.testsRun += 1
        self._mirrorOutput = False
        self._setupStdout()

    def _setupStdout(self):
        if self.buffer:
            if self._stderr_buffer is None:
                self._stderr_buffer = io.StringIO()
                self._stdout_buffer = io.StringIO()
            sys.stdout = self._stdout_buffer
            sys.stderr = self._stderr_buffer

    def startTestRun(self):
        """Called once before any tests are executed.

        See startTest for a method called before each test.
        """

    def stopTest(self, test):
        """Called when the given test has been run"""
        self._restoreStdout()
        self._mirrorOutput = False

    def _restoreStdout(self):
        if self.buffer:
            if self._mirrorOutput:
                output = sys.stdout.getvalue()
                error = sys.stderr.getvalue()
                if output:
                    if not output.endswith('\n'):
                        output += '\n'
                    self._original_stdout.write(STDOUT_LINE % output)
                if error:
                    if not error.endswith('\n'):
                        error += '\n'
                    self._original_stderr.write(STDERR_LINE % error)

            sys.stdout = self._original_stdout
            sys.stderr = self._original_stderr
            self._stdout_buffer.seek(0)
            self._stdout_buffer.truncate()
            self._stderr_buffer.seek(0)
            self._stderr_buffer.truncate()

    def stopTestRun(self):
        """Called once after all tests are executed.

        See stopTest for a method called after each test.
        """

    @failfast
    def addError(self, test, err):
        """Called when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info().
        """
        self.errors.append((test, self._exc_info_to_string(err, test)))
        self._mirrorOutput = True

    @failfast
    def addFailure(self, test, err):
        """Called when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info()."""
        self.failures.append((test, self._exc_info_to_string(err, test)))
        self._mirrorOutput = True

    def addSubTest(self, test, subtest, err):
        """Called at the end of a subtest.
        'err' is None if the subtest ended successfully, otherwise it's a
        tuple of values as returned by sys.exc_info().
        """
        # By default, we don't do anything with successful subtests, but
        # more sophisticated test results might want to record them.
        if err is not None:
            if getattr(self, 'failfast', False):
                self.stop()
            if issubclass(err[0], test.failureException):
                errors = self.failures
            else:
                errors = self.errors
            errors.append((subtest, self._exc_info_to_string(err, test)))
            self._mirrorOutput = True

    def addSuccess(self, test):
        "Called when a test has completed successfully"
        pass

    def addSkip(self, test, reason):
        """Called when a test is skipped."""
        self.skipped.append((test, reason))

    def addExpectedFailure(self, test, err):
        """Called when an expected failure/error occurred."""
        self.expectedFailures.append(
            (test, self._exc_info_to_string(err, test)))

    @failfast
    def addUnexpectedSuccess(self, test):
        """Called when a test was expected to fail, but succeed."""
        self.unexpectedSuccesses.append(test)

    def wasSuccessful(self):
        """Tells whether or not this result was a success."""
        # The hasattr check is for test_result's OldResult test.  That
        # way this method works on objects that lack the attribute.
        # (where would such result intances come from? old stored pickles?)
        return ((len(self.failures) == len(self.errors) == 0) and
                (not hasattr(self, 'unexpectedSuccesses') or
                 len(self.unexpectedSuccesses) == 0))

    def stop(self):
        """Indicates that the tests should be aborted."""
        self.shouldStop = True

    def _exc_info_to_string(self, err, test):
        """Converts a sys.exc_info()-style tuple of values into a string."""
        exctype, value, tb = err
        # Skip test runner traceback levels
        while tb and self._is_relevant_tb_level(tb):
            tb = tb.tb_next

        if exctype is test.failureException:
            # Skip assert*() traceback levels
            length = self._count_relevant_tb_levels(tb)
        else:
            length = None
        tb_e = traceback.TracebackException(
            exctype, value, tb, limit=length, capture_locals=self.tb_locals)
        msgLines = list(tb_e.format())

        if self.buffer:
            output = sys.stdout.getvalue()
            error = sys.stderr.getvalue()
            if output:
                if not output.endswith('\n'):
                    output += '\n'
                msgLines.append(STDOUT_LINE % output)
            if error:
                if not error.endswith('\n'):
                    error += '\n'
                msgLines.append(STDERR_LINE % error)
        return ''.join(msgLines)


    def _is_relevant_tb_level(self, tb):
        return '__unittest' in tb.tb_frame.f_globals

    def _count_relevant_tb_levels(self, tb):
        length = 0
        while tb and not self._is_relevant_tb_level(tb):
            length += 1
            tb = tb.tb_next
        return length

    def __repr__(self):
        return ("<%s run=%i errors=%i failures=%i>" %
               (util.strclass(self.__class__), self.testsRun, len(self.errors),
                len(self.failures)))
PK��[r�n��util.pyonu�[����
{fc@s�dZddlmZmZeZdZed�Zd�Z	d�Z
ed�Zedd	�Zd
�Z
d�Zd�Zd
S(sVarious utility functions.i����(t
namedtupletOrderedDictiPcCs\yt|�}Wn tk
r2tj|�}nX|sLt|�tkrP|S|t dS(Ns [truncated]...(treprt	Exceptiontobjectt__repr__tlent_MAX_LENGTH(tobjtshorttresult((s%/usr/lib64/python2.7/unittest/util.pyt	safe_reprs
cCsd|j|jfS(Ns%s.%s(t
__module__t__name__(tcls((s%/usr/lib64/python2.7/unittest/util.pytstrclassscCshd}}g}g}xEtr]y||}||}||kr}|j|�|d7}x�|||kry|d7}q\Wn�||kr�|j|�|d7}x|||kr�|d7}q�Wn^|d7}z%x|||kr�|d7}q�WWd|d7}x|||kr |d7}qWXWqtk
rY|j||�|j||�PqXqW||fS(srFinds elements in only one or the other of two, sorted input lists.

    Returns a two-element tuple of lists.    The first list contains those
    elements in the "expected" list but not in the "actual" list, and the
    second contains those elements in the "actual" list but not in the
    "expected" list.    Duplicate elements in either input list are ignored.
    iiN(tTruetappendt
IndexErrortextend(texpectedtactualtitjtmissingt
unexpectedteta((s%/usr/lib64/python2.7/unittest/util.pytsorted_list_differences:
	








	cCsg}g}x�|r�|j�}y|j|�Wntk
rR|j|�nX|rxI||fD]8}yxtr�|j|�qrWWqftk
r�qfXqfWqqW|rxU|r|j�}|j|�yxtr�|j|�q�WWq�tk
rq�Xq�W||fS||fS(s�Same behavior as sorted_list_difference but
    for lists of unorderable items (like dicts).

    As it does a linear search per item (remove) it
    has O(n*n) performance.
    (tpoptremovet
ValueErrorRR(RRtignore_duplicateRRtitemtlst((s%/usr/lib64/python2.7/unittest/util.pytunorderable_list_difference>s4	
	
	
	

tMismatchsactual expected valuecCs�t|�t|�}}t|�t|�}}t�}g}x�t|�D]�\}}	|	|krlqNnd}
}x>t||�D]-}|||	kr�|
d7}
|||<q�q�Wx=t|�D]/\}}
|
|	kr�|d7}|||<q�q�W|
|krNt|
||	�}|j|�qNqNWx�t|�D]�\}}	|	|krTq6nd}x>t||�D]-}|||	krj|d7}|||<qjqjWtd||	�}|j|�q6W|S(sHReturns list of (cnt_act, cnt_exp, elem) triples where the counts differii(tlistRRt	enumeratetranget	_MismatchR(RRtstttmtntNULLR
Rtelemtcnt_stcnt_tRt
other_elemtdiff((s%/usr/lib64/python2.7/unittest/util.pyt_count_diff_all_purposeds<	



cCs8t�}x(|D] }|j|d�d||<qW|S(s@Return dict of element counts, in the order they were first seenii(Rtget(titerabletcR.((s%/usr/lib64/python2.7/unittest/util.pyt_ordered_count�s	
c	Cs�t|�t|�}}g}xZ|j�D]L\}}|j|d�}||kr,t|||�}|j|�q,q,WxH|j�D]:\}}||kr�td||�}|j|�q�q�W|S(sHReturns list of (cnt_act, cnt_exp, elem) triples where the counts differi(R7titemsR4R(R(	RRR)R*R
R.R/R0R2((s%/usr/lib64/python2.7/unittest/util.pyt_count_diff_hashable�sN(t__doc__tcollectionsRRRt
__unittestRtFalseRRRR#R(R3R7R9(((s%/usr/lib64/python2.7/unittest/util.pyt<module>s
		)$	#	PK��[��W�p,p,
loader.pycnu�[����
{fc@sdZddlZddlZddlZddlZddlZddlmZddl	m	Z	ddl
mZmZe
Zejdej�Zd�Zd	�Zd
�Zdefd��YZe�Zed
�Zed�Zdeejd�Zdeejd�ZdS(sLoading unittests.i����N(t
cmp_to_key(tfnmatchi(tcasetsuites[_a-z]\w*\.py$cCs/d|tj�f}td|t|�|�S(Ns#Failed to import test module: %s
%stModuleImportFailure(t	tracebackt
format_exct_make_failed_testtImportError(tnamet
suiteClasstmessage((s'/usr/lib64/python2.7/unittest/loader.pyt_make_failed_import_testscCstd|||�S(NtLoadTestsFailure(R(R	t	exceptionR
((s'/usr/lib64/python2.7/unittest/loader.pyt_make_failed_load_testsscsG�fd�}i||6}t|tjf|�}|||�f�S(Ncs
��dS(N((tself(R(s'/usr/lib64/python2.7/unittest/loader.pyttestFailures(ttypeRtTestCase(t	classnamet
methodnameRR
Rtattrst	TestClass((Rs'/usr/lib64/python2.7/unittest/loader.pyRs
t
TestLoadercBs�eZdZdZeZejZdZ
d�Zed�Z
dd�Zdd�Zd�Zddd�Zd	�Zd
�Zd�Zd�Zd
�ZRS(s�
    This class is responsible for loading tests according to various criteria
    and returning them wrapped in a TestSuite
    ttestcCsnt|tj�r!td��n|j|�}|rRt|d�rRdg}n|jt||��}|S(s;Return a suite of all test cases contained in testCaseClasssYTest cases should not be derived from TestSuite. Maybe you meant to derive from TestCase?trunTest(t
issubclassRt	TestSuitet	TypeErrortgetTestCaseNamesthasattrR
tmap(Rt
testCaseClasst
testCaseNamestloaded_suite((s'/usr/lib64/python2.7/unittest/loader.pytloadTestsFromTestCase0scCs�g}x]t|�D]O}t||�}t|t�rt|tj�r|j|j|��qqWt|dd�}|j
|�}|r�|dk	r�y|||d�SWq�tk
r�}t|j
||j
�SXn|S(s>Return a suite of all test cases contained in the given modulet
load_testsN(tdirtgetattrt
isinstanceRRRRtappendR$tNoneR
t	ExceptionRt__name__(Rtmoduletuse_load_teststtestsR	tobjR%te((s'/usr/lib64/python2.7/unittest/loader.pytloadTestsFromModule;s!c
Cs�|jd�}|dkr}|}xK|roytdj|��}PWq%tk
rk|d=|sl�qlq%Xq%W|d}n|}x$|D]}|t||�}}q�Wt|tj�r�|j	|�St|t
�r�t|tj
�r�|j|�St|tj�rPt|t
�rPt|tj
�rP|d}||�}|j|g�St|tj�rf|St|d�r�|�}	t|	tj�r�|	St|	tj
�r�|j|	g�Std||	f��ntd|��dS(sSReturn a suite of all test cases given a string specifier.

        The name may resolve either to a module, a test case class, a
        test method within a test case class, or a callable object which
        returns a TestCase or TestSuite instance.

        The method optionally resolves the names relative to a given module.
        t.i����it__call__s"calling %s returned %s, not a tests$don't know how to make test from: %sN(tsplitR*t
__import__tjoinRR'R(ttypest
ModuleTypeR2RRRRR$tUnboundMethodTypeR
RRRR(
RR	R-tpartst
parts_copyR0tparttparenttinstR((s'/usr/lib64/python2.7/unittest/loader.pytloadTestsFromNameMsH		



!

	cCs2g|D]}|j||�^q}|j|�S(s�Return a suite of all test cases found using the given sequence
        of string specifiers. See 'loadTestsFromName()'.
        (R@R
(RtnamesR-R	tsuites((s'/usr/lib64/python2.7/unittest/loader.pytloadTestsFromNames~s%cCsP||jd�}t|t|��}|jrL|jdt|j��n|S(sLReturn a sorted sequence of method names found within testCaseClass
        cSs%|j|�o$tt||�d�S(NR4(t
startswithRR'(tattrnameR!tprefix((s'/usr/lib64/python2.7/unittest/loader.pytisTestMethod�stkey(ttestMethodPrefixtfilterR&tsortTestMethodsUsingtsortt	_CmpToKey(RR!RGttestFnNames((s'/usr/lib64/python2.7/unittest/loader.pyR�s	stest*.pyc	Cs�t}|dkr-|jdk	r-|j}n|dkrHt}|}ntjj|�}|tjkrtjjd|�n||_t}tjj	tjj|��r�tjj|�}||kr�tjj
tjj|d��}q�n�yt|�Wnt
k
rt}nmXtj|}|jd�d}tjjtjj|j��}|r�|j|�|_tjj|�n|r�t
d|��nt|j||��}|j|�S(s+Find and return all test modules from the specified start
        directory, recursing into subdirectories to find them. Only test files
        that match the pattern will be loaded. (Using shell style pattern
        matching.)

        All test modules must be importable from the top level of the project.
        If the start directory is not the top level directory then the top
        level directory must be specified separately.

        If a test package name (directory with '__init__.py') matches the
        pattern then the package will be checked for a 'load_tests' function. If
        this exists then it will be called with loader, tests, pattern.

        If load_tests exists then discovery does  *not* recurse into the package,
        load_tests is responsible for loading all tests in the package.

        The pattern is deliberately not stored as a loader attribute so that
        packages can continue discovery themselves. top_level_dir is stored so
        load_tests does not need to pass this argument in to loader.discover().
        is__init__.pyR3s%Start directory is not importable: %rN(tFalseR*t_top_level_dirtTruetostpathtabspathtsystinserttisdirtisfileR7R6RtmodulesR5tdirnamet__file__t _get_directory_containing_moduletremovetlistt_find_testsR
(	Rt	start_dirtpatternt
top_level_dirtset_implicit_toptis_not_importablet
the_modulettop_partR/((s'/usr/lib64/python2.7/unittest/loader.pytdiscover�s:		(


!cCsstj|}tjj|j�}tjj|�j�jd�r_tjj	tjj	|��Stjj	|�SdS(Ns__init__.py(
RURYRRRSRTR[tbasenametlowerRDRZ(Rtmodule_nameR-t	full_path((s'/usr/lib64/python2.7/unittest/loader.pyR\�s

!cCs�tjjtjj|��d}tjj||j�}tjj|�sYtd��|jd�sutd��|j	tjj
d�}|S(NisPath must be within the projects..R3(RRRStsplitexttnormpathtrelpathRPtisabstAssertionErrorRDtreplacetsep(RRSt_relpathR	((s'/usr/lib64/python2.7/unittest/loader.pyt_get_name_from_path�s"cCst|�tj|S(N(R6RURY(RR	((s'/usr/lib64/python2.7/unittest/loader.pyt_get_module_from_name�s
cCs
t||�S(N(R(RRSRkRa((s'/usr/lib64/python2.7/unittest/loader.pyt_match_path�sccs�tj|�}x�|D]�}tjj||�}tjj|�r�tj|�sXqn|j|||�ssqn|j|�}y|j	|�}Wnt
||j�Vq�Xtjjt
|d|��}tjjtjj|��d}	tjjtjj|��d}
|	j�|
j�kr�tjj|	�}tjjtjj|��d}tjj|�}
d}t||||
f��n|j|�Vqtjj|�rtjjtjj|d��s�qnd}d}t||�r?|j|�}|j	|�}t
|dd�}|j|dt�}n|dkr�|dk	r_|Vnxd|j||�D]}|VqrWq�y||||�VWq�tk
r�}t|j||j�Vq�XqqWdS(s/Used by discovery. Yields test suites it loads.R[isW%r module incorrectly imported from %r. Expected %r. Is this module globally installed?s__init__.pyR%R.N(RRtlistdirRSR7RXtVALID_MODULE_NAMEtmatchRvRtRuRR
RTR'RltrealpathRiRZRhRR2RWR*RROR_R+RR,(RR`RatpathsRSRkR	R-tmod_fileRztfullpath_noextt
module_dirtmod_nametexpected_dirtmsgR%R/tpackageRR1((s'/usr/lib64/python2.7/unittest/loader.pyR_�sV
"""!N(R,t
__module__t__doc__RItcmpRKRRR
R*RPR$RQR2R@RCRRgR\RtRuRvR_(((s'/usr/lib64/python2.7/unittest/loader.pyR&s 		1	@		
		cCs1t�}||_||_|r-||_n|S(N(RRKRIR
(RFt	sortUsingR
tloader((s'/usr/lib64/python2.7/unittest/loader.pyt_makeLoader+s			cCst||�j|�S(N(R�R(R!RFR�((s'/usr/lib64/python2.7/unittest/loader.pyR3sRcCst|||�j|�S(N(R�R$(R!RFR�R
((s'/usr/lib64/python2.7/unittest/loader.pyt	makeSuite6scCst|||�j|�S(N(R�R2(R-RFR�R
((s'/usr/lib64/python2.7/unittest/loader.pyt
findTestCases:s(R�RRtreRURR8t	functoolsRRMRtRRRQt
__unittesttcompilet
IGNORECASERxRRRtobjectRtdefaultTestLoaderR*R�R�RRR�R�(((s'/usr/lib64/python2.7/unittest/loader.pyt<module>s,			�	PK��[�����
result.pycnu�[����
{fc@s�dZddlZddlZddlZddlmZddlmZddlmZe	Z
d�ZdZd	Z
d
efd��YZdS(sTest result objecti����N(tStringIOi(tutil(twrapscst���fd��}|S(Ncs/t|dt�r|j�n�|||�S(Ntfailfast(tgetattrtFalsetstop(tselftargstkw(tmethod(s'/usr/lib64/python2.7/unittest/result.pytinners
(R(R
R((R
s'/usr/lib64/python2.7/unittest/result.pyRss
Stdout:
%ss
Stderr:
%st
TestResultcBs�eZdZdZeZeZdddd�Zd�Z	d�Z
d�Zd�Zd�Z
d�Zd�Zed	��Zed
��Zd�Zd�Zd
�Zed��Zd�Zd�Zd�Zd�Zd�Zd�ZRS(s�Holder for test result information.

    Test results are automatically managed by the TestCase and TestSuite
    classes, and do not need to be explicitly manipulated by writers of tests.

    Each instance holds the total number of tests run, and collections of
    failures and errors that occurred among those test runs. The collections
    contain tuples of (testcase, exceptioninfo), where exceptioninfo is the
    formatted traceback of the error that occurred.
    cCs�t|_g|_g|_d|_g|_g|_g|_t|_t|_	d|_d|_t
j|_t
j|_t|_dS(Ni(RRtfailuresterrorsttestsRuntskippedtexpectedFailurestunexpectedSuccessest
shouldStoptbuffertNonet_stdout_buffert_stderr_buffertsyststdoutt_original_stdouttstderrt_original_stderrt
_mirrorOutput(Rtstreamtdescriptionst	verbosity((s'/usr/lib64/python2.7/unittest/result.pyt__init__(s											cCsdS(s#Called by TestRunner after test runN((R((s'/usr/lib64/python2.7/unittest/result.pytprintErrors8tcCs&|jd7_t|_|j�dS(s-Called when the given test is about to be runiN(RRRt_setupStdout(Rttest((s'/usr/lib64/python2.7/unittest/result.pyt	startTest;s	cCsR|jrN|jdkr3t�|_t�|_n|jt_|jt_ndS(N(RRRRRRRR(R((s'/usr/lib64/python2.7/unittest/result.pyR$As	cCsdS(spCalled once before any tests are executed.

        See startTest for a method called before each test.
        N((R((s'/usr/lib64/python2.7/unittest/result.pytstartTestRunIR#cCs|j�t|_dS(s'Called when the given test has been runN(t_restoreStdoutRR(RR%((s'/usr/lib64/python2.7/unittest/result.pytstopTestOs
cCs�|jr�|jr�tjj�}tjj�}|ri|jd�sR|d7}n|jjt	|�n|r�|jd�s�|d7}n|j
jt|�q�n|jt_|j
t_|jj
d�|jj�|jj
d�|jj�ndS(Ns
i(RRRRtgetvalueRtendswithRtwritetSTDOUT_LINERtSTDERR_LINERtseekttruncateR(Rtoutputterror((s'/usr/lib64/python2.7/unittest/result.pyR(Ts$		


cCsdS(smCalled once after all tests are executed.

        See stopTest for a method called after each test.
        N((R((s'/usr/lib64/python2.7/unittest/result.pytstopTestRuniR#cCs/|jj||j||�f�t|_dS(smCalled when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info().
        N(Rtappendt_exc_info_to_stringtTrueR(RR%terr((s'/usr/lib64/python2.7/unittest/result.pytaddErroros"cCs/|jj||j||�f�t|_dS(sdCalled when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info().N(R
R4R5R6R(RR%R7((s'/usr/lib64/python2.7/unittest/result.pyt
addFailurews"cCsdS(s-Called when a test has completed successfullyN((RR%((s'/usr/lib64/python2.7/unittest/result.pyt
addSuccess~scCs|jj||f�dS(sCalled when a test is skipped.N(RR4(RR%treason((s'/usr/lib64/python2.7/unittest/result.pytaddSkip�scCs&|jj||j||�f�dS(s/Called when an expected failure/error occurred.N(RR4R5(RR%R7((s'/usr/lib64/python2.7/unittest/result.pytaddExpectedFailure�s	cCs|jj|�dS(s5Called when a test was expected to fail, but succeed.N(RR4(RR%((s'/usr/lib64/python2.7/unittest/result.pytaddUnexpectedSuccess�scCs*t|j�t|j�ko'dkSS(s.Tells whether or not this result was a successi(tlenR
R(R((s'/usr/lib64/python2.7/unittest/result.pyt
wasSuccessful�scCs
t|_dS(s*Indicates that the tests should be abortedN(R6R(R((s'/usr/lib64/python2.7/unittest/result.pyR�sc
Cs%|\}}}x"|r3|j|�r3|j}qW||jkrm|j|�}tj||||�}ntj|||�}|jrtjj	�}tj
j	�}	|r�|jd�s�|d7}n|jt
|�n|	r|	jd�s|	d7}	n|jt|	�qndj|�S(s>Converts a sys.exc_info()-style tuple of values into a string.s
R#(t_is_relevant_tb_levelttb_nexttfailureExceptiont_count_relevant_tb_levelst	tracebacktformat_exceptionRRRR*RR+R4R-R.tjoin(
RR7R%texctypetvaluettbtlengthtmsgLinesR1R2((s'/usr/lib64/python2.7/unittest/result.pyR5�s&
	

cCsd|jjkS(Nt
__unittest(ttb_framet	f_globals(RRJ((s'/usr/lib64/python2.7/unittest/result.pyRA�scCs:d}x-|r5|j|�r5|d7}|j}q	W|S(Nii(RARB(RRJRK((s'/usr/lib64/python2.7/unittest/result.pyRD�s


cCs5dtj|j�|jt|j�t|j�fS(Ns!<%s run=%i errors=%i failures=%i>(Rtstrclasst	__class__RR?RR
(R((s'/usr/lib64/python2.7/unittest/result.pyt__repr__�s!N(t__name__t
__module__t__doc__Rt_previousTestClassRt_testRunEnteredt_moduleSetUpFailedR!R"R&R$R'R)R(R3RR8R9R:R<R=R>R@RR5RARDRR(((s'/usr/lib64/python2.7/unittest/result.pyRs0
															(RUtosRRERR#Rt	functoolsRR6RMRR-R.tobjectR(((s'/usr/lib64/python2.7/unittest/result.pyt<module>s	PK��[(�G<<main.pycnu�[����
{fc@s�dZddlZddlZddlZddlmZmZddlmZe	Z
dZdZdZ
d	Zd
Zdefd��YZeZdS(
sUnittest main programi����Ni(tloadertrunner(tinstallHandlers)  -f, --failfast   Stop on first failure
s7  -c, --catch      Catch control-C and display results
s=  -b, --buffer     Buffer stdout and stderr during test runs
s�Usage: %(progName)s [options] [tests]

Options:
  -h, --help       Show this message
  -v, --verbose    Verbose output
  -q, --quiet      Minimal output
%(failfast)s%(catchbreak)s%(buffer)s
Examples:
  %(progName)s test_module               - run tests from test_module
  %(progName)s module.TestClass          - run tests from module.TestClass
  %(progName)s module.Class.test_method  - run specified test method

[tests] can be a list of any number of test modules, classes and test
methods.

Alternative Usage: %(progName)s discover [options]

Options:
  -v, --verbose    Verbose output
%(failfast)s%(catchbreak)s%(buffer)s  -s directory     Directory to start discovery ('.' default)
  -p pattern       Pattern to match test files ('test*.py' default)
  -t directory     Top level directory of project (default to
                   start directory)

For test discovery all test modules must be importable from the top
level directory of the project.
s1Usage: %(progName)s [options] [test] [...]

Options:
  -h, --help       Show this message
  -v, --verbose    Verbose output
  -q, --quiet      Minimal output
%(failfast)s%(catchbreak)s%(buffer)s
Examples:
  %(progName)s                               - run default set of tests
  %(progName)s MyTestSuite                   - run suite 'MyTestSuite'
  %(progName)s MyTestCase.testSomething      - run MyTestCase.testSomething
  %(progName)s MyTestCase                    - run all 'test*' test methods
                                               in MyTestCase
tTestProgramcBs�eZdZeZd	ZZZZ	dd	d	d	e
jedd	d	d	d�
Z
d	d�Zd�Zd�Zd	d�Zd�ZRS(
sA command-line program that runs a set of tests; this is primarily
       for making test modules conveniently executable.
    t__main__icCs�t|t�rTt|�|_x<|jd�dD]}t|j|�|_q2Wn	||_|dkrutj}n||_	||_
|	|_||_|
|_
||_||_||_tjj|d�|_|j|�|j�dS(Nt.ii(t
isinstancet
basestringt
__import__tmoduletsplittgetattrtNonetsystargvtexittfailfastt
catchbreakt	verbositytbuffertdefaultTestt
testRunnert
testLoadertostpathtbasenametprogNamet	parseArgstrunTests(tselfR	RRRRRRRRRtpart((s%/usr/lib64/python2.7/unittest/main.pyt__init__Hs$									
cCs�|r|GHni|jd6dd6dd6dd6}|jtkrOt|d<n|jtkrkt|d<n|jtkr�t|d<n|j|GHt	j
d�dS(NRtRRRi(RRtFalsetFAILFASTRt
CATCHBREAKRtBUFFEROUTPUTtUSAGER
R(Rtmsgtusage((s%/usr/lib64/python2.7/unittest/main.pyt	usageExitas



c	Cst|�dkr=|dj�dkr=|j|d�dSddl}ddddd	d
g}y}|j|dd|�\}}x�|D]�\}}|dkr�|j�n|dkr�d|_n|dkr�d|_n|dkr	|jdkr	t|_q	n|dkr3|j	dkr3t|_	q3n|d kr�|j
dkr]t|_
q]q�q�Wt|�dkr�|jdkr�d|_nEt|�dkr�||_t
dkr�d|_q�n|jf|_|j�Wn#|jk
r}|j|�nXdS(!Nitdiscoverii����thelptverbosetquietRtcatchRthHvqfcbs-hs-Hs--helps-qs--quietis-vs	--verboses-fs
--failfasts-cs--catchs-bs--bufferR(s-hs-Hs--help(s-qs--quiet(s-vs	--verbose(s-fs
--failfast(s-cs--catch(s-bs--buffer(tlentlowert
_do_discoverytgetoptR(RRRtTrueRRRt	testNamest__name__R	tcreateTeststerror(	RRR2t	long_optstoptionstargstopttvalueR&((s%/usr/lib64/python2.7/unittest/main.pyRosB(
!	cCsL|jdkr*|jj|j�|_n|jj|j|j�|_dS(N(R4RRtloadTestsFromModuleR	ttesttloadTestsFromNames(R((s%/usr/lib64/python2.7/unittest/main.pyR6�sc
s�|dkr�fd�}nd�j�_ddl}|j�}�j|_|jdddddtd	d
dd��jtkr�|jd
ddddtd	ddd�n�jtkr�|jdddddtd	ddd�n�j	tkr(|jdddddtd	ddd�n|jddddddd	d�|jdddd dd!d	d"�|jd#d$dd%ddd	d&�|j
|�\}}t|�d'kr��j�nx-t
d)|�D]\}}t|||�q�W�jdkr|j�_n�jdkr.|j�_n�j	dkrL|j	�_	n|jrad(�_n|j}	|j}
|j}|�}|j|	|
|��_dS(*Ncs�jS(N(R((R(s%/usr/lib64/python2.7/unittest/main.pyt<lambda>�R s%s discoveri����s-vs	--verbosetdestR+tdefaultR*sVerbose outputtactiont
store_trues-fs
--failfastRsStop on first fail or errors-cs--catchRs'Catch Ctrl-C and display results so fars-bs--bufferRs%Buffer stdout and stderr during testss-ss--start-directorytstartRs*Directory to start discovery ('.' default)s-ps	--patterntpatternstest*.pys+Pattern to match tests ('test*.py' default)s-ts--top-level-directoryttops<Top level directory of project (defaults to start directory)ii(RERFRG(RRtoptparsetOptionParsertprogt
add_optionR!RRRt
parse_argsR/R(tziptsetattrR+RRERFRGR)R>(
RRtLoaderRHtparserR9R:tnameR<t	start_dirRFt
top_level_dirR((Rs%/usr/lib64/python2.7/unittest/main.pyR1�sX




					cCs�|jrt�n|jdkr1tj|_nt|jttj	f�r�y+|jd|j
d|jd|j�}Wq�t
k
r�|j�}q�Xn	|j}|j|j�|_|jr�tj|jj��ndS(NRRR(RRRRRtTextTestRunnerRttypettypest	ClassTypeRRRt	TypeErrortrunR>tresultRR
t
wasSuccessful(RR((s%/usr/lib64/python2.7/unittest/main.pyR�s	
	
		N(R5t
__module__t__doc__tUSAGE_FROM_MODULER%RRRRRRtdefaultTestLoaderR3RR(RR6R1R(((s%/usr/lib64/python2.7/unittest/main.pyR?s			*	8(R]R
RRVR RRtsignalsRR3t
__unittestR"R#R$t
USAGE_AS_MAINR^tobjectRtmain(((s%/usr/lib64/python2.7/unittest/main.pyt<module>s�PK��[FE���__main__.pycnu�[����
{fc@stdZddlZejdjd�r8dejd<neZddlmZmZmZee_	edd�dS(	sMain entry pointi����Nis__main__.pyspython -m unittesti(tmaintTestProgramt
USAGE_AS_MAINtmodule(t__doc__tsystargvtendswithtTruet
__unittestRRRtUSAGEtNone(((s)/usr/lib64/python2.7/unittest/__main__.pyt<module>s	PK��[�nT�+�+
loader.pyonu�[����
{fc@sdZddlZddlZddlZddlZddlZddlmZddl	m	Z	ddl
mZmZe
Zejdej�Zd�Zd	�Zd
�Zdefd��YZe�Zed
�Zed�Zdeejd�Zdeejd�ZdS(sLoading unittests.i����N(t
cmp_to_key(tfnmatchi(tcasetsuites[_a-z]\w*\.py$cCs/d|tj�f}td|t|�|�S(Ns#Failed to import test module: %s
%stModuleImportFailure(t	tracebackt
format_exct_make_failed_testtImportError(tnamet
suiteClasstmessage((s'/usr/lib64/python2.7/unittest/loader.pyt_make_failed_import_testscCstd|||�S(NtLoadTestsFailure(R(R	t	exceptionR
((s'/usr/lib64/python2.7/unittest/loader.pyt_make_failed_load_testsscsG�fd�}i||6}t|tjf|�}|||�f�S(Ncs
��dS(N((tself(R(s'/usr/lib64/python2.7/unittest/loader.pyttestFailures(ttypeRtTestCase(t	classnamet
methodnameRR
Rtattrst	TestClass((Rs'/usr/lib64/python2.7/unittest/loader.pyRs
t
TestLoadercBs�eZdZdZeZejZdZ
d�Zed�Z
dd�Zdd�Zd�Zddd�Zd	�Zd
�Zd�Zd�Zd
�ZRS(s�
    This class is responsible for loading tests according to various criteria
    and returning them wrapped in a TestSuite
    ttestcCsnt|tj�r!td��n|j|�}|rRt|d�rRdg}n|jt||��}|S(s;Return a suite of all test cases contained in testCaseClasssYTest cases should not be derived from TestSuite. Maybe you meant to derive from TestCase?trunTest(t
issubclassRt	TestSuitet	TypeErrortgetTestCaseNamesthasattrR
tmap(Rt
testCaseClasst
testCaseNamestloaded_suite((s'/usr/lib64/python2.7/unittest/loader.pytloadTestsFromTestCase0scCs�g}x]t|�D]O}t||�}t|t�rt|tj�r|j|j|��qqWt|dd�}|j
|�}|r�|dk	r�y|||d�SWq�tk
r�}t|j
||j
�SXn|S(s>Return a suite of all test cases contained in the given modulet
load_testsN(tdirtgetattrt
isinstanceRRRRtappendR$tNoneR
t	ExceptionRt__name__(Rtmoduletuse_load_teststtestsR	tobjR%te((s'/usr/lib64/python2.7/unittest/loader.pytloadTestsFromModule;s!c
Cs�|jd�}|dkr}|}xK|roytdj|��}PWq%tk
rk|d=|sl�qlq%Xq%W|d}n|}x$|D]}|t||�}}q�Wt|tj�r�|j	|�St|t
�r�t|tj
�r�|j|�St|tj�rPt|t
�rPt|tj
�rP|d}||�}|j|g�St|tj�rf|St|d�r�|�}	t|	tj�r�|	St|	tj
�r�|j|	g�Std||	f��ntd|��dS(sSReturn a suite of all test cases given a string specifier.

        The name may resolve either to a module, a test case class, a
        test method within a test case class, or a callable object which
        returns a TestCase or TestSuite instance.

        The method optionally resolves the names relative to a given module.
        t.i����it__call__s"calling %s returned %s, not a tests$don't know how to make test from: %sN(tsplitR*t
__import__tjoinRR'R(ttypest
ModuleTypeR2RRRRR$tUnboundMethodTypeR
RRRR(
RR	R-tpartst
parts_copyR0tparttparenttinstR((s'/usr/lib64/python2.7/unittest/loader.pytloadTestsFromNameMsH		



!

	cCs2g|D]}|j||�^q}|j|�S(s�Return a suite of all test cases found using the given sequence
        of string specifiers. See 'loadTestsFromName()'.
        (R@R
(RtnamesR-R	tsuites((s'/usr/lib64/python2.7/unittest/loader.pytloadTestsFromNames~s%cCsP||jd�}t|t|��}|jrL|jdt|j��n|S(sLReturn a sorted sequence of method names found within testCaseClass
        cSs%|j|�o$tt||�d�S(NR4(t
startswithRR'(tattrnameR!tprefix((s'/usr/lib64/python2.7/unittest/loader.pytisTestMethod�stkey(ttestMethodPrefixtfilterR&tsortTestMethodsUsingtsortt	_CmpToKey(RR!RGttestFnNames((s'/usr/lib64/python2.7/unittest/loader.pyR�s	stest*.pyc	Cs�t}|dkr-|jdk	r-|j}n|dkrHt}|}ntjj|�}|tjkrtjjd|�n||_t}tjj	tjj|��r�tjj|�}||kr�tjj
tjj|d��}q�n�yt|�Wnt
k
rt}nmXtj|}|jd�d}tjjtjj|j��}|r�|j|�|_tjj|�n|r�t
d|��nt|j||��}|j|�S(s+Find and return all test modules from the specified start
        directory, recursing into subdirectories to find them. Only test files
        that match the pattern will be loaded. (Using shell style pattern
        matching.)

        All test modules must be importable from the top level of the project.
        If the start directory is not the top level directory then the top
        level directory must be specified separately.

        If a test package name (directory with '__init__.py') matches the
        pattern then the package will be checked for a 'load_tests' function. If
        this exists then it will be called with loader, tests, pattern.

        If load_tests exists then discovery does  *not* recurse into the package,
        load_tests is responsible for loading all tests in the package.

        The pattern is deliberately not stored as a loader attribute so that
        packages can continue discovery themselves. top_level_dir is stored so
        load_tests does not need to pass this argument in to loader.discover().
        is__init__.pyR3s%Start directory is not importable: %rN(tFalseR*t_top_level_dirtTruetostpathtabspathtsystinserttisdirtisfileR7R6RtmodulesR5tdirnamet__file__t _get_directory_containing_moduletremovetlistt_find_testsR
(	Rt	start_dirtpatternt
top_level_dirtset_implicit_toptis_not_importablet
the_modulettop_partR/((s'/usr/lib64/python2.7/unittest/loader.pytdiscover�s:		(


!cCsstj|}tjj|j�}tjj|�j�jd�r_tjj	tjj	|��Stjj	|�SdS(Ns__init__.py(
RURYRRRSRTR[tbasenametlowerRDRZ(Rtmodule_nameR-t	full_path((s'/usr/lib64/python2.7/unittest/loader.pyR\�s

!cCsVtjjtjj|��d}tjj||j�}|jtjjd�}|S(NiR3(RRRStsplitexttnormpathtrelpathRPtreplacetsep(RRSt_relpathR	((s'/usr/lib64/python2.7/unittest/loader.pyt_get_name_from_path�s"cCst|�tj|S(N(R6RURY(RR	((s'/usr/lib64/python2.7/unittest/loader.pyt_get_module_from_name�s
cCs
t||�S(N(R(RRSRkRa((s'/usr/lib64/python2.7/unittest/loader.pyt_match_path�sccs�tj|�}x�|D]�}tjj||�}tjj|�r�tj|�sXqn|j|||�ssqn|j|�}y|j	|�}Wnt
||j�Vq�Xtjjt
|d|��}tjjtjj|��d}	tjjtjj|��d}
|	j�|
j�kr�tjj|	�}tjjtjj|��d}tjj|�}
d}t||||
f��n|j|�Vqtjj|�rtjjtjj|d��s�qnd}d}t||�r?|j|�}|j	|�}t
|dd�}|j|dt�}n|dkr�|dk	r_|Vnxd|j||�D]}|VqrWq�y||||�VWq�tk
r�}t|j||j�Vq�XqqWdS(s/Used by discovery. Yields test suites it loads.R[isW%r module incorrectly imported from %r. Expected %r. Is this module globally installed?s__init__.pyR%R.N(RRtlistdirRSR7RXtVALID_MODULE_NAMEtmatchRtRrRsRR
RTR'RltrealpathRiRZRhRR2RWR*RROR_R+RR,(RR`RatpathsRSRkR	R-tmod_fileRxtfullpath_noextt
module_dirtmod_nametexpected_dirtmsgR%R/tpackageRR1((s'/usr/lib64/python2.7/unittest/loader.pyR_�sV
"""!N(R,t
__module__t__doc__RItcmpRKRRR
R*RPR$RQR2R@RCRRgR\RrRsRtR_(((s'/usr/lib64/python2.7/unittest/loader.pyR&s 		1	@		
		cCs1t�}||_||_|r-||_n|S(N(RRKRIR
(RFt	sortUsingR
tloader((s'/usr/lib64/python2.7/unittest/loader.pyt_makeLoader+s			cCst||�j|�S(N(R�R(R!RFR�((s'/usr/lib64/python2.7/unittest/loader.pyR3sRcCst|||�j|�S(N(R�R$(R!RFR�R
((s'/usr/lib64/python2.7/unittest/loader.pyt	makeSuite6scCst|||�j|�S(N(R�R2(R-RFR�R
((s'/usr/lib64/python2.7/unittest/loader.pyt
findTestCases:s(R�RRtreRURR8t	functoolsRRMRtRRRQt
__unittesttcompilet
IGNORECASERvRRRtobjectRtdefaultTestLoaderR*R�R�RRR�R�(((s'/usr/lib64/python2.7/unittest/loader.pyt<module>s,			�	PK��[&�xK��
runner.pyonu�[����
{fc@s�dZddlZddlZddlmZddlmZeZde	fd��YZ
dejfd	��YZd
e	fd��YZ
dS(s
Running testsi����Ni(tresult(tregisterResultt_WritelnDecoratorcBs,eZdZd�Zd�Zdd�ZRS(s@Used to decorate file-like objects with a handy 'writeln' methodcCs
||_dS(N(tstream(tselfR((s'/usr/lib64/python2.7/unittest/runner.pyt__init__scCs+|dkrt|��nt|j|�S(NRt__getstate__(RR(tAttributeErrortgetattrR(Rtattr((s'/usr/lib64/python2.7/unittest/runner.pyt__getattr__scCs'|r|j|�n|jd�dS(Ns
(twrite(Rtarg((s'/usr/lib64/python2.7/unittest/runner.pytwritelnsN(t__name__t
__module__t__doc__RR
tNoneR
(((s'/usr/lib64/python2.7/unittest/runner.pyRs		tTextTestResultcBs�eZdZddZddZd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�ZRS(shA test result class that can print formatted text results to a stream.

    Used by TextTestRunner.
    t=iFt-cCsPtt|�j|||�||_|dk|_|dk|_||_dS(Ni(tsuperRRRtshowAlltdotstdescriptions(RRRt	verbosity((s'/usr/lib64/python2.7/unittest/runner.pyR$s
	cCsB|j�}|jr4|r4djt|�|f�St|�SdS(Ns
(tshortDescriptionRtjointstr(Rttesttdoc_first_line((s'/usr/lib64/python2.7/unittest/runner.pytgetDescription+scCs\tt|�j|�|jrX|jj|j|��|jjd�|jj�ndS(Ns ... (RRt	startTestRRRRtflush(RR((s'/usr/lib64/python2.7/unittest/runner.pyR 2s
	cCs_tt|�j|�|jr2|jjd�n)|jr[|jjd�|jj�ndS(Ntokt.(	RRt
addSuccessRRR
RRR!(RR((s'/usr/lib64/python2.7/unittest/runner.pyR$9s		cCsbtt|�j||�|jr5|jjd�n)|jr^|jjd�|jj�ndS(NtERRORtE(	RRtaddErrorRRR
RRR!(RRterr((s'/usr/lib64/python2.7/unittest/runner.pyR'As		cCsbtt|�j||�|jr5|jjd�n)|jr^|jjd�|jj�ndS(NtFAILtF(	RRt
addFailureRRR
RRR!(RRR(((s'/usr/lib64/python2.7/unittest/runner.pyR+Is		cCsktt|�j||�|jr>|jjdj|��n)|jrg|jjd�|jj	�ndS(Ns
skipped {0!r}ts(
RRtaddSkipRRR
tformatRRR!(RRtreason((s'/usr/lib64/python2.7/unittest/runner.pyR-Qs		cCsbtt|�j||�|jr5|jjd�n)|jr^|jjd�|jj�ndS(Nsexpected failuretx(	RRtaddExpectedFailureRRR
RRR!(RRR(((s'/usr/lib64/python2.7/unittest/runner.pyR1Ys		cCs_tt|�j|�|jr2|jjd�n)|jr[|jjd�|jj�ndS(Nsunexpected successtu(	RRtaddUnexpectedSuccessRRR
RRR!(RR((s'/usr/lib64/python2.7/unittest/runner.pyR3as		cCsL|js|jr"|jj�n|jd|j�|jd|j�dS(NR%R)(RRRR
tprintErrorListterrorstfailures(R((s'/usr/lib64/python2.7/unittest/runner.pytprintErrorsiscCsxxq|D]i\}}|jj|j�|jjd||j|�f�|jj|j�|jjd|�qWdS(Ns%s: %ss%s(RR
t
separator1Rt
separator2(RtflavourR5RR(((s'/usr/lib64/python2.7/unittest/runner.pyR4os
#(RRRR8R9RRR R$R'R+R-R1R3R7R4(((s'/usr/lib64/python2.7/unittest/runner.pyRs

										tTextTestRunnercBsDeZdZeZejedeedd�Z
d�Zd�ZRS(s�A test runner class that displays results in textual form.

    It prints out the names of tests as they are run, errors as they
    occur, and a summary of the results at the end of the test run.
    icCsOt|�|_||_||_||_||_|dk	rK||_ndS(N(RRRRtfailfasttbufferRtresultclass(RRRRR<R=R>((s'/usr/lib64/python2.7/unittest/runner.pyRs				cCs|j|j|j|j�S(N(R>RRR(R((s'/usr/lib64/python2.7/unittest/runner.pyt_makeResult�scCs�|j�}t|�|j|_|j|_tj�}t|dd�}|dk	rb|�nz||�Wdt|dd�}|dk	r�|�nXtj�}||}|j�t|d�r�|j	j
|j�n|j}|j	j
d||dkrdpd|f�|j	j
�d	}	}
}y%t
t|j|j|jf�}Wntk
rlnX|\}	}
}g}
|j�s�|j	jd
�t
t|j|jf�\}}|r�|
jd|�n|r|
jd|�qn|j	jd
�|r |
jd|�n|	r:|
jd|	�n|
rT|
jd|
�n|
r}|j	j
ddj|
�f�n|j	jd�|S(s&Run the given test case or test suite.tstartTestRunNtstopTestRunR9sRan %d test%s in %.3fsiR,titFAILEDsfailures=%ds	errors=%dtOKs
skipped=%dsexpected failures=%dsunexpected successes=%ds (%s)s, s
(R?RR<R=ttimeRRR7thasattrRR
R9ttestsRuntmaptlentexpectedFailurestunexpectedSuccessestskippedRt
wasSuccessfulRR6R5tappendR(RRRt	startTimeR@RAtstopTimet	timeTakentrunt
expectedFailsRKRLtresultstinfostfailedterrored((s'/usr/lib64/python2.7/unittest/runner.pyRR�sb



	#

!#N(
RRRRR>tsyststderrtTruetFalseRRR?RR(((s'/usr/lib64/python2.7/unittest/runner.pyR;ws		(RRXRERBRtsignalsRRZt
__unittesttobjectRt
TestResultRR;(((s'/usr/lib64/python2.7/unittest/runner.pyt<module>s[PK��['�y9*)*)	suite.pyonu�[����
{fc@s�dZddlZddlmZddlmZeZd�Zdefd��YZ	de	fd	��YZ
d
efd��YZd�Zd
efd��YZ
dS(t	TestSuitei����Ni(tcase(tutilcCs t||d��}|�dS(NcSsdS(N(tNone(((s&/usr/lib64/python2.7/unittest/suite.pyt<lambda>t(tgetattr(tparenttattrtfunc((s&/usr/lib64/python2.7/unittest/suite.pyt_call_if_existsst
BaseTestSuitecBszeZdZdd�Zd�Zd�Zd�Zd
Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�ZRS(sNA simple test suite that doesn't provide class or module shared fixtures.
    cCsg|_|j|�dS(N(t_teststaddTests(tselfttests((s&/usr/lib64/python2.7/unittest/suite.pyt__init__s	cCs dtj|j�t|�fS(Ns
<%s tests=%s>(Rtstrclasst	__class__tlist(R((s&/usr/lib64/python2.7/unittest/suite.pyt__repr__scCs,t||j�stSt|�t|�kS(N(t
isinstanceRtNotImplementedR(Rtother((s&/usr/lib64/python2.7/unittest/suite.pyt__eq__scCs||kS(N((RR((s&/usr/lib64/python2.7/unittest/suite.pyt__ne__scCs
t|j�S(N(titerR(R((s&/usr/lib64/python2.7/unittest/suite.pyt__iter__%scCs+d}x|D]}||j�7}q
W|S(Ni(tcountTestCases(Rtcasesttest((s&/usr/lib64/python2.7/unittest/suite.pyR(s
cCswt|d�s-tdjt|����nt|t�rct|tjt	f�rctd��n|j
j|�dS(Nt__call__s{} is not callablesNTestCases and TestSuites must be instantiated before passing them to addTest()(thasattrt	TypeErrortformattreprRttypet
issubclassRtTestCaseRRtappend(RR((s&/usr/lib64/python2.7/unittest/suite.pytaddTest.scCs@t|t�rtd��nx|D]}|j|�q%WdS(Ns0tests must be an iterable of tests, not a string(Rt
basestringR!R((RRR((s&/usr/lib64/python2.7/unittest/suite.pyR
8s
cCs,x%|D]}|jrPn||�qW|S(N(t
shouldStop(RtresultR((s&/usr/lib64/python2.7/unittest/suite.pytrun>s

	cOs|j||�S(N(R,(Rtargstkwds((s&/usr/lib64/python2.7/unittest/suite.pyREscCsx|D]}|j�qWdS(s7Run the tests without collecting errors in a TestResultN(tdebug(RR((s&/usr/lib64/python2.7/unittest/suite.pyR/Hs
(N(t__name__t
__module__t__doc__RRRRRt__hash__RRR(R
R,RR/(((s&/usr/lib64/python2.7/unittest/suite.pyRs						
			cBsYeZdZed�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�ZRS(	s�A test suite is a composite test consisting of a number of TestCases.

    For use, create an instance of TestSuite, then add test case instances.
    When all tests have been added, the suite can be passed to a test
    runner, such as TextTestRunner. It will run the individual test cases
    in the order in which they were added, aggregating the results. When
    subclassing, do not forget to call the base class constructor.
    cCst}t|dt�tkr.t|_}nx�|D]�}|jrHPnt|�r�|j||�|j||�|j||�|j	|_
t|j	dt�s5t|dt�r�q5q�n|s�||�q5|j�q5W|r|jd|�|j
|�t|_n|S(Nt_testRunEnteredt_classSetupFailedt_moduleSetUpFailed(tFalseRtTrueR4R*t_isnotsuitet_tearDownPreviousClasst_handleModuleFixturet_handleClassSetUpRt_previousTestClassR/Rt_handleModuleTearDown(RR+R/ttopLevelR((s&/usr/lib64/python2.7/unittest/suite.pyR,Xs,
		

cCst�}|j|t�dS(s7Run the tests without collecting errors in a TestResultN(t_DebugResultR,R8(RR/((s&/usr/lib64/python2.7/unittest/suite.pyR/vs	c	Cs!t|dd�}|j}||kr+dS|jr8dSt|dt�rNdSy
t|_Wntk
rnnXt|dd�}|dk	rt|d�zoy|�Wn]tk
r}t	|t
�r��nt|_tj
|�}d|}|j|||�nXWdt|d�XndS(NR=t__unittest_skip__t
setUpClasst_setupStdoutssetUpClass (%s)t_restoreStdout(RRRR6R7R5R!R
t	ExceptionRR@R8RRt_addClassOrModuleLevelException(	RRR+t
previousClasstcurrentClassRBtet	classNamet	errorName((s&/usr/lib64/python2.7/unittest/suite.pyR<}s4		


	
cCs4d}t|dd�}|dk	r0|j}n|S(NR=(RRR1(RR+tpreviousModuleRG((s&/usr/lib64/python2.7/unittest/suite.pyt_get_previous_module�s
c	Cs
|j|�}|jj}||kr+dS|j|�t|_ytj|}Wntk
rfdSXt	|dd�}|dk	rt|d�z`y|�WnNtk
r�}t
|t�r��nt|_d|}|j|||�nXWdt|d�XndS(NtsetUpModuleRCssetUpModule (%s)RD(RMRR1R>R7R6tsystmodulestKeyErrorRRR
RERR@R8RF(	RRR+RLt
currentModuletmoduleRNRIRK((s&/usr/lib64/python2.7/unittest/suite.pyR;�s.
	

	
cCslt|�}t|dd�}|dk	rRt|tj�rR||t|��n|j|tj	��dS(NtaddSkip(
t_ErrorHolderRRRRtSkipTesttstrtaddErrorROtexc_info(RR+t	exceptionRKterrorRT((s&/usr/lib64/python2.7/unittest/suite.pyRF�s
cCs�|j|�}|dkrdS|jr,dSytj|}Wntk
rQdSXt|dd�}|dk	r�t|d�zWy|�WnEtk
r�}t	|t
�r��nd|}|j|||�nXWdt|d�XndS(NttearDownModuleRCstearDownModule (%s)RD(RMRR6RORPRQRR
RERR@RF(RR+RLRSR\RIRK((s&/usr/lib64/python2.7/unittest/suite.pyR>�s*	


c	Cst|dd�}|j}||kr+dSt|dt�rAdSt|dt�rWdSt|dt�rmdSt|dd�}|dk	rt|d�zfy|�WnTtk
r�}t|t�r��ntj	|�}d|}|j
|||�nXWdt|d�XndS(	NR=R5R6RAt
tearDownClassRCstearDownClass (%s)RD(RRRR7R
RERR@RRRF(	RRR+RGRHR]RIRJRK((s&/usr/lib64/python2.7/unittest/suite.pyR:�s.	

(R0R1R2R7R,R/R<RMR;RFR>R:(((s&/usr/lib64/python2.7/unittest/suite.pyRNs		 				RUcBs\eZdZd	Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd�ZRS(
s�
    Placeholder for a TestCase inside a result. As far as a TestResult
    is concerned, this looks exactly like a unit test. Used to insert
    arbitrary errors into a test suite run.
    cCs
||_dS(N(tdescription(RR^((s&/usr/lib64/python2.7/unittest/suite.pyRscCs|jS(N(R^(R((s&/usr/lib64/python2.7/unittest/suite.pytidscCsdS(N(R(R((s&/usr/lib64/python2.7/unittest/suite.pytshortDescriptionscCsd|jfS(Ns<ErrorHolder description=%r>(R^(R((s&/usr/lib64/python2.7/unittest/suite.pyRscCs
|j�S(N(R_(R((s&/usr/lib64/python2.7/unittest/suite.pyt__str__scCsdS(N((RR+((s&/usr/lib64/python2.7/unittest/suite.pyR,scCs
|j|�S(N(R,(RR+((s&/usr/lib64/python2.7/unittest/suite.pyRscCsdS(Ni((R((s&/usr/lib64/python2.7/unittest/suite.pyRsN(
R0R1R2RtfailureExceptionRR_R`RRaR,RR(((s&/usr/lib64/python2.7/unittest/suite.pyRU�s							cCs'yt|�Wntk
r"tSXtS(s?A crude way to tell apart testcases and suites with duck-typing(RR!R8R7(R((s&/usr/lib64/python2.7/unittest/suite.pyR9"s

R@cBs eZdZdZeZeZRS(sCUsed by the TestSuite to hold previous class when running in debug.N(R0R1R2RR=R7R6R*(((s&/usr/lib64/python2.7/unittest/suite.pyR@+s(R2RORRRR8t
__unittestR
tobjectRRRUR9R@(((s&/usr/lib64/python2.7/unittest/suite.pyt<module>s	>�&		PK��[(�G<<main.pyonu�[����
{fc@s�dZddlZddlZddlZddlmZmZddlmZe	Z
dZdZdZ
d	Zd
Zdefd��YZeZdS(
sUnittest main programi����Ni(tloadertrunner(tinstallHandlers)  -f, --failfast   Stop on first failure
s7  -c, --catch      Catch control-C and display results
s=  -b, --buffer     Buffer stdout and stderr during test runs
s�Usage: %(progName)s [options] [tests]

Options:
  -h, --help       Show this message
  -v, --verbose    Verbose output
  -q, --quiet      Minimal output
%(failfast)s%(catchbreak)s%(buffer)s
Examples:
  %(progName)s test_module               - run tests from test_module
  %(progName)s module.TestClass          - run tests from module.TestClass
  %(progName)s module.Class.test_method  - run specified test method

[tests] can be a list of any number of test modules, classes and test
methods.

Alternative Usage: %(progName)s discover [options]

Options:
  -v, --verbose    Verbose output
%(failfast)s%(catchbreak)s%(buffer)s  -s directory     Directory to start discovery ('.' default)
  -p pattern       Pattern to match test files ('test*.py' default)
  -t directory     Top level directory of project (default to
                   start directory)

For test discovery all test modules must be importable from the top
level directory of the project.
s1Usage: %(progName)s [options] [test] [...]

Options:
  -h, --help       Show this message
  -v, --verbose    Verbose output
  -q, --quiet      Minimal output
%(failfast)s%(catchbreak)s%(buffer)s
Examples:
  %(progName)s                               - run default set of tests
  %(progName)s MyTestSuite                   - run suite 'MyTestSuite'
  %(progName)s MyTestCase.testSomething      - run MyTestCase.testSomething
  %(progName)s MyTestCase                    - run all 'test*' test methods
                                               in MyTestCase
tTestProgramcBs�eZdZeZd	ZZZZ	dd	d	d	e
jedd	d	d	d�
Z
d	d�Zd�Zd�Zd	d�Zd�ZRS(
sA command-line program that runs a set of tests; this is primarily
       for making test modules conveniently executable.
    t__main__icCs�t|t�rTt|�|_x<|jd�dD]}t|j|�|_q2Wn	||_|dkrutj}n||_	||_
|	|_||_|
|_
||_||_||_tjj|d�|_|j|�|j�dS(Nt.ii(t
isinstancet
basestringt
__import__tmoduletsplittgetattrtNonetsystargvtexittfailfastt
catchbreakt	verbositytbuffertdefaultTestt
testRunnert
testLoadertostpathtbasenametprogNamet	parseArgstrunTests(tselfR	RRRRRRRRRtpart((s%/usr/lib64/python2.7/unittest/main.pyt__init__Hs$									
cCs�|r|GHni|jd6dd6dd6dd6}|jtkrOt|d<n|jtkrkt|d<n|jtkr�t|d<n|j|GHt	j
d�dS(NRtRRRi(RRtFalsetFAILFASTRt
CATCHBREAKRtBUFFEROUTPUTtUSAGER
R(Rtmsgtusage((s%/usr/lib64/python2.7/unittest/main.pyt	usageExitas



c	Cst|�dkr=|dj�dkr=|j|d�dSddl}ddddd	d
g}y}|j|dd|�\}}x�|D]�\}}|dkr�|j�n|dkr�d|_n|dkr�d|_n|dkr	|jdkr	t|_q	n|dkr3|j	dkr3t|_	q3n|d kr�|j
dkr]t|_
q]q�q�Wt|�dkr�|jdkr�d|_nEt|�dkr�||_t
dkr�d|_q�n|jf|_|j�Wn#|jk
r}|j|�nXdS(!Nitdiscoverii����thelptverbosetquietRtcatchRthHvqfcbs-hs-Hs--helps-qs--quietis-vs	--verboses-fs
--failfasts-cs--catchs-bs--bufferR(s-hs-Hs--help(s-qs--quiet(s-vs	--verbose(s-fs
--failfast(s-cs--catch(s-bs--buffer(tlentlowert
_do_discoverytgetoptR(RRRtTrueRRRt	testNamest__name__R	tcreateTeststerror(	RRR2t	long_optstoptionstargstopttvalueR&((s%/usr/lib64/python2.7/unittest/main.pyRosB(
!	cCsL|jdkr*|jj|j�|_n|jj|j|j�|_dS(N(R4RRtloadTestsFromModuleR	ttesttloadTestsFromNames(R((s%/usr/lib64/python2.7/unittest/main.pyR6�sc
s�|dkr�fd�}nd�j�_ddl}|j�}�j|_|jdddddtd	d
dd��jtkr�|jd
ddddtd	ddd�n�jtkr�|jdddddtd	ddd�n�j	tkr(|jdddddtd	ddd�n|jddddddd	d�|jdddd dd!d	d"�|jd#d$dd%ddd	d&�|j
|�\}}t|�d'kr��j�nx-t
d)|�D]\}}t|||�q�W�jdkr|j�_n�jdkr.|j�_n�j	dkrL|j	�_	n|jrad(�_n|j}	|j}
|j}|�}|j|	|
|��_dS(*Ncs�jS(N(R((R(s%/usr/lib64/python2.7/unittest/main.pyt<lambda>�R s%s discoveri����s-vs	--verbosetdestR+tdefaultR*sVerbose outputtactiont
store_trues-fs
--failfastRsStop on first fail or errors-cs--catchRs'Catch Ctrl-C and display results so fars-bs--bufferRs%Buffer stdout and stderr during testss-ss--start-directorytstartRs*Directory to start discovery ('.' default)s-ps	--patterntpatternstest*.pys+Pattern to match tests ('test*.py' default)s-ts--top-level-directoryttops<Top level directory of project (defaults to start directory)ii(RERFRG(RRtoptparsetOptionParsertprogt
add_optionR!RRRt
parse_argsR/R(tziptsetattrR+RRERFRGR)R>(
RRtLoaderRHtparserR9R:tnameR<t	start_dirRFt
top_level_dirR((Rs%/usr/lib64/python2.7/unittest/main.pyR1�sX




					cCs�|jrt�n|jdkr1tj|_nt|jttj	f�r�y+|jd|j
d|jd|j�}Wq�t
k
r�|j�}q�Xn	|j}|j|j�|_|jr�tj|jj��ndS(NRRR(RRRRRtTextTestRunnerRttypettypest	ClassTypeRRRt	TypeErrortrunR>tresultRR
t
wasSuccessful(RR((s%/usr/lib64/python2.7/unittest/main.pyR�s	
	
		N(R5t
__module__t__doc__tUSAGE_FROM_MODULER%RRRRRRtdefaultTestLoaderR3RR(RR6R1R(((s%/usr/lib64/python2.7/unittest/main.pyR?s			*	8(R]R
RRVR RRtsignalsRR3t
__unittestR"R#R$t
USAGE_AS_MAINR^tobjectRtmain(((s%/usr/lib64/python2.7/unittest/main.pyt<module>s�PK��[+���%�%test/test_skipping.pyonu�[����
|fc@sRddlZddlmZdejfd��YZedkrNej�ndS(i����N(t
LoggingResulttTest_TestSkippingcBsYeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(	cCs	dtjfd��Y}g}t|�}|d�}|j|�|j|dddg�|j|j|dfg�dtjfd��Y}g}t|�}|d	�}|j|�|j|dddg�|j|j|d
fg�|j|jd�dS(NtFoocBseZd�ZRS(cSs|jd�dS(Ntskip(tskipTest(tself((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_skip_me
s(t__name__t
__module__R(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR	sRt	startTesttaddSkiptstopTestRcBseZd�Zd�ZRS(cSs|jd�dS(Nttesting(R(R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pytsetUpscSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_nothingt(RRR
R(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRs	RRi(tunittesttTestCaseRtruntassertEqualtskippedttestsRun(RRteventstresultttest((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyt
test_skippings

c	s6tjttftjttff}x|D]\���dtjf���fd��Y}|d�}|d�}tj||g�}g}t|�}|j|�|j	t
|j�d�ddddd	dg}|j	||�|j	|jd
�|j	|j|dfg�|j
|j��q+WdS(NRcs8eZ��d�d��Z��d�d��ZRS(RcSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyt	test_skip%scSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_dont_skip(s(RRRR((tdecotdo_skipt	dont_skip(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR$sRRiR	R
Rt
addSuccessiR(Rt
skipUnlesstFalsetTruetskipIfRt	TestSuiteRRRtlenRRt
assertTruet
wasSuccessful(	Rtop_tableRttest_do_skipRtsuiteRRtexpected((RRRs3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_skipping_decorators s"%
	cs�tjd�dtjf�fd��Y�}g�tj�}|d�}tj|g�}|j|�|j|j|dfg�|j�g�dS(NRRcseZ�fd�ZRS(cs�jd�dS(Ni(tappend(R(trecord(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_1;s(RRR/((R.(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR9sR/(RRRt
TestResultR$RRR(RRRRR*((R.s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_skip_class8s
cs�tjd�dd�fd��Y�}d|tjfd��Y}g�tj�}|d�}tj|g�}|j|�|j|j|dfg�|j�g�dS(NRtMixincseZ�fd�ZRS(cs�jd�dS(Ni(R-(R(R.(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR/Hs(RRR/((R.(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR2FsRcBseZRS((RR(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRJsR/((RRRR0R$RRR(RR2RRRR*((R.s3/usr/lib64/python2.7/unittest/test/test_skipping.pyt&test_skip_non_unittest_class_old_styleEs(
cs�tjd�dtf�fd��Y�}d|tjfd��Y}g�tj�}|d�}tj|g�}|j|�|j|j|dfg�|j�g�dS(NRR2cseZ�fd�ZRS(cs�jd�dS(Ni(R-(R(R.(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR/Ws(RRR/((R.(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR2UsRcBseZRS((RR(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRYsR/(	RRtobjectRR0R$RRR(RR2RRRR*((R.s3/usr/lib64/python2.7/unittest/test/test_skipping.pyt&test_skip_non_unittest_class_new_styleTs
cCs�dtjfd��Y}g}t|�}|d�}|j|�|j|dddg�|j|jdd|�|j|j��dS(NRcBseZejd��ZRS(cSs|jd�dS(Nshelp me!(tfail(R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_diees(RRRtexpectedFailureR7(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRdsR7R	taddExpectedFailureRi(RRRRRtexpectedFailuresR&R'(RRRRR((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_expected_failurecs
	cCs�dtjfd��Y}g}t|�}|d�}|j|�|j|dddg�|j|j�|j|j|g�|j|j	��dS(NRcBseZejd��ZRS(cSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR7ss(RRRR8R7(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRrsR7R	taddUnexpectedSuccessR(
RRRRRtassertFalsetfailurestunexpectedSuccessesR&R'(RRRRR((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_unexpected_successqs
	cs�dtjf�fd��Y�tj�}�d�}tj|g�}|j|�|j|j|dfg�|j�j�|j�j	�dS(NRcsJeZeZeZ�fd�Z�fd�Zejd�d��Z	RS(cs
t�_dS(N(R"twasSetUp(R(R(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR
�scs
t�_dS(N(R"twasTornDown(R(R(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttornDown�sRcSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR/�s(
RRR!RARBR
RCRRR/((R(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR�s
R/R(
RRR0R$RRRR=RARB(RRRR*((Rs3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_skip_doesnt_run_setup�s
csd��dtjf�fd��Y}tj�}|d�}tj|g�}|j|�|j|j|dfg�dS(Ncs�fd�}|S(Ncs
�|�S(N((ta(tfunc(s3/usr/lib64/python2.7/unittest/test/test_skipping.pytinner�s((RFRG((RFs3/usr/lib64/python2.7/unittest/test/test_skipping.pyt	decorator�sRcs&eZ�ejd�d���ZRS(RcSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR/�s(RRRRR/((RH(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR�sR/R(RRR0R$RRR(RRRRR*((RHs3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_decorated_skip�s	
(RRRR,R1R3R5R;R@RDRI(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRs			
					t__main__(Rtunittest.test.supportRRRRtmain(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyt<module>s�PK��[D����test/dummy.pycnu�[����
{fc@sdS(N((((s+/usr/lib64/python2.7/unittest/test/dummy.pyt<module>tPK��[+���%�%test/test_skipping.pycnu�[����
|fc@sRddlZddlmZdejfd��YZedkrNej�ndS(i����N(t
LoggingResulttTest_TestSkippingcBsYeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(	cCs	dtjfd��Y}g}t|�}|d�}|j|�|j|dddg�|j|j|dfg�dtjfd��Y}g}t|�}|d	�}|j|�|j|dddg�|j|j|d
fg�|j|jd�dS(NtFoocBseZd�ZRS(cSs|jd�dS(Ntskip(tskipTest(tself((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_skip_me
s(t__name__t
__module__R(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR	sRt	startTesttaddSkiptstopTestRcBseZd�Zd�ZRS(cSs|jd�dS(Nttesting(R(R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pytsetUpscSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_nothingt(RRR
R(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRs	RRi(tunittesttTestCaseRtruntassertEqualtskippedttestsRun(RRteventstresultttest((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyt
test_skippings

c	s6tjttftjttff}x|D]\���dtjf���fd��Y}|d�}|d�}tj||g�}g}t|�}|j|�|j	t
|j�d�ddddd	dg}|j	||�|j	|jd
�|j	|j|dfg�|j
|j��q+WdS(NRcs8eZ��d�d��Z��d�d��ZRS(RcSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyt	test_skip%scSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_dont_skip(s(RRRR((tdecotdo_skipt	dont_skip(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR$sRRiR	R
Rt
addSuccessiR(Rt
skipUnlesstFalsetTruetskipIfRt	TestSuiteRRRtlenRRt
assertTruet
wasSuccessful(	Rtop_tableRttest_do_skipRtsuiteRRtexpected((RRRs3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_skipping_decorators s"%
	cs�tjd�dtjf�fd��Y�}g�tj�}|d�}tj|g�}|j|�|j|j|dfg�|j�g�dS(NRRcseZ�fd�ZRS(cs�jd�dS(Ni(tappend(R(trecord(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_1;s(RRR/((R.(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR9sR/(RRRt
TestResultR$RRR(RRRRR*((R.s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_skip_class8s
cs�tjd�dd�fd��Y�}d|tjfd��Y}g�tj�}|d�}tj|g�}|j|�|j|j|dfg�|j�g�dS(NRtMixincseZ�fd�ZRS(cs�jd�dS(Ni(R-(R(R.(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR/Hs(RRR/((R.(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR2FsRcBseZRS((RR(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRJsR/((RRRR0R$RRR(RR2RRRR*((R.s3/usr/lib64/python2.7/unittest/test/test_skipping.pyt&test_skip_non_unittest_class_old_styleEs(
cs�tjd�dtf�fd��Y�}d|tjfd��Y}g�tj�}|d�}tj|g�}|j|�|j|j|dfg�|j�g�dS(NRR2cseZ�fd�ZRS(cs�jd�dS(Ni(R-(R(R.(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR/Ws(RRR/((R.(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR2UsRcBseZRS((RR(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRYsR/(	RRtobjectRR0R$RRR(RR2RRRR*((R.s3/usr/lib64/python2.7/unittest/test/test_skipping.pyt&test_skip_non_unittest_class_new_styleTs
cCs�dtjfd��Y}g}t|�}|d�}|j|�|j|dddg�|j|jdd|�|j|j��dS(NRcBseZejd��ZRS(cSs|jd�dS(Nshelp me!(tfail(R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_diees(RRRtexpectedFailureR7(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRdsR7R	taddExpectedFailureRi(RRRRRtexpectedFailuresR&R'(RRRRR((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_expected_failurecs
	cCs�dtjfd��Y}g}t|�}|d�}|j|�|j|dddg�|j|j�|j|j|g�|j|j	��dS(NRcBseZejd��ZRS(cSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR7ss(RRRR8R7(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRrsR7R	taddUnexpectedSuccessR(
RRRRRtassertFalsetfailurestunexpectedSuccessesR&R'(RRRRR((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_unexpected_successqs
	cs�dtjf�fd��Y�tj�}�d�}tj|g�}|j|�|j|j|dfg�|j�j�|j�j	�dS(NRcsJeZeZeZ�fd�Z�fd�Zejd�d��Z	RS(cs
t�_dS(N(R"twasSetUp(R(R(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR
�scs
t�_dS(N(R"twasTornDown(R(R(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyttornDown�sRcSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR/�s(
RRR!RARBR
RCRRR/((R(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR�s
R/R(
RRR0R$RRRR=RARB(RRRR*((Rs3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_skip_doesnt_run_setup�s
csd��dtjf�fd��Y}tj�}|d�}tj|g�}|j|�|j|j|dfg�dS(Ncs�fd�}|S(Ncs
�|�S(N((ta(tfunc(s3/usr/lib64/python2.7/unittest/test/test_skipping.pytinner�s((RFRG((RFs3/usr/lib64/python2.7/unittest/test/test_skipping.pyt	decorator�sRcs&eZ�ejd�d���ZRS(RcSsdS(N((R((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR/�s(RRRRR/((RH(s3/usr/lib64/python2.7/unittest/test/test_skipping.pyR�sR/R(RRR0R$RRR(RRRRR*((RHs3/usr/lib64/python2.7/unittest/test/test_skipping.pyttest_decorated_skip�s	
(RRRR,R1R3R5R;R@RDRI(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyRs			
					t__main__(Rtunittest.test.supportRRRRtmain(((s3/usr/lib64/python2.7/unittest/test/test_skipping.pyt<module>s�PK��[o5��z4z4test/test_assertions.pycnu�[����
{fc@sgddlZddlZdejfd��YZdejfd��YZedkrcej�ndS(i����NtTest_AssertionscBs,eZd�Zd�Zd�Zd�ZRS(cCsH|jdd�|jdd�|j|j|jdd�|j|j|jdd�|jdddd�|j|j|jdddd�|jdddd�|jdddd�|j|j|jdd
dd�|j|j|jdddd�|jtd
�td
��|j|j|jtd
�td
��dS(Ng�1��?g�?g����?g�������?tplacesiig�������?y�������?tinfy�������?�������?y�������?�������?y�������?�������?y�������?�������?(tassertAlmostEqualtassertNotAlmostEqualtassertRaisestfailureExceptiontfloat(tself((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttest_AlmostEquals$c	Cs�|jdddd�|jdddd�|jdddd�|jdddd�|jdddd�|j|j|jdddd�|j|j|jdddd�|j|j|jdddd�|jt|jdddddd�|jt|jdddddd�tjj�}|tjdd	�}|j||dtjdd
��|j||dtjdd��dS(Ng�������?g�?tdeltag�?g�������?Ritsecondsi
ii(RRRRt	TypeErrortdatetimetnowt	timedelta(Rtfirsttsecond((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttest_AmostEqualWithDeltas*c	Cs�d�}|jt|t�|jt|td��y|jtd��Wn)|jk
rw}|jd|j�nX|jd�y|jt|t�Wntk
r�nX|jd�|jt��*}y
t�Wntk
r�}�nXWdQX|j|j	|�|jt��td��WdQXy|jt��WdQXWn)|jk
rr}|jd|j�nX|jd�y |jt��t�WdQXWntk
r�nX|jd�dS(NcSs
|�dS(N((te((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt_raise:stkeycSsdS(N(tNone(((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt<lambda>?tsKeyError not raisedsassertRaises() didn't fails0assertRaises() didn't let exception pass through(
RtKeyErrorRtassertIntargstfailt
ValueErrort	ExceptiontassertIst	exception(RRRtcm((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttest_assertRaises9sB	







cCs|jdd�y|jddd�WnD|jk
rm}|jd|jd�|jd|jd�nX|jd�dS(NsAla ma kotasr+sk.ttMessages'kot'is*assertNotRegexpMatches should have failed.(tassertNotRegexpMatchesRRRR(RR((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertNotRegexpMatchesbs(t__name__t
__module__R	RR"R%(((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyRs			)tTestLongMessagecBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(s�Test that the individual asserts honour longMessage.
    This actually tests all the message behaviour for
    asserts that use longMessage.cs`dtjf�fd��Y}dtjf�fd��Y}|d��_|d��_dS(NtTestableTestFalsecs eZeZ�jZd�ZRS(cSsdS(N((R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestTestws(R&R'tFalsetlongMessageRR*((R(s5/usr/lib64/python2.7/unittest/test/test_assertions.pyR)ss	tTestableTestTruecs eZeZ�jZd�ZRS(cSsdS(N((R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyR*~s(R&R'tTrueR,RR*((R(s5/usr/lib64/python2.7/unittest/test/test_assertions.pyR-zs	R*(tunittesttTestCasettestableTruet
testableFalse(RR)R-((Rs5/usr/lib64/python2.7/unittest/test/test_assertions.pytsetUprscCs|jtjj�dS(N(tassertFalseR/R0R,(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestDefault�scCs�|j|jjdd�d�|j|jjdd�d�|j|jjdd�d�|j|jjdd�d�|jjt�d�dS(Ntfootbars	bar : foo(tassertEqualR2t_formatMessageRR1tobject(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttest_formatMsg�s
cCs6djd�td�D��}|jj|d�dS(NRcss|]}t|�VqdS(N(tchr(t.0ti((s5/usr/lib64/python2.7/unittest/test/test_assertions.pys	<genexpr>�si�u�(tjointrangeR1R9(Rtone((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt test_formatMessage_unicode_error�sc
s���fd�}xxt|�D]j\}}||�}i}|d}	|	r]idd6}n�j�jd|��|||�WdQXqWdS(Ncs4|dk}|r�j}n	�j}t|��S(Ni(R2R1tgetattr(R>tuseTestableFalsettest(t
methodNameR(s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt	getMethod�s
	itoopstmsgtexpected_regexp(t	enumeratetassertRaisesRegexpR(
RRFRterrorsRGR>RJt
testMethodtkwargstwithMsg((RFRs5/usr/lib64/python2.7/unittest/test/test_assertions.pytassertMessages�s

cCs&|jdtfddddg�dS(Nt
assertTrues^False is not true$s^oops$s^False is not true : oops$(RQR+(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertTrue�s	cCs&|jdtfddddg�dS(NR4s^True is not false$s^oops$s^True is not false : oops$(RQR.(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertFalse�s	cCs#|jddddddg�dS(NtassertNotEqualis^1 == 1$s^oops$s^1 == 1 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestNotEqual�s	cCs#|jddddddg�dS(NRiis^1 != 2 within 7 places$s^oops$s^1 != 2 within 7 places : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAlmostEqual�scCs#|jddddddg�dS(NRis^1 == 1 within 7 places$s^oops$s^1 == 1 within 7 places : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestNotAlmostEqual�scCs#|jddddddg�dS(Nt_baseAssertEqualiis^1 != 2$s^oops$s^1 != 2 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttest_baseAssertEqual�scCs,|jdgdgfddddg�dS(NtassertSequenceEquals\+ \[None\]$s^oops$s\+ \[None\] : oops$(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertSequenceEqual�s	cCs5|jdt�tdg�fddddg�dS(NtassertSetEqualsNone$s^oops$sNone : oops$(RQtsetR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertSetEqual�s	cCs)|jddgfddddg�dS(NRs^None not found in \[\]$s^oops$s^None not found in \[\] : oops$(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertIn�scCs,|jdddgfddddg�dS(NtassertNotIns%^None unexpectedly found in \[None\]$s^oops$s,^None unexpectedly found in \[None\] : oops$(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertNotIn�scCs0|jdiidd6fddddg�dS(NtassertDictEqualtvalueRs\+ \{'key': 'value'\}$s^oops$s\+ \{'key': 'value'\} : oops$(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertDictEqual�scCs0|jdidd6ifddddg�dS(NtassertDictContainsSubsetRdRs^Missing: 'key'$s^oops$s^Missing: 'key' : oops$(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertDictContainsSubset�scCs#|jddddddg�dS(NtassertMultiLineEqualRR6s\+ foo$s^oops$s\+ foo : oops$(RR6(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertMultiLineEqual�scCs#|jddddddg�dS(Nt
assertLessiis^2 not less than 1$s^oops$s^2 not less than 1 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertLess�scCs#|jddddddg�dS(NtassertLessEqualiis^2 not less than or equal to 1$s^oops$s&^2 not less than or equal to 1 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertLessEqual�scCs#|jddddddg�dS(Nt
assertGreateriis^1 not greater than 2$s^oops$s^1 not greater than 2 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertGreater�scCs#|jddddddg�dS(NtassertGreaterEqualiis"^1 not greater than or equal to 2$s^oops$s)^1 not greater than or equal to 2 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertGreaterEqualscCs#|jddddddg�dS(NtassertIsNonesnot Nones^'not None' is not None$s^oops$s^'not None' is not None : oops$(snot None(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertIsNonescCs#|jddddddg�dS(NtassertIsNotNones^unexpectedly None$s^oops$s^unexpectedly None : oops$(N(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertIsNotNonescCs#|jddddddg�dS(NRR6s^None is not 'foo'$s^oops$s^None is not 'foo' : oops$(NR6(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertIsscCs#|jddddddg�dS(NtassertIsNots^unexpectedly identical: None$s^oops$s%^unexpectedly identical: None : oops$(NN(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertIsNots(R&R't__doc__R3R5R;RBRQRSRTRVRWRXRZR\R_R`RbReRgRiRkRmRoRqRsRuRvRx(((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyR(ms6			
																						t__main__(R
R/R0RR(R&tmain(((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt<module>s
g�PK��[ٙ7�L@L@test/test_setups.pynu�[���import sys

from cStringIO import StringIO

import unittest


def resultFactory(*_):
    return unittest.TestResult()


class TestSetups(unittest.TestCase):

    def getRunner(self):
        return unittest.TextTestRunner(resultclass=resultFactory,
                                          stream=StringIO())
    def runTests(self, *cases):
        suite = unittest.TestSuite()
        for case in cases:
            tests = unittest.defaultTestLoader.loadTestsFromTestCase(case)
            suite.addTests(tests)

        runner = self.getRunner()

        # creating a nested suite exposes some potential bugs
        realSuite = unittest.TestSuite()
        realSuite.addTest(suite)
        # adding empty suites to the end exposes potential bugs
        suite.addTest(unittest.TestSuite())
        realSuite.addTest(unittest.TestSuite())
        return runner.run(realSuite)

    def test_setup_class(self):
        class Test(unittest.TestCase):
            setUpCalled = 0
            @classmethod
            def setUpClass(cls):
                Test.setUpCalled += 1
                unittest.TestCase.setUpClass()
            def test_one(self):
                pass
            def test_two(self):
                pass

        result = self.runTests(Test)

        self.assertEqual(Test.setUpCalled, 1)
        self.assertEqual(result.testsRun, 2)
        self.assertEqual(len(result.errors), 0)

    def test_teardown_class(self):
        class Test(unittest.TestCase):
            tearDownCalled = 0
            @classmethod
            def tearDownClass(cls):
                Test.tearDownCalled += 1
                unittest.TestCase.tearDownClass()
            def test_one(self):
                pass
            def test_two(self):
                pass

        result = self.runTests(Test)

        self.assertEqual(Test.tearDownCalled, 1)
        self.assertEqual(result.testsRun, 2)
        self.assertEqual(len(result.errors), 0)

    def test_teardown_class_two_classes(self):
        class Test(unittest.TestCase):
            tearDownCalled = 0
            @classmethod
            def tearDownClass(cls):
                Test.tearDownCalled += 1
                unittest.TestCase.tearDownClass()
            def test_one(self):
                pass
            def test_two(self):
                pass

        class Test2(unittest.TestCase):
            tearDownCalled = 0
            @classmethod
            def tearDownClass(cls):
                Test2.tearDownCalled += 1
                unittest.TestCase.tearDownClass()
            def test_one(self):
                pass
            def test_two(self):
                pass

        result = self.runTests(Test, Test2)

        self.assertEqual(Test.tearDownCalled, 1)
        self.assertEqual(Test2.tearDownCalled, 1)
        self.assertEqual(result.testsRun, 4)
        self.assertEqual(len(result.errors), 0)

    def test_error_in_setupclass(self):
        class BrokenTest(unittest.TestCase):
            @classmethod
            def setUpClass(cls):
                raise TypeError('foo')
            def test_one(self):
                pass
            def test_two(self):
                pass

        result = self.runTests(BrokenTest)

        self.assertEqual(result.testsRun, 0)
        self.assertEqual(len(result.errors), 1)
        error, _ = result.errors[0]
        self.assertEqual(str(error),
                    'setUpClass (%s.BrokenTest)' % __name__)

    def test_error_in_teardown_class(self):
        class Test(unittest.TestCase):
            tornDown = 0
            @classmethod
            def tearDownClass(cls):
                Test.tornDown += 1
                raise TypeError('foo')
            def test_one(self):
                pass
            def test_two(self):
                pass

        class Test2(unittest.TestCase):
            tornDown = 0
            @classmethod
            def tearDownClass(cls):
                Test2.tornDown += 1
                raise TypeError('foo')
            def test_one(self):
                pass
            def test_two(self):
                pass

        result = self.runTests(Test, Test2)
        self.assertEqual(result.testsRun, 4)
        self.assertEqual(len(result.errors), 2)
        self.assertEqual(Test.tornDown, 1)
        self.assertEqual(Test2.tornDown, 1)

        error, _ = result.errors[0]
        self.assertEqual(str(error),
                    'tearDownClass (%s.Test)' % __name__)

    def test_class_not_torndown_when_setup_fails(self):
        class Test(unittest.TestCase):
            tornDown = False
            @classmethod
            def setUpClass(cls):
                raise TypeError
            @classmethod
            def tearDownClass(cls):
                Test.tornDown = True
                raise TypeError('foo')
            def test_one(self):
                pass

        self.runTests(Test)
        self.assertFalse(Test.tornDown)

    def test_class_not_setup_or_torndown_when_skipped(self):
        class Test(unittest.TestCase):
            classSetUp = False
            tornDown = False
            @classmethod
            def setUpClass(cls):
                Test.classSetUp = True
            @classmethod
            def tearDownClass(cls):
                Test.tornDown = True
            def test_one(self):
                pass

        Test = unittest.skip("hop")(Test)
        self.runTests(Test)
        self.assertFalse(Test.classSetUp)
        self.assertFalse(Test.tornDown)

    def test_setup_teardown_order_with_pathological_suite(self):
        results = []

        class Module1(object):
            @staticmethod
            def setUpModule():
                results.append('Module1.setUpModule')
            @staticmethod
            def tearDownModule():
                results.append('Module1.tearDownModule')

        class Module2(object):
            @staticmethod
            def setUpModule():
                results.append('Module2.setUpModule')
            @staticmethod
            def tearDownModule():
                results.append('Module2.tearDownModule')

        class Test1(unittest.TestCase):
            @classmethod
            def setUpClass(cls):
                results.append('setup 1')
            @classmethod
            def tearDownClass(cls):
                results.append('teardown 1')
            def testOne(self):
                results.append('Test1.testOne')
            def testTwo(self):
                results.append('Test1.testTwo')

        class Test2(unittest.TestCase):
            @classmethod
            def setUpClass(cls):
                results.append('setup 2')
            @classmethod
            def tearDownClass(cls):
                results.append('teardown 2')
            def testOne(self):
                results.append('Test2.testOne')
            def testTwo(self):
                results.append('Test2.testTwo')

        class Test3(unittest.TestCase):
            @classmethod
            def setUpClass(cls):
                results.append('setup 3')
            @classmethod
            def tearDownClass(cls):
                results.append('teardown 3')
            def testOne(self):
                results.append('Test3.testOne')
            def testTwo(self):
                results.append('Test3.testTwo')

        Test1.__module__ = Test2.__module__ = 'Module'
        Test3.__module__ = 'Module2'
        sys.modules['Module'] = Module1
        sys.modules['Module2'] = Module2

        first = unittest.TestSuite((Test1('testOne'),))
        second = unittest.TestSuite((Test1('testTwo'),))
        third = unittest.TestSuite((Test2('testOne'),))
        fourth = unittest.TestSuite((Test2('testTwo'),))
        fifth = unittest.TestSuite((Test3('testOne'),))
        sixth = unittest.TestSuite((Test3('testTwo'),))
        suite = unittest.TestSuite((first, second, third, fourth, fifth, sixth))

        runner = self.getRunner()
        result = runner.run(suite)
        self.assertEqual(result.testsRun, 6)
        self.assertEqual(len(result.errors), 0)

        self.assertEqual(results,
                         ['Module1.setUpModule', 'setup 1',
                          'Test1.testOne', 'Test1.testTwo', 'teardown 1',
                          'setup 2', 'Test2.testOne', 'Test2.testTwo',
                          'teardown 2', 'Module1.tearDownModule',
                          'Module2.setUpModule', 'setup 3',
                          'Test3.testOne', 'Test3.testTwo',
                          'teardown 3', 'Module2.tearDownModule'])

    def test_setup_module(self):
        class Module(object):
            moduleSetup = 0
            @staticmethod
            def setUpModule():
                Module.moduleSetup += 1

        class Test(unittest.TestCase):
            def test_one(self):
                pass
            def test_two(self):
                pass
        Test.__module__ = 'Module'
        sys.modules['Module'] = Module

        result = self.runTests(Test)
        self.assertEqual(Module.moduleSetup, 1)
        self.assertEqual(result.testsRun, 2)
        self.assertEqual(len(result.errors), 0)

    def test_error_in_setup_module(self):
        class Module(object):
            moduleSetup = 0
            moduleTornDown = 0
            @staticmethod
            def setUpModule():
                Module.moduleSetup += 1
                raise TypeError('foo')
            @staticmethod
            def tearDownModule():
                Module.moduleTornDown += 1

        class Test(unittest.TestCase):
            classSetUp = False
            classTornDown = False
            @classmethod
            def setUpClass(cls):
                Test.classSetUp = True
            @classmethod
            def tearDownClass(cls):
                Test.classTornDown = True
            def test_one(self):
                pass
            def test_two(self):
                pass

        class Test2(unittest.TestCase):
            def test_one(self):
                pass
            def test_two(self):
                pass
        Test.__module__ = 'Module'
        Test2.__module__ = 'Module'
        sys.modules['Module'] = Module

        result = self.runTests(Test, Test2)
        self.assertEqual(Module.moduleSetup, 1)
        self.assertEqual(Module.moduleTornDown, 0)
        self.assertEqual(result.testsRun, 0)
        self.assertFalse(Test.classSetUp)
        self.assertFalse(Test.classTornDown)
        self.assertEqual(len(result.errors), 1)
        error, _ = result.errors[0]
        self.assertEqual(str(error), 'setUpModule (Module)')

    def test_testcase_with_missing_module(self):
        class Test(unittest.TestCase):
            def test_one(self):
                pass
            def test_two(self):
                pass
        Test.__module__ = 'Module'
        sys.modules.pop('Module', None)

        result = self.runTests(Test)
        self.assertEqual(result.testsRun, 2)

    def test_teardown_module(self):
        class Module(object):
            moduleTornDown = 0
            @staticmethod
            def tearDownModule():
                Module.moduleTornDown += 1

        class Test(unittest.TestCase):
            def test_one(self):
                pass
            def test_two(self):
                pass
        Test.__module__ = 'Module'
        sys.modules['Module'] = Module

        result = self.runTests(Test)
        self.assertEqual(Module.moduleTornDown, 1)
        self.assertEqual(result.testsRun, 2)
        self.assertEqual(len(result.errors), 0)

    def test_error_in_teardown_module(self):
        class Module(object):
            moduleTornDown = 0
            @staticmethod
            def tearDownModule():
                Module.moduleTornDown += 1
                raise TypeError('foo')

        class Test(unittest.TestCase):
            classSetUp = False
            classTornDown = False
            @classmethod
            def setUpClass(cls):
                Test.classSetUp = True
            @classmethod
            def tearDownClass(cls):
                Test.classTornDown = True
            def test_one(self):
                pass
            def test_two(self):
                pass

        class Test2(unittest.TestCase):
            def test_one(self):
                pass
            def test_two(self):
                pass
        Test.__module__ = 'Module'
        Test2.__module__ = 'Module'
        sys.modules['Module'] = Module

        result = self.runTests(Test, Test2)
        self.assertEqual(Module.moduleTornDown, 1)
        self.assertEqual(result.testsRun, 4)
        self.assertTrue(Test.classSetUp)
        self.assertTrue(Test.classTornDown)
        self.assertEqual(len(result.errors), 1)
        error, _ = result.errors[0]
        self.assertEqual(str(error), 'tearDownModule (Module)')

    def test_skiptest_in_setupclass(self):
        class Test(unittest.TestCase):
            @classmethod
            def setUpClass(cls):
                raise unittest.SkipTest('foo')
            def test_one(self):
                pass
            def test_two(self):
                pass

        result = self.runTests(Test)
        self.assertEqual(result.testsRun, 0)
        self.assertEqual(len(result.errors), 0)
        self.assertEqual(len(result.skipped), 1)
        skipped = result.skipped[0][0]
        self.assertEqual(str(skipped), 'setUpClass (%s.Test)' % __name__)

    def test_skiptest_in_setupmodule(self):
        class Test(unittest.TestCase):
            def test_one(self):
                pass
            def test_two(self):
                pass

        class Module(object):
            @staticmethod
            def setUpModule():
                raise unittest.SkipTest('foo')

        Test.__module__ = 'Module'
        sys.modules['Module'] = Module

        result = self.runTests(Test)
        self.assertEqual(result.testsRun, 0)
        self.assertEqual(len(result.errors), 0)
        self.assertEqual(len(result.skipped), 1)
        skipped = result.skipped[0][0]
        self.assertEqual(str(skipped), 'setUpModule (Module)')

    def test_suite_debug_executes_setups_and_teardowns(self):
        ordering = []

        class Module(object):
            @staticmethod
            def setUpModule():
                ordering.append('setUpModule')
            @staticmethod
            def tearDownModule():
                ordering.append('tearDownModule')

        class Test(unittest.TestCase):
            @classmethod
            def setUpClass(cls):
                ordering.append('setUpClass')
            @classmethod
            def tearDownClass(cls):
                ordering.append('tearDownClass')
            def test_something(self):
                ordering.append('test_something')

        Test.__module__ = 'Module'
        sys.modules['Module'] = Module

        suite = unittest.defaultTestLoader.loadTestsFromTestCase(Test)
        suite.debug()
        expectedOrder = ['setUpModule', 'setUpClass', 'test_something', 'tearDownClass', 'tearDownModule']
        self.assertEqual(ordering, expectedOrder)

    def test_suite_debug_propagates_exceptions(self):
        class Module(object):
            @staticmethod
            def setUpModule():
                if phase == 0:
                    raise Exception('setUpModule')
            @staticmethod
            def tearDownModule():
                if phase == 1:
                    raise Exception('tearDownModule')

        class Test(unittest.TestCase):
            @classmethod
            def setUpClass(cls):
                if phase == 2:
                    raise Exception('setUpClass')
            @classmethod
            def tearDownClass(cls):
                if phase == 3:
                    raise Exception('tearDownClass')
            def test_something(self):
                if phase == 4:
                    raise Exception('test_something')

        Test.__module__ = 'Module'
        sys.modules['Module'] = Module

        _suite = unittest.defaultTestLoader.loadTestsFromTestCase(Test)
        suite = unittest.TestSuite()
        suite.addTest(_suite)

        messages = ('setUpModule', 'tearDownModule', 'setUpClass', 'tearDownClass', 'test_something')
        for phase, msg in enumerate(messages):
            with self.assertRaisesRegexp(Exception, msg):
                suite.debug()

if __name__ == '__main__':
    unittest.main()
PK��[Ij̟'�'test/test_break.pycnu�[����
{fc@s�ddlZddlZddlZddlZddlZddlmZddlZeje	ed�d�ej
ejdkd�ej
ejdkd�d	ejfd
��Y���Z
eje	ed�d�ej
ejdkd�ej
ejdkd�de
fd��Y���Zeje	ed�d�ej
ejdkd�ej
ejdkd�d
e
fd��Y���Zeje	ed�d�ej
ejdkd�ej
ejdkd�de
fd��Y���ZdS(i����N(tStringIOtkillsTest requires os.killtwin32sTest cannot run on Windowstfreebsd6s9Test kills regrtest on freebsd6 if threads have been usedt	TestBreakcBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�Zd
�ZRS(cCsAtjtj�|_|jdk	r=tjtj|j�ndS(N(tsignalt	getsignaltSIGINTt_default_handlertint_handlertNone(tself((s0/usr/lib64/python2.7/unittest/test/test_break.pytsetUpscCs8tjtj|j�tj�tj_dtj_	dS(N(
RRRtweakreftWeakKeyDictionarytunittesttsignalst_resultsR
t_interrupt_handler(R((s0/usr/lib64/python2.7/unittest/test/test_break.pyttearDownscCs�tjtj�}tj�|jtjtj�|�y#tj�}tj|tj�Wnt	k
r{|j
d�nX|jtjj
j�dS(NsKeyboardInterrupt not handled(RRRRtinstallHandlertassertNotEqualtostgetpidRtKeyboardInterrupttfailt
assertTrueRRtcalled(Rtdefault_handlertpid((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestInstallHandlers

cCsmtj�}tj|�xMtjjD]2}||kr<Pq&||k	r&|jd�q&q&W|jd�dS(Nsodd object in result setsresult not found(Rt
TestResulttregisterResultRRR(Rtresulttref((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestRegisterResult,s
cs�tjtj�}tj�}tj�tj|��jtjtj�|��fd�}y||�Wntk
r��j	d�nX�j
|j�dS(Ncs<tj�}tj|tj�t|_�j|j�dS(N(	RRRRRtTruetbreakCaughtRt
shouldStop(R!R(R(s0/usr/lib64/python2.7/unittest/test/test_break.pyttestBs	sKeyboardInterrupt not handled(RRRRRRR RRRRR%(RRR!R'((Rs0/usr/lib64/python2.7/unittest/test/test_break.pyttestInterruptCaught9s


cs�tjtj�tjkr+�jd�ntj�}tj�tj|��fd�}y||�Wnt	k
r~nX�j
d��j|j�dS(Ns&test requires SIGINT to not be ignoredcs\tj�}tj|tj�t|_�j|j�tj|tj��j	d�dS(Ns#Second KeyboardInterrupt not raised(
RRRRRR$R%RR&R(R!R(R(s0/usr/lib64/python2.7/unittest/test/test_break.pyR'Xs	s#Second KeyboardInterrupt not raised(
RRRtSIG_IGNtskipTestRRRR RRRR%(RR!R'((Rs0/usr/lib64/python2.7/unittest/test/test_break.pyttestSecondInterruptOs



cCs�tj�tj�}tj|�tjtj�}tj�}tj|�|jtjtj�|�tj�}d�}y||�Wntk
r�|j	d�nX|j
|j�|j
|j�|j|j�dS(NcSs#tj�}tj|tj�dS(N(RRRRR(R!R((s0/usr/lib64/python2.7/unittest/test/test_break.pyR'vssKeyboardInterrupt not handled(
RRRR RRRtassertEqualRRRR&tassertFalse(RR!tnew_handlertresult2tresult3R'((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestTwoResultsis 


	
cs�tjtj�tjkr+|jd�ntj�tjtj���fd�}tjtj|�y#tj�}tj	|tj�Wnt
k
r�nX|jd�dS(Ns&test requires SIGINT to not be ignoredcs�||�dS(N((tframetsignum(thandler(s0/usr/lib64/python2.7/unittest/test/test_break.pyR.�ss6replaced but delegated handler doesn't raise interrupt(RRRR)R*RRRRRRR(RR.R((R4s0/usr/lib64/python2.7/unittest/test/test_break.pyttestHandlerReplacedButCalled�s

cCsDtjdt��}|jtj��}|j|tjj�dS(Ntstream(RtTextTestRunnerRtrunt	TestSuitetassertInRR(RtrunnerR!((s0/usr/lib64/python2.7/unittest/test/test_break.pyt
testRunner�scCsStj�}tj|�tj|�}~tj�tj�|j|��dS(N(RRR R
R"tgctcollecttassertIsNone(RR!R"((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestWeakReferences�s


cCs�tj�}tj|�tj�|jtj|��|jtjtj���y#tj�}tj	|t
j�Wntk
r�nX|j|j
�dS(N(RRR RRtremoveResultR-RRRRRRR&(RR!R((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestRemoveResult�s


cs�t��t��t��t��tjtj�}dtf�fd��Y�dtjf����fd��Y}|t�}|j�|j�j	didd6�d6�d6fg�|j�j�g�|j|j��|jtjtj�|�g�_	g�_|t
�}|j�|j�j	d	idd6�d6�d6fg�|j�j�g�|j|j��|jtjtj�|�dS(
Nt
FakeRunnercs,eZgZgZd�Z�fd�ZRS(c_s|jj||f�dS(N(tinitArgstappend(Rtargstkwargs((s0/usr/lib64/python2.7/unittest/test/test_break.pyt__init__�scs|jj|��S(N(trunArgsRE(RR'(R!(s0/usr/lib64/python2.7/unittest/test/test_break.pyR8�s(t__name__t
__module__RDRIRHR8((R!(s0/usr/lib64/python2.7/unittest/test/test_break.pyRC�s	tProgramcs eZ����fd�ZRS(csCt|_�|_�|_||_�|_�|_d|_dS(N(	tFalsetexitt	verbositytfailfastt
catchbreakR<R'R
R!(RRQ(RCRPR'RO(s0/usr/lib64/python2.7/unittest/test/test_break.pyRH�s						(RJRKRH((RCRPR'RO(s0/usr/lib64/python2.7/unittest/test/test_break.pyRL�stbufferRORP(((tobjectRRRRtTestProgramRMtrunTestsR,RDR
RIR!R$R(RRRLtp((RCRPR!R'ROs0/usr/lib64/python2.7/unittest/test/test_break.pyttestMainInstallsHandler�s2					(

		
cCsltjtj�}tj�tj�|jtjtj�|�tj�|jtjtj�|�dS(N(RRRRRt
removeHandlerR,(RR((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestRemoveHandler�s


cs^tjtj��tj�tj��fd��}|��jtjtj���dS(Ncs �jtjtj���dS(N(R,RRR((RR(s0/usr/lib64/python2.7/unittest/test/test_break.pyR's(RRRRRRXR(RR'((RRs0/usr/lib64/python2.7/unittest/test/test_break.pyttestRemoveHandlerAsDecorator�s

N(RJRKR
R	RRRR#R(R+R1R5R<R@RBRWRYRZ(((s0/usr/lib64/python2.7/unittest/test/test_break.pyR
s			
	
						
		2	
tTestBreakDefaultIntHandlercBseZejZRS((RJRKRtdefault_int_handlerR	(((s0/usr/lib64/python2.7/unittest/test/test_break.pyR[	stTestBreakSignalIgnoredcBseZejZRS((RJRKRR)R	(((s0/usr/lib64/python2.7/unittest/test/test_break.pyR]stTestBreakSignalDefaultcBseZejZRS((RJRKRtSIG_DFLR	(((s0/usr/lib64/python2.7/unittest/test/test_break.pyR^s(R=RtsysRR
t	cStringIORRt
skipUnlessthasattrtskipIftplatformtTestCaseRR[R]R^(((s0/usr/lib64/python2.7/unittest/test/test_break.pyt<module>s,�PK��[��4}pptest/test_skipping.pynu�[���import unittest

from unittest.test.support import LoggingResult


class Test_TestSkipping(unittest.TestCase):

    def test_skipping(self):
        class Foo(unittest.TestCase):
            def test_skip_me(self):
                self.skipTest("skip")
        events = []
        result = LoggingResult(events)
        test = Foo("test_skip_me")
        test.run(result)
        self.assertEqual(events, ['startTest', 'addSkip', 'stopTest'])
        self.assertEqual(result.skipped, [(test, "skip")])

        # Try letting setUp skip the test now.
        class Foo(unittest.TestCase):
            def setUp(self):
                self.skipTest("testing")
            def test_nothing(self): pass
        events = []
        result = LoggingResult(events)
        test = Foo("test_nothing")
        test.run(result)
        self.assertEqual(events, ['startTest', 'addSkip', 'stopTest'])
        self.assertEqual(result.skipped, [(test, "testing")])
        self.assertEqual(result.testsRun, 1)

    def test_skipping_decorators(self):
        op_table = ((unittest.skipUnless, False, True),
                    (unittest.skipIf, True, False))
        for deco, do_skip, dont_skip in op_table:
            class Foo(unittest.TestCase):
                @deco(do_skip, "testing")
                def test_skip(self): pass

                @deco(dont_skip, "testing")
                def test_dont_skip(self): pass
            test_do_skip = Foo("test_skip")
            test_dont_skip = Foo("test_dont_skip")
            suite = unittest.TestSuite([test_do_skip, test_dont_skip])
            events = []
            result = LoggingResult(events)
            suite.run(result)
            self.assertEqual(len(result.skipped), 1)
            expected = ['startTest', 'addSkip', 'stopTest',
                        'startTest', 'addSuccess', 'stopTest']
            self.assertEqual(events, expected)
            self.assertEqual(result.testsRun, 2)
            self.assertEqual(result.skipped, [(test_do_skip, "testing")])
            self.assertTrue(result.wasSuccessful())

    def test_skip_class(self):
        @unittest.skip("testing")
        class Foo(unittest.TestCase):
            def test_1(self):
                record.append(1)
        record = []
        result = unittest.TestResult()
        test = Foo("test_1")
        suite = unittest.TestSuite([test])
        suite.run(result)
        self.assertEqual(result.skipped, [(test, "testing")])
        self.assertEqual(record, [])

    def test_skip_non_unittest_class_old_style(self):
        @unittest.skip("testing")
        class Mixin:
            def test_1(self):
                record.append(1)
        class Foo(Mixin, unittest.TestCase):
            pass
        record = []
        result = unittest.TestResult()
        test = Foo("test_1")
        suite = unittest.TestSuite([test])
        suite.run(result)
        self.assertEqual(result.skipped, [(test, "testing")])
        self.assertEqual(record, [])

    def test_skip_non_unittest_class_new_style(self):
        @unittest.skip("testing")
        class Mixin(object):
            def test_1(self):
                record.append(1)
        class Foo(Mixin, unittest.TestCase):
            pass
        record = []
        result = unittest.TestResult()
        test = Foo("test_1")
        suite = unittest.TestSuite([test])
        suite.run(result)
        self.assertEqual(result.skipped, [(test, "testing")])
        self.assertEqual(record, [])

    def test_expected_failure(self):
        class Foo(unittest.TestCase):
            @unittest.expectedFailure
            def test_die(self):
                self.fail("help me!")
        events = []
        result = LoggingResult(events)
        test = Foo("test_die")
        test.run(result)
        self.assertEqual(events,
                         ['startTest', 'addExpectedFailure', 'stopTest'])
        self.assertEqual(result.expectedFailures[0][0], test)
        self.assertTrue(result.wasSuccessful())

    def test_unexpected_success(self):
        class Foo(unittest.TestCase):
            @unittest.expectedFailure
            def test_die(self):
                pass
        events = []
        result = LoggingResult(events)
        test = Foo("test_die")
        test.run(result)
        self.assertEqual(events,
                         ['startTest', 'addUnexpectedSuccess', 'stopTest'])
        self.assertFalse(result.failures)
        self.assertEqual(result.unexpectedSuccesses, [test])
        self.assertTrue(result.wasSuccessful())

    def test_skip_doesnt_run_setup(self):
        class Foo(unittest.TestCase):
            wasSetUp = False
            wasTornDown = False
            def setUp(self):
                Foo.wasSetUp = True
            def tornDown(self):
                Foo.wasTornDown = True
            @unittest.skip('testing')
            def test_1(self):
                pass

        result = unittest.TestResult()
        test = Foo("test_1")
        suite = unittest.TestSuite([test])
        suite.run(result)
        self.assertEqual(result.skipped, [(test, "testing")])
        self.assertFalse(Foo.wasSetUp)
        self.assertFalse(Foo.wasTornDown)

    def test_decorated_skip(self):
        def decorator(func):
            def inner(*a):
                return func(*a)
            return inner

        class Foo(unittest.TestCase):
            @decorator
            @unittest.skip('testing')
            def test_1(self):
                pass

        result = unittest.TestResult()
        test = Foo("test_1")
        suite = unittest.TestSuite([test])
        suite.run(result)
        self.assertEqual(result.skipped, [(test, "testing")])


if __name__ == '__main__':
    unittest.main()
PK��[�22
test/dummy.pynu�[���# Empty module for testing the loading of modules
PK��[��Yo��test/test_functiontestcase.pynu�[���import unittest

from unittest.test.support import LoggingResult


class Test_FunctionTestCase(unittest.TestCase):

    # "Return the number of tests represented by the this test object. For
    # TestCase instances, this will always be 1"
    def test_countTestCases(self):
        test = unittest.FunctionTestCase(lambda: None)

        self.assertEqual(test.countTestCases(), 1)

    # "When a setUp() method is defined, the test runner will run that method
    # prior to each test. Likewise, if a tearDown() method is defined, the
    # test runner will invoke that method after each test. In the example,
    # setUp() was used to create a fresh sequence for each test."
    #
    # Make sure the proper call order is maintained, even if setUp() raises
    # an exception.
    def test_run_call_order__error_in_setUp(self):
        events = []
        result = LoggingResult(events)

        def setUp():
            events.append('setUp')
            raise RuntimeError('raised by setUp')

        def test():
            events.append('test')

        def tearDown():
            events.append('tearDown')

        expected = ['startTest', 'setUp', 'addError', 'stopTest']
        unittest.FunctionTestCase(test, setUp, tearDown).run(result)
        self.assertEqual(events, expected)

    # "When a setUp() method is defined, the test runner will run that method
    # prior to each test. Likewise, if a tearDown() method is defined, the
    # test runner will invoke that method after each test. In the example,
    # setUp() was used to create a fresh sequence for each test."
    #
    # Make sure the proper call order is maintained, even if the test raises
    # an error (as opposed to a failure).
    def test_run_call_order__error_in_test(self):
        events = []
        result = LoggingResult(events)

        def setUp():
            events.append('setUp')

        def test():
            events.append('test')
            raise RuntimeError('raised by test')

        def tearDown():
            events.append('tearDown')

        expected = ['startTest', 'setUp', 'test', 'addError', 'tearDown',
                    'stopTest']
        unittest.FunctionTestCase(test, setUp, tearDown).run(result)
        self.assertEqual(events, expected)

    # "When a setUp() method is defined, the test runner will run that method
    # prior to each test. Likewise, if a tearDown() method is defined, the
    # test runner will invoke that method after each test. In the example,
    # setUp() was used to create a fresh sequence for each test."
    #
    # Make sure the proper call order is maintained, even if the test signals
    # a failure (as opposed to an error).
    def test_run_call_order__failure_in_test(self):
        events = []
        result = LoggingResult(events)

        def setUp():
            events.append('setUp')

        def test():
            events.append('test')
            self.fail('raised by test')

        def tearDown():
            events.append('tearDown')

        expected = ['startTest', 'setUp', 'test', 'addFailure', 'tearDown',
                    'stopTest']
        unittest.FunctionTestCase(test, setUp, tearDown).run(result)
        self.assertEqual(events, expected)

    # "When a setUp() method is defined, the test runner will run that method
    # prior to each test. Likewise, if a tearDown() method is defined, the
    # test runner will invoke that method after each test. In the example,
    # setUp() was used to create a fresh sequence for each test."
    #
    # Make sure the proper call order is maintained, even if tearDown() raises
    # an exception.
    def test_run_call_order__error_in_tearDown(self):
        events = []
        result = LoggingResult(events)

        def setUp():
            events.append('setUp')

        def test():
            events.append('test')

        def tearDown():
            events.append('tearDown')
            raise RuntimeError('raised by tearDown')

        expected = ['startTest', 'setUp', 'test', 'tearDown', 'addError',
                    'stopTest']
        unittest.FunctionTestCase(test, setUp, tearDown).run(result)
        self.assertEqual(events, expected)

    # "Return a string identifying the specific test case."
    #
    # Because of the vague nature of the docs, I'm not going to lock this
    # test down too much. Really all that can be asserted is that the id()
    # will be a string (either 8-byte or unicode -- again, because the docs
    # just say "string")
    def test_id(self):
        test = unittest.FunctionTestCase(lambda: None)

        self.assertIsInstance(test.id(), basestring)

    # "Returns a one-line description of the test, or None if no description
    # has been provided. The default implementation of this method returns
    # the first line of the test method's docstring, if available, or None."
    def test_shortDescription__no_docstring(self):
        test = unittest.FunctionTestCase(lambda: None)

        self.assertEqual(test.shortDescription(), None)

    # "Returns a one-line description of the test, or None if no description
    # has been provided. The default implementation of this method returns
    # the first line of the test method's docstring, if available, or None."
    def test_shortDescription__singleline_docstring(self):
        desc = "this tests foo"
        test = unittest.FunctionTestCase(lambda: None, description=desc)

        self.assertEqual(test.shortDescription(), "this tests foo")


if __name__ == '__main__':
    unittest.main()
PK��[aDϗS�Stest/test_result.pyonu�[����
|fc@s>ddlZddlZddlmZddlmZddlZddlZdejfd��YZe	ej
j�Zx!dddd	fD]
Z
ee
=q�Weeed
�Zeed	<edefe�Zdejfd
��YZdefd��YZd�Zdejfd��YZedkr:ej�ndS(i����N(tStringIO(ttest_supporttTest_TestResultcBs�eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
eje
jjd	kd
�d��Zeje
jjd	kd
�d��Zd
�Zd�Zd�ZRS(cCs�tj�}|j|j��|jt|j�d�|jt|j�d�|j|jd�|j|j	t
�|j|j�|j|j
�dS(Ni(tunittestt
TestResultt
assertTruet
wasSuccessfultassertEqualtlenterrorstfailuresttestsRunt
shouldStoptFalsetassertIsNonet_stdout_buffert_stderr_buffer(tselftresult((s1/usr/lib64/python2.7/unittest/test/test_result.pyt	test_initscCs-tj�}|j�|j|jt�dS(N(RRtstopRRtTrue(RR((s1/usr/lib64/python2.7/unittest/test/test_result.pyt	test_stop#s
cCs�dtjfd��Y}|d�}tj�}|j|�|j|j��|jt|j�d�|jt|j	�d�|j|j
d�|j|jt�|j
|�dS(NtFoocBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttest_1.s(t__name__t
__module__R(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR-sRii(RtTestCaseRt	startTestRRRRR	R
RRR
tstopTest(RRttestR((s1/usr/lib64/python2.7/unittest/test/test_result.pyttest_startTest,s
cCs%dtjfd��Y}|d�}tj�}|j|�|j|j��|jt|j�d�|jt|j	�d�|j|j
d�|j|jt�|j
|�|j|j��|jt|j�d�|jt|j	�d�|j|j
d�|j|jt�dS(NRcBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyRCs(RRR(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRBsRii(RRRRRRRRR	R
RRR
R(RRRR((s1/usr/lib64/python2.7/unittest/test/test_result.pyt
test_stopTestAs

cCs$tj�}|j�|j�dS(N(RRtstartTestRuntstopTestRun(RR((s1/usr/lib64/python2.7/unittest/test/test_result.pyttest_startTestRun_stopTestRun\s
cCs�dtjfd��Y}|d�}tj�}|j|�|j|�|j|�|j|j��|jt	|j
�d�|jt	|j�d�|j|jd�|j|j
t�dS(NRcBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyRvs(RRR(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRusRii(RRRRt
addSuccessRRRRRR	R
RRR
(RRRR((s1/usr/lib64/python2.7/unittest/test/test_result.pyttest_addSuccessts


cCs$dtjfd��Y}|d�}y|jd�Wntj�}nXtj�}|j|�|j||�|j|�|j	|j
��|jt|j
�d�|jt|j�d�|j|jd�|j|jt�|jd\}}|j||�|j|t�dS(NRcBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyR�s(RRR(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR�sRtfooii(RRtfailtsystexc_infoRRt
addFailureRtassertFalseRRRR	R
RRR
tassertIstassertIsInstancetstr(RRRtexc_info_tupleRt	test_caset
formatted_exc((s1/usr/lib64/python2.7/unittest/test/test_result.pyttest_addFailure�s$

cCs dtjfd��Y}|d�}y
t��Wntj�}nXtj�}|j|�|j||�|j|�|j	|j
��|jt|j
�d�|jt|j�d�|j|jd�|j|jt�|j
d\}}|j||�|j|t�dS(NRcBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyR�s(RRR(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR�sRii(RRt	TypeErrorR(R)RRtaddErrorRR+RRRR	R
RRR
R,R-R.(RRRR/RR0R1((s1/usr/lib64/python2.7/unittest/test/test_result.pyt
test_addError�s$


cCs:tjdtd�}|j|j|�dtd�dS(Nis$testGetDescriptionWithoutDocstring (s.Test_TestResult)(RtTextTestResulttNoneRRtgetDescriptionR(RR((s1/usr/lib64/python2.7/unittest/test/test_result.pyt"testGetDescriptionWithoutDocstring�s
is)Docstrings are omitted with -O2 and abovecCs:tjdtd�}|j|j|�dtd�dS(s5Tests getDescription() for a method with a docstring.is(testGetDescriptionWithOneLineDocstring (sG.Test_TestResult)
Tests getDescription() for a method with a docstring.N(RR6R7RRR8R(RR((s1/usr/lib64/python2.7/unittest/test/test_result.pyt&testGetDescriptionWithOneLineDocstring�scCs:tjdtd�}|j|j|�dtd�dS(soTests getDescription() for a method with a longer docstring.
        The second line of the docstring.
        is*testGetDescriptionWithMultiLineDocstring (sN.Test_TestResult)
Tests getDescription() for a method with a longer docstring.N(RR6R7RRR8R(RR((s1/usr/lib64/python2.7/unittest/test/test_result.pyt(testGetDescriptionWithMultiLineDocstring�scCsbdtfd��Y}tj�}|j|j|��t|jjd<|j|j|��dS(NtFramecBseZdefd��YZRS(ttb_framecBseZiZRS((RRt	f_globals(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR=s(RRtobjectR=(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR<st
__unittest(	R?RRR+t_is_relevant_tb_levelRR=R>R(RR<R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestStackFrameTrimmings
cCs�tj�}d�|_t|_|jdd�|j|j�tj�}d�|_t|_|j	dd�|j|j�tj�}d�|_t|_|j
d�|j|j�dS(NcWsdS(Nt((t_((s1/usr/lib64/python2.7/unittest/test/test_result.pyt<lambda>RCcWsdS(NRC((RD((s1/usr/lib64/python2.7/unittest/test/test_result.pyRERCcWsdS(NRC((RD((s1/usr/lib64/python2.7/unittest/test/test_result.pyRERC(RRt_exc_info_to_stringRtfailfastR4R7RRR*taddUnexpectedSuccess(RR((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestFailFasts			
cs;tjdt�dt�}�fd�}|j|�dS(NtstreamRGcs�j|j�dS(N(RRG(R(R(s1/usr/lib64/python2.7/unittest/test/test_result.pyR%s(RtTextTestRunnerRRtrun(RtrunnerR((Rs1/usr/lib64/python2.7/unittest/test/test_result.pyttestFailFastSetByRunner#s(RRRRRR R#R%R2R5R9RtskipIfR(tflagstoptimizeR:R;RBRIRN(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR
s 
							'	0		

	
	taddSkiptaddExpectedFailureRHt__init__cCs1g|_g|_d|_t|_t|_dS(Ni(R
R	RR
Rtbuffer(RRJtdescriptionst	verbosity((s1/usr/lib64/python2.7/unittest/test/test_result.pyRT/s
				t	OldResulttTest_OldTestResultcBs5eZd�Zd�Zd�Zd�Zd�ZRS(cCsOtjdtf��4t�}|j|�|jt|j�|�WdQXdS(NsTestResult has no add.+ method,(Rtcheck_warningstRuntimeWarningRXRLRRR
(RRR
R((s1/usr/lib64/python2.7/unittest/test/test_result.pytassertOldResultWarning;s
	
	
cCsrdtjfd��Y}xRdtfdtfdtffD]/\}}||�}|j|t|��q;WdS(NtTestcBs5eZd�Zejd��Zejd��ZRS(cSs|jd�dS(Ntfoobar(tskipTest(R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestSkipDscSs
t�dS(N(R3(R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestExpectedFailFscSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestUnexpectedSuccessIs(RRR`RtexpectedFailureRaRb(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR]Cs	R`RaRb(RRRR
R\tint(RR]t	test_nametshould_passR((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestOldTestResultBs
	cCs3dtjfd��Y}|j|d�d�dS(NR]cBseZd�Zd�ZRS(cSs|jd�dS(Ns	no reason(R_(R((s1/usr/lib64/python2.7/unittest/test/test_result.pytsetUpUscSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestFooWs(RRRhRi(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR]Ts	Rii(RRR\(RR]((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestOldTestTesultSetupSscCsBtjd�dtjfd��Y�}|j|d�d�dS(Ns	no reasonR]cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyRi^s(RRRi(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR]\sRii(RtskipRR\(RR]((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestOldTestResultClass[scCsKdtjfd��Y}tjdtdt��}|j|d��dS(NR]cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyRids(RRRi(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR]cstresultclassRJRi(RRRKRXRRL(RR]RM((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestOldResultWithRunnerbs(RRR\RgRjRlRn(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRY9s
				t
MockTracebackcBseZed��ZRS(cGsdgS(NsA traceback((RD((s1/usr/lib64/python2.7/unittest/test/test_result.pytformat_exceptionns(RRtstaticmethodRp(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRomscCsttj_dS(N(t	tracebackRR(((s1/usr/lib64/python2.7/unittest/test/test_result.pytrestore_tracebackrstTestOutputBufferingcBsbeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�ZRS(
cCstj|_tj|_dS(N(R(tstdoutt	_real_outtstderrt	_real_err(R((s1/usr/lib64/python2.7/unittest/test/test_result.pyRhxscCs|jt_|jt_dS(N(RvR(RuRxRw(R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttearDown|scCs�|j}|j}tj�}|j|j�|j|tj�|j|tj	�|j
|�|j|tj�|j|tj	�dS(N(RvRxRRR+RUR,R(RuRwR(Rtreal_outtreal_errR((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestBufferOutputOff�s		
cCs|j}|j}tj�}|j|j�t|_|j|tj	�|j|tj
�|j|�|j|tj	�|j|tj
�|j
tj	t�|j
tj
t�|jtj	tj
�tj	}tj
}t�|_t�|_dGHtj
dIJ|j|j�d�|j|j�d�|j|jj�d�|j|jj�d�|j|�|j|�|jtj	|j�|jtj
|j�|j|jj�d�|j|jj�d�|j|j�d�|j|j�d�dS(NR&tbarsfoo
sbar
RC(RvRxRRR+RURR,R(RuRwRtassertIsNotR-Rt_original_stdoutt_original_stderrRtgetvalueR$R(RRzR{Rt
out_streamt
err_stream((s1/usr/lib64/python2.7/unittest/test/test_result.pyt#testBufferOutputStartTestAddSuccess�s>			
		


cCs&tj�}t|_|j|�|S(N(RRRRUR(RR((s1/usr/lib64/python2.7/unittest/test/test_result.pytgetStartedResult�s	
cCs�ttj_|jt�x�ddtfddtfddtfddtfgD]U\}}}|j�}t	j
}t	j}t�|_
t�|_t	j
dIJ|r�t	jdIJnt||�}||d
�|j|�t||�}|jt|�d�|d\}	}
tjd	�}d
}|rCtjd�}nd||f}
|j|	|�|j|j
j�|�|j|jj�|�|j|
|
�qPWdS(NR	R4R
R*R&R}iis9
                Stdout:
                foo
            RCs9
                Stderr:
                bar
            sA traceback%s%s(NNN(RoRRRrt
addCleanupRsRR
R�R(RuRwRRR�tgetattrR7RRRttextwraptdedentR,R�tassertMultiLineEqual(Rtmessage_attrtadd_attrt
include_errorRtbuffered_outtbuffered_errtaddFunctiontresult_listRtmessagetexpectedOutMessagetexpectedErrMessagetexpectedFullMessage((s1/usr/lib64/python2.7/unittest/test/test_result.pyt!testBufferOutputAddErrorOrFailure�s@
		


	cCsmtj�}t|_dtjfd��Y}tj|d�g�}||�|jt|j�d�dS(NRcBs eZed��Zd�ZRS(cSsdddS(Nii((tcls((s1/usr/lib64/python2.7/unittest/test/test_result.pyt
setUpClass�scSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttest_foo�s(RRtclassmethodR�R�(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR�sR�i(	RRRRURt	TestSuiteRRR	(RRRtsuite((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestBufferSetupClass�s	
cCsmtj�}t|_dtjfd��Y}tj|d�g�}||�|jt|j�d�dS(NRcBs eZed��Zd�ZRS(cSsdddS(Nii((R�((s1/usr/lib64/python2.7/unittest/test/test_result.pyt
tearDownClassscSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyR�	s(RRR�R�R�(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRsR�i(	RRRRURR�RRR	(RRRR�((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestBufferTearDownClasss	
cCs�tj�}t|_dtjfd��Y}dtfd��Y}d|_|tjd<|j	tjj
d�tj|d�g�}||�|jt
|j�d�dS(NRcBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyR�s(RRR�(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRstModulecBseZed��ZRS(cSsdddS(Nii((((s1/usr/lib64/python2.7/unittest/test/test_result.pytsetUpModules(RRRqR�(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR�sR�i(RRRRURR?RR(tmodulesR�tpopR�RRR	(RRRR�R�((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestBufferSetUpModules		

cCs�tj�}t|_dtjfd��Y}dtfd��Y}d|_|tjd<|j	tjj
d�tj|d�g�}||�|jt
|j�d�dS(NRcBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyR�'s(RRR�(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR&sR�cBseZed��ZRS(cSsdddS(Nii((((s1/usr/lib64/python2.7/unittest/test/test_result.pyttearDownModule*s(RRRqR�(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR�)sR�i(RRRRURR?RR(R�R�R�R�RRR	(RRRR�R�((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestBufferTearDownModule"s		

(RRRhRyR|R�R�R�R�R�R�R�(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRtvs				0		.			t__main__(R(R�RRRRrRRRtdictRt__dict__t	classDicttmR7RTttypeR?RXRYRoRsRtRtmain(((s1/usr/lib64/python2.7/unittest/test/test_result.pyt<module>s(�!

4	�PK��[M;E,2/2/test/test_suite.pynu�[���import unittest

import sys
from unittest.test.support import LoggingResult, TestEquality


### Support code for Test_TestSuite
################################################################

class Test(object):
    class Foo(unittest.TestCase):
        def test_1(self): pass
        def test_2(self): pass
        def test_3(self): pass
        def runTest(self): pass

def _mk_TestSuite(*names):
    return unittest.TestSuite(Test.Foo(n) for n in names)

################################################################


class Test_TestSuite(unittest.TestCase, TestEquality):

    ### Set up attributes needed by inherited tests
    ################################################################

    # Used by TestEquality.test_eq
    eq_pairs = [(unittest.TestSuite(), unittest.TestSuite()),
                (unittest.TestSuite(), unittest.TestSuite([])),
               (_mk_TestSuite('test_1'), _mk_TestSuite('test_1'))]

    # Used by TestEquality.test_ne
    ne_pairs = [(unittest.TestSuite(), _mk_TestSuite('test_1')),
                (unittest.TestSuite([]), _mk_TestSuite('test_1')),
                (_mk_TestSuite('test_1', 'test_2'), _mk_TestSuite('test_1', 'test_3')),
                (_mk_TestSuite('test_1'), _mk_TestSuite('test_2'))]

    ################################################################
    ### /Set up attributes needed by inherited tests

    ### Tests for TestSuite.__init__
    ################################################################

    # "class TestSuite([tests])"
    #
    # The tests iterable should be optional
    def test_init__tests_optional(self):
        suite = unittest.TestSuite()

        self.assertEqual(suite.countTestCases(), 0)

    # "class TestSuite([tests])"
    # ...
    # "If tests is given, it must be an iterable of individual test cases
    # or other test suites that will be used to build the suite initially"
    #
    # TestSuite should deal with empty tests iterables by allowing the
    # creation of an empty suite
    def test_init__empty_tests(self):
        suite = unittest.TestSuite([])

        self.assertEqual(suite.countTestCases(), 0)

    # "class TestSuite([tests])"
    # ...
    # "If tests is given, it must be an iterable of individual test cases
    # or other test suites that will be used to build the suite initially"
    #
    # TestSuite should allow any iterable to provide tests
    def test_init__tests_from_any_iterable(self):
        def tests():
            yield unittest.FunctionTestCase(lambda: None)
            yield unittest.FunctionTestCase(lambda: None)

        suite_1 = unittest.TestSuite(tests())
        self.assertEqual(suite_1.countTestCases(), 2)

        suite_2 = unittest.TestSuite(suite_1)
        self.assertEqual(suite_2.countTestCases(), 2)

        suite_3 = unittest.TestSuite(set(suite_1))
        self.assertEqual(suite_3.countTestCases(), 2)

    # "class TestSuite([tests])"
    # ...
    # "If tests is given, it must be an iterable of individual test cases
    # or other test suites that will be used to build the suite initially"
    #
    # Does TestSuite() also allow other TestSuite() instances to be present
    # in the tests iterable?
    def test_init__TestSuite_instances_in_tests(self):
        def tests():
            ftc = unittest.FunctionTestCase(lambda: None)
            yield unittest.TestSuite([ftc])
            yield unittest.FunctionTestCase(lambda: None)

        suite = unittest.TestSuite(tests())
        self.assertEqual(suite.countTestCases(), 2)

    ################################################################
    ### /Tests for TestSuite.__init__

    # Container types should support the iter protocol
    def test_iter(self):
        test1 = unittest.FunctionTestCase(lambda: None)
        test2 = unittest.FunctionTestCase(lambda: None)
        suite = unittest.TestSuite((test1, test2))

        self.assertEqual(list(suite), [test1, test2])

    # "Return the number of tests represented by the this test object.
    # ...this method is also implemented by the TestSuite class, which can
    # return larger [greater than 1] values"
    #
    # Presumably an empty TestSuite returns 0?
    def test_countTestCases_zero_simple(self):
        suite = unittest.TestSuite()

        self.assertEqual(suite.countTestCases(), 0)

    # "Return the number of tests represented by the this test object.
    # ...this method is also implemented by the TestSuite class, which can
    # return larger [greater than 1] values"
    #
    # Presumably an empty TestSuite (even if it contains other empty
    # TestSuite instances) returns 0?
    def test_countTestCases_zero_nested(self):
        class Test1(unittest.TestCase):
            def test(self):
                pass

        suite = unittest.TestSuite([unittest.TestSuite()])

        self.assertEqual(suite.countTestCases(), 0)

    # "Return the number of tests represented by the this test object.
    # ...this method is also implemented by the TestSuite class, which can
    # return larger [greater than 1] values"
    def test_countTestCases_simple(self):
        test1 = unittest.FunctionTestCase(lambda: None)
        test2 = unittest.FunctionTestCase(lambda: None)
        suite = unittest.TestSuite((test1, test2))

        self.assertEqual(suite.countTestCases(), 2)

    # "Return the number of tests represented by the this test object.
    # ...this method is also implemented by the TestSuite class, which can
    # return larger [greater than 1] values"
    #
    # Make sure this holds for nested TestSuite instances, too
    def test_countTestCases_nested(self):
        class Test1(unittest.TestCase):
            def test1(self): pass
            def test2(self): pass

        test2 = unittest.FunctionTestCase(lambda: None)
        test3 = unittest.FunctionTestCase(lambda: None)
        child = unittest.TestSuite((Test1('test2'), test2))
        parent = unittest.TestSuite((test3, child, Test1('test1')))

        self.assertEqual(parent.countTestCases(), 4)

    # "Run the tests associated with this suite, collecting the result into
    # the test result object passed as result."
    #
    # And if there are no tests? What then?
    def test_run__empty_suite(self):
        events = []
        result = LoggingResult(events)

        suite = unittest.TestSuite()

        suite.run(result)

        self.assertEqual(events, [])

    # "Note that unlike TestCase.run(), TestSuite.run() requires the
    # "result object to be passed in."
    def test_run__requires_result(self):
        suite = unittest.TestSuite()

        try:
            suite.run()
        except TypeError:
            pass
        else:
            self.fail("Failed to raise TypeError")

    # "Run the tests associated with this suite, collecting the result into
    # the test result object passed as result."
    def test_run(self):
        events = []
        result = LoggingResult(events)

        class LoggingCase(unittest.TestCase):
            def run(self, result):
                events.append('run %s' % self._testMethodName)

            def test1(self): pass
            def test2(self): pass

        tests = [LoggingCase('test1'), LoggingCase('test2')]

        unittest.TestSuite(tests).run(result)

        self.assertEqual(events, ['run test1', 'run test2'])

    # "Add a TestCase ... to the suite"
    def test_addTest__TestCase(self):
        class Foo(unittest.TestCase):
            def test(self): pass

        test = Foo('test')
        suite = unittest.TestSuite()

        suite.addTest(test)

        self.assertEqual(suite.countTestCases(), 1)
        self.assertEqual(list(suite), [test])

    # "Add a ... TestSuite to the suite"
    def test_addTest__TestSuite(self):
        class Foo(unittest.TestCase):
            def test(self): pass

        suite_2 = unittest.TestSuite([Foo('test')])

        suite = unittest.TestSuite()
        suite.addTest(suite_2)

        self.assertEqual(suite.countTestCases(), 1)
        self.assertEqual(list(suite), [suite_2])

    # "Add all the tests from an iterable of TestCase and TestSuite
    # instances to this test suite."
    #
    # "This is equivalent to iterating over tests, calling addTest() for
    # each element"
    def test_addTests(self):
        class Foo(unittest.TestCase):
            def test_1(self): pass
            def test_2(self): pass

        test_1 = Foo('test_1')
        test_2 = Foo('test_2')
        inner_suite = unittest.TestSuite([test_2])

        def gen():
            yield test_1
            yield test_2
            yield inner_suite

        suite_1 = unittest.TestSuite()
        suite_1.addTests(gen())

        self.assertEqual(list(suite_1), list(gen()))

        # "This is equivalent to iterating over tests, calling addTest() for
        # each element"
        suite_2 = unittest.TestSuite()
        for t in gen():
            suite_2.addTest(t)

        self.assertEqual(suite_1, suite_2)

    # "Add all the tests from an iterable of TestCase and TestSuite
    # instances to this test suite."
    #
    # What happens if it doesn't get an iterable?
    def test_addTest__noniterable(self):
        suite = unittest.TestSuite()

        try:
            suite.addTests(5)
        except TypeError:
            pass
        else:
            self.fail("Failed to raise TypeError")

    def test_addTest__noncallable(self):
        suite = unittest.TestSuite()
        self.assertRaises(TypeError, suite.addTest, 5)

    def test_addTest__casesuiteclass(self):
        suite = unittest.TestSuite()
        self.assertRaises(TypeError, suite.addTest, Test_TestSuite)
        self.assertRaises(TypeError, suite.addTest, unittest.TestSuite)

    def test_addTests__string(self):
        suite = unittest.TestSuite()
        self.assertRaises(TypeError, suite.addTests, "foo")

    def test_function_in_suite(self):
        def f(_):
            pass
        suite = unittest.TestSuite()
        suite.addTest(f)

        # when the bug is fixed this line will not crash
        suite.run(unittest.TestResult())



    def test_basetestsuite(self):
        class Test(unittest.TestCase):
            wasSetUp = False
            wasTornDown = False
            @classmethod
            def setUpClass(cls):
                cls.wasSetUp = True
            @classmethod
            def tearDownClass(cls):
                cls.wasTornDown = True
            def testPass(self):
                pass
            def testFail(self):
                fail
        class Module(object):
            wasSetUp = False
            wasTornDown = False
            @staticmethod
            def setUpModule():
                Module.wasSetUp = True
            @staticmethod
            def tearDownModule():
                Module.wasTornDown = True

        Test.__module__ = 'Module'
        sys.modules['Module'] = Module
        self.addCleanup(sys.modules.pop, 'Module')

        suite = unittest.BaseTestSuite()
        suite.addTests([Test('testPass'), Test('testFail')])
        self.assertEqual(suite.countTestCases(), 2)

        result = unittest.TestResult()
        suite.run(result)
        self.assertFalse(Module.wasSetUp)
        self.assertFalse(Module.wasTornDown)
        self.assertFalse(Test.wasSetUp)
        self.assertFalse(Test.wasTornDown)
        self.assertEqual(len(result.errors), 1)
        self.assertEqual(len(result.failures), 0)
        self.assertEqual(result.testsRun, 2)


    def test_overriding_call(self):
        class MySuite(unittest.TestSuite):
            called = False
            def __call__(self, *args, **kw):
                self.called = True
                unittest.TestSuite.__call__(self, *args, **kw)

        suite = MySuite()
        result = unittest.TestResult()
        wrapper = unittest.TestSuite()
        wrapper.addTest(suite)
        wrapper(result)
        self.assertTrue(suite.called)

        # reusing results should be permitted even if abominable
        self.assertFalse(result._testRunEntered)


if __name__ == '__main__':
    unittest.main()
PK��[4���-7-7test/test_runner.pyonu�[����
|fc@s�ddlZddlmZddlZddlmZmZdejfd��YZdejfd��YZ	e
dkr�ej�ndS(	i����N(tStringIO(t
LoggingResultt#ResultWithNoStartTestRunStopTestRuntTestCleanUpcBs,eZd�Zd�Zd�Zd�ZRS(c
sdtjfd��Y}|d�}|j|jg�g��fd�}�fd�}|j|dddd	d
dd�|j|�|j|j|d
td	d
dd�f|difg�|j�}|j|�|j�ddifddtd	d
dd�fg�dS(NtTestableTestcBseZd�ZRS(cSsdS(N((tself((s1/usr/lib64/python2.7/unittest/test/test_runner.pyttestNothings(t__name__t
__module__R(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR
sRcs�jd||f�dS(Ni(tappend(targstkwargs(tcleanups(s1/usr/lib64/python2.7/unittest/test/test_runner.pytcleanup1scs�jd||f�dS(Ni(R	(R
R(R(s1/usr/lib64/python2.7/unittest/test/test_runner.pytcleanup2siiitfourthellotfivetgoodbye(iii(((iii(tunittesttTestCasetassertEqualt	_cleanupst
addCleanuptdictt
doCleanupst
assertTrue(RRttestR
Rtresult((Rs1/usr/lib64/python2.7/unittest/test/test_runner.pyttestCleanUps"

cs+dtjfd��Y}dtfd��Y}|�}|d�}||_td��td���fd�}�fd	�}|j|�|j|�|j|j��t|j	�\\}\}}	}
\}\}}
}
|j
|||	f|t�f�|j
|||
f|t�f�dS(
NRcBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR+s(RRR(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR*st
MockResultcBseZgZd�ZRS(cSs|jj||f�dS(N(terrorsR	(RRtexc_info((s1/usr/lib64/python2.7/unittest/test/test_runner.pytaddError0s(RRRR!(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR.sRtfootbarcs
��dS(N(((texc1(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR
9scs
��dS(N(((texc2(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR<s(RRtobjectt_resultForDoCleanupst	ExceptionRtassertFalseRtreversedRR(RRRRRR
Rttest1tType1t	instance1t_ttest2tType2t	instance2((R$R%s1/usr/lib64/python2.7/unittest/test/test_runner.pyttestCleanUpWithErrors)s		

3"cst�g�dtjf��fd��Y}|d���fd�}�fd�}�j|��j|����fd�}tj�}||_�j|��j�ddd	d
ddg�t�g�|d���j|��j|��j�ddg�dS(
NRcs8eZ��fd�Z�fd�Z�fd�ZRS(cs&�jd��r"td��ndS(NtsetUpR"(R	R((R(tblowUptordering(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR3Ms
cs�jd�dS(NR(R	(R(R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRRscs�jd�dS(NttearDown(R	(R(R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR6Us(RRR3RR6((R4R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRLsRcs�jd�dS(NR
(R	((R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR
Zscs�jd�dS(NR(R	((R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR\scs!�j|���jd�dS(Ntsuccess(RR	(t	some_test(R5RR(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR7asR3RR6RR
R7(	tFalseRRRt
TestResultt
addSuccesstrunRtTrue(RRR
RR7R((R4R5RRs1/usr/lib64/python2.7/unittest/test/test_runner.pyttestCleanupInRunHs("

	


cs�g�dtjf��fd��Y}|d�����fd���fd���j�|j�dddd	d
g�dS(NRcs8eZ��fd�Z�fd�Z�fd�ZRS(cs�jd�|j��dS(NR3(R	R(R(R
R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR3ws
cs�jd�dS(NR(R	(R(R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR{scs�jd�dS(NR6(R	(R(R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR6~s(RRR3RR6((R
R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRvsRcs�jd��j��dS(NR
(R	R((RR5R(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR
�s
cs�jd�dS(NR(R	((R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR�sR3RR6R
R(RRtdebugR(RR((R
RR5Rs1/usr/lib64/python2.7/unittest/test/test_runner.pyt!testTestCaseDebugExecutesCleanupsss"
(RRRR2R>R@(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR
s			+tTest_TextTestRunnercBsVeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(	sTests for TextTestRunner.cCsitj�}|j|j�|j|j�|j|jd�|j|j�|j|j	tj
�dS(Ni(RtTextTestRunnerR)tfailfasttbufferRt	verbosityRtdescriptionstresultclasstTextTestResult(Rtrunner((s1/usr/lib64/python2.7/unittest/test/test_runner.pyt	test_init�scsOdtjf�fd��Y�dtj�fd��Y}|ddd�dS(NtAResultcseZ�fd�ZRS(cs t�|�j|||�dS(N(tsupert__init__(RtstreamRFRE(RK(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRM�s(RRRM((RK(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRK�stATextResultcBseZRS((RR(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRO�si(RR:RHtNone(RRO((RKs1/usr/lib64/python2.7/unittest/test/test_runner.pyttest_multiple_inheritance�scs�dtjfd��Y}tj��tjdt�dtdt�}�fd�|_|j|d��|j�j	�|j�j
�dS(NtTestcBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_runner.pyttestFoo�s(RRRS(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRR�sRNRCRDcs�S(N(((R(s1/usr/lib64/python2.7/unittest/test/test_runner.pyt<lambda>�tRS(RRR:RBRR=t_makeResultR<RRCRD(RRRRI((Rs1/usr/lib64/python2.7/unittest/test/test_runner.pyttestBufferAndFailfast�s	cs�dtjfd��Y}tjj��fd�}�j|�tj��tjdt��}�fd�|_d�_	��fd�}|tj_|j
tj���j�j	d�dS(	NRRcBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRS�s(RRRS(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRR�scs�tj_dS(N(RRItregisterResult((toriginalRegisterResult(s1/usr/lib64/python2.7/unittest/test/test_runner.pytcleanup�sRNcs�S(N(((R(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRT�RUics#�jd7_�j|��dS(Ni(t
wasRegisteredR(t
thisResult(RR(s1/usr/lib64/python2.7/unittest/test/test_runner.pytfakeRegisterResult�si(
RRRIRXRR:RBRRVR[R<t	TestSuiteR(RRRRZRIR]((RYRRs1/usr/lib64/python2.7/unittest/test/test_runner.pyttestRunnerRegistersResult�s
	csXdtfd��Y�dtjf��fd��Y���}|jtj��dS(Nt
OldTextResultcBseZdZd�ZRS(RUcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_runner.pytprintErrors�s(RRt
separator2Ra(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR`�stRunnercs&eZ�fd�Z�fd�ZRS(cst�|�jt��dS(N(RLRMR(R(Rc(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRM�scs��S(N((R(R`(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRV�s(RRRMRV((R`Rc(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRc�s(RRRBR<R^(RRI((R`Rcs1/usr/lib64/python2.7/unittest/test/test_runner.pyt7test_works_with_result_without_startTestRun_stopTestRun�s"	cs}dtfd��Y�dtjf��fd��Y�g}�|�}|jtj��ddg}|j||�dS(NtLoggingTextResultcBseZdZd�ZRS(RUcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRa�s(RRRbRa(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRe�st
LoggingRunnercs&eZ�fd�Z�fd�ZRS(cs&t�|�jt��||_dS(N(RLRMRt_events(Rtevents(Rf(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRM�scs
�|j�S(N(Rg(R(Re(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRV�s(RRRMRV((RfRe(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRf�ststartTestRuntstopTestRun(RRRBR<R^R(RRhRItexpected((RfRes1/usr/lib64/python2.7/unittest/test/test_runner.pyt$test_startTestRun_stopTestRun_called�s"cCs�ddlm}|d�}tj|�}x^ttjd�D]I}tj|d|�}tj|�}|j|j	j
�|j
��q?WdS(Ni����(RR"itprotocol(RRRBtrangetpickletHIGHEST_PROTOCOLtdumpstloadsRRNtgetvalue(RtPickleableIORNRIRmtstobj((s1/usr/lib64/python2.7/unittest/test/test_runner.pyttest_pickle_unpickle�scCs~d�}t�}t�}t�}tj|||d|�}|j|j|�|j||f}|j|j�|�dS(NcWs|S(N((R
((s1/usr/lib64/python2.7/unittest/test/test_runner.pytMockResultClass�sRG(R&RRBRRGRNRV(RRxtSTREAMtDESCRIPTIONSt	VERBOSITYRItexpectedresult((s1/usr/lib64/python2.7/unittest/test/test_runner.pyttest_resultclass�s					(RRt__doc__RJRQRWR_RdRlRwR}(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRA�s			
					
t__main__(Rt	cStringIORRotunittest.test.supportRRRRRARtmain(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyt<module>s�}PK��[CV�EEtest/test_discovery.pyonu�[����
{fc@srddlZddlZddlZddlZddlZdejfd��YZedkrnej�ndS(i����Nt
TestDiscoverycBs}eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�ZRS(
cCsetj�}d|_|jd�}|j|d�ts>dS|jt��|jd�WdQXdS(Ns/foos/foo/bar/baz.pysbar.bazs/bar/baz.py(tunittestt
TestLoadert_top_level_dirt_get_name_from_pathtassertEqualt	__debug__tassertRaisestAssertionError(tselftloadertname((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_get_name_from_paths	cs�tj�}tj��fd�}tjj��fd�}tjj��fd�}dddddd	d
gddgg��fd
�t_|j|�d�}|tj_|j|�d�}|tj_|j|�d�|_d�|_	tjj
d�}||_t|j
|d��}gdD]}	|	d^q6}
|
jgdD]}	d|	d^qY�|j||
�dS(Ncs
�t_dS(N(tostlistdir((toriginal_listdir(s4/usr/lib64/python2.7/unittest/test/test_discovery.pytrestore_listdirscs�tj_dS(N(R
tpathtisfile((toriginal_isfile(s4/usr/lib64/python2.7/unittest/test/test_discovery.pytrestore_isfile!scs�tj_dS(N(R
Rtisdir((toriginal_isdir(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt
restore_isdir$sstest1.pystest2.pys
not_a_test.pyttest_dirstest.foostest-not-a-module.pytanother_dirstest3.pystest4.pycs
�jd�S(Ni(tpop(R(t
path_lists(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt<lambda>*tcSs
|jd�S(Ntdir(tendswith(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR-scSs|jd�od|kS(NRR(R(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR2scSs|dS(Ns module((R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR8RcSs|dS(Ns tests((tmodule((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR9Rs/foostest*.pyttest1ttest2s
 module teststtest3ttest4stest_dir.%s(R!R"(R#R$(RRR
RRRRt
addCleanupt_get_module_from_nametloadTestsFromModuletabspathRtlistt_find_teststextendR(R	R
RRRRRt	top_leveltsuiteRtexpected((RRRRs4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_find_testss8	
	
	
		cs�tj�}tj��fd�}tjj��fd�}tjj��fd�}dddg��gggg��fd�t_�j|�d�tj_�j|��fd	�tj_�j|�d
tfd��Y��fd�|_	�fd
�}||_
d|_t|j
dd��}�j|dddg��j�jddg��j�j|dddfg�dS(Ncs
�t_dS(N(R
R((R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRIscs�tj_dS(N(R
RR((R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRLscs�tj_dS(N(R
RR((R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyROsta_directoryttest_directoryttest_directory2cs
�jd�S(Ni(R(R(R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRTRcSstS(N(tTrue(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRWRcstjj|��kS(N(R
Rtbasename(R(tdirectories(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRZRtModulecBs,eZgZgZd�Zd�ZdZRS(csP|�_�jj|�tjj|�dkrL�fd�}|�_ndS(NR1cs�jj|||f�dS(Nt
load_tests(tload_tests_argstappend(R
tteststpattern(R	(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR7es(RtpathsR9R
R4R7(R	RR7((R	s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt__init__as
	cSs|j|jkS(N(R(R	tother((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt__eq__jsN(t__name__t
__module__R<R8R=R?tNonet__hash__(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR6]s
			cs
�|�S(N((R(R6(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRpRcs#|r�jd��n|jdS(Ns+use_load_tests should be False for packagess
 module tests(tfailureExceptionR(R tuse_load_tests(R	(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR'qss/foostest*R7s
 module tests(RRR
RRRRR%tobjectR&R'RR)R*RR<R8(R	R
RRRR'R-((R6R5RRRRR	s4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_find_tests_with_packageEs4	


			c
s�tj�}tjj�tjj��fd�}d�tj_|j|�tj��fd�}|j|�tjjtjj	d��}|j
t��|jddd�WdQX|j
|j|�|j|tj�d�tj_d�tj_�fd	�}|j|�g��fd
�}||_t|_|jddd�}tjjd�}tjjd�}	|j
|d
�|j
|j|�|j
�|	dfg�|j|tj�dS(Ncs�tj_dS(N(R
RR((R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR�scSstS(N(tFalse(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR�Rcs�tj(dS(N(tsysR((t
orig_sys_path(s4/usr/lib64/python2.7/unittest/test/test_discovery.pytrestore_path�ss/foos/foo/bart
top_level_dircSstS(N(R3(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR�RcSstS(N(R3(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR�Rcs�tj_dS(N(R
RR((R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR�scs�j||f�dgS(NR:(R9(t	start_dirR;(t_find_tests_args(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR*�ss/foo/bar/bazR;s	['tests'](RRR
RRRR%RIR(tnormpathRtImportErrortdiscoverRRtassertInR*tstrt
suiteClass(
R	R
RRKt	full_pathRR*R-RLRM((RNRJRRs4/usr/lib64/python2.7/unittest/test/test_discovery.pyt
test_discover�s:



		cs�tj�}tj�d�t_tjj�d�tj_tj����fd�}|j|�|jd�}|j	tj
�tj�|j|j�d�t
t
|�d�d}|jt��|j�WdQXdS(NcSsdgS(Nstest_this_does_not_exist.py((t_((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR�RcSstS(N(R3(RW((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR�Rcs#�tj_�t_�tj(dS(N(R
RRRRI((RRRJ(s4/usr/lib64/python2.7/unittest/test/test_discovery.pytrestore�s	t.ii(RRR
RRRRIR%RQRRtgetcwdRtcountTestCasesR)RRPttest_this_does_not_exist(R	R
RXR-ttest((RRRJs4/usr/lib64/python2.7/unittest/test/test_discovery.pyt.test_discover_with_modules_that_fail_to_import�s	

cs�tjtj�}g��fd�}||_|jddg�|j�g�|jddddg�|j�ddg�dS(Ncs�j|�dS(N(R+(targv(targs(s4/usr/lib64/python2.7/unittest/test/test_discovery.pytdo_discovery�st	somethingRQtfootbar(RFt__new__RtTestProgramt
_do_discoveryt	parseArgsR(R	tprogramRa((R`s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt$test_command_line_handling_parseArgs�s	c	s|dtfd��Y��fd�}tjtj�}||_d|_|j���|j	ddddg�WdQXdS(NtStopcBseZRS((R@RA(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRk�scs
��dS(N(((Rk(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt	usageExit�stonettwotthreetfour(
t	ExceptionRFReRRfRlRBt
testLoaderRRg(R	RlRi((Rks4/usr/lib64/python2.7/unittest/test/test_discovery.pyt:test_command_line_handling_do_discovery_too_many_arguments�s		cCs^tjtj�}dtfd��Y}|�|_|jdg�|j|jdg�dS(NtLoadercBseZgZd�ZRS(cSs|jj|||f�dS(NR:(R`R9(R	RMR;RL((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRQ�s(R@RAR`RQ(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRt�ss-vRYstest*.py(RYstest*.pyN(	RFReRRfRrRgRR`RB(R	RiRt((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt;test_command_line_handling_do_discovery_uses_default_loader�s
cCstjtj�}dtfd��Y}|jdgd|�|j|jd�|j|jd�|j|jdg�g|_tjtj�}|jdgd|�|j|jd�|j|jdg�g|_tjtj�}|jgd|�|j|jd�|j|jdg�g|_tjtj�}|jd	gd|�|j|jd�|j|jdg�g|_tjtj�}|jd	d
gd|�|j|jd�|j|jdg�g|_tjtj�}|jd	d
dgd|�|j|jd�|j|jdg�g|_tjtj�}|jdd	gd|�|j|jd�|j|jdg�g|_tjtj�}|jd
d	gd|�|j|jd�|j|jdg�g|_tjtj�}|jdd	gd|�|j|jd�|j|jdg�|j
|j�|j
|j�g|_tjtj�}|jdd
dd	dddgd|�|j|jd�|j|jdg�|j|jd�|j
|j�|j
|j�dS(NRtcBseZgZd�ZRS(cSs|jj|||f�dS(NR:(R`R9(R	RMR;RL((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRQ�s(R@RAR`RQ(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRt�ss-viR:RYstest*.pys	--verbosetfishteggsthams-ss-ts-ps-fs-c(RYstest*.pyN(RYstest*.pyN(RYstest*.pyN(Rvstest*.pyN(RvRwN(RvRwRx(Rvstest*.pyN(RYstest*.pyRv(RYRvN(RvRwN(RFReRRfRgRt	verbosityR]R`RBtassertFalsetfailfastt
catchbreakt
assertTrue(R	RiRt((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt4test_command_line_handling_do_discovery_calls_loader�sr									!cs�dtfd��Y}|tjd<tjjd��tj�tjj�tjj�����fd�}|j	|�d�}d�}d�}|t_|tj_|tj_�S(NR6cBseZdZRS(s
bar/foo.py(R@RAt__file__(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR6?sRccsQ�t_�tj_�tj_tjd=�tjkrMtjj��ndS(NRc(R
RRRRRItmodulestremove((RURRR(s4/usr/lib64/python2.7/unittest/test/test_discovery.pytcleanupGs	
cSsdgS(Nsfoo.py((RW((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRPscSstS(N(R3(RW((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRRscSstS(N(R3(RW((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRTs(
RFRIR�R
RR(RRRR%(R	R6R�RRR((RURRRs4/usr/lib64/python2.7/unittest/test/test_discovery.pytsetup_module_clash>s
	
				cCs�|j�}tj�}tjjd�}tjjd�}tjd||f�}|jt	d||j
dddd�|jtjd|�dS(	NRdRcsZ'foo' module incorrectly imported from %r. Expected %r. Is this module globally installed?s^%s$RMR;sfoo.pyi(
R�RRR
RR(tretescapetassertRaisesRegexpRPRQRRI(R	RUR
tmod_dirtexpected_dirtmsg((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_detect_module_clash[s	
cs�|j�}tjj�tjjd��tjjd���fd�}|j|���fd�}|tj_tj�}|jdddd�dS(NRdRccs�tj_dS(N(R
Rtrealpath((toriginal_realpath(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR�qscs2|tjj�d�kr.tjj�d�S|S(Nsfoo.py(R
Rtjoin(R(R�R�(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR�usRMR;sfoo.py(	R�R
RR�R(R%RRRQ(R	RUR�R�R
((R�R�R�s4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_module_symlink_okis
cs�tj�}�g�tjjtjjtjj���t�_	���fd�}||_
|jd�}�j�j	��j
|j��dS(Ncst�_�j|���S(N(R3twasRunR(RMR;(texpectedPathR	R:(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR*�s	s
unittest.test(RRR
RR(tdirnameR]RRHR�R*RQR}Rt_tests(R	R
R*R-((R�R	R:s4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_discovery_from_dotted_path}s	$		(R@RARR/RGRVR^RjRsRuR~R�R�R�R�(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR	s		+	A	.				
	J			t__main__(	R
R�RIRt
unittest.testtTestCaseRR@tmain(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt<module>s��PK��[pV'�.�.test/test_assertions.pynu�[���import datetime

import unittest


class Test_Assertions(unittest.TestCase):
    def test_AlmostEqual(self):
        self.assertAlmostEqual(1.00000001, 1.0)
        self.assertNotAlmostEqual(1.0000001, 1.0)
        self.assertRaises(self.failureException,
                          self.assertAlmostEqual, 1.0000001, 1.0)
        self.assertRaises(self.failureException,
                          self.assertNotAlmostEqual, 1.00000001, 1.0)

        self.assertAlmostEqual(1.1, 1.0, places=0)
        self.assertRaises(self.failureException,
                          self.assertAlmostEqual, 1.1, 1.0, places=1)

        self.assertAlmostEqual(0, .1+.1j, places=0)
        self.assertNotAlmostEqual(0, .1+.1j, places=1)
        self.assertRaises(self.failureException,
                          self.assertAlmostEqual, 0, .1+.1j, places=1)
        self.assertRaises(self.failureException,
                          self.assertNotAlmostEqual, 0, .1+.1j, places=0)

        self.assertAlmostEqual(float('inf'), float('inf'))
        self.assertRaises(self.failureException, self.assertNotAlmostEqual,
                          float('inf'), float('inf'))

    def test_AmostEqualWithDelta(self):
        self.assertAlmostEqual(1.1, 1.0, delta=0.5)
        self.assertAlmostEqual(1.0, 1.1, delta=0.5)
        self.assertNotAlmostEqual(1.1, 1.0, delta=0.05)
        self.assertNotAlmostEqual(1.0, 1.1, delta=0.05)

        self.assertAlmostEqual(1.0, 1.0, delta=0.5)
        self.assertRaises(self.failureException, self.assertNotAlmostEqual,
                          1.0, 1.0, delta=0.5)

        self.assertRaises(self.failureException, self.assertAlmostEqual,
                          1.1, 1.0, delta=0.05)
        self.assertRaises(self.failureException, self.assertNotAlmostEqual,
                          1.1, 1.0, delta=0.5)

        self.assertRaises(TypeError, self.assertAlmostEqual,
                          1.1, 1.0, places=2, delta=2)
        self.assertRaises(TypeError, self.assertNotAlmostEqual,
                          1.1, 1.0, places=2, delta=2)

        first = datetime.datetime.now()
        second = first + datetime.timedelta(seconds=10)
        self.assertAlmostEqual(first, second,
                               delta=datetime.timedelta(seconds=20))
        self.assertNotAlmostEqual(first, second,
                                  delta=datetime.timedelta(seconds=5))

    def test_assertRaises(self):
        def _raise(e):
            raise e
        self.assertRaises(KeyError, _raise, KeyError)
        self.assertRaises(KeyError, _raise, KeyError("key"))
        try:
            self.assertRaises(KeyError, lambda: None)
        except self.failureException as e:
            self.assertIn("KeyError not raised", e.args)
        else:
            self.fail("assertRaises() didn't fail")
        try:
            self.assertRaises(KeyError, _raise, ValueError)
        except ValueError:
            pass
        else:
            self.fail("assertRaises() didn't let exception pass through")
        with self.assertRaises(KeyError) as cm:
            try:
                raise KeyError
            except Exception, e:
                raise
        self.assertIs(cm.exception, e)

        with self.assertRaises(KeyError):
            raise KeyError("key")
        try:
            with self.assertRaises(KeyError):
                pass
        except self.failureException as e:
            self.assertIn("KeyError not raised", e.args)
        else:
            self.fail("assertRaises() didn't fail")
        try:
            with self.assertRaises(KeyError):
                raise ValueError
        except ValueError:
            pass
        else:
            self.fail("assertRaises() didn't let exception pass through")

    def testAssertNotRegexpMatches(self):
        self.assertNotRegexpMatches('Ala ma kota', r'r+')
        try:
            self.assertNotRegexpMatches('Ala ma kota', r'k.t', 'Message')
        except self.failureException, e:
            self.assertIn("'kot'", e.args[0])
            self.assertIn('Message', e.args[0])
        else:
            self.fail('assertNotRegexpMatches should have failed.')


class TestLongMessage(unittest.TestCase):
    """Test that the individual asserts honour longMessage.
    This actually tests all the message behaviour for
    asserts that use longMessage."""

    def setUp(self):
        class TestableTestFalse(unittest.TestCase):
            longMessage = False
            failureException = self.failureException

            def testTest(self):
                pass

        class TestableTestTrue(unittest.TestCase):
            longMessage = True
            failureException = self.failureException

            def testTest(self):
                pass

        self.testableTrue = TestableTestTrue('testTest')
        self.testableFalse = TestableTestFalse('testTest')

    def testDefault(self):
        self.assertFalse(unittest.TestCase.longMessage)

    def test_formatMsg(self):
        self.assertEqual(self.testableFalse._formatMessage(None, "foo"), "foo")
        self.assertEqual(self.testableFalse._formatMessage("foo", "bar"), "foo")

        self.assertEqual(self.testableTrue._formatMessage(None, "foo"), "foo")
        self.assertEqual(self.testableTrue._formatMessage("foo", "bar"), "bar : foo")

        # This blows up if _formatMessage uses string concatenation
        self.testableTrue._formatMessage(object(), 'foo')

    def test_formatMessage_unicode_error(self):
        one = ''.join(chr(i) for i in range(255))
        # this used to cause a UnicodeDecodeError constructing msg
        self.testableTrue._formatMessage(one, u'\uFFFD')

    def assertMessages(self, methodName, args, errors):
        def getMethod(i):
            useTestableFalse  = i < 2
            if useTestableFalse:
                test = self.testableFalse
            else:
                test = self.testableTrue
            return getattr(test, methodName)

        for i, expected_regexp in enumerate(errors):
            testMethod = getMethod(i)
            kwargs = {}
            withMsg = i % 2
            if withMsg:
                kwargs = {"msg": "oops"}

            with self.assertRaisesRegexp(self.failureException,
                                         expected_regexp=expected_regexp):
                testMethod(*args, **kwargs)

    def testAssertTrue(self):
        self.assertMessages('assertTrue', (False,),
                            ["^False is not true$", "^oops$", "^False is not true$",
                             "^False is not true : oops$"])

    def testAssertFalse(self):
        self.assertMessages('assertFalse', (True,),
                            ["^True is not false$", "^oops$", "^True is not false$",
                             "^True is not false : oops$"])

    def testNotEqual(self):
        self.assertMessages('assertNotEqual', (1, 1),
                            ["^1 == 1$", "^oops$", "^1 == 1$",
                             "^1 == 1 : oops$"])

    def testAlmostEqual(self):
        self.assertMessages('assertAlmostEqual', (1, 2),
                            ["^1 != 2 within 7 places$", "^oops$",
                             "^1 != 2 within 7 places$", "^1 != 2 within 7 places : oops$"])

    def testNotAlmostEqual(self):
        self.assertMessages('assertNotAlmostEqual', (1, 1),
                            ["^1 == 1 within 7 places$", "^oops$",
                             "^1 == 1 within 7 places$", "^1 == 1 within 7 places : oops$"])

    def test_baseAssertEqual(self):
        self.assertMessages('_baseAssertEqual', (1, 2),
                            ["^1 != 2$", "^oops$", "^1 != 2$", "^1 != 2 : oops$"])

    def testAssertSequenceEqual(self):
        # Error messages are multiline so not testing on full message
        # assertTupleEqual and assertListEqual delegate to this method
        self.assertMessages('assertSequenceEqual', ([], [None]),
                            ["\+ \[None\]$", "^oops$", r"\+ \[None\]$",
                             r"\+ \[None\] : oops$"])

    def testAssertSetEqual(self):
        self.assertMessages('assertSetEqual', (set(), set([None])),
                            ["None$", "^oops$", "None$",
                             "None : oops$"])

    def testAssertIn(self):
        self.assertMessages('assertIn', (None, []),
                            ['^None not found in \[\]$', "^oops$",
                             '^None not found in \[\]$',
                             '^None not found in \[\] : oops$'])

    def testAssertNotIn(self):
        self.assertMessages('assertNotIn', (None, [None]),
                            ['^None unexpectedly found in \[None\]$', "^oops$",
                             '^None unexpectedly found in \[None\]$',
                             '^None unexpectedly found in \[None\] : oops$'])

    def testAssertDictEqual(self):
        self.assertMessages('assertDictEqual', ({}, {'key': 'value'}),
                            [r"\+ \{'key': 'value'\}$", "^oops$",
                             "\+ \{'key': 'value'\}$",
                             "\+ \{'key': 'value'\} : oops$"])

    def testAssertDictContainsSubset(self):
        self.assertMessages('assertDictContainsSubset', ({'key': 'value'}, {}),
                            ["^Missing: 'key'$", "^oops$",
                             "^Missing: 'key'$",
                             "^Missing: 'key' : oops$"])

    def testAssertMultiLineEqual(self):
        self.assertMessages('assertMultiLineEqual', ("", "foo"),
                            [r"\+ foo$", "^oops$",
                             r"\+ foo$",
                             r"\+ foo : oops$"])

    def testAssertLess(self):
        self.assertMessages('assertLess', (2, 1),
                            ["^2 not less than 1$", "^oops$",
                             "^2 not less than 1$", "^2 not less than 1 : oops$"])

    def testAssertLessEqual(self):
        self.assertMessages('assertLessEqual', (2, 1),
                            ["^2 not less than or equal to 1$", "^oops$",
                             "^2 not less than or equal to 1$",
                             "^2 not less than or equal to 1 : oops$"])

    def testAssertGreater(self):
        self.assertMessages('assertGreater', (1, 2),
                            ["^1 not greater than 2$", "^oops$",
                             "^1 not greater than 2$",
                             "^1 not greater than 2 : oops$"])

    def testAssertGreaterEqual(self):
        self.assertMessages('assertGreaterEqual', (1, 2),
                            ["^1 not greater than or equal to 2$", "^oops$",
                             "^1 not greater than or equal to 2$",
                             "^1 not greater than or equal to 2 : oops$"])

    def testAssertIsNone(self):
        self.assertMessages('assertIsNone', ('not None',),
                            ["^'not None' is not None$", "^oops$",
                             "^'not None' is not None$",
                             "^'not None' is not None : oops$"])

    def testAssertIsNotNone(self):
        self.assertMessages('assertIsNotNone', (None,),
                            ["^unexpectedly None$", "^oops$",
                             "^unexpectedly None$",
                             "^unexpectedly None : oops$"])

    def testAssertIs(self):
        self.assertMessages('assertIs', (None, 'foo'),
                            ["^None is not 'foo'$", "^oops$",
                             "^None is not 'foo'$",
                             "^None is not 'foo' : oops$"])

    def testAssertIsNot(self):
        self.assertMessages('assertIsNot', (None, None),
                            ["^unexpectedly identical: None$", "^oops$",
                             "^unexpectedly identical: None$",
                             "^unexpectedly identical: None : oops$"])


if __name__ == '__main__':
    unittest.main()
PK��[�
�����test/test_case.pynu�[���import difflib
import pprint
import pickle
import re
import sys

from copy import deepcopy
from test import test_support

import unittest

from unittest.test.support import (
    TestEquality, TestHashing, LoggingResult, ResultWithNoStartTestRunStopTestRun
)


class Test(object):
    "Keep these TestCase classes out of the main namespace"

    class Foo(unittest.TestCase):
        def runTest(self): pass
        def test1(self): pass

    class Bar(Foo):
        def test2(self): pass

    class LoggingTestCase(unittest.TestCase):
        """A test case which logs its calls."""

        def __init__(self, events):
            super(Test.LoggingTestCase, self).__init__('test')
            self.events = events

        def setUp(self):
            self.events.append('setUp')

        def test(self):
            self.events.append('test')

        def tearDown(self):
            self.events.append('tearDown')


class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):

    ### Set up attributes used by inherited tests
    ################################################################

    # Used by TestHashing.test_hash and TestEquality.test_eq
    eq_pairs = [(Test.Foo('test1'), Test.Foo('test1'))]

    # Used by TestEquality.test_ne
    ne_pairs = [(Test.Foo('test1'), Test.Foo('runTest'))
               ,(Test.Foo('test1'), Test.Bar('test1'))
               ,(Test.Foo('test1'), Test.Bar('test2'))]

    ################################################################
    ### /Set up attributes used by inherited tests


    # "class TestCase([methodName])"
    # ...
    # "Each instance of TestCase will run a single test method: the
    # method named methodName."
    # ...
    # "methodName defaults to "runTest"."
    #
    # Make sure it really is optional, and that it defaults to the proper
    # thing.
    def test_init__no_test_name(self):
        class Test(unittest.TestCase):
            def runTest(self): raise TypeError()
            def test(self): pass

        self.assertEqual(Test().id()[-13:], '.Test.runTest')

    # "class TestCase([methodName])"
    # ...
    # "Each instance of TestCase will run a single test method: the
    # method named methodName."
    def test_init__test_name__valid(self):
        class Test(unittest.TestCase):
            def runTest(self): raise TypeError()
            def test(self): pass

        self.assertEqual(Test('test').id()[-10:], '.Test.test')

    # "class TestCase([methodName])"
    # ...
    # "Each instance of TestCase will run a single test method: the
    # method named methodName."
    def test_init__test_name__invalid(self):
        class Test(unittest.TestCase):
            def runTest(self): raise TypeError()
            def test(self): pass

        try:
            Test('testfoo')
        except ValueError:
            pass
        else:
            self.fail("Failed to raise ValueError")

    # "Return the number of tests represented by the this test object. For
    # TestCase instances, this will always be 1"
    def test_countTestCases(self):
        class Foo(unittest.TestCase):
            def test(self): pass

        self.assertEqual(Foo('test').countTestCases(), 1)

    # "Return the default type of test result object to be used to run this
    # test. For TestCase instances, this will always be
    # unittest.TestResult;  subclasses of TestCase should
    # override this as necessary."
    def test_defaultTestResult(self):
        class Foo(unittest.TestCase):
            def runTest(self):
                pass

        result = Foo().defaultTestResult()
        self.assertEqual(type(result), unittest.TestResult)

    # "When a setUp() method is defined, the test runner will run that method
    # prior to each test. Likewise, if a tearDown() method is defined, the
    # test runner will invoke that method after each test. In the example,
    # setUp() was used to create a fresh sequence for each test."
    #
    # Make sure the proper call order is maintained, even if setUp() raises
    # an exception.
    def test_run_call_order__error_in_setUp(self):
        events = []
        result = LoggingResult(events)

        class Foo(Test.LoggingTestCase):
            def setUp(self):
                super(Foo, self).setUp()
                raise RuntimeError('raised by Foo.setUp')

        Foo(events).run(result)
        expected = ['startTest', 'setUp', 'addError', 'stopTest']
        self.assertEqual(events, expected)

    # "With a temporary result stopTestRun is called when setUp errors.
    def test_run_call_order__error_in_setUp_default_result(self):
        events = []

        class Foo(Test.LoggingTestCase):
            def defaultTestResult(self):
                return LoggingResult(self.events)

            def setUp(self):
                super(Foo, self).setUp()
                raise RuntimeError('raised by Foo.setUp')

        Foo(events).run()
        expected = ['startTestRun', 'startTest', 'setUp', 'addError',
                    'stopTest', 'stopTestRun']
        self.assertEqual(events, expected)

    # "When a setUp() method is defined, the test runner will run that method
    # prior to each test. Likewise, if a tearDown() method is defined, the
    # test runner will invoke that method after each test. In the example,
    # setUp() was used to create a fresh sequence for each test."
    #
    # Make sure the proper call order is maintained, even if the test raises
    # an error (as opposed to a failure).
    def test_run_call_order__error_in_test(self):
        events = []
        result = LoggingResult(events)

        class Foo(Test.LoggingTestCase):
            def test(self):
                super(Foo, self).test()
                raise RuntimeError('raised by Foo.test')

        expected = ['startTest', 'setUp', 'test', 'addError', 'tearDown',
                    'stopTest']
        Foo(events).run(result)
        self.assertEqual(events, expected)

    # "With a default result, an error in the test still results in stopTestRun
    # being called."
    def test_run_call_order__error_in_test_default_result(self):
        events = []

        class Foo(Test.LoggingTestCase):
            def defaultTestResult(self):
                return LoggingResult(self.events)

            def test(self):
                super(Foo, self).test()
                raise RuntimeError('raised by Foo.test')

        expected = ['startTestRun', 'startTest', 'setUp', 'test', 'addError',
                    'tearDown', 'stopTest', 'stopTestRun']
        Foo(events).run()
        self.assertEqual(events, expected)

    # "When a setUp() method is defined, the test runner will run that method
    # prior to each test. Likewise, if a tearDown() method is defined, the
    # test runner will invoke that method after each test. In the example,
    # setUp() was used to create a fresh sequence for each test."
    #
    # Make sure the proper call order is maintained, even if the test signals
    # a failure (as opposed to an error).
    def test_run_call_order__failure_in_test(self):
        events = []
        result = LoggingResult(events)

        class Foo(Test.LoggingTestCase):
            def test(self):
                super(Foo, self).test()
                self.fail('raised by Foo.test')

        expected = ['startTest', 'setUp', 'test', 'addFailure', 'tearDown',
                    'stopTest']
        Foo(events).run(result)
        self.assertEqual(events, expected)

    # "When a test fails with a default result stopTestRun is still called."
    def test_run_call_order__failure_in_test_default_result(self):

        class Foo(Test.LoggingTestCase):
            def defaultTestResult(self):
                return LoggingResult(self.events)
            def test(self):
                super(Foo, self).test()
                self.fail('raised by Foo.test')

        expected = ['startTestRun', 'startTest', 'setUp', 'test', 'addFailure',
                    'tearDown', 'stopTest', 'stopTestRun']
        events = []
        Foo(events).run()
        self.assertEqual(events, expected)

    # "When a setUp() method is defined, the test runner will run that method
    # prior to each test. Likewise, if a tearDown() method is defined, the
    # test runner will invoke that method after each test. In the example,
    # setUp() was used to create a fresh sequence for each test."
    #
    # Make sure the proper call order is maintained, even if tearDown() raises
    # an exception.
    def test_run_call_order__error_in_tearDown(self):
        events = []
        result = LoggingResult(events)

        class Foo(Test.LoggingTestCase):
            def tearDown(self):
                super(Foo, self).tearDown()
                raise RuntimeError('raised by Foo.tearDown')

        Foo(events).run(result)
        expected = ['startTest', 'setUp', 'test', 'tearDown', 'addError',
                    'stopTest']
        self.assertEqual(events, expected)

    # "When tearDown errors with a default result stopTestRun is still called."
    def test_run_call_order__error_in_tearDown_default_result(self):

        class Foo(Test.LoggingTestCase):
            def defaultTestResult(self):
                return LoggingResult(self.events)
            def tearDown(self):
                super(Foo, self).tearDown()
                raise RuntimeError('raised by Foo.tearDown')

        events = []
        Foo(events).run()
        expected = ['startTestRun', 'startTest', 'setUp', 'test', 'tearDown',
                    'addError', 'stopTest', 'stopTestRun']
        self.assertEqual(events, expected)

    # "TestCase.run() still works when the defaultTestResult is a TestResult
    # that does not support startTestRun and stopTestRun.
    def test_run_call_order_default_result(self):

        class Foo(unittest.TestCase):
            def defaultTestResult(self):
                return ResultWithNoStartTestRunStopTestRun()
            def test(self):
                pass

        Foo('test').run()

    # "This class attribute gives the exception raised by the test() method.
    # If a test framework needs to use a specialized exception, possibly to
    # carry additional information, it must subclass this exception in
    # order to ``play fair'' with the framework.  The initial value of this
    # attribute is AssertionError"
    def test_failureException__default(self):
        class Foo(unittest.TestCase):
            def test(self):
                pass

        self.assertIs(Foo('test').failureException, AssertionError)

    # "This class attribute gives the exception raised by the test() method.
    # If a test framework needs to use a specialized exception, possibly to
    # carry additional information, it must subclass this exception in
    # order to ``play fair'' with the framework."
    #
    # Make sure TestCase.run() respects the designated failureException
    def test_failureException__subclassing__explicit_raise(self):
        events = []
        result = LoggingResult(events)

        class Foo(unittest.TestCase):
            def test(self):
                raise RuntimeError()

            failureException = RuntimeError

        self.assertIs(Foo('test').failureException, RuntimeError)


        Foo('test').run(result)
        expected = ['startTest', 'addFailure', 'stopTest']
        self.assertEqual(events, expected)

    # "This class attribute gives the exception raised by the test() method.
    # If a test framework needs to use a specialized exception, possibly to
    # carry additional information, it must subclass this exception in
    # order to ``play fair'' with the framework."
    #
    # Make sure TestCase.run() respects the designated failureException
    def test_failureException__subclassing__implicit_raise(self):
        events = []
        result = LoggingResult(events)

        class Foo(unittest.TestCase):
            def test(self):
                self.fail("foo")

            failureException = RuntimeError

        self.assertIs(Foo('test').failureException, RuntimeError)


        Foo('test').run(result)
        expected = ['startTest', 'addFailure', 'stopTest']
        self.assertEqual(events, expected)

    # "The default implementation does nothing."
    def test_setUp(self):
        class Foo(unittest.TestCase):
            def runTest(self):
                pass

        # ... and nothing should happen
        Foo().setUp()

    # "The default implementation does nothing."
    def test_tearDown(self):
        class Foo(unittest.TestCase):
            def runTest(self):
                pass

        # ... and nothing should happen
        Foo().tearDown()

    # "Return a string identifying the specific test case."
    #
    # Because of the vague nature of the docs, I'm not going to lock this
    # test down too much. Really all that can be asserted is that the id()
    # will be a string (either 8-byte or unicode -- again, because the docs
    # just say "string")
    def test_id(self):
        class Foo(unittest.TestCase):
            def runTest(self):
                pass

        self.assertIsInstance(Foo().id(), basestring)

    # "If result is omitted or None, a temporary result object is created
    # and used, but is not made available to the caller. As TestCase owns the
    # temporary result startTestRun and stopTestRun are called.

    def test_run__uses_defaultTestResult(self):
        events = []

        class Foo(unittest.TestCase):
            def test(self):
                events.append('test')

            def defaultTestResult(self):
                return LoggingResult(events)

        # Make run() find a result object on its own
        Foo('test').run()

        expected = ['startTestRun', 'startTest', 'test', 'addSuccess',
            'stopTest', 'stopTestRun']
        self.assertEqual(events, expected)

    def testShortDescriptionWithoutDocstring(self):
        self.assertIsNone(self.shortDescription())

    @unittest.skipIf(sys.flags.optimize >= 2,
                     "Docstrings are omitted with -O2 and above")
    def testShortDescriptionWithOneLineDocstring(self):
        """Tests shortDescription() for a method with a docstring."""
        self.assertEqual(
                self.shortDescription(),
                'Tests shortDescription() for a method with a docstring.')

    @unittest.skipIf(sys.flags.optimize >= 2,
                     "Docstrings are omitted with -O2 and above")
    def testShortDescriptionWithMultiLineDocstring(self):
        """Tests shortDescription() for a method with a longer docstring.

        This method ensures that only the first line of a docstring is
        returned used in the short description, no matter how long the
        whole thing is.
        """
        self.assertEqual(
                self.shortDescription(),
                 'Tests shortDescription() for a method with a longer '
                 'docstring.')

    def testAddTypeEqualityFunc(self):
        class SadSnake(object):
            """Dummy class for test_addTypeEqualityFunc."""
        s1, s2 = SadSnake(), SadSnake()
        self.assertNotEqual(s1, s2)
        def AllSnakesCreatedEqual(a, b, msg=None):
            return type(a) is type(b) is SadSnake
        self.addTypeEqualityFunc(SadSnake, AllSnakesCreatedEqual)
        self.assertEqual(s1, s2)
        # No this doesn't clean up and remove the SadSnake equality func
        # from this TestCase instance but since its a local nothing else
        # will ever notice that.

    def testAssertIs(self):
        thing = object()
        self.assertIs(thing, thing)
        self.assertRaises(self.failureException, self.assertIs, thing, object())

    def testAssertIsNot(self):
        thing = object()
        self.assertIsNot(thing, object())
        self.assertRaises(self.failureException, self.assertIsNot, thing, thing)

    def testAssertIsInstance(self):
        thing = []
        self.assertIsInstance(thing, list)
        self.assertRaises(self.failureException, self.assertIsInstance,
                          thing, dict)

    def testAssertNotIsInstance(self):
        thing = []
        self.assertNotIsInstance(thing, dict)
        self.assertRaises(self.failureException, self.assertNotIsInstance,
                          thing, list)

    def testAssertIn(self):
        animals = {'monkey': 'banana', 'cow': 'grass', 'seal': 'fish'}

        self.assertIn('a', 'abc')
        self.assertIn(2, [1, 2, 3])
        self.assertIn('monkey', animals)

        self.assertNotIn('d', 'abc')
        self.assertNotIn(0, [1, 2, 3])
        self.assertNotIn('otter', animals)

        self.assertRaises(self.failureException, self.assertIn, 'x', 'abc')
        self.assertRaises(self.failureException, self.assertIn, 4, [1, 2, 3])
        self.assertRaises(self.failureException, self.assertIn, 'elephant',
                          animals)

        self.assertRaises(self.failureException, self.assertNotIn, 'c', 'abc')
        self.assertRaises(self.failureException, self.assertNotIn, 1, [1, 2, 3])
        self.assertRaises(self.failureException, self.assertNotIn, 'cow',
                          animals)

    def testAssertDictContainsSubset(self):
        self.assertDictContainsSubset({}, {})
        self.assertDictContainsSubset({}, {'a': 1})
        self.assertDictContainsSubset({'a': 1}, {'a': 1})
        self.assertDictContainsSubset({'a': 1}, {'a': 1, 'b': 2})
        self.assertDictContainsSubset({'a': 1, 'b': 2}, {'a': 1, 'b': 2})

        with self.assertRaises(self.failureException):
            self.assertDictContainsSubset({1: "one"}, {})

        with self.assertRaises(self.failureException):
            self.assertDictContainsSubset({'a': 2}, {'a': 1})

        with self.assertRaises(self.failureException):
            self.assertDictContainsSubset({'c': 1}, {'a': 1})

        with self.assertRaises(self.failureException):
            self.assertDictContainsSubset({'a': 1, 'c': 1}, {'a': 1})

        with self.assertRaises(self.failureException):
            self.assertDictContainsSubset({'a': 1, 'c': 1}, {'a': 1})

        with test_support.check_warnings(("", UnicodeWarning)):
            one = ''.join(chr(i) for i in range(255))
            # this used to cause a UnicodeDecodeError constructing the failure msg
            with self.assertRaises(self.failureException):
                self.assertDictContainsSubset({'foo': one}, {'foo': u'\uFFFD'})

    def testAssertEqual(self):
        equal_pairs = [
                ((), ()),
                ({}, {}),
                ([], []),
                (set(), set()),
                (frozenset(), frozenset())]
        for a, b in equal_pairs:
            # This mess of try excepts is to test the assertEqual behavior
            # itself.
            try:
                self.assertEqual(a, b)
            except self.failureException:
                self.fail('assertEqual(%r, %r) failed' % (a, b))
            try:
                self.assertEqual(a, b, msg='foo')
            except self.failureException:
                self.fail('assertEqual(%r, %r) with msg= failed' % (a, b))
            try:
                self.assertEqual(a, b, 'foo')
            except self.failureException:
                self.fail('assertEqual(%r, %r) with third parameter failed' %
                          (a, b))

        unequal_pairs = [
               ((), []),
               ({}, set()),
               (set([4,1]), frozenset([4,2])),
               (frozenset([4,5]), set([2,3])),
               (set([3,4]), set([5,4]))]
        for a, b in unequal_pairs:
            self.assertRaises(self.failureException, self.assertEqual, a, b)
            self.assertRaises(self.failureException, self.assertEqual, a, b,
                              'foo')
            self.assertRaises(self.failureException, self.assertEqual, a, b,
                              msg='foo')

    def testEquality(self):
        self.assertListEqual([], [])
        self.assertTupleEqual((), ())
        self.assertSequenceEqual([], ())

        a = [0, 'a', []]
        b = []
        self.assertRaises(unittest.TestCase.failureException,
                          self.assertListEqual, a, b)
        self.assertRaises(unittest.TestCase.failureException,
                          self.assertListEqual, tuple(a), tuple(b))
        self.assertRaises(unittest.TestCase.failureException,
                          self.assertSequenceEqual, a, tuple(b))

        b.extend(a)
        self.assertListEqual(a, b)
        self.assertTupleEqual(tuple(a), tuple(b))
        self.assertSequenceEqual(a, tuple(b))
        self.assertSequenceEqual(tuple(a), b)

        self.assertRaises(self.failureException, self.assertListEqual,
                          a, tuple(b))
        self.assertRaises(self.failureException, self.assertTupleEqual,
                          tuple(a), b)
        self.assertRaises(self.failureException, self.assertListEqual, None, b)
        self.assertRaises(self.failureException, self.assertTupleEqual, None,
                          tuple(b))
        self.assertRaises(self.failureException, self.assertSequenceEqual,
                          None, tuple(b))
        self.assertRaises(self.failureException, self.assertListEqual, 1, 1)
        self.assertRaises(self.failureException, self.assertTupleEqual, 1, 1)
        self.assertRaises(self.failureException, self.assertSequenceEqual,
                          1, 1)

        self.assertDictEqual({}, {})

        c = { 'x': 1 }
        d = {}
        self.assertRaises(unittest.TestCase.failureException,
                          self.assertDictEqual, c, d)

        d.update(c)
        self.assertDictEqual(c, d)

        d['x'] = 0
        self.assertRaises(unittest.TestCase.failureException,
                          self.assertDictEqual, c, d, 'These are unequal')

        self.assertRaises(self.failureException, self.assertDictEqual, None, d)
        self.assertRaises(self.failureException, self.assertDictEqual, [], d)
        self.assertRaises(self.failureException, self.assertDictEqual, 1, 1)

    def testAssertSequenceEqualMaxDiff(self):
        self.assertEqual(self.maxDiff, 80*8)
        seq1 = 'a' + 'x' * 80**2
        seq2 = 'b' + 'x' * 80**2
        diff = '\n'.join(difflib.ndiff(pprint.pformat(seq1).splitlines(),
                                       pprint.pformat(seq2).splitlines()))
        # the +1 is the leading \n added by assertSequenceEqual
        omitted = unittest.case.DIFF_OMITTED % (len(diff) + 1,)

        self.maxDiff = len(diff)//2
        try:
            self.assertSequenceEqual(seq1, seq2)
        except self.failureException as e:
            msg = e.args[0]
        else:
            self.fail('assertSequenceEqual did not fail.')
        self.assertLess(len(msg), len(diff))
        self.assertIn(omitted, msg)

        self.maxDiff = len(diff) * 2
        try:
            self.assertSequenceEqual(seq1, seq2)
        except self.failureException as e:
            msg = e.args[0]
        else:
            self.fail('assertSequenceEqual did not fail.')
        self.assertGreater(len(msg), len(diff))
        self.assertNotIn(omitted, msg)

        self.maxDiff = None
        try:
            self.assertSequenceEqual(seq1, seq2)
        except self.failureException as e:
            msg = e.args[0]
        else:
            self.fail('assertSequenceEqual did not fail.')
        self.assertGreater(len(msg), len(diff))
        self.assertNotIn(omitted, msg)

    def testTruncateMessage(self):
        self.maxDiff = 1
        message = self._truncateMessage('foo', 'bar')
        omitted = unittest.case.DIFF_OMITTED % len('bar')
        self.assertEqual(message, 'foo' + omitted)

        self.maxDiff = None
        message = self._truncateMessage('foo', 'bar')
        self.assertEqual(message, 'foobar')

        self.maxDiff = 4
        message = self._truncateMessage('foo', 'bar')
        self.assertEqual(message, 'foobar')

    def testAssertDictEqualTruncates(self):
        test = unittest.TestCase('assertEqual')
        def truncate(msg, diff):
            return 'foo'
        test._truncateMessage = truncate
        try:
            test.assertDictEqual({}, {1: 0})
        except self.failureException as e:
            self.assertEqual(str(e), 'foo')
        else:
            self.fail('assertDictEqual did not fail')

    def testAssertMultiLineEqualTruncates(self):
        test = unittest.TestCase('assertEqual')
        def truncate(msg, diff):
            return 'foo'
        test._truncateMessage = truncate
        try:
            test.assertMultiLineEqual('foo', 'bar')
        except self.failureException as e:
            self.assertEqual(str(e), 'foo')
        else:
            self.fail('assertMultiLineEqual did not fail')

    def testAssertEqual_diffThreshold(self):
        # check threshold value
        self.assertEqual(self._diffThreshold, 2**16)
        # disable madDiff to get diff markers
        self.maxDiff = None

        # set a lower threshold value and add a cleanup to restore it
        old_threshold = self._diffThreshold
        self._diffThreshold = 2**8
        self.addCleanup(lambda: setattr(self, '_diffThreshold', old_threshold))

        # under the threshold: diff marker (^) in error message
        s = u'x' * (2**7)
        with self.assertRaises(self.failureException) as cm:
            self.assertEqual(s + 'a', s + 'b')
        self.assertIn('^', str(cm.exception))
        self.assertEqual(s + 'a', s + 'a')

        # over the threshold: diff not used and marker (^) not in error message
        s = u'x' * (2**9)
        # if the path that uses difflib is taken, _truncateMessage will be
        # called -- replace it with explodingTruncation to verify that this
        # doesn't happen
        def explodingTruncation(message, diff):
            raise SystemError('this should not be raised')
        old_truncate = self._truncateMessage
        self._truncateMessage = explodingTruncation
        self.addCleanup(lambda: setattr(self, '_truncateMessage', old_truncate))

        s1, s2 = s + 'a', s + 'b'
        with self.assertRaises(self.failureException) as cm:
            self.assertEqual(s1, s2)
        self.assertNotIn('^', str(cm.exception))
        self.assertEqual(str(cm.exception), '%r != %r' % (s1, s2))
        self.assertEqual(s + 'a', s + 'a')

    def testAssertItemsEqual(self):
        a = object()
        self.assertItemsEqual([1, 2, 3], [3, 2, 1])
        self.assertItemsEqual(['foo', 'bar', 'baz'], ['bar', 'baz', 'foo'])
        self.assertItemsEqual([a, a, 2, 2, 3], (a, 2, 3, a, 2))
        self.assertItemsEqual([1, "2", "a", "a"], ["a", "2", True, "a"])
        self.assertRaises(self.failureException, self.assertItemsEqual,
                          [1, 2] + [3] * 100, [1] * 100 + [2, 3])
        self.assertRaises(self.failureException, self.assertItemsEqual,
                          [1, "2", "a", "a"], ["a", "2", True, 1])
        self.assertRaises(self.failureException, self.assertItemsEqual,
                          [10], [10, 11])
        self.assertRaises(self.failureException, self.assertItemsEqual,
                          [10, 11], [10])
        self.assertRaises(self.failureException, self.assertItemsEqual,
                          [10, 11, 10], [10, 11])

        # Test that sequences of unhashable objects can be tested for sameness:
        self.assertItemsEqual([[1, 2], [3, 4], 0], [False, [3, 4], [1, 2]])
        # Test that iterator of unhashable objects can be tested for sameness:
        self.assertItemsEqual(iter([1, 2, [], 3, 4]),
                              iter([1, 2, [], 3, 4]))

        # hashable types, but not orderable
        self.assertRaises(self.failureException, self.assertItemsEqual,
                          [], [divmod, 'x', 1, 5j, 2j, frozenset()])
        # comparing dicts
        self.assertItemsEqual([{'a': 1}, {'b': 2}], [{'b': 2}, {'a': 1}])
        # comparing heterogenous non-hashable sequences
        self.assertItemsEqual([1, 'x', divmod, []], [divmod, [], 'x', 1])
        self.assertRaises(self.failureException, self.assertItemsEqual,
                          [], [divmod, [], 'x', 1, 5j, 2j, set()])
        self.assertRaises(self.failureException, self.assertItemsEqual,
                          [[1]], [[2]])

        # Same elements, but not same sequence length
        self.assertRaises(self.failureException, self.assertItemsEqual,
                          [1, 1, 2], [2, 1])
        self.assertRaises(self.failureException, self.assertItemsEqual,
                          [1, 1, "2", "a", "a"], ["2", "2", True, "a"])
        self.assertRaises(self.failureException, self.assertItemsEqual,
                          [1, {'b': 2}, None, True], [{'b': 2}, True, None])

        # Same elements which don't reliably compare, in
        # different order, see issue 10242
        a = [{2,4}, {1,2}]
        b = a[::-1]
        self.assertItemsEqual(a, b)

        # test utility functions supporting assertItemsEqual()

        diffs = set(unittest.util._count_diff_all_purpose('aaabccd', 'abbbcce'))
        expected = {(3,1,'a'), (1,3,'b'), (1,0,'d'), (0,1,'e')}
        self.assertEqual(diffs, expected)

        diffs = unittest.util._count_diff_all_purpose([[]], [])
        self.assertEqual(diffs, [(1, 0, [])])

        diffs = set(unittest.util._count_diff_hashable('aaabccd', 'abbbcce'))
        expected = {(3,1,'a'), (1,3,'b'), (1,0,'d'), (0,1,'e')}
        self.assertEqual(diffs, expected)

    def testAssertSetEqual(self):
        set1 = set()
        set2 = set()
        self.assertSetEqual(set1, set2)

        self.assertRaises(self.failureException, self.assertSetEqual, None, set2)
        self.assertRaises(self.failureException, self.assertSetEqual, [], set2)
        self.assertRaises(self.failureException, self.assertSetEqual, set1, None)
        self.assertRaises(self.failureException, self.assertSetEqual, set1, [])

        set1 = set(['a'])
        set2 = set()
        self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)

        set1 = set(['a'])
        set2 = set(['a'])
        self.assertSetEqual(set1, set2)

        set1 = set(['a'])
        set2 = set(['a', 'b'])
        self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)

        set1 = set(['a'])
        set2 = frozenset(['a', 'b'])
        self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)

        set1 = set(['a', 'b'])
        set2 = frozenset(['a', 'b'])
        self.assertSetEqual(set1, set2)

        set1 = set()
        set2 = "foo"
        self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)
        self.assertRaises(self.failureException, self.assertSetEqual, set2, set1)

        # make sure any string formatting is tuple-safe
        set1 = set([(0, 1), (2, 3)])
        set2 = set([(4, 5)])
        self.assertRaises(self.failureException, self.assertSetEqual, set1, set2)

    def testInequality(self):
        # Try ints
        self.assertGreater(2, 1)
        self.assertGreaterEqual(2, 1)
        self.assertGreaterEqual(1, 1)
        self.assertLess(1, 2)
        self.assertLessEqual(1, 2)
        self.assertLessEqual(1, 1)
        self.assertRaises(self.failureException, self.assertGreater, 1, 2)
        self.assertRaises(self.failureException, self.assertGreater, 1, 1)
        self.assertRaises(self.failureException, self.assertGreaterEqual, 1, 2)
        self.assertRaises(self.failureException, self.assertLess, 2, 1)
        self.assertRaises(self.failureException, self.assertLess, 1, 1)
        self.assertRaises(self.failureException, self.assertLessEqual, 2, 1)

        # Try Floats
        self.assertGreater(1.1, 1.0)
        self.assertGreaterEqual(1.1, 1.0)
        self.assertGreaterEqual(1.0, 1.0)
        self.assertLess(1.0, 1.1)
        self.assertLessEqual(1.0, 1.1)
        self.assertLessEqual(1.0, 1.0)
        self.assertRaises(self.failureException, self.assertGreater, 1.0, 1.1)
        self.assertRaises(self.failureException, self.assertGreater, 1.0, 1.0)
        self.assertRaises(self.failureException, self.assertGreaterEqual, 1.0, 1.1)
        self.assertRaises(self.failureException, self.assertLess, 1.1, 1.0)
        self.assertRaises(self.failureException, self.assertLess, 1.0, 1.0)
        self.assertRaises(self.failureException, self.assertLessEqual, 1.1, 1.0)

        # Try Strings
        self.assertGreater('bug', 'ant')
        self.assertGreaterEqual('bug', 'ant')
        self.assertGreaterEqual('ant', 'ant')
        self.assertLess('ant', 'bug')
        self.assertLessEqual('ant', 'bug')
        self.assertLessEqual('ant', 'ant')
        self.assertRaises(self.failureException, self.assertGreater, 'ant', 'bug')
        self.assertRaises(self.failureException, self.assertGreater, 'ant', 'ant')
        self.assertRaises(self.failureException, self.assertGreaterEqual, 'ant', 'bug')
        self.assertRaises(self.failureException, self.assertLess, 'bug', 'ant')
        self.assertRaises(self.failureException, self.assertLess, 'ant', 'ant')
        self.assertRaises(self.failureException, self.assertLessEqual, 'bug', 'ant')

        # Try Unicode
        self.assertGreater(u'bug', u'ant')
        self.assertGreaterEqual(u'bug', u'ant')
        self.assertGreaterEqual(u'ant', u'ant')
        self.assertLess(u'ant', u'bug')
        self.assertLessEqual(u'ant', u'bug')
        self.assertLessEqual(u'ant', u'ant')
        self.assertRaises(self.failureException, self.assertGreater, u'ant', u'bug')
        self.assertRaises(self.failureException, self.assertGreater, u'ant', u'ant')
        self.assertRaises(self.failureException, self.assertGreaterEqual, u'ant',
                          u'bug')
        self.assertRaises(self.failureException, self.assertLess, u'bug', u'ant')
        self.assertRaises(self.failureException, self.assertLess, u'ant', u'ant')
        self.assertRaises(self.failureException, self.assertLessEqual, u'bug', u'ant')

        # Try Mixed String/Unicode
        self.assertGreater('bug', u'ant')
        self.assertGreater(u'bug', 'ant')
        self.assertGreaterEqual('bug', u'ant')
        self.assertGreaterEqual(u'bug', 'ant')
        self.assertGreaterEqual('ant', u'ant')
        self.assertGreaterEqual(u'ant', 'ant')
        self.assertLess('ant', u'bug')
        self.assertLess(u'ant', 'bug')
        self.assertLessEqual('ant', u'bug')
        self.assertLessEqual(u'ant', 'bug')
        self.assertLessEqual('ant', u'ant')
        self.assertLessEqual(u'ant', 'ant')
        self.assertRaises(self.failureException, self.assertGreater, 'ant', u'bug')
        self.assertRaises(self.failureException, self.assertGreater, u'ant', 'bug')
        self.assertRaises(self.failureException, self.assertGreater, 'ant', u'ant')
        self.assertRaises(self.failureException, self.assertGreater, u'ant', 'ant')
        self.assertRaises(self.failureException, self.assertGreaterEqual, 'ant',
                          u'bug')
        self.assertRaises(self.failureException, self.assertGreaterEqual, u'ant',
                          'bug')
        self.assertRaises(self.failureException, self.assertLess, 'bug', u'ant')
        self.assertRaises(self.failureException, self.assertLess, u'bug', 'ant')
        self.assertRaises(self.failureException, self.assertLess, 'ant', u'ant')
        self.assertRaises(self.failureException, self.assertLess, u'ant', 'ant')
        self.assertRaises(self.failureException, self.assertLessEqual, 'bug', u'ant')
        self.assertRaises(self.failureException, self.assertLessEqual, u'bug', 'ant')

    def testAssertMultiLineEqual(self):
        sample_text = b"""\
http://www.python.org/doc/2.3/lib/module-unittest.html
test case
    A test case is the smallest unit of testing. [...]
"""
        revised_sample_text = b"""\
http://www.python.org/doc/2.4.1/lib/module-unittest.html
test case
    A test case is the smallest unit of testing. [...] You may provide your
    own implementation that does not subclass from TestCase, of course.
"""
        sample_text_error = b"""\
- http://www.python.org/doc/2.3/lib/module-unittest.html
?                             ^
+ http://www.python.org/doc/2.4.1/lib/module-unittest.html
?                             ^^^
  test case
-     A test case is the smallest unit of testing. [...]
+     A test case is the smallest unit of testing. [...] You may provide your
?                                                       +++++++++++++++++++++
+     own implementation that does not subclass from TestCase, of course.
"""
        self.maxDiff = None
        for type_changer in (lambda x: x, lambda x: x.decode('utf8')):
            try:
                self.assertMultiLineEqual(type_changer(sample_text),
                                          type_changer(revised_sample_text))
            except self.failureException, e:
                # need to remove the first line of the error message
                error = str(e).encode('utf8').split('\n', 1)[1]

                # assertMultiLineEqual is hooked up as the default for
                # unicode strings - so we can't use it for this check
                self.assertTrue(sample_text_error == error)

    def testAsertEqualSingleLine(self):
        sample_text = u"laden swallows fly slowly"
        revised_sample_text = u"unladen swallows fly quickly"
        sample_text_error = """\
- laden swallows fly slowly
?                    ^^^^
+ unladen swallows fly quickly
? ++                   ^^^^^
"""
        try:
            self.assertEqual(sample_text, revised_sample_text)
        except self.failureException as e:
            error = str(e).split('\n', 1)[1]
            self.assertTrue(sample_text_error == error)

    def testAssertIsNone(self):
        self.assertIsNone(None)
        self.assertRaises(self.failureException, self.assertIsNone, False)
        self.assertIsNotNone('DjZoPloGears on Rails')
        self.assertRaises(self.failureException, self.assertIsNotNone, None)

    def testAssertRegexpMatches(self):
        self.assertRegexpMatches('asdfabasdf', r'ab+')
        self.assertRaises(self.failureException, self.assertRegexpMatches,
                          'saaas', r'aaaa')

    def testAssertRaisesCallable(self):
        class ExceptionMock(Exception):
            pass
        def Stub():
            raise ExceptionMock('We expect')
        self.assertRaises(ExceptionMock, Stub)
        # A tuple of exception classes is accepted
        self.assertRaises((ValueError, ExceptionMock), Stub)
        # *args and **kwargs also work
        self.assertRaises(ValueError, int, '19', base=8)
        # Failure when no exception is raised
        with self.assertRaises(self.failureException):
            self.assertRaises(ExceptionMock, lambda: 0)
        # Failure when another exception is raised
        with self.assertRaises(ExceptionMock):
            self.assertRaises(ValueError, Stub)

    def testAssertRaisesContext(self):
        class ExceptionMock(Exception):
            pass
        def Stub():
            raise ExceptionMock('We expect')
        with self.assertRaises(ExceptionMock):
            Stub()
        # A tuple of exception classes is accepted
        with self.assertRaises((ValueError, ExceptionMock)) as cm:
            Stub()
        # The context manager exposes caught exception
        self.assertIsInstance(cm.exception, ExceptionMock)
        self.assertEqual(cm.exception.args[0], 'We expect')
        # *args and **kwargs also work
        with self.assertRaises(ValueError):
            int('19', base=8)
        # Failure when no exception is raised
        with self.assertRaises(self.failureException):
            with self.assertRaises(ExceptionMock):
                pass
        # Failure when another exception is raised
        with self.assertRaises(ExceptionMock):
            self.assertRaises(ValueError, Stub)

    def testAssertRaisesRegexp(self):
        class ExceptionMock(Exception):
            pass

        def Stub():
            raise ExceptionMock('We expect')

        self.assertRaisesRegexp(ExceptionMock, re.compile('expect$'), Stub)
        self.assertRaisesRegexp(ExceptionMock, 'expect$', Stub)
        self.assertRaisesRegexp(ExceptionMock, u'expect$', Stub)

    def testAssertNotRaisesRegexp(self):
        self.assertRaisesRegexp(
                self.failureException, '^Exception not raised$',
                self.assertRaisesRegexp, Exception, re.compile('x'),
                lambda: None)
        self.assertRaisesRegexp(
                self.failureException, '^Exception not raised$',
                self.assertRaisesRegexp, Exception, 'x',
                lambda: None)
        self.assertRaisesRegexp(
                self.failureException, '^Exception not raised$',
                self.assertRaisesRegexp, Exception, u'x',
                lambda: None)

    def testAssertRaisesRegexpInvalidRegexp(self):
        # Issue 20145.
        class MyExc(Exception):
            pass
        self.assertRaises(TypeError, self.assertRaisesRegexp, MyExc, lambda: True)

    def testAssertRaisesRegexpMismatch(self):
        def Stub():
            raise Exception('Unexpected')

        self.assertRaisesRegexp(
                self.failureException,
                r'"\^Expected\$" does not match "Unexpected"',
                self.assertRaisesRegexp, Exception, '^Expected$',
                Stub)
        self.assertRaisesRegexp(
                self.failureException,
                r'"\^Expected\$" does not match "Unexpected"',
                self.assertRaisesRegexp, Exception, u'^Expected$',
                Stub)
        self.assertRaisesRegexp(
                self.failureException,
                r'"\^Expected\$" does not match "Unexpected"',
                self.assertRaisesRegexp, Exception,
                re.compile('^Expected$'), Stub)

    def testAssertRaisesExcValue(self):
        class ExceptionMock(Exception):
            pass

        def Stub(foo):
            raise ExceptionMock(foo)
        v = "particular value"

        ctx = self.assertRaises(ExceptionMock)
        with ctx:
            Stub(v)
        e = ctx.exception
        self.assertIsInstance(e, ExceptionMock)
        self.assertEqual(e.args[0], v)

    def testSynonymAssertMethodNames(self):
        """Test undocumented method name synonyms.

        Please do not use these methods names in your own code.

        This test confirms their continued existence and functionality
        in order to avoid breaking existing code.
        """
        self.assertNotEquals(3, 5)
        self.assertEquals(3, 3)
        self.assertAlmostEquals(2.0, 2.0)
        self.assertNotAlmostEquals(3.0, 5.0)
        self.assert_(True)

    def testPendingDeprecationMethodNames(self):
        """Test fail* methods pending deprecation, they will warn in 3.2.

        Do not use these methods.  They will go away in 3.3.
        """
        with test_support.check_warnings():
            self.failIfEqual(3, 5)
            self.failUnlessEqual(3, 3)
            self.failUnlessAlmostEqual(2.0, 2.0)
            self.failIfAlmostEqual(3.0, 5.0)
            self.failUnless(True)
            self.failUnlessRaises(TypeError, lambda _: 3.14 + u'spam')
            self.failIf(False)

    def testDeepcopy(self):
        # Issue: 5660
        class TestableTest(unittest.TestCase):
            def testNothing(self):
                pass

        test = TestableTest('testNothing')

        # This shouldn't blow up
        deepcopy(test)

    def testKeyboardInterrupt(self):
        def _raise(self=None):
            raise KeyboardInterrupt
        def nothing(self):
            pass

        class Test1(unittest.TestCase):
            test_something = _raise

        class Test2(unittest.TestCase):
            setUp = _raise
            test_something = nothing

        class Test3(unittest.TestCase):
            test_something = nothing
            tearDown = _raise

        class Test4(unittest.TestCase):
            def test_something(self):
                self.addCleanup(_raise)

        for klass in (Test1, Test2, Test3, Test4):
            with self.assertRaises(KeyboardInterrupt):
                klass('test_something').run()

    def testSystemExit(self):
        def _raise(self=None):
            raise SystemExit
        def nothing(self):
            pass

        class Test1(unittest.TestCase):
            test_something = _raise

        class Test2(unittest.TestCase):
            setUp = _raise
            test_something = nothing

        class Test3(unittest.TestCase):
            test_something = nothing
            tearDown = _raise

        class Test4(unittest.TestCase):
            def test_something(self):
                self.addCleanup(_raise)

        for klass in (Test1, Test2, Test3, Test4):
            result = unittest.TestResult()
            klass('test_something').run(result)
            self.assertEqual(len(result.errors), 1)
            self.assertEqual(result.testsRun, 1)

    def testPickle(self):
        # Issue 10326

        # Can't use TestCase classes defined in Test class as
        # pickle does not work with inner classes
        test = unittest.TestCase('run')
        for protocol in range(pickle.HIGHEST_PROTOCOL + 1):

            # blew up prior to fix
            pickled_test = pickle.dumps(test, protocol=protocol)

            unpickled_test = pickle.loads(pickled_test)
            self.assertEqual(test, unpickled_test)


if __name__ == '__main__':
    unittest.main()
PK��[r�=��
�
test/support.pynu�[���import unittest


class TestHashing(object):
    """Used as a mixin for TestCase"""

    # Check for a valid __hash__ implementation
    def test_hash(self):
        for obj_1, obj_2 in self.eq_pairs:
            try:
                if not hash(obj_1) == hash(obj_2):
                    self.fail("%r and %r do not hash equal" % (obj_1, obj_2))
            except KeyboardInterrupt:
                raise
            except Exception, e:
                self.fail("Problem hashing %r and %r: %s" % (obj_1, obj_2, e))

        for obj_1, obj_2 in self.ne_pairs:
            try:
                if hash(obj_1) == hash(obj_2):
                    self.fail("%s and %s hash equal, but shouldn't" %
                              (obj_1, obj_2))
            except KeyboardInterrupt:
                raise
            except Exception, e:
                self.fail("Problem hashing %s and %s: %s" % (obj_1, obj_2, e))


class TestEquality(object):
    """Used as a mixin for TestCase"""

    # Check for a valid __eq__ implementation
    def test_eq(self):
        for obj_1, obj_2 in self.eq_pairs:
            self.assertEqual(obj_1, obj_2)
            self.assertEqual(obj_2, obj_1)

    # Check for a valid __ne__ implementation
    def test_ne(self):
        for obj_1, obj_2 in self.ne_pairs:
            self.assertNotEqual(obj_1, obj_2)
            self.assertNotEqual(obj_2, obj_1)


class LoggingResult(unittest.TestResult):
    def __init__(self, log):
        self._events = log
        super(LoggingResult, self).__init__()

    def startTest(self, test):
        self._events.append('startTest')
        super(LoggingResult, self).startTest(test)

    def startTestRun(self):
        self._events.append('startTestRun')
        super(LoggingResult, self).startTestRun()

    def stopTest(self, test):
        self._events.append('stopTest')
        super(LoggingResult, self).stopTest(test)

    def stopTestRun(self):
        self._events.append('stopTestRun')
        super(LoggingResult, self).stopTestRun()

    def addFailure(self, *args):
        self._events.append('addFailure')
        super(LoggingResult, self).addFailure(*args)

    def addSuccess(self, *args):
        self._events.append('addSuccess')
        super(LoggingResult, self).addSuccess(*args)

    def addError(self, *args):
        self._events.append('addError')
        super(LoggingResult, self).addError(*args)

    def addSkip(self, *args):
        self._events.append('addSkip')
        super(LoggingResult, self).addSkip(*args)

    def addExpectedFailure(self, *args):
        self._events.append('addExpectedFailure')
        super(LoggingResult, self).addExpectedFailure(*args)

    def addUnexpectedSuccess(self, *args):
        self._events.append('addUnexpectedSuccess')
        super(LoggingResult, self).addUnexpectedSuccess(*args)


class ResultWithNoStartTestRunStopTestRun(object):
    """An object honouring TestResult before startTestRun/stopTestRun."""

    def __init__(self):
        self.failures = []
        self.errors = []
        self.testsRun = 0
        self.skipped = []
        self.expectedFailures = []
        self.unexpectedSuccesses = []
        self.shouldStop = False

    def startTest(self, test):
        pass

    def stopTest(self, test):
        pass

    def addError(self, test):
        pass

    def addFailure(self, test):
        pass

    def addSuccess(self, test):
        pass

    def wasSuccessful(self):
        return True
PK��[�grx�%�%test/test_break.pynu�[���import gc
import os
import sys
import signal
import weakref

from cStringIO import StringIO


import unittest


@unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill")
@unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows")
@unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 "
    "if threads have been used")
class TestBreak(unittest.TestCase):
    int_handler = None

    def setUp(self):
        self._default_handler = signal.getsignal(signal.SIGINT)
        if self.int_handler is not None:
            signal.signal(signal.SIGINT, self.int_handler)

    def tearDown(self):
        signal.signal(signal.SIGINT, self._default_handler)
        unittest.signals._results = weakref.WeakKeyDictionary()
        unittest.signals._interrupt_handler = None


    def testInstallHandler(self):
        default_handler = signal.getsignal(signal.SIGINT)
        unittest.installHandler()
        self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler)

        try:
            pid = os.getpid()
            os.kill(pid, signal.SIGINT)
        except KeyboardInterrupt:
            self.fail("KeyboardInterrupt not handled")

        self.assertTrue(unittest.signals._interrupt_handler.called)

    def testRegisterResult(self):
        result = unittest.TestResult()
        unittest.registerResult(result)

        for ref in unittest.signals._results:
            if ref is result:
                break
            elif ref is not result:
                self.fail("odd object in result set")
        else:
            self.fail("result not found")


    def testInterruptCaught(self):
        default_handler = signal.getsignal(signal.SIGINT)

        result = unittest.TestResult()
        unittest.installHandler()
        unittest.registerResult(result)

        self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler)

        def test(result):
            pid = os.getpid()
            os.kill(pid, signal.SIGINT)
            result.breakCaught = True
            self.assertTrue(result.shouldStop)

        try:
            test(result)
        except KeyboardInterrupt:
            self.fail("KeyboardInterrupt not handled")
        self.assertTrue(result.breakCaught)


    def testSecondInterrupt(self):
        # Can't use skipIf decorator because the signal handler may have
        # been changed after defining this method.
        if signal.getsignal(signal.SIGINT) == signal.SIG_IGN:
            self.skipTest("test requires SIGINT to not be ignored")
        result = unittest.TestResult()
        unittest.installHandler()
        unittest.registerResult(result)

        def test(result):
            pid = os.getpid()
            os.kill(pid, signal.SIGINT)
            result.breakCaught = True
            self.assertTrue(result.shouldStop)
            os.kill(pid, signal.SIGINT)
            self.fail("Second KeyboardInterrupt not raised")

        try:
            test(result)
        except KeyboardInterrupt:
            pass
        else:
            self.fail("Second KeyboardInterrupt not raised")
        self.assertTrue(result.breakCaught)


    def testTwoResults(self):
        unittest.installHandler()

        result = unittest.TestResult()
        unittest.registerResult(result)
        new_handler = signal.getsignal(signal.SIGINT)

        result2 = unittest.TestResult()
        unittest.registerResult(result2)
        self.assertEqual(signal.getsignal(signal.SIGINT), new_handler)

        result3 = unittest.TestResult()

        def test(result):
            pid = os.getpid()
            os.kill(pid, signal.SIGINT)

        try:
            test(result)
        except KeyboardInterrupt:
            self.fail("KeyboardInterrupt not handled")

        self.assertTrue(result.shouldStop)
        self.assertTrue(result2.shouldStop)
        self.assertFalse(result3.shouldStop)


    def testHandlerReplacedButCalled(self):
        # Can't use skipIf decorator because the signal handler may have
        # been changed after defining this method.
        if signal.getsignal(signal.SIGINT) == signal.SIG_IGN:
            self.skipTest("test requires SIGINT to not be ignored")
        # If our handler has been replaced (is no longer installed) but is
        # called by the *new* handler, then it isn't safe to delay the
        # SIGINT and we should immediately delegate to the default handler
        unittest.installHandler()

        handler = signal.getsignal(signal.SIGINT)
        def new_handler(frame, signum):
            handler(frame, signum)
        signal.signal(signal.SIGINT, new_handler)

        try:
            pid = os.getpid()
            os.kill(pid, signal.SIGINT)
        except KeyboardInterrupt:
            pass
        else:
            self.fail("replaced but delegated handler doesn't raise interrupt")

    def testRunner(self):
        # Creating a TextTestRunner with the appropriate argument should
        # register the TextTestResult it creates
        runner = unittest.TextTestRunner(stream=StringIO())

        result = runner.run(unittest.TestSuite())
        self.assertIn(result, unittest.signals._results)

    def testWeakReferences(self):
        # Calling registerResult on a result should not keep it alive
        result = unittest.TestResult()
        unittest.registerResult(result)

        ref = weakref.ref(result)
        del result

        # For non-reference counting implementations
        gc.collect();gc.collect()
        self.assertIsNone(ref())


    def testRemoveResult(self):
        result = unittest.TestResult()
        unittest.registerResult(result)

        unittest.installHandler()
        self.assertTrue(unittest.removeResult(result))

        # Should this raise an error instead?
        self.assertFalse(unittest.removeResult(unittest.TestResult()))

        try:
            pid = os.getpid()
            os.kill(pid, signal.SIGINT)
        except KeyboardInterrupt:
            pass

        self.assertFalse(result.shouldStop)

    def testMainInstallsHandler(self):
        failfast = object()
        test = object()
        verbosity = object()
        result = object()
        default_handler = signal.getsignal(signal.SIGINT)

        class FakeRunner(object):
            initArgs = []
            runArgs = []
            def __init__(self, *args, **kwargs):
                self.initArgs.append((args, kwargs))
            def run(self, test):
                self.runArgs.append(test)
                return result

        class Program(unittest.TestProgram):
            def __init__(self, catchbreak):
                self.exit = False
                self.verbosity = verbosity
                self.failfast = failfast
                self.catchbreak = catchbreak
                self.testRunner = FakeRunner
                self.test = test
                self.result = None

        p = Program(False)
        p.runTests()

        self.assertEqual(FakeRunner.initArgs, [((), {'buffer': None,
                                                     'verbosity': verbosity,
                                                     'failfast': failfast})])
        self.assertEqual(FakeRunner.runArgs, [test])
        self.assertEqual(p.result, result)

        self.assertEqual(signal.getsignal(signal.SIGINT), default_handler)

        FakeRunner.initArgs = []
        FakeRunner.runArgs = []
        p = Program(True)
        p.runTests()

        self.assertEqual(FakeRunner.initArgs, [((), {'buffer': None,
                                                     'verbosity': verbosity,
                                                     'failfast': failfast})])
        self.assertEqual(FakeRunner.runArgs, [test])
        self.assertEqual(p.result, result)

        self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler)

    def testRemoveHandler(self):
        default_handler = signal.getsignal(signal.SIGINT)
        unittest.installHandler()
        unittest.removeHandler()
        self.assertEqual(signal.getsignal(signal.SIGINT), default_handler)

        # check that calling removeHandler multiple times has no ill-effect
        unittest.removeHandler()
        self.assertEqual(signal.getsignal(signal.SIGINT), default_handler)

    def testRemoveHandlerAsDecorator(self):
        default_handler = signal.getsignal(signal.SIGINT)
        unittest.installHandler()

        @unittest.removeHandler
        def test():
            self.assertEqual(signal.getsignal(signal.SIGINT), default_handler)

        test()
        self.assertNotEqual(signal.getsignal(signal.SIGINT), default_handler)

@unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill")
@unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows")
@unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 "
    "if threads have been used")
class TestBreakDefaultIntHandler(TestBreak):
    int_handler = signal.default_int_handler

@unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill")
@unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows")
@unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 "
    "if threads have been used")
class TestBreakSignalIgnored(TestBreak):
    int_handler = signal.SIG_IGN

@unittest.skipUnless(hasattr(os, 'kill'), "Test requires os.kill")
@unittest.skipIf(sys.platform =="win32", "Test cannot run on Windows")
@unittest.skipIf(sys.platform == 'freebsd6', "Test kills regrtest on freebsd6 "
    "if threads have been used")
class TestBreakSignalDefault(TestBreak):
    int_handler = signal.SIG_DFL
PK��[z#���test/__init__.pyonu�[����
{fc@skddlZddlZddlZejje�ZejZd�Z	e
dkrgejdd�ndS(i����NcCs�tj�}xstjt�D]b}|jd�r|jd�rd|d }t|�tj	|}|j
tj|��qqW|S(Nttests.pysunittest.test.i����(
tunittestt	TestSuitetostlistdirtheret
startswithtendswitht
__import__tsystmodulestaddTesttloadertloadTestsFromModule(tsuitetfntmodnametmodule((s./usr/lib64/python2.7/unittest/test/__init__.pyR	s

t__main__tdefaultTestR(RR	Rtpathtdirnamet__file__RtdefaultTestLoaderRRt__name__tmain(((s./usr/lib64/python2.7/unittest/test/__init__.pyt<module>s		PK��[lױœ���test/test_loader.pyonu�[����
|fc@sZddlZddlZddlZdejfd��YZedkrVej�ndS(i����NtTest_TestLoadercBs�eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&d%�Z'd&�Z(d'�Z)d(�Z*d)�Z+d*�Z,d+�Z-d,�Z.d-�Z/d.�Z0d/�Z1d0�Z2d1�Z3d2�Z4d3�Z5d4�Z6d5�Z7d6�Z8d7�Z9d8�Z:d9�Z;d:�Z<d;�Z=d<�Z>d=�Z?d>�Z@d?�ZAd@�ZBdA�ZCdB�ZDdC�ZEdD�ZFdE�ZGdF�ZHdG�ZIRS(HcCscdtjfd��Y}tj|d�|d�g�}tj�}|j|j|�|�dS(NtFoocBs#eZd�Zd�Zd�ZRS(cSsdS(N((tself((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_1tcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_2RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pytfoo_barR(t__name__t
__module__RRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs		RR(tunittesttTestCaset	TestSuitet
TestLoadertassertEqualtloadTestsFromTestCase(RRtteststloader((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_loadTestsFromTestCases!cCsNdtjfd��Y}tj�}tj�}|j|j|�|�dS(NRcBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR R(RRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs(R	R
RRR
R(RRtempty_suiteR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt&test_loadTestsFromTestCase__no_matchesscCs[dtjfd��Y}tj�}y|j|�Wntk
rInX|jd�dS(NtNotATestCasecBseZRS((RR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR1ssShould raise TypeError(R	RRRt	TypeErrortfail(RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt.test_loadTestsFromTestCase__TestSuite_subclass0s
cCs�dtjfd��Y}tj�}|jdj|j��|j|�}|j||j�|j	t
|�|d�g�dS(NRcBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pytrunTestDs(RRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRCsR(R	R
RtassertFalset
startswithttestMethodPrefixRtassertIsInstancet
suiteClassR
tlist(RRRtsuite((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt/test_loadTestsFromTestCase__default_method_nameBscCs�tjd�}dtjfd��Y}||_tj�}|j|�}|j||j�|j|d�g�g}|j	t
|�|�dS(Ntmt
MyTestCasecBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttestYs(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"XsR#(ttypest
ModuleTypeR	R
t
testcase_1RtloadTestsFromModuleRRR
R(RR!R"RRtexpected((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromModule__TestCase_subclassVs	cCsWtjd�}tj�}|j|�}|j||j�|jt|�g�dS(NR!(	R$R%R	RR'RRR
R(RR!RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt/test_loadTestsFromModule__no_TestCase_instancesgs
cCs�tjd�}dtjfd��Y}||_tj�}|j|�}|j||j�|j	t
|�|j�g�dS(NR!R"cBseZRS((RR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"ts(R$R%R	R
R&RR'RRR
R(RR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromModule__no_TestCase_testsrs	cs�dtjfd��Y�dtf�fd��Y}tj�}|j|�}tj�d�g�g}|jt|�|�dS(NR"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#�s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"�st
NotAModulecseZ�ZRS((RRR((R"(s1/usr/lib64/python2.7/unittest/test/test_loader.pyR,�sR#(R	R
tobjectRR'RR
R(RR,RRt	reference((R"s1/usr/lib64/python2.7/unittest/test/test_loader.pyt&test_loadTestsFromModule__not_a_module�scs�tjd�}dtjfd��Y}||_g���fd�}||_tj�}|j|�}�j|tj	��j
�||dg�g�|j|dt�}�j
�g�dS(NR!R"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#�s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"�scs-�j|tj��j|||f�|S(N(RR	Rtextend(RRtpattern(tload_tests_argsR(s1/usr/lib64/python2.7/unittest/test/test_loader.pyt
load_tests�stuse_load_tests(
R$R%R	R
R&R3RR'RRR
tNonetFalse(RR!R"R3RR((R2Rs1/usr/lib64/python2.7/unittest/test/test_loader.pyt$test_loadTestsFromModule__load_tests�s		cCs�tjd�}d�}||_tj�}|j|�}|j|tj�|j|j	�d�t
|�d}|jtd|j
�dS(NR!cSstd��dS(Nssome failure(R(RRR1((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR3�siissome failure(R$R%R3R	RR'RRR
tcountTestCasesRtassertRaisesRegexpRR!(RR!R3RRR#((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromModule__faulty_load_tests�s		cCsZtj�}y|jd�Wn)tk
rH}|jt|�d�nX|jd�dS(NRsEmpty module names7TestLoader.loadTestsFromName failed to raise ValueError(R	RtloadTestsFromNamet
ValueErrorR
tstrR(RRte((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt"test_loadTestsFromName__empty_name�scCsRtj�}y|jd�Wn!tk
r0ntk
r@nX|jd�dS(Ns	abc () //s7TestLoader.loadTestsFromName failed to raise ValueError(R	RR;R<tImportErrorR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt&test_loadTestsFromName__malformed_name�s

cCsZtj�}y|jd�Wn)tk
rH}|jt|�d�nX|jd�dS(NtsdasfasfasdfsNo module named sdasfasfasdfs8TestLoader.loadTestsFromName failed to raise ImportError(R	RR;R@R
R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromName__unknown_module_name�scCsZtj�}y|jd�Wn)tk
rH}|jt|�d�nX|jd�dS(Nsunittest.sdasfasfasdfs/'module' object has no attribute 'sdasfasfasdf's;TestLoader.loadTestsFromName failed to raise AttributeError(R	RR;tAttributeErrorR
R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt)test_loadTestsFromName__unknown_attr_name�scCs]tj�}y|jdt�Wn)tk
rK}|jt|�d�nX|jd�dS(NRBs/'module' object has no attribute 'sdasfasfasdf's;TestLoader.loadTestsFromName failed to raise AttributeError(R	RR;RDR
R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt-test_loadTestsFromName__relative_unknown_name
scCsEtj�}y|jdt�Wntk
r3nX|jd�dS(NRsFailed to raise AttributeError(R	RR;RDR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromName__relative_empty_name"s
cCsUtj�}y|jdt�Wn!tk
r3ntk
rCnX|jd�dS(Ns	abc () //s7TestLoader.loadTestsFromName failed to raise ValueError(R	RR;R<RDR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt/test_loadTestsFromName__relative_malformed_name5s

cs|dtjfd��Y�dtf�fd��Y}tj�}|jd|�}�d�g}|jt|�|�dS(NR"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#Ms(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"LsR,cseZ�ZRS((RRR((R"(s1/usr/lib64/python2.7/unittest/test/test_loader.pyR,PsRR#(R	R
R-RR;R
R(RR,RRR.((R"s1/usr/lib64/python2.7/unittest/test/test_loader.pyt-test_loadTestsFromName__relative_not_a_moduleKscCs`tjd�}t�|_tj�}y|jd|�Wntk
rNnX|jd�dS(NR!R&sShould have raised TypeError(	R$R%R-R&R	RR;RR(RR!R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromName__relative_bad_object`s
cCs�tjd�}dtjfd��Y}||_tj�}|jd|�}|j||j�|j	t
|�|d�g�dS(NR!R"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#qs(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"psR&R#(R$R%R	R
R&RR;RRR
R(RR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt2test_loadTestsFromName__relative_TestCase_subclassns	cCs�tjd�}dtjfd��Y}tj|d�g�|_tj�}|jd|�}|j||j	�|j
t|�|d�g�dS(NR!R"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#�s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"�sR#t	testsuite(R$R%R	R
RRLRR;RRR
R(RR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt*test_loadTestsFromName__relative_TestSuite~scCs�tjd�}dtjfd��Y}||_tj�}|jd|�}|j||j�|j	t
|�|d�g�dS(NR!R"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#�s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"�sstestcase_1.testR#(R$R%R	R
R&RR;RRR
R(RR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromName__relative_testmethod�s	cCs�tjd�}dtjfd��Y}||_tj�}y|jd|�Wn)tk
r|}|jt	|�d�nX|j
d�dS(NR!R"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#�s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"�sstestcase_1.testfoos3type object 'MyTestCase' has no attribute 'testfoo'sFailed to raise AttributeError(R$R%R	R
R&RR;RDR
R=R(RR!R"RR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt3test_loadTestsFromName__relative_invalid_testmethod�s	cs�tjd�}tjd���tjd�����fd�}||_tj�}|jd|�}|j||j�|j	t
|���g�dS(NR!cSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt<lambda>�RcSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRP�Rcstj��g�S(N(R	R((R&t
testcase_2(s1/usr/lib64/python2.7/unittest/test/test_loader.pytreturn_TestSuite�sRR(R$R%R	tFunctionTestCaseRRRR;RRR
R(RR!RRRR((R&RQs1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromName__callable__TestSuite�s	cs�tjd�}tjd����fd�}||_tj�}|jd|�}|j||j�|j	t
|��g�dS(NR!cSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRP�Rcs�S(N(((R&(s1/usr/lib64/python2.7/unittest/test/test_loader.pytreturn_TestCase�sRU(R$R%R	RSRURR;RRR
R(RR!RURR((R&s1/usr/lib64/python2.7/unittest/test/test_loader.pyt3test_loadTestsFromName__callable__TestCase_instance�s	cs�dtjfd��Y}tjd�}tjd����fd�}||_tj�}||_|jd|�}|j	||j�|j
t|��g�dS(NtSubTestSuitecBseZRS((RR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRW�sR!cSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRP�Rcs�S(N(((R&(s1/usr/lib64/python2.7/unittest/test/test_loader.pyRU�sRU(R	RR$R%RSRURRR;RR
R(RRWR!RURR((R&s1/usr/lib64/python2.7/unittest/test/test_loader.pytDtest_loadTestsFromName__callable__TestCase_instance_ProperSuiteClass�s		cCs�dtjfd��Y}tjd�}dtjfd��Y}||_tj�}||_|jd|�}|j	||j�|j
t|�|d�g�dS(NRWcBseZRS((RR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRW�sR!R"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#�s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"�sstestcase_1.testR#(R	RR$R%R
R&RRR;RR
R(RRWR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt<test_loadTestsFromName__relative_testmethod_ProperSuiteClass�s		cCsftjd�}d�}||_tj�}y|jd|�Wntk
rTnX|jd�dS(NR!cSsdS(Ni((((s1/usr/lib64/python2.7/unittest/test/test_loader.pytreturn_wrong�sRZs6TestLoader.loadTestsFromName failed to raise TypeError(R$R%RZR	RR;RR(RR!RZR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromName__callable__wrong_type�s		
cCs�d}tjj|d�tj�}zO|j|�}|j||j�|j	t
|�g�|j|tj�Wd|tjkr�tj|=nXdS(Nsunittest.test.dummy(tsystmodulestpopR5R	RR;RRR
RtassertIn(Rtmodule_nameRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt)test_loadTestsFromName__module_not_loadedscCsHtj�}|jg�}|j||j�|jt|�g�dS(N(R	RtloadTestsFromNamesRRR
R(RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt(test_loadTestsFromNames__empty_name_list)scCsKtj�}|jgt�}|j||j�|jt|�g�dS(N(R	RRbRRR
R(RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt1test_loadTestsFromNames__relative_empty_name_list8scCs]tj�}y|jdg�Wn)tk
rK}|jt|�d�nX|jd�dS(NRsEmpty module names8TestLoader.loadTestsFromNames failed to raise ValueError(R	RRbR<R
R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt#test_loadTestsFromNames__empty_nameEscCsUtj�}y|jdg�Wn!tk
r3ntk
rCnX|jd�dS(Ns	abc () //s8TestLoader.loadTestsFromNames failed to raise ValueError(R	RRbR<R@R(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt'test_loadTestsFromNames__malformed_nameUs

cCs]tj�}y|jdg�Wn)tk
rK}|jt|�d�nX|jd�dS(NRBsNo module named sdasfasfasdfs9TestLoader.loadTestsFromNames failed to raise ImportError(R	RRbR@R
R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromNames__unknown_module_namehscCs`tj�}y|jddg�Wn)tk
rN}|jt|�d�nX|jd�dS(Nsunittest.sdasfasfasdfR	s/'module' object has no attribute 'sdasfasfasdf's<TestLoader.loadTestsFromNames failed to raise AttributeError(R	RRbRDR
R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt*test_loadTestsFromNames__unknown_attr_namexscCs`tj�}y|jdgt�Wn)tk
rN}|jt|�d�nX|jd�dS(NRBs/'module' object has no attribute 'sdasfasfasdf's;TestLoader.loadTestsFromName failed to raise AttributeError(R	RRbRDR
R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt0test_loadTestsFromNames__unknown_name_relative_1�scCsctj�}y|jddgt�Wn)tk
rQ}|jt|�d�nX|jd�dS(NR
RBs/'module' object has no attribute 'sdasfasfasdf's;TestLoader.loadTestsFromName failed to raise AttributeError(R	RRbRDR
R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt0test_loadTestsFromNames__unknown_name_relative_2�scCsHtj�}y|jdgt�Wntk
r6nX|jd�dS(NRsFailed to raise ValueError(R	RRbRDR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromNames__relative_empty_name�s
cCsXtj�}y|jdgt�Wn!tk
r6ntk
rFnX|jd�dS(Ns	abc () //s8TestLoader.loadTestsFromNames failed to raise ValueError(R	RRbRDR<R(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt0test_loadTestsFromNames__relative_malformed_name�s

cs�dtjfd��Y�dtf�fd��Y}tj�}|jdg|�}tj�d�g�g}|jt|�|�dS(NR"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#�s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"�sR,cseZ�ZRS((RRR((R"(s1/usr/lib64/python2.7/unittest/test/test_loader.pyR,�sRR#(R	R
R-RRbRR
R(RR,RRR.((R"s1/usr/lib64/python2.7/unittest/test/test_loader.pyt.test_loadTestsFromNames__relative_not_a_module�scCsctjd�}t�|_tj�}y|jdg|�Wntk
rQnX|jd�dS(NR!R&sShould have raised TypeError(	R$R%R-R&R	RRbRR(RR!R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromNames__relative_bad_object�s
cCs�tjd�}dtjfd��Y}||_tj�}|jdg|�}|j||j�|j|d�g�}|j	t
|�|g�dS(NR!R"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#�s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"�sR&R#(R$R%R	R
R&RRbRRR
R(RR!R"RRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt3test_loadTestsFromNames__relative_TestCase_subclass�s	cCs�tjd�}dtjfd��Y}tj|d�g�|_tj�}|jdg|�}|j||j	�|j
t|�|jg�dS(NR!R"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"sR#RL(R$R%R	R
RRLRRbRRR
R(RR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromNames__relative_TestSuitescCs�tjd�}dtjfd��Y}||_tj�}|jdg|�}|j||j�tj	|d�g�}|j
t|�|g�dS(NR!R"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"sstestcase_1.testR#(R$R%R	R
R&RRbRRRR
R(RR!R"RRt	ref_suite((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromNames__relative_testmethods	cCs�tjd�}dtjfd��Y}||_tj�}y|jdg|�Wn)tk
r}|jt	|�d�nX|j
d�dS(NR!R"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#1s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"0sstestcase_1.testfoos3type object 'MyTestCase' has no attribute 'testfoo'sFailed to raise AttributeError(R$R%R	R
R&RRbRDR
R=R(RR!R"RR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt4test_loadTestsFromNames__relative_invalid_testmethod.s	cs�tjd�}tjd���tjd�����fd�}||_tj�}|jdg|�}|j||j�tj	��g�}|j
t|�|g�dS(NR!cSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRPARcSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRPBRcstj��g�S(N(R	R((R&RQ(s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRCsRR(R$R%R	RSRRRRbRRRR
R(RR!RRRRR(((R&RQs1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromNames__callable__TestSuite?s	cs�tjd�}tjd����fd�}||_tj�}|jdg|�}|j||j�tj	�g�}|j
t|�|g�dS(NR!cSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRPRRcs�S(N(((R&(s1/usr/lib64/python2.7/unittest/test/test_loader.pyRUSsRU(R$R%R	RSRURRbRRRR
R(RR!RURRRq((R&s1/usr/lib64/python2.7/unittest/test/test_loader.pyt4test_loadTestsFromNames__callable__TestCase_instancePs	cs�tjd�}dtjfd��Y}|d��dtjf�fd��Y}||_tj�}|jdg|�}|j||j�tj	�g�}|j
t|�|g�dS(NR!tTest1cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#es(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRvdsR#RcseZe�fd��ZRS(cs�S(N(((R&(s1/usr/lib64/python2.7/unittest/test/test_loader.pytfoojs(RRtstaticmethodRw((R&(s1/usr/lib64/python2.7/unittest/test/test_loader.pyRissFoo.foo(R$R%R	R
RRRbRRRR
R(RR!RvRRRRq((R&s1/usr/lib64/python2.7/unittest/test/test_loader.pyt4test_loadTestsFromNames__callable__call_staticmethodbs	cCsitjd�}d�}||_tj�}y|jdg|�Wntk
rWnX|jd�dS(NR!cSsdS(Ni((((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRZ|sRZs7TestLoader.loadTestsFromNames failed to raise TypeError(R$R%RZR	RRbRR(RR!RZR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt-test_loadTestsFromNames__callable__wrong_typezs		
cCs�d}tjj|d�tj�}z[|j|g�}|j||j�|j	t
|�tj�g�|j|tj�Wd|tjkr�tj|=nXdS(Nsunittest.test.dummy(
R\R]R^R5R	RRbRRR
RRR_(RR`RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt*test_loadTestsFromNames__module_not_loaded�scCsHdtjfd��Y}tj�}|j|j|�ddg�dS(NtTestcBs#eZd�Zd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pytfoobar�R(RRRRR}(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR|�s		RR(R	R
RR
tgetTestCaseNames(RR|R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_getTestCaseNames�scCsBdtjfd��Y}tj�}|j|j|�g�dS(NR|cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR}�R(RRR}(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR|�s(R	R
RR
R~(RR|R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_getTestCaseNames__no_tests�scCsHdtfd��Y}tj�}|j|�}|j|dg�dS(NtBadCasecBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_foo�s(RRR�(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR��sR�(tintR	RR~R
(RR�Rtnames((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt%test_getTestCaseNames__not_a_TestCase�scCsgdtjfd��Y}d|fd��Y}tj�}dddg}|j|j|�|�dS(NtTestPcBs#eZd�Zd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR}�R(RRRRR}(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR��s		tTestCcBseZd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_3�R(RRRR�(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR��s	RRR�(R	R
RR
R~(RR�R�RR�((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt"test_getTestCaseNames__inheritance�s
cCs�dtjfd��Y}tj|d�g�}tj|d�|d�g�}tj�}d|_|j|j|�|�d|_|j|j|�|�dS(NRcBs#eZd�Zd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�R(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�s		RRRRwR#(R	R
RRRR
R(RRttests_1ttests_2R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_testMethodPrefix__loadTestsFromTestCase�s!		cCs�tjd�}dtjfd��Y}||_tj|d�g�g}tj|d�|d�g�g}tj�}d|_|jt	|j
|��|�d|_|jt	|j
|��|�dS(	NR!RcBs#eZd�Zd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR	R(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs		RRRRwR#(R$R%R	R
RRRRR
RR'(RR!RR�R�R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt*test_testMethodPrefix__loadTestsFromModules	$		cCs�tjd�}dtjfd��Y}||_tj|d�g�}tj|d�|d�g�}tj�}d|_|j|j	d|�|�d|_|j|j	d|�|�dS(	NR!RcBs#eZd�Zd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR R(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs		RRRRwR#(
R$R%R	R
RRRRR
R;(RR!RR�R�R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt(test_testMethodPrefix__loadTestsFromNames	!		cCs�tjd�}dtjfd��Y}||_tjtj|d�g�g�}tj|d�|d�g�}tj|g�}tj�}d|_|j|j	dg|�|�d|_|j|j	dg|�|�dS(	NR!RcBs#eZd�Zd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR5RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR6RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR7R(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR4s		RRRRwR#(
R$R%R	R
RRRRR
Rb(RR!RR�R�R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt)test_testMethodPrefix__loadTestsFromNames2s	$!		cCs&tj�}|j|jdk�dS(NR#(R	Rt
assertTrueR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt$test_testMethodPrefix__default_valueFscCsud�}dtjfd��Y}tj�}||_|j|d�|d�g�}|j|j|�|�dS(NcSst||�S(N(tcmp(txty((s1/usr/lib64/python2.7/unittest/test/test_loader.pytreversed_cmpSsRcBseZd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRWRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRXR(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRVs	RR(R	R
RtsortTestMethodsUsingRR
R(RR�RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt0test_sortTestMethodsUsing__loadTestsFromTestCaseRs		!cCs�d�}tjd�}dtjfd��Y}||_tj�}||_|j|d�|d�g�g}|jt	|j
|��|�dS(NcSst||�S(N(R�(R�R�((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�csR!RcBseZd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRhRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRiR(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRgs	RR(R$R%R	R
RRR�RR
RR'(RR�R!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt.test_sortTestMethodsUsing__loadTestsFromModulebs			$cCs�d�}tjd�}dtjfd��Y}||_tj�}||_|j|d�|d�g�}|j|j	d|�|�dS(NcSst||�S(N(R�(R�R�((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�usR!RcBseZd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRzRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR{R(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRys	RR(
R$R%R	R
RRR�RR
R;(RR�R!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_sortTestMethodsUsing__loadTestsFromNamets			!cCs�d�}tjd�}dtjfd��Y}||_tj�}||_|j|d�|d�g�g}|jt	|j
dg|��|�dS(NcSst||�S(N(R�(R�R�((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR��sR!RcBseZd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�R(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�s	RR(R$R%R	R
RRR�RR
RRb(RR�R!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt-test_sortTestMethodsUsing__loadTestsFromNames�s			$cCs`d�}dtjfd��Y}tj�}||_ddg}|j|j|�|�dS(NcSst||�S(N(R�(R�R�((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR��sRcBseZd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�R(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�s	RR(R	R
RR�R
R~(RR�RRt
test_names((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_sortTestMethodsUsing__getTestCaseNames�s		cCs&tj�}|j|jtk�dS(N(R	RR�R�R�(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt(test_sortTestMethodsUsing__default_value�scCscdtjfd��Y}tj�}d|_ddg}|jt|j|��t|��dS(NRcBseZd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�R(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�s	RR(R	R
RR5R�R
tsetR~(RRRR�((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_sortTestMethodsUsing__None�s
	cCscdtjfd��Y}|d�|d�g}tj�}t|_|j|j|�|�dS(NRcBs#eZd�Zd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�R(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�s		RR(R	R
RRRR
R(RRRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt&test_suiteClass__loadTestsFromTestCase�s
	cCs~tjd�}dtjfd��Y}||_|d�|d�gg}tj�}t|_|j|j	|�|�dS(NR!RcBs#eZd�Zd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�R(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�s		RR(
R$R%R	R
RRRRR
R'(RR!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt$test_suiteClass__loadTestsFromModule�s		cCs~tjd�}dtjfd��Y}||_|d�|d�g}tj�}t|_|j|j	d|�|�dS(NR!RcBs#eZd�Zd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�R(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�s		RR(
R$R%R	R
RRRRR
R;(RR!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt"test_suiteClass__loadTestsFromName�s		cCs�tjd�}dtjfd��Y}||_|d�|d�gg}tj�}t|_|j|j	dg|�|�dS(NR!RcBs#eZd�Zd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�R(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�s		RR(
R$R%R	R
RRRRR
Rb(RR!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt#test_suiteClass__loadTestsFromNames�s		cCs&tj�}|j|jtj�dS(N(R	RtassertIsRR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_suiteClass__default_valuescCs�tjd�}dtjfd��Y}||_tj�}|jdg|�}|j||j�tj	|d�g�}|j
t|�|g�dS(NR!R"cBseZd�ZRS(cSsdS(Ni((((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRP
R(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"	sstestcase_1.testR#(R$R%R	R
R&RRbRRRR
R(RR!R"RRRq((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt@test_loadTestsFromName__function_with_different_name_than_methods	(JRRRRRR R)R*R+R/R7R:R?RARCRERFRGRHRIRJRKRMRNRORTRVRXRYR[RaRcRdReRfRgRhRiRjRkRlRmRnRoRpRrRsRtRuRyRzR{RR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs�																															
																				
																				t__main__(R\R$R	R
RRtmain(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt<module>s�����PK��[lױœ���test/test_loader.pycnu�[����
|fc@sZddlZddlZddlZdejfd��YZedkrVej�ndS(i����NtTest_TestLoadercBs�eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&d%�Z'd&�Z(d'�Z)d(�Z*d)�Z+d*�Z,d+�Z-d,�Z.d-�Z/d.�Z0d/�Z1d0�Z2d1�Z3d2�Z4d3�Z5d4�Z6d5�Z7d6�Z8d7�Z9d8�Z:d9�Z;d:�Z<d;�Z=d<�Z>d=�Z?d>�Z@d?�ZAd@�ZBdA�ZCdB�ZDdC�ZEdD�ZFdE�ZGdF�ZHdG�ZIRS(HcCscdtjfd��Y}tj|d�|d�g�}tj�}|j|j|�|�dS(NtFoocBs#eZd�Zd�Zd�ZRS(cSsdS(N((tself((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_1tcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_2RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pytfoo_barR(t__name__t
__module__RRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs		RR(tunittesttTestCaset	TestSuitet
TestLoadertassertEqualtloadTestsFromTestCase(RRtteststloader((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_loadTestsFromTestCases!cCsNdtjfd��Y}tj�}tj�}|j|j|�|�dS(NRcBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR R(RRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs(R	R
RRR
R(RRtempty_suiteR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt&test_loadTestsFromTestCase__no_matchesscCs[dtjfd��Y}tj�}y|j|�Wntk
rInX|jd�dS(NtNotATestCasecBseZRS((RR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR1ssShould raise TypeError(R	RRRt	TypeErrortfail(RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt.test_loadTestsFromTestCase__TestSuite_subclass0s
cCs�dtjfd��Y}tj�}|jdj|j��|j|�}|j||j�|j	t
|�|d�g�dS(NRcBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pytrunTestDs(RRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRCsR(R	R
RtassertFalset
startswithttestMethodPrefixRtassertIsInstancet
suiteClassR
tlist(RRRtsuite((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt/test_loadTestsFromTestCase__default_method_nameBscCs�tjd�}dtjfd��Y}||_tj�}|j|�}|j||j�|j|d�g�g}|j	t
|�|�dS(Ntmt
MyTestCasecBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttestYs(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"XsR#(ttypest
ModuleTypeR	R
t
testcase_1RtloadTestsFromModuleRRR
R(RR!R"RRtexpected((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromModule__TestCase_subclassVs	cCsWtjd�}tj�}|j|�}|j||j�|jt|�g�dS(NR!(	R$R%R	RR'RRR
R(RR!RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt/test_loadTestsFromModule__no_TestCase_instancesgs
cCs�tjd�}dtjfd��Y}||_tj�}|j|�}|j||j�|j	t
|�|j�g�dS(NR!R"cBseZRS((RR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"ts(R$R%R	R
R&RR'RRR
R(RR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromModule__no_TestCase_testsrs	cs�dtjfd��Y�dtf�fd��Y}tj�}|j|�}tj�d�g�g}|jt|�|�dS(NR"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#�s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"�st
NotAModulecseZ�ZRS((RRR((R"(s1/usr/lib64/python2.7/unittest/test/test_loader.pyR,�sR#(R	R
tobjectRR'RR
R(RR,RRt	reference((R"s1/usr/lib64/python2.7/unittest/test/test_loader.pyt&test_loadTestsFromModule__not_a_module�scs�tjd�}dtjfd��Y}||_g���fd�}||_tj�}|j|�}�j|tj	��j
�||dg�g�|j|dt�}�j
�g�dS(NR!R"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#�s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"�scs-�j|tj��j|||f�|S(N(RR	Rtextend(RRtpattern(tload_tests_argsR(s1/usr/lib64/python2.7/unittest/test/test_loader.pyt
load_tests�stuse_load_tests(
R$R%R	R
R&R3RR'RRR
tNonetFalse(RR!R"R3RR((R2Rs1/usr/lib64/python2.7/unittest/test/test_loader.pyt$test_loadTestsFromModule__load_tests�s		cCs�tjd�}d�}||_tj�}|j|�}|j|tj�|j|j	�d�t
|�d}|jtd|j
�dS(NR!cSstd��dS(Nssome failure(R(RRR1((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR3�siissome failure(R$R%R3R	RR'RRR
tcountTestCasesRtassertRaisesRegexpRR!(RR!R3RRR#((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromModule__faulty_load_tests�s		cCsZtj�}y|jd�Wn)tk
rH}|jt|�d�nX|jd�dS(NRsEmpty module names7TestLoader.loadTestsFromName failed to raise ValueError(R	RtloadTestsFromNamet
ValueErrorR
tstrR(RRte((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt"test_loadTestsFromName__empty_name�scCsRtj�}y|jd�Wn!tk
r0ntk
r@nX|jd�dS(Ns	abc () //s7TestLoader.loadTestsFromName failed to raise ValueError(R	RR;R<tImportErrorR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt&test_loadTestsFromName__malformed_name�s

cCsZtj�}y|jd�Wn)tk
rH}|jt|�d�nX|jd�dS(NtsdasfasfasdfsNo module named sdasfasfasdfs8TestLoader.loadTestsFromName failed to raise ImportError(R	RR;R@R
R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromName__unknown_module_name�scCsZtj�}y|jd�Wn)tk
rH}|jt|�d�nX|jd�dS(Nsunittest.sdasfasfasdfs/'module' object has no attribute 'sdasfasfasdf's;TestLoader.loadTestsFromName failed to raise AttributeError(R	RR;tAttributeErrorR
R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt)test_loadTestsFromName__unknown_attr_name�scCs]tj�}y|jdt�Wn)tk
rK}|jt|�d�nX|jd�dS(NRBs/'module' object has no attribute 'sdasfasfasdf's;TestLoader.loadTestsFromName failed to raise AttributeError(R	RR;RDR
R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt-test_loadTestsFromName__relative_unknown_name
scCsEtj�}y|jdt�Wntk
r3nX|jd�dS(NRsFailed to raise AttributeError(R	RR;RDR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromName__relative_empty_name"s
cCsUtj�}y|jdt�Wn!tk
r3ntk
rCnX|jd�dS(Ns	abc () //s7TestLoader.loadTestsFromName failed to raise ValueError(R	RR;R<RDR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt/test_loadTestsFromName__relative_malformed_name5s

cs|dtjfd��Y�dtf�fd��Y}tj�}|jd|�}�d�g}|jt|�|�dS(NR"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#Ms(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"LsR,cseZ�ZRS((RRR((R"(s1/usr/lib64/python2.7/unittest/test/test_loader.pyR,PsRR#(R	R
R-RR;R
R(RR,RRR.((R"s1/usr/lib64/python2.7/unittest/test/test_loader.pyt-test_loadTestsFromName__relative_not_a_moduleKscCs`tjd�}t�|_tj�}y|jd|�Wntk
rNnX|jd�dS(NR!R&sShould have raised TypeError(	R$R%R-R&R	RR;RR(RR!R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromName__relative_bad_object`s
cCs�tjd�}dtjfd��Y}||_tj�}|jd|�}|j||j�|j	t
|�|d�g�dS(NR!R"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#qs(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"psR&R#(R$R%R	R
R&RR;RRR
R(RR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt2test_loadTestsFromName__relative_TestCase_subclassns	cCs�tjd�}dtjfd��Y}tj|d�g�|_tj�}|jd|�}|j||j	�|j
t|�|d�g�dS(NR!R"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#�s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"�sR#t	testsuite(R$R%R	R
RRLRR;RRR
R(RR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt*test_loadTestsFromName__relative_TestSuite~scCs�tjd�}dtjfd��Y}||_tj�}|jd|�}|j||j�|j	t
|�|d�g�dS(NR!R"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#�s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"�sstestcase_1.testR#(R$R%R	R
R&RR;RRR
R(RR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromName__relative_testmethod�s	cCs�tjd�}dtjfd��Y}||_tj�}y|jd|�Wn)tk
r|}|jt	|�d�nX|j
d�dS(NR!R"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#�s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"�sstestcase_1.testfoos3type object 'MyTestCase' has no attribute 'testfoo'sFailed to raise AttributeError(R$R%R	R
R&RR;RDR
R=R(RR!R"RR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt3test_loadTestsFromName__relative_invalid_testmethod�s	cs�tjd�}tjd���tjd�����fd�}||_tj�}|jd|�}|j||j�|j	t
|���g�dS(NR!cSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt<lambda>�RcSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRP�Rcstj��g�S(N(R	R((R&t
testcase_2(s1/usr/lib64/python2.7/unittest/test/test_loader.pytreturn_TestSuite�sRR(R$R%R	tFunctionTestCaseRRRR;RRR
R(RR!RRRR((R&RQs1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromName__callable__TestSuite�s	cs�tjd�}tjd����fd�}||_tj�}|jd|�}|j||j�|j	t
|��g�dS(NR!cSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRP�Rcs�S(N(((R&(s1/usr/lib64/python2.7/unittest/test/test_loader.pytreturn_TestCase�sRU(R$R%R	RSRURR;RRR
R(RR!RURR((R&s1/usr/lib64/python2.7/unittest/test/test_loader.pyt3test_loadTestsFromName__callable__TestCase_instance�s	cs�dtjfd��Y}tjd�}tjd����fd�}||_tj�}||_|jd|�}|j	||j�|j
t|��g�dS(NtSubTestSuitecBseZRS((RR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRW�sR!cSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRP�Rcs�S(N(((R&(s1/usr/lib64/python2.7/unittest/test/test_loader.pyRU�sRU(R	RR$R%RSRURRR;RR
R(RRWR!RURR((R&s1/usr/lib64/python2.7/unittest/test/test_loader.pytDtest_loadTestsFromName__callable__TestCase_instance_ProperSuiteClass�s		cCs�dtjfd��Y}tjd�}dtjfd��Y}||_tj�}||_|jd|�}|j	||j�|j
t|�|d�g�dS(NRWcBseZRS((RR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRW�sR!R"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#�s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"�sstestcase_1.testR#(R	RR$R%R
R&RRR;RR
R(RRWR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt<test_loadTestsFromName__relative_testmethod_ProperSuiteClass�s		cCsftjd�}d�}||_tj�}y|jd|�Wntk
rTnX|jd�dS(NR!cSsdS(Ni((((s1/usr/lib64/python2.7/unittest/test/test_loader.pytreturn_wrong�sRZs6TestLoader.loadTestsFromName failed to raise TypeError(R$R%RZR	RR;RR(RR!RZR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromName__callable__wrong_type�s		
cCs�d}tjj|d�tj�}zO|j|�}|j||j�|j	t
|�g�|j|tj�Wd|tjkr�tj|=nXdS(Nsunittest.test.dummy(tsystmodulestpopR5R	RR;RRR
RtassertIn(Rtmodule_nameRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt)test_loadTestsFromName__module_not_loadedscCsHtj�}|jg�}|j||j�|jt|�g�dS(N(R	RtloadTestsFromNamesRRR
R(RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt(test_loadTestsFromNames__empty_name_list)scCsKtj�}|jgt�}|j||j�|jt|�g�dS(N(R	RRbRRR
R(RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt1test_loadTestsFromNames__relative_empty_name_list8scCs]tj�}y|jdg�Wn)tk
rK}|jt|�d�nX|jd�dS(NRsEmpty module names8TestLoader.loadTestsFromNames failed to raise ValueError(R	RRbR<R
R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt#test_loadTestsFromNames__empty_nameEscCsUtj�}y|jdg�Wn!tk
r3ntk
rCnX|jd�dS(Ns	abc () //s8TestLoader.loadTestsFromNames failed to raise ValueError(R	RRbR<R@R(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt'test_loadTestsFromNames__malformed_nameUs

cCs]tj�}y|jdg�Wn)tk
rK}|jt|�d�nX|jd�dS(NRBsNo module named sdasfasfasdfs9TestLoader.loadTestsFromNames failed to raise ImportError(R	RRbR@R
R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromNames__unknown_module_namehscCs`tj�}y|jddg�Wn)tk
rN}|jt|�d�nX|jd�dS(Nsunittest.sdasfasfasdfR	s/'module' object has no attribute 'sdasfasfasdf's<TestLoader.loadTestsFromNames failed to raise AttributeError(R	RRbRDR
R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt*test_loadTestsFromNames__unknown_attr_namexscCs`tj�}y|jdgt�Wn)tk
rN}|jt|�d�nX|jd�dS(NRBs/'module' object has no attribute 'sdasfasfasdf's;TestLoader.loadTestsFromName failed to raise AttributeError(R	RRbRDR
R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt0test_loadTestsFromNames__unknown_name_relative_1�scCsctj�}y|jddgt�Wn)tk
rQ}|jt|�d�nX|jd�dS(NR
RBs/'module' object has no attribute 'sdasfasfasdf's;TestLoader.loadTestsFromName failed to raise AttributeError(R	RRbRDR
R=R(RRR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt0test_loadTestsFromNames__unknown_name_relative_2�scCsHtj�}y|jdgt�Wntk
r6nX|jd�dS(NRsFailed to raise ValueError(R	RRbRDR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromNames__relative_empty_name�s
cCsXtj�}y|jdgt�Wn!tk
r6ntk
rFnX|jd�dS(Ns	abc () //s8TestLoader.loadTestsFromNames failed to raise ValueError(R	RRbRDR<R(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt0test_loadTestsFromNames__relative_malformed_name�s

cs�dtjfd��Y�dtf�fd��Y}tj�}|jdg|�}tj�d�g�g}|jt|�|�dS(NR"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#�s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"�sR,cseZ�ZRS((RRR((R"(s1/usr/lib64/python2.7/unittest/test/test_loader.pyR,�sRR#(R	R
R-RRbRR
R(RR,RRR.((R"s1/usr/lib64/python2.7/unittest/test/test_loader.pyt.test_loadTestsFromNames__relative_not_a_module�scCsctjd�}t�|_tj�}y|jdg|�Wntk
rQnX|jd�dS(NR!R&sShould have raised TypeError(	R$R%R-R&R	RRbRR(RR!R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromNames__relative_bad_object�s
cCs�tjd�}dtjfd��Y}||_tj�}|jdg|�}|j||j�|j|d�g�}|j	t
|�|g�dS(NR!R"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#�s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"�sR&R#(R$R%R	R
R&RRbRRR
R(RR!R"RRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt3test_loadTestsFromNames__relative_TestCase_subclass�s	cCs�tjd�}dtjfd��Y}tj|d�g�|_tj�}|jdg|�}|j||j	�|j
t|�|jg�dS(NR!R"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"sR#RL(R$R%R	R
RRLRRbRRR
R(RR!R"RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_loadTestsFromNames__relative_TestSuitescCs�tjd�}dtjfd��Y}||_tj�}|jdg|�}|j||j�tj	|d�g�}|j
t|�|g�dS(NR!R"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"sstestcase_1.testR#(R$R%R	R
R&RRbRRRR
R(RR!R"RRt	ref_suite((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromNames__relative_testmethods	cCs�tjd�}dtjfd��Y}||_tj�}y|jdg|�Wn)tk
r}|jt	|�d�nX|j
d�dS(NR!R"cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#1s(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"0sstestcase_1.testfoos3type object 'MyTestCase' has no attribute 'testfoo'sFailed to raise AttributeError(R$R%R	R
R&RRbRDR
R=R(RR!R"RR>((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt4test_loadTestsFromNames__relative_invalid_testmethod.s	cs�tjd�}tjd���tjd�����fd�}||_tj�}|jdg|�}|j||j�tj	��g�}|j
t|�|g�dS(NR!cSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRPARcSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRPBRcstj��g�S(N(R	R((R&RQ(s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRCsRR(R$R%R	RSRRRRbRRRR
R(RR!RRRRR(((R&RQs1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_loadTestsFromNames__callable__TestSuite?s	cs�tjd�}tjd����fd�}||_tj�}|jdg|�}|j||j�tj	�g�}|j
t|�|g�dS(NR!cSsdS(N(R5(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRPRRcs�S(N(((R&(s1/usr/lib64/python2.7/unittest/test/test_loader.pyRUSsRU(R$R%R	RSRURRbRRRR
R(RR!RURRRq((R&s1/usr/lib64/python2.7/unittest/test/test_loader.pyt4test_loadTestsFromNames__callable__TestCase_instancePs	cs�tjd�}dtjfd��Y}|d��dtjf�fd��Y}||_tj�}|jdg|�}|j||j�tj	�g�}|j
t|�|g�dS(NR!tTest1cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR#es(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRvdsR#RcseZe�fd��ZRS(cs�S(N(((R&(s1/usr/lib64/python2.7/unittest/test/test_loader.pytfoojs(RRtstaticmethodRw((R&(s1/usr/lib64/python2.7/unittest/test/test_loader.pyRissFoo.foo(R$R%R	R
RRRbRRRR
R(RR!RvRRRRq((R&s1/usr/lib64/python2.7/unittest/test/test_loader.pyt4test_loadTestsFromNames__callable__call_staticmethodbs	cCsitjd�}d�}||_tj�}y|jdg|�Wntk
rWnX|jd�dS(NR!cSsdS(Ni((((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRZ|sRZs7TestLoader.loadTestsFromNames failed to raise TypeError(R$R%RZR	RRbRR(RR!RZR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt-test_loadTestsFromNames__callable__wrong_typezs		
cCs�d}tjj|d�tj�}z[|j|g�}|j||j�|j	t
|�tj�g�|j|tj�Wd|tjkr�tj|=nXdS(Nsunittest.test.dummy(
R\R]R^R5R	RRbRRR
RRR_(RR`RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt*test_loadTestsFromNames__module_not_loaded�scCsHdtjfd��Y}tj�}|j|j|�ddg�dS(NtTestcBs#eZd�Zd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pytfoobar�R(RRRRR}(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR|�s		RR(R	R
RR
tgetTestCaseNames(RR|R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_getTestCaseNames�scCsBdtjfd��Y}tj�}|j|j|�g�dS(NR|cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR}�R(RRR}(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR|�s(R	R
RR
R~(RR|R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_getTestCaseNames__no_tests�scCsHdtfd��Y}tj�}|j|�}|j|dg�dS(NtBadCasecBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_foo�s(RRR�(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR��sR�(tintR	RR~R
(RR�Rtnames((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt%test_getTestCaseNames__not_a_TestCase�scCsgdtjfd��Y}d|fd��Y}tj�}dddg}|j|j|�|�dS(NtTestPcBs#eZd�Zd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR}�R(RRRRR}(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR��s		tTestCcBseZd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_3�R(RRRR�(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR��s	RRR�(R	R
RR
R~(RR�R�RR�((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt"test_getTestCaseNames__inheritance�s
cCs�dtjfd��Y}tj|d�g�}tj|d�|d�g�}tj�}d|_|j|j|�|�d|_|j|j|�|�dS(NRcBs#eZd�Zd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�R(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�s		RRRRwR#(R	R
RRRR
R(RRttests_1ttests_2R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_testMethodPrefix__loadTestsFromTestCase�s!		cCs�tjd�}dtjfd��Y}||_tj|d�g�g}tj|d�|d�g�g}tj�}d|_|jt	|j
|��|�d|_|jt	|j
|��|�dS(	NR!RcBs#eZd�Zd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR	R(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs		RRRRwR#(R$R%R	R
RRRRR
RR'(RR!RR�R�R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt*test_testMethodPrefix__loadTestsFromModules	$		cCs�tjd�}dtjfd��Y}||_tj|d�g�}tj|d�|d�g�}tj�}d|_|j|j	d|�|�d|_|j|j	d|�|�dS(	NR!RcBs#eZd�Zd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR R(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs		RRRRwR#(
R$R%R	R
RRRRR
R;(RR!RR�R�R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt(test_testMethodPrefix__loadTestsFromNames	!		cCs�tjd�}dtjfd��Y}||_tjtj|d�g�g�}tj|d�|d�g�}tj|g�}tj�}d|_|j|j	dg|�|�d|_|j|j	dg|�|�dS(	NR!RcBs#eZd�Zd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR5RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR6RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR7R(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR4s		RRRRwR#(
R$R%R	R
RRRRR
Rb(RR!RR�R�R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt)test_testMethodPrefix__loadTestsFromNames2s	$!		cCs&tj�}|j|jdk�dS(NR#(R	Rt
assertTrueR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt$test_testMethodPrefix__default_valueFscCsud�}dtjfd��Y}tj�}||_|j|d�|d�g�}|j|j|�|�dS(NcSst||�S(N(tcmp(txty((s1/usr/lib64/python2.7/unittest/test/test_loader.pytreversed_cmpSsRcBseZd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRWRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRXR(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRVs	RR(R	R
RtsortTestMethodsUsingRR
R(RR�RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt0test_sortTestMethodsUsing__loadTestsFromTestCaseRs		!cCs�d�}tjd�}dtjfd��Y}||_tj�}||_|j|d�|d�g�g}|jt	|j
|��|�dS(NcSst||�S(N(R�(R�R�((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�csR!RcBseZd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRhRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRiR(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRgs	RR(R$R%R	R
RRR�RR
RR'(RR�R!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt.test_sortTestMethodsUsing__loadTestsFromModulebs			$cCs�d�}tjd�}dtjfd��Y}||_tj�}||_|j|d�|d�g�}|j|j	d|�|�dS(NcSst||�S(N(R�(R�R�((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�usR!RcBseZd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRzRcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR{R(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRys	RR(
R$R%R	R
RRR�RR
R;(RR�R!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt,test_sortTestMethodsUsing__loadTestsFromNamets			!cCs�d�}tjd�}dtjfd��Y}||_tj�}||_|j|d�|d�g�g}|jt	|j
dg|��|�dS(NcSst||�S(N(R�(R�R�((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR��sR!RcBseZd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�R(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�s	RR(R$R%R	R
RRR�RR
RRb(RR�R!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt-test_sortTestMethodsUsing__loadTestsFromNames�s			$cCs`d�}dtjfd��Y}tj�}||_ddg}|j|j|�|�dS(NcSst||�S(N(R�(R�R�((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR��sRcBseZd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�R(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�s	RR(R	R
RR�R
R~(RR�RRt
test_names((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt+test_sortTestMethodsUsing__getTestCaseNames�s		cCs&tj�}|j|jtk�dS(N(R	RR�R�R�(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt(test_sortTestMethodsUsing__default_value�scCscdtjfd��Y}tj�}d|_ddg}|jt|j|��t|��dS(NRcBseZd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�R(RRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�s	RR(R	R
RR5R�R
tsetR~(RRRR�((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_sortTestMethodsUsing__None�s
	cCscdtjfd��Y}|d�|d�g}tj�}t|_|j|j|�|�dS(NRcBs#eZd�Zd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�R(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�s		RR(R	R
RRRR
R(RRRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt&test_suiteClass__loadTestsFromTestCase�s
	cCs~tjd�}dtjfd��Y}||_|d�|d�gg}tj�}t|_|j|j	|�|�dS(NR!RcBs#eZd�Zd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�R(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�s		RR(
R$R%R	R
RRRRR
R'(RR!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt$test_suiteClass__loadTestsFromModule�s		cCs~tjd�}dtjfd��Y}||_|d�|d�g}tj�}t|_|j|j	d|�|�dS(NR!RcBs#eZd�Zd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�R(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�s		RR(
R$R%R	R
RRRRR
R;(RR!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt"test_suiteClass__loadTestsFromName�s		cCs�tjd�}dtjfd��Y}||_|d�|d�gg}tj�}t|_|j|j	dg|�|�dS(NR!RcBs#eZd�Zd�Zd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�RcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�R(RRRRR(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR�s		RR(
R$R%R	R
RRRRR
Rb(RR!RRR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt#test_suiteClass__loadTestsFromNames�s		cCs&tj�}|j|jtj�dS(N(R	RtassertIsRR(RR((s1/usr/lib64/python2.7/unittest/test/test_loader.pyttest_suiteClass__default_valuescCs�tjd�}dtjfd��Y}||_tj�}|jdg|�}|j||j�tj	|d�g�}|j
t|�|g�dS(NR!R"cBseZd�ZRS(cSsdS(Ni((((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRP
R(RRR#(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyR"	sstestcase_1.testR#(R$R%R	R
R&RRbRRRR
R(RR!R"RRRq((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt@test_loadTestsFromName__function_with_different_name_than_methods	(JRRRRRR R)R*R+R/R7R:R?RARCRERFRGRHRIRJRKRMRNRORTRVRXRYR[RaRcRdReRfRgRhRiRjRkRlRmRnRoRpRrRsRtRuRyRzR{RR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyRs�																															
																				
																				t__main__(R\R$R	R
RRtmain(((s1/usr/lib64/python2.7/unittest/test/test_loader.pyt<module>s�����PK��[�L�����test/test_case.pycnu�[����
{fc@s�ddlZddlZddlZddlZddlZddlmZddlmZddl	Z	ddl
mZmZm
Z
mZdefd��YZde	jeefd��YZed	kr�e	j�ndS(
i����N(tdeepcopy(ttest_support(tTestEqualitytTestHashingt
LoggingResultt#ResultWithNoStartTestRunStopTestRuntTestcBsVeZdZdejfd��YZdefd��YZdejfd��YZRS(s5Keep these TestCase classes out of the main namespacetFoocBseZd�Zd�ZRS(cCsdS(N((tself((s//usr/lib64/python2.7/unittest/test/test_case.pytrunTesttcCsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyttest1R
(t__name__t
__module__R	R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRs	tBarcBseZd�ZRS(cCsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyttest2R
(RR
R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRstLoggingTestCasecBs2eZdZd�Zd�Zd�Zd�ZRS(s!A test case which logs its calls.cCs&ttj|�jd�||_dS(Nttest(tsuperRRt__init__tevents(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyRscCs|jjd�dS(NtsetUp(Rtappend(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR"scCs|jjd�dS(NR(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR%scCs|jjd�dS(NttearDown(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR(s(RR
t__doc__RRRR(((s//usr/lib64/python2.7/unittest/test/test_case.pyRs
			(RR
RtunittesttTestCaseRRR(((s//usr/lib64/python2.7/unittest/test/test_case.pyRst
Test_TestCasecBs�eZejd�ejd�fgZejd�ejd�fejd�ejd�fejd�ejd�fgZd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zejej j!dkd�d��Z"ejej j!dkd�d��Z#d�Z$d�Z%d�Z&d �Z'd!�Z(d"�Z)d#�Z*d$�Z+d%�Z,d&�Z-d'�Z.d(�Z/d)�Z0d*�Z1d+�Z2d,�Z3d-�Z4d.�Z5d/�Z6d0�Z7d1�Z8d2�Z9d3�Z:d4�Z;d5�Z<d6�Z=d7�Z>d8�Z?d9�Z@d:�ZAd;�ZBd<�ZCd=�ZDd>�ZERS(?RR	RcCs:dtjfd��Y}|j|�j�dd�dS(NRcBseZd�Zd�ZRS(cSs
t��dS(N(t	TypeError(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR	HR
cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyRIR
(RR
R	R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRGs	i�s
.Test.runTest(RRtassertEqualtid(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_init__no_test_nameFscCs=dtjfd��Y}|j|d�j�dd�dS(NRcBseZd�Zd�ZRS(cSs
t��dS(N(R(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR	SR
cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyRTR
(RR
R	R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRRs	Ri����s
.Test.test(RRRR(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_init__test_name__validQscCsLdtjfd��Y}y|d�Wntk
r:nX|jd�dS(NRcBseZd�Zd�ZRS(cSs
t��dS(N(R(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR	^R
cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR_R
(RR
R	R(((s//usr/lib64/python2.7/unittest/test/test_case.pyR]s	ttestfoosFailed to raise ValueError(RRt
ValueErrortfail(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_init__test_name__invalid\s
cCs9dtjfd��Y}|j|d�j�d�dS(NRcBseZd�ZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyRlR
(RR
R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRksRi(RRRtcountTestCases(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_countTestCasesjscCsEdtjfd��Y}|�j�}|jt|�tj�dS(NRcBseZd�ZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR	vs(RR
R	(((s//usr/lib64/python2.7/unittest/test/test_case.pyRus(RRtdefaultTestResultRttypet
TestResult(RRtresult((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_defaultTestResulttscsjg}t|�}dtjf�fd��Y��|�j|�ddddg}|j||�dS(NRcseZ�fd�ZRS(cs#t�|�j�td��dS(Nsraised by Foo.setUp(RRtRuntimeError(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�s(RR
R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�st	startTestRtaddErrortstopTest(RRRtrunR(RRR*texpected((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt#test_run_call_order__error_in_setUp�scsag}dtjf�fd��Y��|�j�ddddddg}|j||�dS(	NRcs eZd�Z�fd�ZRS(cSs
t|j�S(N(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR'�scs#t�|�j�td��dS(Nsraised by Foo.setUp(RRR,(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�s(RR
R'R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�s	tstartTestRunR-RR.R/tstopTestRun(RRR0R(RRR1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt2test_run_call_order__error_in_setUp_default_result�scspg}t|�}dtjf�fd��Y�ddddddg}�|�j|�|j||�dS(	NRcseZ�fd�ZRS(cs#t�|�j�td��dS(Nsraised by Foo.test(RRR,(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�s(RR
R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�sR-RRR.RR/(RRRR0R(RRR*R1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt"test_run_call_order__error_in_test�s	csgg}dtjf�fd��Y�ddddddd	d
g}�|�j�|j||�dS(NRcs eZd�Z�fd�ZRS(cSs
t|j�S(N(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR'�scs#t�|�j�td��dS(Nsraised by Foo.test(RRR,(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�s(RR
R'R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�s	R3R-RRR.RR/R4(RRR0R(RRR1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt1test_run_call_order__error_in_test_default_result�scspg}t|�}dtjf�fd��Y�ddddddg}�|�j|�|j||�dS(	NRcseZ�fd�ZRS(cs$t�|�j�|jd�dS(Nsraised by Foo.test(RRR#(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�s(RR
R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�sR-RRt
addFailureRR/(RRRR0R(RRR*R1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt$test_run_call_order__failure_in_test�s	csgdtjf�fd��Y�ddddddd	d
g}g}�|�j�|j||�dS(NRcs eZd�Z�fd�ZRS(cSs
t|j�S(N(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR'�scs$t�|�j�|jd�dS(Nsraised by Foo.test(RRR#(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�s(RR
R'R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�s	R3R-RRR8RR/R4(RRR0R(RR1R((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt3test_run_call_order__failure_in_test_default_result�scspg}t|�}dtjf�fd��Y��|�j|�ddddddg}|j||�dS(	NRcseZ�fd�ZRS(cs#t�|�j�td��dS(Nsraised by Foo.tearDown(RRR,(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�s(RR
R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�sR-RRRR.R/(RRRR0R(RRR*R1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt&test_run_call_order__error_in_tearDown�s	csgdtjf�fd��Y�g}�|�j�ddddddd	d
g}|j||�dS(NRcs eZd�Z�fd�ZRS(cSs
t|j�S(N(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR'scs#t�|�j�td��dS(Nsraised by Foo.tearDown(RRR,(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs(RR
R'R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs	R3R-RRRR.R/R4(RRR0R(RRR1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt5test_run_call_order__error_in_tearDown_default_resultscCs-dtjfd��Y}|d�j�dS(NRcBseZd�Zd�ZRS(cSst�S(N(R(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR'scSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyRs(RR
R'R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRs	R(RRR0(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyt"test_run_call_order_default_resultscCs6dtjfd��Y}|j|d�jt�dS(NRcBseZd�ZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR%s(RR
R(((s//usr/lib64/python2.7/unittest/test/test_case.pyR$sR(RRtassertIstfailureExceptiontAssertionError(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_failureException__default#scCszg}t|�}dtjfd��Y}|j|d�jt�|d�j|�dddg}|j||�dS(NRcBseZd�ZeZRS(cSs
t��dS(N(R,(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR5s(RR
RR,R?(((s//usr/lib64/python2.7/unittest/test/test_case.pyR4s	RR-R8R/(RRRR>R?R,R0R(RRR*RR1((s//usr/lib64/python2.7/unittest/test/test_case.pyt2test_failureException__subclassing__explicit_raise0scCszg}t|�}dtjfd��Y}|j|d�jt�|d�j|�dddg}|j||�dS(NRcBseZd�ZeZRS(cSs|jd�dS(Ntfoo(R#(R((s//usr/lib64/python2.7/unittest/test/test_case.pyRLs(RR
RR,R?(((s//usr/lib64/python2.7/unittest/test/test_case.pyRKs	RR-R8R/(RRRR>R?R,R0R(RRR*RR1((s//usr/lib64/python2.7/unittest/test/test_case.pyt2test_failureException__subclassing__implicit_raiseGscCs*dtjfd��Y}|�j�dS(NRcBseZd�ZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR	[s(RR
R	(((s//usr/lib64/python2.7/unittest/test/test_case.pyRZs(RRR(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyt
test_setUpYscCs*dtjfd��Y}|�j�dS(NRcBseZd�ZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR	ds(RR
R	(((s//usr/lib64/python2.7/unittest/test/test_case.pyRcs(RRR(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyt
test_tearDownbscCs6dtjfd��Y}|j|�j�t�dS(NRcBseZd�ZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR	rs(RR
R	(((s//usr/lib64/python2.7/unittest/test/test_case.pyRqs(RRtassertIsInstanceRt
basestring(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_idpscsag�dtjf�fd��Y}|d�j�ddddddg}|j�|�dS(	NRcs&eZ�fd�Z�fd�ZRS(cs�jd�dS(NR(R(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRscs
t��S(N(R(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyR'�s(RR
RR'((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR~sRR3R-t
addSuccessR/R4(RRR0R(RRR1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt test_run__uses_defaultTestResult{scCs|j|j��dS(N(tassertIsNonetshortDescription(R((s//usr/lib64/python2.7/unittest/test/test_case.pyt$testShortDescriptionWithoutDocstring�sis)Docstrings are omitted with -O2 and abovecCs|j|j�d�dS(s7Tests shortDescription() for a method with a docstring.N(RRM(R((s//usr/lib64/python2.7/unittest/test/test_case.pyt(testShortDescriptionWithOneLineDocstring�s	cCs|j|j�d�dS(s�Tests shortDescription() for a method with a longer docstring.

        This method ensures that only the first line of a docstring is
        returned used in the short description, no matter how long the
        whole thing is.
        s>Tests shortDescription() for a method with a longer docstring.N(RRM(R((s//usr/lib64/python2.7/unittest/test/test_case.pyt*testShortDescriptionWithMultiLineDocstring�s		csodtfd��Y�����}}|j||�d�fd�}|j�|�|j||�dS(NtSadSnakecBseZdZRS(s)Dummy class for test_addTypeEqualityFunc.(RR
R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRQ�scs$t|�t|�ko!�kSS(N(R((tatbtmsg(RQ(s//usr/lib64/python2.7/unittest/test/test_case.pytAllSnakesCreatedEqual�s(tobjecttassertNotEqualtNonetaddTypeEqualityFuncR(Rts1ts2RU((RQs//usr/lib64/python2.7/unittest/test/test_case.pyttestAddTypeEqualityFunc�scCs<t�}|j||�|j|j|j|t��dS(N(RVR>tassertRaisesR?(Rtthing((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertIs�s	cCs<t�}|j|t��|j|j|j||�dS(N(RVtassertIsNotR]R?(RR^((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertIsNot�s	cCs6g}|j|t�|j|j|j|t�dS(N(RGtlistR]R?tdict(RR^((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertIsInstance�scCs6g}|j|t�|j|j|j|t�dS(N(tassertNotIsInstanceRcR]R?Rb(RR^((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertNotIsInstance�scCsKidd6dd6dd6}|jdd�|jd	d
d	dg�|jd|�|jdd�|jd
d
d	dg�|jd|�|j|j|jdd�|j|j|jdd
d	dg�|j|j|jd|�|j|j|jdd�|j|j|jd
d
d	dg�|j|j|jd|�dS(NtbananatmonkeytgrasstcowtfishtsealRRtabciiitditottertxitelephanttc(tassertIntassertNotInR]R?(Rtanimals((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertIn�s%%cCs&|jii�|jiidd6�|jidd6idd6�|jidd6idd6dd6�|jidd6dd6idd6dd6�|j|j��|jidd6i�WdQX|j|j��#|jidd6idd6�WdQX|j|j��#|jidd6idd6�WdQX|j|j��*|jidd6dd6idd6�WdQX|j|j��*|jidd6dd6idd6�WdQXtjdtf��[djd�td	�D��}|j|j��#|ji|d
6idd
6�WdQXWdQXdS(NiRRiRStoneRrR
css|]}t|�VqdS(N(tchr(t.0ti((s//usr/lib64/python2.7/unittest/test/test_case.pys	<genexpr>�si�RCu�(tassertDictContainsSubsetR]R?Rtcheck_warningstUnicodeWarningtjointrange(RRw((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertDictContainsSubset�s&%,$$++cCsddfiifggft�t�ft�t�fg}x�|D]�\}}y|j||�Wn+|jk
r�|jd||f�nXy|j||dd�Wn+|jk
r�|jd||f�nXy|j||d�WqF|jk
r |jd||f�qFXqFWd
gfit�ftddg�tddg�ftdd	g�tdd
g�ftd
dg�td	dg�fg}xq|D]i\}}|j|j|j||�|j|j|j||d�|j|j|j||dd�q�WdS(NsassertEqual(%r, %r) failedRTRCs$assertEqual(%r, %r) with msg= faileds/assertEqual(%r, %r) with third parameter failediiiii((((tsett	frozensetRR?R#R](Rtequal_pairsRRRSt
unequal_pairs((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertEqual�s<					!!'cCs�|jgg�|jdd�|jgd�ddgg}g}|jtjj|j||�|jtjj|jt|�t|��|jtjj|j|t|��|j|�|j||�|jt|�t|��|j|t|��|jt|�|�|j|j|j|t|��|j|j|jt|�|�|j|j|jd|�|j|j|jdt|��|j|j|jdt|��|j|j|jdd�|j|j|jdd�|j|j|jdd�|j
ii�idd6}i}|jtjj|j
||�|j|�|j
||�d|d<|jtjj|j
||d�|j|j|j
d|�|j|j|j
g|�|j|j|j
dd�dS(	NiRRiRpsThese are unequal((((tassertListEqualtassertTupleEqualtassertSequenceEqualR]RRR?ttupletextendRXtassertDictEqualtupdate(RRRRSRrRn((s//usr/lib64/python2.7/unittest/test/test_case.pyttestEqualitysT





cCs|j|jd�ddd}ddd
}djtjtj|�j�tj|�j���}tj	j
t|�df}t|�d|_y|j||�Wn#|j
k
r�}|jd	}nX|jd
�|jt|�t|��|j||�t|�d|_y|j||�Wn#|j
k
rW}|jd	}nX|jd
�|jt|�t|��|j||�d|_y|j||�Wn#|j
k
r�}|jd	}nX|jd
�|jt|�t|��|j||�dS(NiPiRRRpiRSs
iis!assertSequenceEqual did not fail.i�ii(RtmaxDiffR~tdifflibtndifftpprinttpformatt
splitlinesRtcasetDIFF_OMITTEDtlenR�R?targsR#t
assertLessRst
assertGreaterRtRX(Rtseq1tseq2tdifftomittedteRT((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertSequenceEqualMaxDiffRs<

	
cCs�d|_|jdd�}tjjtd�}|j|d|�d|_|jdd�}|j|d�d|_|jdd�}|j|d�dS(NiRCtbartfoobari(R�t_truncateMessageRR�R�R�RRX(RtmessageR�((s//usr/lib64/python2.7/unittest/test/test_case.pyttestTruncateMessageys			cCs|tjd�}d�}||_y|jiidd6�Wn,|jk
rj}|jt|�d�nX|jd�dS(NRcSsdS(NRC((RTR�((s//usr/lib64/python2.7/unittest/test/test_case.pyttruncate�siiRCsassertDictEqual did not fail(RRR�R�R?RtstrR#(RRR�R�((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertDictEqualTruncates�s		cCsutjd�}d�}||_y|jdd�Wn,|jk
rc}|jt|�d�nX|jd�dS(NRcSsdS(NRC((RTR�((s//usr/lib64/python2.7/unittest/test/test_case.pyR��sRCR�s!assertMultiLineEqual did not fail(RRR�tassertMultiLineEqualR?RR�R#(RRR�R�((s//usr/lib64/python2.7/unittest/test/test_case.pyt!testAssertMultiLineEqualTruncates�s		cs��j�jd�d�_�j�d�_�j��fd��dd}�j�j��}�j|d|d�WdQX�jd	t|j	���j|d|d�dd}d�}�j
�|�_
�j��fd��|d|d}}�j�j��}�j||�WdQX�jd	t|j	���jt|j	�d
||f��j|d|d�dS(Niiicst�d��S(Nt_diffThreshold(tsetattr((t
old_thresholdR(s//usr/lib64/python2.7/unittest/test/test_case.pyt<lambda>�R
uxiRRRSt^i	cSstd��dS(Nsthis should not be raised(tSystemError(R�R�((s//usr/lib64/python2.7/unittest/test/test_case.pytexplodingTruncation�scst�d��S(NR�(R�((told_truncateR(s//usr/lib64/python2.7/unittest/test/test_case.pyR��R
s%r != %riii�i(RR�RXR�t
addCleanupR]R?RsR�t	exceptionR�Rt(RtstcmR�RZR[((R�R�Rs//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertEqual_diffThreshold�s*			

			#cCsyt�}|jdddgdddg�|jdddgdddg�|j||dddg|dd|df�|jddddgddtdg�|j|j|jddgdgd	dgd	ddg�|j|j|jddddgddtdg�|j|j|jd
gd
dg�|j|j|jd
dgd
g�|j|j|jd
dd
gd
dg�|jddgddgd
gtddgddgg�|jtddgddg�tddgddg��|j|j|jgtddddt�g�|jidd6idd6gidd6idd6g�|jddtggtgddg�|j|j|jgtgddddt	�g�|j|j|jdggdgg�|j|j|jdddgddg�|j|j|jdddddgddtdg�|j|j|jdidd6dtgidd6tdg�ddhddhg}|ddd�}|j||�t	tjj
dd��}ddddh}|j||�tjj
ggg�}|j|dd
gfg�t	tjjdd��}ddddh}|j||�dS(NiiiRCR�tbazt2RRidi
iiiRpy@y@RSi����taaabccdtabbbcceRnR�(iiRR(iiRS(iiRn(iiR�(iiRR(iiRS(iiRn(iiR�(RVtassertItemsEqualtTrueR]R?tFalsetitertdivmodR�R�RXRtutilt_count_diff_all_purposeRt_count_diff_hashable(RRRRStdiffsR1((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertItemsEqual�sV	"".(,":8("%-cCs*t�}t�}|j||�|j|j|jd|�|j|j|jg|�|j|j|j|d�|j|j|j|g�tdg�}t�}|j|j|j||�tdg�}tdg�}|j||�tdg�}tddg�}|j|j|j||�tdg�}tddg�}|j|j|j||�tddg�}tddg�}|j||�t�}d}|j|j|j||�|j|j|j||�td
dg�}tdg�}|j|j|j||�dS(
NRRRSRCiiiiii(ii(ii(ii(R�tassertSetEqualR]R?RXR�(Rtset1tset2((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertSetEquals:				cCs4|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�dS(	Niig�������?g�?tbugtantubuguant(R�tassertGreaterEqualR�tassertLessEqualR]R?(R((s//usr/lib64/python2.7/unittest/test/test_case.pyttestInequality)s�cCs�d}d}d}d|_x�d�d�fD]w}y |j||�||��Wq.|jk
r�}t|�jd�jdd�d}|j||k�q.Xq.WdS(	Nsxhttp://www.python.org/doc/2.3/lib/module-unittest.html
test case
    A test case is the smallest unit of testing. [...]
s�http://www.python.org/doc/2.4.1/lib/module-unittest.html
test case
    A test case is the smallest unit of testing. [...] You may provide your
    own implementation that does not subclass from TestCase, of course.
s�- http://www.python.org/doc/2.3/lib/module-unittest.html
?                             ^
+ http://www.python.org/doc/2.4.1/lib/module-unittest.html
?                             ^^^
  test case
-     A test case is the smallest unit of testing. [...]
+     A test case is the smallest unit of testing. [...] You may provide your
?                                                       +++++++++++++++++++++
+     own implementation that does not subclass from TestCase, of course.
cSs|S(N((Rp((s//usr/lib64/python2.7/unittest/test/test_case.pyR��R
cSs
|jd�S(Ntutf8(tdecode(Rp((s//usr/lib64/python2.7/unittest/test/test_case.pyR��R
R�s
i(RXR�R�R?R�tencodetsplitt
assertTrue(Rtsample_texttrevised_sample_texttsample_text_errorttype_changerR�terror((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertMultiLineEquals	%cCsrd}d}d}y|j||�WnE|jk
rm}t|�jdd�d}|j||k�nXdS(Nuladen swallows fly slowlyuunladen swallows fly quicklysr- laden swallows fly slowly
?                    ^^^^
+ unladen swallows fly quickly
? ++                   ^^^^^
s
i(RR?R�R�R�(RR�R�R�R�R�((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAsertEqualSingleLine�scCsP|jd�|j|j|jt�|jd�|j|j|jd�dS(NsDjZoPloGears on Rails(RLRXR]R?R�tassertIsNotNone(R((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertIsNone�s

cCs0|jdd�|j|j|jdd�dS(Nt
asdfabasdfsab+tsaaastaaaa(tassertRegexpMatchesR]R?(R((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRegexpMatches�scs�dtfd��Y��fd�}|j�|�|jt�f|�|jttddd�|j|j��|j�d��WdQX|j���|jt|�WdQXdS(Nt
ExceptionMockcBseZRS((RR
(((s//usr/lib64/python2.7/unittest/test/test_case.pyR��scs�d��dS(Ns	We expect(((R�(s//usr/lib64/python2.7/unittest/test/test_case.pytStub�st19tbaseicSsdS(Ni((((s//usr/lib64/python2.7/unittest/test/test_case.pyR��R
(t	ExceptionR]R"tintR?(RR�((R�s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRaisesCallable�scsdtfd��Y��fd�}|j���|�WdQX|jt�f��}|�WdQX|j|j��|j|jjdd�|jt��tddd�WdQX|j|j��|j���WdQXWdQX|j���|jt|�WdQXdS(	NR�cBseZRS((RR
(((s//usr/lib64/python2.7/unittest/test/test_case.pyR��scs�d��dS(Ns	We expect(((R�(s//usr/lib64/python2.7/unittest/test/test_case.pyR��sis	We expectR�R�i(	R�R]R"RGR�RR�R�R?(RR�R�((R�s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRaisesContext�s

cskdtfd��Y��fd�}|j�tjd�|�|j�d|�|j�d|�dS(NR�cBseZRS((RR
(((s//usr/lib64/python2.7/unittest/test/test_case.pyR��scs�d��dS(Ns	We expect(((R�(s//usr/lib64/python2.7/unittest/test/test_case.pyR��ssexpect$uexpect$(R�tassertRaisesRegexptretcompile(RR�((R�s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRaisesRegexp�s
cCs||j|jd|jttjd�d��|j|jd|jtdd��|j|jd|jtdd��dS(Ns^Exception not raised$RpcSsdS(N(RX(((s//usr/lib64/python2.7/unittest/test/test_case.pyR��R
cSsdS(N(RX(((s//usr/lib64/python2.7/unittest/test/test_case.pyR��R
uxcSsdS(N(RX(((s//usr/lib64/python2.7/unittest/test/test_case.pyR��R
(R�R?R�R�R�(R((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertNotRaisesRegexp�s	
	
	cCs6dtfd��Y}|jt|j|d��dS(NtMyExccBseZRS((RR
(((s//usr/lib64/python2.7/unittest/test/test_case.pyR�scSstS(N(R�(((s//usr/lib64/python2.7/unittest/test/test_case.pyR�R
(R�R]RR�(RR�((s//usr/lib64/python2.7/unittest/test/test_case.pyt#testAssertRaisesRegexpInvalidRegexp�scCs|d�}|j|jd|jtd|�|j|jd|jtd|�|j|jd|jttjd�|�dS(NcSstd��dS(Nt
Unexpected(R�(((s//usr/lib64/python2.7/unittest/test/test_case.pyR�ss*"\^Expected\$" does not match "Unexpected"s
^Expected$u
^Expected$(R�R?R�R�R�(RR�((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRaisesRegexpMismatchs 		cs�dtfd��Y��fd�}d}|j��}|�||�WdQX|j}|j|��|j|jd|�dS(NR�cBseZRS((RR
(((s//usr/lib64/python2.7/unittest/test/test_case.pyR�scs�|��dS(N((RC(R�(s//usr/lib64/python2.7/unittest/test/test_case.pyR�ssparticular valuei(R�R]R�RGRR�(RR�tvtctxR�((R�s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRaisesExcValues	cCsQ|jdd�|jdd�|jdd�|jdd�|jt�dS(s�Test undocumented method name synonyms.

        Please do not use these methods names in your own code.

        This test confirms their continued existence and functionality
        in order to avoid breaking existing code.
        iig@g@g@N(tassertNotEqualstassertEqualstassertAlmostEqualstassertNotAlmostEqualstassert_R�(R((s//usr/lib64/python2.7/unittest/test/test_case.pyttestSynonymAssertMethodNames(s
cCs�tj��r|jdd�|jdd�|jdd�|jdd�|jt�|jt	d��|j
t�WdQXdS(s�Test fail* methods pending deprecation, they will warn in 3.2.

        Do not use these methods.  They will go away in 3.3.
        iig@g@g@cSsddS(Ng��Q�	@uspam((t_((s//usr/lib64/python2.7/unittest/test/test_case.pyR�AR
N(RR|tfailIfEqualtfailUnlessEqualtfailUnlessAlmostEqualtfailIfAlmostEqualt
failUnlessR�tfailUnlessRaisesRtfailIfR�(R((s//usr/lib64/python2.7/unittest/test/test_case.pyt!testPendingDeprecationMethodNames6s

cCs3dtjfd��Y}|d�}t|�dS(NtTestableTestcBseZd�ZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyttestNothingGs(RR
R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRFsR(RRR(RRR((s//usr/lib64/python2.7/unittest/test/test_case.pyttestDeepcopyDscs�dd��d��dtjf�fd��Y}dtjf��fd��Y}dtjf��fd��Y}d	tjf�fd
��Y}x@||||fD],}|jt��|d�j�WdQXq�WdS(NcSs
t�dS(N(tKeyboardInterrupt(R((s//usr/lib64/python2.7/unittest/test/test_case.pyt_raisePscSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pytnothingRstTest1cseZ�ZRS((RR
ttest_something((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR
UstTest2cseZ�Z�ZRS((RR
RR((RR	(s//usr/lib64/python2.7/unittest/test/test_case.pyRXstTest3cseZ�Z�ZRS((RR
RR((RR	(s//usr/lib64/python2.7/unittest/test/test_case.pyR
\stTest4cseZ�fd�ZRS(cs|j��dS(N(R�(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRas(RR
R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR`sR(RXRRR]RR0(RR
RR
Rtklass((RR	s//usr/lib64/python2.7/unittest/test/test_case.pyttestKeyboardInterruptOs	""csdd��d��dtjf�fd��Y}dtjf��fd��Y}dtjf��fd��Y}d	tjf�fd
��Y}xe||||fD]Q}tj�}|d�j|�|jt|j�d�|j|jd�q�WdS(
NcSs
t�dS(N(t
SystemExit(R((s//usr/lib64/python2.7/unittest/test/test_case.pyRiscSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR	ksR
cseZ�ZRS((RR
R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR
nsRcseZ�Z�ZRS((RR
RR((RR	(s//usr/lib64/python2.7/unittest/test/test_case.pyRqsR
cseZ�Z�ZRS((RR
RR((RR	(s//usr/lib64/python2.7/unittest/test/test_case.pyR
usRcseZ�fd�ZRS(cs|j��dS(N(R�(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRzs(RR
R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRysRi(	RXRRR)R0RR�terrorsttestsRun(RR
RR
RRR*((RR	s//usr/lib64/python2.7/unittest/test/test_case.pyttestSystemExiths	""cCsetjd�}xOttjd�D]:}tj|d|�}tj|�}|j||�q#WdS(NR0itprotocol(RRRtpickletHIGHEST_PROTOCOLtdumpstloadsR(RRRtpickled_testtunpickled_test((s//usr/lib64/python2.7/unittest/test/test_case.pyt
testPickle�s
(FRR
RRteq_pairsRtne_pairsRR R$R&R+R2R5R6R7R9R:R;R<R=RARBRDRERFRIRKRNRtskipIftsystflagstoptimizeRORPR\R_RaRdRfRvR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�RRRRR(((s//usr/lib64/python2.7/unittest/test/test_case.pyR,s�!!				
											
								
	
							%	4	'				$	>	(	V	$															t__main__(R�R�RR�R tcopyRRRRtunittest.test.supportRRRRRVRRRRtmain(((s//usr/lib64/python2.7/unittest/test/test_case.pyt<module>s "����jPK��[�L�����test/test_case.pyonu�[����
{fc@s�ddlZddlZddlZddlZddlZddlmZddlmZddl	Z	ddl
mZmZm
Z
mZdefd��YZde	jeefd��YZed	kr�e	j�ndS(
i����N(tdeepcopy(ttest_support(tTestEqualitytTestHashingt
LoggingResultt#ResultWithNoStartTestRunStopTestRuntTestcBsVeZdZdejfd��YZdefd��YZdejfd��YZRS(s5Keep these TestCase classes out of the main namespacetFoocBseZd�Zd�ZRS(cCsdS(N((tself((s//usr/lib64/python2.7/unittest/test/test_case.pytrunTesttcCsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyttest1R
(t__name__t
__module__R	R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRs	tBarcBseZd�ZRS(cCsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyttest2R
(RR
R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRstLoggingTestCasecBs2eZdZd�Zd�Zd�Zd�ZRS(s!A test case which logs its calls.cCs&ttj|�jd�||_dS(Nttest(tsuperRRt__init__tevents(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyRscCs|jjd�dS(NtsetUp(Rtappend(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR"scCs|jjd�dS(NR(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR%scCs|jjd�dS(NttearDown(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR(s(RR
t__doc__RRRR(((s//usr/lib64/python2.7/unittest/test/test_case.pyRs
			(RR
RtunittesttTestCaseRRR(((s//usr/lib64/python2.7/unittest/test/test_case.pyRst
Test_TestCasecBs�eZejd�ejd�fgZejd�ejd�fejd�ejd�fejd�ejd�fgZd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zejej j!dkd�d��Z"ejej j!dkd�d��Z#d�Z$d�Z%d�Z&d �Z'd!�Z(d"�Z)d#�Z*d$�Z+d%�Z,d&�Z-d'�Z.d(�Z/d)�Z0d*�Z1d+�Z2d,�Z3d-�Z4d.�Z5d/�Z6d0�Z7d1�Z8d2�Z9d3�Z:d4�Z;d5�Z<d6�Z=d7�Z>d8�Z?d9�Z@d:�ZAd;�ZBd<�ZCd=�ZDd>�ZERS(?RR	RcCs:dtjfd��Y}|j|�j�dd�dS(NRcBseZd�Zd�ZRS(cSs
t��dS(N(t	TypeError(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR	HR
cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyRIR
(RR
R	R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRGs	i�s
.Test.runTest(RRtassertEqualtid(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_init__no_test_nameFscCs=dtjfd��Y}|j|d�j�dd�dS(NRcBseZd�Zd�ZRS(cSs
t��dS(N(R(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR	SR
cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyRTR
(RR
R	R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRRs	Ri����s
.Test.test(RRRR(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_init__test_name__validQscCsLdtjfd��Y}y|d�Wntk
r:nX|jd�dS(NRcBseZd�Zd�ZRS(cSs
t��dS(N(R(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR	^R
cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR_R
(RR
R	R(((s//usr/lib64/python2.7/unittest/test/test_case.pyR]s	ttestfoosFailed to raise ValueError(RRt
ValueErrortfail(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_init__test_name__invalid\s
cCs9dtjfd��Y}|j|d�j�d�dS(NRcBseZd�ZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyRlR
(RR
R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRksRi(RRRtcountTestCases(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_countTestCasesjscCsEdtjfd��Y}|�j�}|jt|�tj�dS(NRcBseZd�ZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR	vs(RR
R	(((s//usr/lib64/python2.7/unittest/test/test_case.pyRus(RRtdefaultTestResultRttypet
TestResult(RRtresult((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_defaultTestResulttscsjg}t|�}dtjf�fd��Y��|�j|�ddddg}|j||�dS(NRcseZ�fd�ZRS(cs#t�|�j�td��dS(Nsraised by Foo.setUp(RRtRuntimeError(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�s(RR
R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�st	startTestRtaddErrortstopTest(RRRtrunR(RRR*texpected((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt#test_run_call_order__error_in_setUp�scsag}dtjf�fd��Y��|�j�ddddddg}|j||�dS(	NRcs eZd�Z�fd�ZRS(cSs
t|j�S(N(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR'�scs#t�|�j�td��dS(Nsraised by Foo.setUp(RRR,(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�s(RR
R'R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�s	tstartTestRunR-RR.R/tstopTestRun(RRR0R(RRR1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt2test_run_call_order__error_in_setUp_default_result�scspg}t|�}dtjf�fd��Y�ddddddg}�|�j|�|j||�dS(	NRcseZ�fd�ZRS(cs#t�|�j�td��dS(Nsraised by Foo.test(RRR,(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�s(RR
R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�sR-RRR.RR/(RRRR0R(RRR*R1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt"test_run_call_order__error_in_test�s	csgg}dtjf�fd��Y�ddddddd	d
g}�|�j�|j||�dS(NRcs eZd�Z�fd�ZRS(cSs
t|j�S(N(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR'�scs#t�|�j�td��dS(Nsraised by Foo.test(RRR,(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�s(RR
R'R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�s	R3R-RRR.RR/R4(RRR0R(RRR1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt1test_run_call_order__error_in_test_default_result�scspg}t|�}dtjf�fd��Y�ddddddg}�|�j|�|j||�dS(	NRcseZ�fd�ZRS(cs$t�|�j�|jd�dS(Nsraised by Foo.test(RRR#(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�s(RR
R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�sR-RRt
addFailureRR/(RRRR0R(RRR*R1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt$test_run_call_order__failure_in_test�s	csgdtjf�fd��Y�ddddddd	d
g}g}�|�j�|j||�dS(NRcs eZd�Z�fd�ZRS(cSs
t|j�S(N(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR'�scs$t�|�j�|jd�dS(Nsraised by Foo.test(RRR#(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�s(RR
R'R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�s	R3R-RRR8RR/R4(RRR0R(RR1R((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt3test_run_call_order__failure_in_test_default_result�scspg}t|�}dtjf�fd��Y��|�j|�ddddddg}|j||�dS(	NRcseZ�fd�ZRS(cs#t�|�j�td��dS(Nsraised by Foo.tearDown(RRR,(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�s(RR
R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR�sR-RRRR.R/(RRRR0R(RRR*R1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt&test_run_call_order__error_in_tearDown�s	csgdtjf�fd��Y�g}�|�j�ddddddd	d
g}|j||�dS(NRcs eZd�Z�fd�ZRS(cSs
t|j�S(N(RR(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR'scs#t�|�j�td��dS(Nsraised by Foo.tearDown(RRR,(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs(RR
R'R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRs	R3R-RRRR.R/R4(RRR0R(RRR1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt5test_run_call_order__error_in_tearDown_default_resultscCs-dtjfd��Y}|d�j�dS(NRcBseZd�Zd�ZRS(cSst�S(N(R(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR'scSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyRs(RR
R'R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRs	R(RRR0(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyt"test_run_call_order_default_resultscCs6dtjfd��Y}|j|d�jt�dS(NRcBseZd�ZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR%s(RR
R(((s//usr/lib64/python2.7/unittest/test/test_case.pyR$sR(RRtassertIstfailureExceptiontAssertionError(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_failureException__default#scCszg}t|�}dtjfd��Y}|j|d�jt�|d�j|�dddg}|j||�dS(NRcBseZd�ZeZRS(cSs
t��dS(N(R,(R((s//usr/lib64/python2.7/unittest/test/test_case.pyR5s(RR
RR,R?(((s//usr/lib64/python2.7/unittest/test/test_case.pyR4s	RR-R8R/(RRRR>R?R,R0R(RRR*RR1((s//usr/lib64/python2.7/unittest/test/test_case.pyt2test_failureException__subclassing__explicit_raise0scCszg}t|�}dtjfd��Y}|j|d�jt�|d�j|�dddg}|j||�dS(NRcBseZd�ZeZRS(cSs|jd�dS(Ntfoo(R#(R((s//usr/lib64/python2.7/unittest/test/test_case.pyRLs(RR
RR,R?(((s//usr/lib64/python2.7/unittest/test/test_case.pyRKs	RR-R8R/(RRRR>R?R,R0R(RRR*RR1((s//usr/lib64/python2.7/unittest/test/test_case.pyt2test_failureException__subclassing__implicit_raiseGscCs*dtjfd��Y}|�j�dS(NRcBseZd�ZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR	[s(RR
R	(((s//usr/lib64/python2.7/unittest/test/test_case.pyRZs(RRR(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyt
test_setUpYscCs*dtjfd��Y}|�j�dS(NRcBseZd�ZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR	ds(RR
R	(((s//usr/lib64/python2.7/unittest/test/test_case.pyRcs(RRR(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyt
test_tearDownbscCs6dtjfd��Y}|j|�j�t�dS(NRcBseZd�ZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR	rs(RR
R	(((s//usr/lib64/python2.7/unittest/test/test_case.pyRqs(RRtassertIsInstanceRt
basestring(RR((s//usr/lib64/python2.7/unittest/test/test_case.pyttest_idpscsag�dtjf�fd��Y}|d�j�ddddddg}|j�|�dS(	NRcs&eZ�fd�Z�fd�ZRS(cs�jd�dS(NR(R(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRscs
t��S(N(R(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyR'�s(RR
RR'((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR~sRR3R-t
addSuccessR/R4(RRR0R(RRR1((Rs//usr/lib64/python2.7/unittest/test/test_case.pyt test_run__uses_defaultTestResult{scCs|j|j��dS(N(tassertIsNonetshortDescription(R((s//usr/lib64/python2.7/unittest/test/test_case.pyt$testShortDescriptionWithoutDocstring�sis)Docstrings are omitted with -O2 and abovecCs|j|j�d�dS(s7Tests shortDescription() for a method with a docstring.N(RRM(R((s//usr/lib64/python2.7/unittest/test/test_case.pyt(testShortDescriptionWithOneLineDocstring�s	cCs|j|j�d�dS(s�Tests shortDescription() for a method with a longer docstring.

        This method ensures that only the first line of a docstring is
        returned used in the short description, no matter how long the
        whole thing is.
        s>Tests shortDescription() for a method with a longer docstring.N(RRM(R((s//usr/lib64/python2.7/unittest/test/test_case.pyt*testShortDescriptionWithMultiLineDocstring�s		csodtfd��Y�����}}|j||�d�fd�}|j�|�|j||�dS(NtSadSnakecBseZdZRS(s)Dummy class for test_addTypeEqualityFunc.(RR
R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRQ�scs$t|�t|�ko!�kSS(N(R((tatbtmsg(RQ(s//usr/lib64/python2.7/unittest/test/test_case.pytAllSnakesCreatedEqual�s(tobjecttassertNotEqualtNonetaddTypeEqualityFuncR(Rts1ts2RU((RQs//usr/lib64/python2.7/unittest/test/test_case.pyttestAddTypeEqualityFunc�scCs<t�}|j||�|j|j|j|t��dS(N(RVR>tassertRaisesR?(Rtthing((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertIs�s	cCs<t�}|j|t��|j|j|j||�dS(N(RVtassertIsNotR]R?(RR^((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertIsNot�s	cCs6g}|j|t�|j|j|j|t�dS(N(RGtlistR]R?tdict(RR^((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertIsInstance�scCs6g}|j|t�|j|j|j|t�dS(N(tassertNotIsInstanceRcR]R?Rb(RR^((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertNotIsInstance�scCsKidd6dd6dd6}|jdd�|jd	d
d	dg�|jd|�|jdd�|jd
d
d	dg�|jd|�|j|j|jdd�|j|j|jdd
d	dg�|j|j|jd|�|j|j|jdd�|j|j|jd
d
d	dg�|j|j|jd|�dS(NtbananatmonkeytgrasstcowtfishtsealRRtabciiitditottertxitelephanttc(tassertIntassertNotInR]R?(Rtanimals((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertIn�s%%cCs&|jii�|jiidd6�|jidd6idd6�|jidd6idd6dd6�|jidd6dd6idd6dd6�|j|j��|jidd6i�WdQX|j|j��#|jidd6idd6�WdQX|j|j��#|jidd6idd6�WdQX|j|j��*|jidd6dd6idd6�WdQX|j|j��*|jidd6dd6idd6�WdQXtjdtf��[djd�td	�D��}|j|j��#|ji|d
6idd
6�WdQXWdQXdS(NiRRiRStoneRrR
css|]}t|�VqdS(N(tchr(t.0ti((s//usr/lib64/python2.7/unittest/test/test_case.pys	<genexpr>�si�RCu�(tassertDictContainsSubsetR]R?Rtcheck_warningstUnicodeWarningtjointrange(RRw((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertDictContainsSubset�s&%,$$++cCsddfiifggft�t�ft�t�fg}x�|D]�\}}y|j||�Wn+|jk
r�|jd||f�nXy|j||dd�Wn+|jk
r�|jd||f�nXy|j||d�WqF|jk
r |jd||f�qFXqFWd
gfit�ftddg�tddg�ftdd	g�tdd
g�ftd
dg�td	dg�fg}xq|D]i\}}|j|j|j||�|j|j|j||d�|j|j|j||dd�q�WdS(NsassertEqual(%r, %r) failedRTRCs$assertEqual(%r, %r) with msg= faileds/assertEqual(%r, %r) with third parameter failediiiii((((tsett	frozensetRR?R#R](Rtequal_pairsRRRSt
unequal_pairs((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertEqual�s<					!!'cCs�|jgg�|jdd�|jgd�ddgg}g}|jtjj|j||�|jtjj|jt|�t|��|jtjj|j|t|��|j|�|j||�|jt|�t|��|j|t|��|jt|�|�|j|j|j|t|��|j|j|jt|�|�|j|j|jd|�|j|j|jdt|��|j|j|jdt|��|j|j|jdd�|j|j|jdd�|j|j|jdd�|j
ii�idd6}i}|jtjj|j
||�|j|�|j
||�d|d<|jtjj|j
||d�|j|j|j
d|�|j|j|j
g|�|j|j|j
dd�dS(	NiRRiRpsThese are unequal((((tassertListEqualtassertTupleEqualtassertSequenceEqualR]RRR?ttupletextendRXtassertDictEqualtupdate(RRRRSRrRn((s//usr/lib64/python2.7/unittest/test/test_case.pyttestEqualitysT





cCs|j|jd�ddd}ddd
}djtjtj|�j�tj|�j���}tj	j
t|�df}t|�d|_y|j||�Wn#|j
k
r�}|jd	}nX|jd
�|jt|�t|��|j||�t|�d|_y|j||�Wn#|j
k
rW}|jd	}nX|jd
�|jt|�t|��|j||�d|_y|j||�Wn#|j
k
r�}|jd	}nX|jd
�|jt|�t|��|j||�dS(NiPiRRRpiRSs
iis!assertSequenceEqual did not fail.i�ii(RtmaxDiffR~tdifflibtndifftpprinttpformatt
splitlinesRtcasetDIFF_OMITTEDtlenR�R?targsR#t
assertLessRst
assertGreaterRtRX(Rtseq1tseq2tdifftomittedteRT((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertSequenceEqualMaxDiffRs<

	
cCs�d|_|jdd�}tjjtd�}|j|d|�d|_|jdd�}|j|d�d|_|jdd�}|j|d�dS(NiRCtbartfoobari(R�t_truncateMessageRR�R�R�RRX(RtmessageR�((s//usr/lib64/python2.7/unittest/test/test_case.pyttestTruncateMessageys			cCs|tjd�}d�}||_y|jiidd6�Wn,|jk
rj}|jt|�d�nX|jd�dS(NRcSsdS(NRC((RTR�((s//usr/lib64/python2.7/unittest/test/test_case.pyttruncate�siiRCsassertDictEqual did not fail(RRR�R�R?RtstrR#(RRR�R�((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertDictEqualTruncates�s		cCsutjd�}d�}||_y|jdd�Wn,|jk
rc}|jt|�d�nX|jd�dS(NRcSsdS(NRC((RTR�((s//usr/lib64/python2.7/unittest/test/test_case.pyR��sRCR�s!assertMultiLineEqual did not fail(RRR�tassertMultiLineEqualR?RR�R#(RRR�R�((s//usr/lib64/python2.7/unittest/test/test_case.pyt!testAssertMultiLineEqualTruncates�s		cs��j�jd�d�_�j�d�_�j��fd��dd}�j�j��}�j|d|d�WdQX�jd	t|j	���j|d|d�dd}d�}�j
�|�_
�j��fd��|d|d}}�j�j��}�j||�WdQX�jd	t|j	���jt|j	�d
||f��j|d|d�dS(Niiicst�d��S(Nt_diffThreshold(tsetattr((t
old_thresholdR(s//usr/lib64/python2.7/unittest/test/test_case.pyt<lambda>�R
uxiRRRSt^i	cSstd��dS(Nsthis should not be raised(tSystemError(R�R�((s//usr/lib64/python2.7/unittest/test/test_case.pytexplodingTruncation�scst�d��S(NR�(R�((told_truncateR(s//usr/lib64/python2.7/unittest/test/test_case.pyR��R
s%r != %riii�i(RR�RXR�t
addCleanupR]R?RsR�t	exceptionR�Rt(RtstcmR�RZR[((R�R�Rs//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertEqual_diffThreshold�s*			

			#cCsyt�}|jdddgdddg�|jdddgdddg�|j||dddg|dd|df�|jddddgddtdg�|j|j|jddgdgd	dgd	ddg�|j|j|jddddgddtdg�|j|j|jd
gd
dg�|j|j|jd
dgd
g�|j|j|jd
dd
gd
dg�|jddgddgd
gtddgddgg�|jtddgddg�tddgddg��|j|j|jgtddddt�g�|jidd6idd6gidd6idd6g�|jddtggtgddg�|j|j|jgtgddddt	�g�|j|j|jdggdgg�|j|j|jdddgddg�|j|j|jdddddgddtdg�|j|j|jdidd6dtgidd6tdg�ddhddhg}|ddd�}|j||�t	tjj
dd��}ddddh}|j||�tjj
ggg�}|j|dd
gfg�t	tjjdd��}ddddh}|j||�dS(NiiiRCR�tbazt2RRidi
iiiRpy@y@RSi����taaabccdtabbbcceRnR�(iiRR(iiRS(iiRn(iiR�(iiRR(iiRS(iiRn(iiR�(RVtassertItemsEqualtTrueR]R?tFalsetitertdivmodR�R�RXRtutilt_count_diff_all_purposeRt_count_diff_hashable(RRRRStdiffsR1((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertItemsEqual�sV	"".(,":8("%-cCs*t�}t�}|j||�|j|j|jd|�|j|j|jg|�|j|j|j|d�|j|j|j|g�tdg�}t�}|j|j|j||�tdg�}tdg�}|j||�tdg�}tddg�}|j|j|j||�tdg�}tddg�}|j|j|j||�tddg�}tddg�}|j||�t�}d}|j|j|j||�|j|j|j||�td
dg�}tdg�}|j|j|j||�dS(
NRRRSRCiiiiii(ii(ii(ii(R�tassertSetEqualR]R?RXR�(Rtset1tset2((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertSetEquals:				cCs4|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�dS(	Niig�������?g�?tbugtantubuguant(R�tassertGreaterEqualR�tassertLessEqualR]R?(R((s//usr/lib64/python2.7/unittest/test/test_case.pyttestInequality)s�cCs�d}d}d}d|_x�d�d�fD]w}y |j||�||��Wq.|jk
r�}t|�jd�jdd�d}|j||k�q.Xq.WdS(	Nsxhttp://www.python.org/doc/2.3/lib/module-unittest.html
test case
    A test case is the smallest unit of testing. [...]
s�http://www.python.org/doc/2.4.1/lib/module-unittest.html
test case
    A test case is the smallest unit of testing. [...] You may provide your
    own implementation that does not subclass from TestCase, of course.
s�- http://www.python.org/doc/2.3/lib/module-unittest.html
?                             ^
+ http://www.python.org/doc/2.4.1/lib/module-unittest.html
?                             ^^^
  test case
-     A test case is the smallest unit of testing. [...]
+     A test case is the smallest unit of testing. [...] You may provide your
?                                                       +++++++++++++++++++++
+     own implementation that does not subclass from TestCase, of course.
cSs|S(N((Rp((s//usr/lib64/python2.7/unittest/test/test_case.pyR��R
cSs
|jd�S(Ntutf8(tdecode(Rp((s//usr/lib64/python2.7/unittest/test/test_case.pyR��R
R�s
i(RXR�R�R?R�tencodetsplitt
assertTrue(Rtsample_texttrevised_sample_texttsample_text_errorttype_changerR�terror((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertMultiLineEquals	%cCsrd}d}d}y|j||�WnE|jk
rm}t|�jdd�d}|j||k�nXdS(Nuladen swallows fly slowlyuunladen swallows fly quicklysr- laden swallows fly slowly
?                    ^^^^
+ unladen swallows fly quickly
? ++                   ^^^^^
s
i(RR?R�R�R�(RR�R�R�R�R�((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAsertEqualSingleLine�scCsP|jd�|j|j|jt�|jd�|j|j|jd�dS(NsDjZoPloGears on Rails(RLRXR]R?R�tassertIsNotNone(R((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertIsNone�s

cCs0|jdd�|j|j|jdd�dS(Nt
asdfabasdfsab+tsaaastaaaa(tassertRegexpMatchesR]R?(R((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRegexpMatches�scs�dtfd��Y��fd�}|j�|�|jt�f|�|jttddd�|j|j��|j�d��WdQX|j���|jt|�WdQXdS(Nt
ExceptionMockcBseZRS((RR
(((s//usr/lib64/python2.7/unittest/test/test_case.pyR��scs�d��dS(Ns	We expect(((R�(s//usr/lib64/python2.7/unittest/test/test_case.pytStub�st19tbaseicSsdS(Ni((((s//usr/lib64/python2.7/unittest/test/test_case.pyR��R
(t	ExceptionR]R"tintR?(RR�((R�s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRaisesCallable�scsdtfd��Y��fd�}|j���|�WdQX|jt�f��}|�WdQX|j|j��|j|jjdd�|jt��tddd�WdQX|j|j��|j���WdQXWdQX|j���|jt|�WdQXdS(	NR�cBseZRS((RR
(((s//usr/lib64/python2.7/unittest/test/test_case.pyR��scs�d��dS(Ns	We expect(((R�(s//usr/lib64/python2.7/unittest/test/test_case.pyR��sis	We expectR�R�i(	R�R]R"RGR�RR�R�R?(RR�R�((R�s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRaisesContext�s

cskdtfd��Y��fd�}|j�tjd�|�|j�d|�|j�d|�dS(NR�cBseZRS((RR
(((s//usr/lib64/python2.7/unittest/test/test_case.pyR��scs�d��dS(Ns	We expect(((R�(s//usr/lib64/python2.7/unittest/test/test_case.pyR��ssexpect$uexpect$(R�tassertRaisesRegexptretcompile(RR�((R�s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRaisesRegexp�s
cCs||j|jd|jttjd�d��|j|jd|jtdd��|j|jd|jtdd��dS(Ns^Exception not raised$RpcSsdS(N(RX(((s//usr/lib64/python2.7/unittest/test/test_case.pyR��R
cSsdS(N(RX(((s//usr/lib64/python2.7/unittest/test/test_case.pyR��R
uxcSsdS(N(RX(((s//usr/lib64/python2.7/unittest/test/test_case.pyR��R
(R�R?R�R�R�(R((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertNotRaisesRegexp�s	
	
	cCs6dtfd��Y}|jt|j|d��dS(NtMyExccBseZRS((RR
(((s//usr/lib64/python2.7/unittest/test/test_case.pyR�scSstS(N(R�(((s//usr/lib64/python2.7/unittest/test/test_case.pyR�R
(R�R]RR�(RR�((s//usr/lib64/python2.7/unittest/test/test_case.pyt#testAssertRaisesRegexpInvalidRegexp�scCs|d�}|j|jd|jtd|�|j|jd|jtd|�|j|jd|jttjd�|�dS(NcSstd��dS(Nt
Unexpected(R�(((s//usr/lib64/python2.7/unittest/test/test_case.pyR�ss*"\^Expected\$" does not match "Unexpected"s
^Expected$u
^Expected$(R�R?R�R�R�(RR�((s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRaisesRegexpMismatchs 		cs�dtfd��Y��fd�}d}|j��}|�||�WdQX|j}|j|��|j|jd|�dS(NR�cBseZRS((RR
(((s//usr/lib64/python2.7/unittest/test/test_case.pyR�scs�|��dS(N((RC(R�(s//usr/lib64/python2.7/unittest/test/test_case.pyR�ssparticular valuei(R�R]R�RGRR�(RR�tvtctxR�((R�s//usr/lib64/python2.7/unittest/test/test_case.pyttestAssertRaisesExcValues	cCsQ|jdd�|jdd�|jdd�|jdd�|jt�dS(s�Test undocumented method name synonyms.

        Please do not use these methods names in your own code.

        This test confirms their continued existence and functionality
        in order to avoid breaking existing code.
        iig@g@g@N(tassertNotEqualstassertEqualstassertAlmostEqualstassertNotAlmostEqualstassert_R�(R((s//usr/lib64/python2.7/unittest/test/test_case.pyttestSynonymAssertMethodNames(s
cCs�tj��r|jdd�|jdd�|jdd�|jdd�|jt�|jt	d��|j
t�WdQXdS(s�Test fail* methods pending deprecation, they will warn in 3.2.

        Do not use these methods.  They will go away in 3.3.
        iig@g@g@cSsddS(Ng��Q�	@uspam((t_((s//usr/lib64/python2.7/unittest/test/test_case.pyR�AR
N(RR|tfailIfEqualtfailUnlessEqualtfailUnlessAlmostEqualtfailIfAlmostEqualt
failUnlessR�tfailUnlessRaisesRtfailIfR�(R((s//usr/lib64/python2.7/unittest/test/test_case.pyt!testPendingDeprecationMethodNames6s

cCs3dtjfd��Y}|d�}t|�dS(NtTestableTestcBseZd�ZRS(cSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyttestNothingGs(RR
R(((s//usr/lib64/python2.7/unittest/test/test_case.pyRFsR(RRR(RRR((s//usr/lib64/python2.7/unittest/test/test_case.pyttestDeepcopyDscs�dd��d��dtjf�fd��Y}dtjf��fd��Y}dtjf��fd��Y}d	tjf�fd
��Y}x@||||fD],}|jt��|d�j�WdQXq�WdS(NcSs
t�dS(N(tKeyboardInterrupt(R((s//usr/lib64/python2.7/unittest/test/test_case.pyt_raisePscSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pytnothingRstTest1cseZ�ZRS((RR
ttest_something((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR
UstTest2cseZ�Z�ZRS((RR
RR((RR	(s//usr/lib64/python2.7/unittest/test/test_case.pyRXstTest3cseZ�Z�ZRS((RR
RR((RR	(s//usr/lib64/python2.7/unittest/test/test_case.pyR
\stTest4cseZ�fd�ZRS(cs|j��dS(N(R�(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRas(RR
R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR`sR(RXRRR]RR0(RR
RR
Rtklass((RR	s//usr/lib64/python2.7/unittest/test/test_case.pyttestKeyboardInterruptOs	""csdd��d��dtjf�fd��Y}dtjf��fd��Y}dtjf��fd��Y}d	tjf�fd
��Y}xe||||fD]Q}tj�}|d�j|�|jt|j�d�|j|jd�q�WdS(
NcSs
t�dS(N(t
SystemExit(R((s//usr/lib64/python2.7/unittest/test/test_case.pyRiscSsdS(N((R((s//usr/lib64/python2.7/unittest/test/test_case.pyR	ksR
cseZ�ZRS((RR
R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyR
nsRcseZ�Z�ZRS((RR
RR((RR	(s//usr/lib64/python2.7/unittest/test/test_case.pyRqsR
cseZ�Z�ZRS((RR
RR((RR	(s//usr/lib64/python2.7/unittest/test/test_case.pyR
usRcseZ�fd�ZRS(cs|j��dS(N(R�(R(R(s//usr/lib64/python2.7/unittest/test/test_case.pyRzs(RR
R((R(s//usr/lib64/python2.7/unittest/test/test_case.pyRysRi(	RXRRR)R0RR�terrorsttestsRun(RR
RR
RRR*((RR	s//usr/lib64/python2.7/unittest/test/test_case.pyttestSystemExiths	""cCsetjd�}xOttjd�D]:}tj|d|�}tj|�}|j||�q#WdS(NR0itprotocol(RRRtpickletHIGHEST_PROTOCOLtdumpstloadsR(RRRtpickled_testtunpickled_test((s//usr/lib64/python2.7/unittest/test/test_case.pyt
testPickle�s
(FRR
RRteq_pairsRtne_pairsRR R$R&R+R2R5R6R7R9R:R;R<R=RARBRDRERFRIRKRNRtskipIftsystflagstoptimizeRORPR\R_RaRdRfRvR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�RRRRR(((s//usr/lib64/python2.7/unittest/test/test_case.pyR,s�!!				
											
								
	
							%	4	'				$	>	(	V	$															t__main__(R�R�RR�R tcopyRRRRtunittest.test.supportRRRRRVRRRRtmain(((s//usr/lib64/python2.7/unittest/test/test_case.pyt<module>s "����jPK��[%v
�tttest/support.pyonu�[����
{fc@skddlZdefd��YZdefd��YZdejfd��YZdefd	��YZdS(
i����NtTestHashingcBseZdZd�ZRS(sUsed as a mixin for TestCasecCs*x�|jD]�\}}y6t|�t|�ksK|jd||f�nWq
tk
rb�q
tk
r�}|jd|||f�q
Xq
Wx�|jD]�\}}y6t|�t|�kr�|jd||f�nWq�tk
r��q�tk
r!}|jd|||f�q�Xq�WdS(Ns%r and %r do not hash equalsProblem hashing %r and %r: %ss#%s and %s hash equal, but shouldn'tsProblem hashing %s and %s: %s(teq_pairsthashtfailtKeyboardInterruptt	Exceptiontne_pairs(tselftobj_1tobj_2te((s-/usr/lib64/python2.7/unittest/test/support.pyt	test_hashs"
"	
(t__name__t
__module__t__doc__R(((s-/usr/lib64/python2.7/unittest/test/support.pyRstTestEqualitycBs eZdZd�Zd�ZRS(sUsed as a mixin for TestCasecCs>x7|jD],\}}|j||�|j||�q
WdS(N(RtassertEqual(RRR	((s-/usr/lib64/python2.7/unittest/test/support.pyttest_eq!scCs>x7|jD],\}}|j||�|j||�q
WdS(N(RtassertNotEqual(RRR	((s-/usr/lib64/python2.7/unittest/test/support.pyttest_ne's(RR
RRR(((s-/usr/lib64/python2.7/unittest/test/support.pyRs	t
LoggingResultcBskeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�ZRS(cCs ||_tt|�j�dS(N(t_eventstsuperRt__init__(Rtlog((s-/usr/lib64/python2.7/unittest/test/support.pyR.s	cCs*|jjd�tt|�j|�dS(Nt	startTest(RtappendRRR(Rttest((s-/usr/lib64/python2.7/unittest/test/support.pyR2scCs'|jjd�tt|�j�dS(NtstartTestRun(RRRRR(R((s-/usr/lib64/python2.7/unittest/test/support.pyR6scCs*|jjd�tt|�j|�dS(NtstopTest(RRRRR(RR((s-/usr/lib64/python2.7/unittest/test/support.pyR:scCs'|jjd�tt|�j�dS(NtstopTestRun(RRRRR(R((s-/usr/lib64/python2.7/unittest/test/support.pyR>scGs*|jjd�tt|�j|�dS(Nt
addFailure(RRRRR(Rtargs((s-/usr/lib64/python2.7/unittest/test/support.pyRBscGs*|jjd�tt|�j|�dS(Nt
addSuccess(RRRRR!(RR ((s-/usr/lib64/python2.7/unittest/test/support.pyR!FscGs*|jjd�tt|�j|�dS(NtaddError(RRRRR"(RR ((s-/usr/lib64/python2.7/unittest/test/support.pyR"JscGs*|jjd�tt|�j|�dS(NtaddSkip(RRRRR#(RR ((s-/usr/lib64/python2.7/unittest/test/support.pyR#NscGs*|jjd�tt|�j|�dS(NtaddExpectedFailure(RRRRR$(RR ((s-/usr/lib64/python2.7/unittest/test/support.pyR$RscGs*|jjd�tt|�j|�dS(NtaddUnexpectedSuccess(RRRRR%(RR ((s-/usr/lib64/python2.7/unittest/test/support.pyR%Vs(
RR
RRRRRRR!R"R#R$R%(((s-/usr/lib64/python2.7/unittest/test/support.pyR-s										t#ResultWithNoStartTestRunStopTestRuncBsMeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(s?An object honouring TestResult before startTestRun/stopTestRun.cCsCg|_g|_d|_g|_g|_g|_t|_dS(Ni(tfailuresterrorsttestsRuntskippedtexpectedFailurestunexpectedSuccessestFalset
shouldStop(R((s-/usr/lib64/python2.7/unittest/test/support.pyR^s						cCsdS(N((RR((s-/usr/lib64/python2.7/unittest/test/support.pyRgscCsdS(N((RR((s-/usr/lib64/python2.7/unittest/test/support.pyRjscCsdS(N((RR((s-/usr/lib64/python2.7/unittest/test/support.pyR"mscCsdS(N((RR((s-/usr/lib64/python2.7/unittest/test/support.pyRpscCsdS(N((RR((s-/usr/lib64/python2.7/unittest/test/support.pyR!sscCstS(N(tTrue(R((s-/usr/lib64/python2.7/unittest/test/support.pyt
wasSuccessfulvs(
RR
RRRRR"RR!R0(((s-/usr/lib64/python2.7/unittest/test/support.pyR&[s							(tunittesttobjectRRt
TestResultRR&(((s-/usr/lib64/python2.7/unittest/test/support.pyt<module>s.PK��[4���-7-7test/test_runner.pycnu�[����
|fc@s�ddlZddlmZddlZddlmZmZdejfd��YZdejfd��YZ	e
dkr�ej�ndS(	i����N(tStringIO(t
LoggingResultt#ResultWithNoStartTestRunStopTestRuntTestCleanUpcBs,eZd�Zd�Zd�Zd�ZRS(c
sdtjfd��Y}|d�}|j|jg�g��fd�}�fd�}|j|dddd	d
dd�|j|�|j|j|d
td	d
dd�f|difg�|j�}|j|�|j�ddifddtd	d
dd�fg�dS(NtTestableTestcBseZd�ZRS(cSsdS(N((tself((s1/usr/lib64/python2.7/unittest/test/test_runner.pyttestNothings(t__name__t
__module__R(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR
sRcs�jd||f�dS(Ni(tappend(targstkwargs(tcleanups(s1/usr/lib64/python2.7/unittest/test/test_runner.pytcleanup1scs�jd||f�dS(Ni(R	(R
R(R(s1/usr/lib64/python2.7/unittest/test/test_runner.pytcleanup2siiitfourthellotfivetgoodbye(iii(((iii(tunittesttTestCasetassertEqualt	_cleanupst
addCleanuptdictt
doCleanupst
assertTrue(RRttestR
Rtresult((Rs1/usr/lib64/python2.7/unittest/test/test_runner.pyttestCleanUps"

cs+dtjfd��Y}dtfd��Y}|�}|d�}||_td��td���fd�}�fd	�}|j|�|j|�|j|j��t|j	�\\}\}}	}
\}\}}
}
|j
|||	f|t�f�|j
|||
f|t�f�dS(
NRcBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR+s(RRR(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR*st
MockResultcBseZgZd�ZRS(cSs|jj||f�dS(N(terrorsR	(RRtexc_info((s1/usr/lib64/python2.7/unittest/test/test_runner.pytaddError0s(RRRR!(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR.sRtfootbarcs
��dS(N(((texc1(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR
9scs
��dS(N(((texc2(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR<s(RRtobjectt_resultForDoCleanupst	ExceptionRtassertFalseRtreversedRR(RRRRRR
Rttest1tType1t	instance1t_ttest2tType2t	instance2((R$R%s1/usr/lib64/python2.7/unittest/test/test_runner.pyttestCleanUpWithErrors)s		

3"cst�g�dtjf��fd��Y}|d���fd�}�fd�}�j|��j|����fd�}tj�}||_�j|��j�ddd	d
ddg�t�g�|d���j|��j|��j�ddg�dS(
NRcs8eZ��fd�Z�fd�Z�fd�ZRS(cs&�jd��r"td��ndS(NtsetUpR"(R	R((R(tblowUptordering(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR3Ms
cs�jd�dS(NR(R	(R(R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRRscs�jd�dS(NttearDown(R	(R(R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR6Us(RRR3RR6((R4R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRLsRcs�jd�dS(NR
(R	((R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR
Zscs�jd�dS(NR(R	((R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR\scs!�j|���jd�dS(Ntsuccess(RR	(t	some_test(R5RR(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR7asR3RR6RR
R7(	tFalseRRRt
TestResultt
addSuccesstrunRtTrue(RRR
RR7R((R4R5RRs1/usr/lib64/python2.7/unittest/test/test_runner.pyttestCleanupInRunHs("

	


cs�g�dtjf��fd��Y}|d�����fd���fd���j�|j�dddd	d
g�dS(NRcs8eZ��fd�Z�fd�Z�fd�ZRS(cs�jd�|j��dS(NR3(R	R(R(R
R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR3ws
cs�jd�dS(NR(R	(R(R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR{scs�jd�dS(NR6(R	(R(R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR6~s(RRR3RR6((R
R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRvsRcs�jd��j��dS(NR
(R	R((RR5R(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR
�s
cs�jd�dS(NR(R	((R5(s1/usr/lib64/python2.7/unittest/test/test_runner.pyR�sR3RR6R
R(RRtdebugR(RR((R
RR5Rs1/usr/lib64/python2.7/unittest/test/test_runner.pyt!testTestCaseDebugExecutesCleanupsss"
(RRRR2R>R@(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR
s			+tTest_TextTestRunnercBsVeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(	sTests for TextTestRunner.cCsitj�}|j|j�|j|j�|j|jd�|j|j�|j|j	tj
�dS(Ni(RtTextTestRunnerR)tfailfasttbufferRt	verbosityRtdescriptionstresultclasstTextTestResult(Rtrunner((s1/usr/lib64/python2.7/unittest/test/test_runner.pyt	test_init�scsOdtjf�fd��Y�dtj�fd��Y}|ddd�dS(NtAResultcseZ�fd�ZRS(cs t�|�j|||�dS(N(tsupert__init__(RtstreamRFRE(RK(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRM�s(RRRM((RK(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRK�stATextResultcBseZRS((RR(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRO�si(RR:RHtNone(RRO((RKs1/usr/lib64/python2.7/unittest/test/test_runner.pyttest_multiple_inheritance�scs�dtjfd��Y}tj��tjdt�dtdt�}�fd�|_|j|d��|j�j	�|j�j
�dS(NtTestcBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_runner.pyttestFoo�s(RRRS(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRR�sRNRCRDcs�S(N(((R(s1/usr/lib64/python2.7/unittest/test/test_runner.pyt<lambda>�tRS(RRR:RBRR=t_makeResultR<RRCRD(RRRRI((Rs1/usr/lib64/python2.7/unittest/test/test_runner.pyttestBufferAndFailfast�s	cs�dtjfd��Y}tjj��fd�}�j|�tj��tjdt��}�fd�|_d�_	��fd�}|tj_|j
tj���j�j	d�dS(	NRRcBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRS�s(RRRS(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRR�scs�tj_dS(N(RRItregisterResult((toriginalRegisterResult(s1/usr/lib64/python2.7/unittest/test/test_runner.pytcleanup�sRNcs�S(N(((R(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRT�RUics#�jd7_�j|��dS(Ni(t
wasRegisteredR(t
thisResult(RR(s1/usr/lib64/python2.7/unittest/test/test_runner.pytfakeRegisterResult�si(
RRRIRXRR:RBRRVR[R<t	TestSuiteR(RRRRZRIR]((RYRRs1/usr/lib64/python2.7/unittest/test/test_runner.pyttestRunnerRegistersResult�s
	csXdtfd��Y�dtjf��fd��Y���}|jtj��dS(Nt
OldTextResultcBseZdZd�ZRS(RUcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_runner.pytprintErrors�s(RRt
separator2Ra(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyR`�stRunnercs&eZ�fd�Z�fd�ZRS(cst�|�jt��dS(N(RLRMR(R(Rc(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRM�scs��S(N((R(R`(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRV�s(RRRMRV((R`Rc(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRc�s(RRRBR<R^(RRI((R`Rcs1/usr/lib64/python2.7/unittest/test/test_runner.pyt7test_works_with_result_without_startTestRun_stopTestRun�s"	cs}dtfd��Y�dtjf��fd��Y�g}�|�}|jtj��ddg}|j||�dS(NtLoggingTextResultcBseZdZd�ZRS(RUcSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRa�s(RRRbRa(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRe�st
LoggingRunnercs&eZ�fd�Z�fd�ZRS(cs&t�|�jt��||_dS(N(RLRMRt_events(Rtevents(Rf(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRM�scs
�|j�S(N(Rg(R(Re(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRV�s(RRRMRV((RfRe(s1/usr/lib64/python2.7/unittest/test/test_runner.pyRf�ststartTestRuntstopTestRun(RRRBR<R^R(RRhRItexpected((RfRes1/usr/lib64/python2.7/unittest/test/test_runner.pyt$test_startTestRun_stopTestRun_called�s"cCs�ddlm}|d�}tj|�}x^ttjd�D]I}tj|d|�}tj|�}|j|j	j
�|j
��q?WdS(Ni����(RR"itprotocol(RRRBtrangetpickletHIGHEST_PROTOCOLtdumpstloadsRRNtgetvalue(RtPickleableIORNRIRmtstobj((s1/usr/lib64/python2.7/unittest/test/test_runner.pyttest_pickle_unpickle�scCs~d�}t�}t�}t�}tj|||d|�}|j|j|�|j||f}|j|j�|�dS(NcWs|S(N((R
((s1/usr/lib64/python2.7/unittest/test/test_runner.pytMockResultClass�sRG(R&RRBRRGRNRV(RRxtSTREAMtDESCRIPTIONSt	VERBOSITYRItexpectedresult((s1/usr/lib64/python2.7/unittest/test/test_runner.pyttest_resultclass�s					(RRt__doc__RJRQRWR_RdRlRwR}(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyRA�s			
					
t__main__(Rt	cStringIORRotunittest.test.supportRRRRRARtmain(((s1/usr/lib64/python2.7/unittest/test/test_runner.pyt<module>s�}PK��[�}'��test/test_functiontestcase.pyonu�[����
|fc@sRddlZddlmZdejfd��YZedkrNej�ndS(i����N(t
LoggingResulttTest_FunctionTestCasecBsPeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(cCs,tjd��}|j|j�d�dS(NcSsdS(N(tNone(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt<lambda>ti(tunittesttFunctionTestCasetassertEqualtcountTestCases(tselfttest((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyttest_countTestCases
scs�g�t��}�fd�}�fd�}�fd�}ddddg}tj|||�j|�|j�|�dS(Ncs�jd�td��dS(NtsetUpsraised by setUp(tappendtRuntimeError((tevents(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyRs
cs�jd�dS(NR
(R
((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR
scs�jd�dS(NttearDown(R
((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR!st	startTestRtaddErrortstopTest(RRRtrunR(R	tresultRR
Rtexpected((Rs;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt#test_run_call_order__error_in_setUpscs�g�t��}�fd�}�fd�}�fd�}dddddd	g}tj|||�j|�|j�|�dS(
Ncs�jd�dS(NR(R
((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR3scs�jd�td��dS(NR
sraised by test(R
R((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR
6s
cs�jd�dS(NR(R
((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR:sRRR
RRR(RRRRR(R	RRR
RR((Rs;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt"test_run_call_order__error_in_test/s	cs�g�t��}�fd�}��fd�}�fd�}dddddd	g}tj|||�j|��j�|�dS(
Ncs�jd�dS(NR(R
((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyRMscs�jd��jd�dS(NR
sraised by test(R
tfail((RR	(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR
Ps
cs�jd�dS(NR(R
((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyRTsRRR
t
addFailureRR(RRRRR(R	RRR
RR((RR	s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt$test_run_call_order__failure_in_testIs	cs�g�t��}�fd�}�fd�}�fd�}dddddd	g}tj|||�j|�|j�|�dS(
Ncs�jd�dS(NR(R
((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyRgscs�jd�dS(NR
(R
((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR
jscs�jd�td��dS(NRsraised by tearDown(R
R((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyRms
RRR
RRR(RRRRR(R	RRR
RR((Rs;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt&test_run_call_order__error_in_tearDowncs	cCs,tjd��}|j|j�t�dS(NcSsdS(N(R(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR}R(RRtassertIsInstancetidt
basestring(R	R
((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyttest_id|scCs,tjd��}|j|j�d�dS(NcSsdS(N(R(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR�R(RRRtshortDescriptionR(R	R
((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt#test_shortDescription__no_docstring�scCs8d}tjd�d|�}|j|j�d�dS(Nsthis tests foocSsdS(N(R(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR�Rtdescription(RRRR!(R	tdescR
((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt+test_shortDescription__singleline_docstring�s(
t__name__t
__module__RRRRRR R"R%(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyRs							t__main__(Rtunittest.test.supportRtTestCaseRR&tmain(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt<module>s�PK��[����(�(test/test_program.pyonu�[����
|fc@s�ddlmZddlZddlZddlZddlZdejfd��YZdejfd��YZ	e
�Zde
fd��YZd	ejfd
��YZ
edkr�ej�ndS(i����(tStringIONtTest_TestProgramcBsgeZd�Zd�Zdejfd��YZdejfd��YZd�Z	d�Z
d�ZRS(	cs�tj�}�g�tjjtjjtjj���t�_	���fd�}||_
|jd�}�j�j	��j
|j��dS(Ncst�_�j|���S(N(tTruetwasRuntassertEqual(t	start_dirtpattern(texpectedPathtselfttests(s2/usr/lib64/python2.7/unittest/test/test_program.pyt_find_testss	s
unittest.test(tunittestt
TestLoadertostpathtabspathtdirnamettestt__file__tFalseRR
tdiscovert
assertTrueRt_tests(RtloaderR
tsuite((RRR	s2/usr/lib64/python2.7/unittest/test/test_program.pyttest_discovery_from_dotted_paths	$		cs�t��t�}dtf�fd��Y}|�}tjj��fd�}d�tj_|j|�d�}|tj_|j|�tjd|dtdd	�}|j|j��|j|j|�|j|j	d	�dS(
Nt
FakeRunnercseZ�fd�ZRS(cs
||_�S(N(R(RR(tresult(s2/usr/lib64/python2.7/unittest/test/test_program.pytrun!s	(t__name__t
__module__R((R(s2/usr/lib64/python2.7/unittest/test/test_program.pyR scs�tj_dS(N(RtTestProgramt	parseArgs((toldParseArgs(s2/usr/lib64/python2.7/unittest/test/test_program.pytrestoreParseArgs(scWsdS(N(tNone(targs((s2/usr/lib64/python2.7/unittest/test/test_program.pyt<lambda>*tcSs
tj`dS(N(RRR(((s2/usr/lib64/python2.7/unittest/test/test_program.pyt
removeTest-st
testRunnertexitt	verbosityi(
tobjectRRR t
addCleanupRRRRR*(RRRtrunnerR"R'tprogram((R!Rs2/usr/lib64/python2.7/unittest/test/test_program.pyt
testNoExits			
	
tFooBarcBseZd�Zd�ZRS(cCsdS(N((R((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestPass9scCsdS(N((R((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestFail;s(RRR1R2(((s2/usr/lib64/python2.7/unittest/test/test_program.pyR08s	tFooBarLoadercBseZdZd�ZRS(s3Test loader that returns a suite containing FooBar.cCs|j|jtj�g�S(N(t
suiteClasstloadTestsFromTestCaseRR0(Rtmodule((s2/usr/lib64/python2.7/unittest/test/test_program.pytloadTestsFromModule@s(RRt__doc__R7(((s2/usr/lib64/python2.7/unittest/test/test_program.pyR3>sc	CsVtjdtddgdtjdt��d|j��}|jt|d��dS(NR)targvtfoobarR(tstreamt
testLoaderR(RtmainRtTextTestRunnerRR3Rthasattr(RR.((s2/usr/lib64/python2.7/unittest/test/test_program.pyttest_NonExitEs
	cCsG|jttjddgdtjdt��dtd|j��dS(NR9R:R(R;R)R<(tassertRaisest
SystemExitRR=R>RRR3(R((s2/usr/lib64/python2.7/unittest/test/test_program.pyt	test_ExitMs		c	CsA|jttjddgdtjdt��d|j��dS(NR9R:R(R;R<(RARBRR=R>RR3(R((s2/usr/lib64/python2.7/unittest/test/test_program.pyttest_ExitAsDefaultWs		(RRRR/RtTestCaseR0RR3R@RCRD(((s2/usr/lib64/python2.7/unittest/test/test_program.pyR	s				
tInitialisableProgramcBsDeZeZdZdZdZdZe	j
ZdZdZ
d�ZRS(iRcGsdS(N((RR$((s2/usr/lib64/python2.7/unittest/test/test_program.pyt__init__isN(RRRR)R#RR*tdefaultTestR(RtdefaultTestLoaderR<tprogNameRRG(((s2/usr/lib64/python2.7/unittest/test/test_program.pyRF`s	RcBs,eZdZdZeZd�Zd�ZRS(cKs(|t_tjr$tt_t�ndS(N(RtinitArgst
raiseErrorRt	TypeError(Rtkwargs((s2/usr/lib64/python2.7/unittest/test/test_program.pyRGss			cCs
|t_tS(N(RRtRESULT(RR((s2/usr/lib64/python2.7/unittest/test/test_program.pyRys	N(	RRR#RKRRRLRGR(((s2/usr/lib64/python2.7/unittest/test/test_program.pyRns
	tTestCommandLineArgscBsPeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(cCs:t�|_d�|j_dt_dt_tt_dS(NcSsdS(N(R#(((s2/usr/lib64/python2.7/unittest/test/test_program.pyR%�R&(	RFR.tcreateTestsR#RRKRRRL(R((s2/usr/lib64/python2.7/unittest/test/test_program.pytsetUps
		cs�|j�d�fd�}|�_xJdD]B}t�_�jd|g�|j�j�|j�j�q+W�jddg�|j�j�|j	�j�dS(Ncs|�_t�_dS(N(tmsgRR)(RS(R.(s2/usr/lib64/python2.7/unittest/test/test_program.pyt	usageExit�s	s-hs-Hs--helps-$(s-hs-Hs--help(
R.R#RTRR)R RtassertIsNoneRStassertIsNotNone(RRTtopt((R.s2/usr/lib64/python2.7/unittest/test/test_program.pyttestHelpAndUnknown�s		
	cCs�|j}x=dD]5}d|_|jd|g�|j|jd�qWx=d	D]5}d|_|jd|g�|j|jd�qPWdS(
Ns-qs--quietiis-vs	--verbosei(s-qs--quiet(s-vs	--verbose(R.R*R R#R(RR.RW((s2/usr/lib64/python2.7/unittest/test/test_program.pyt
testVerbosity�s	
	
	cCs
|j}x�dd	d
fD]�\}}|dkr>tr>qnd|d}d|}xM||fD]?}t||d�|jd|g�|jt||��qcWxY||fD]K}t�}t|||�|jd|g�|jt||�|�q�WqWdS(Ntbuffertfailfasttcatcht
catchbreaks-%sis--%s(RZRZ(R[R[(R\R](	R.thasInstallHandlertsetattrR#R RtgetattrR+R(RR.targtattrt	short_opttlong_optRWtnot_none((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestBufferCatchFailfast�s 		
	cCs�|j}t|_d|_d|_d|_|j�|jtjidd6dd6dd6�|jtj	d�|j
|jt�dS(NR*R[RZR(
R.RR(R*R[RZtrunTestsRRKRtassertIsRRO(RR.((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestRunTestsRunnerClass�s					
cCsb|j}t�|_dt_|j�|jtj�|jtjd�|j	|j
t�dS(NR(R.RR(R#RKRgRURRRhRRO(RR.((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestRunTestsRunnerInstance�s		
cCs�|j}tt_t|_d|_d|_d|_d|_|j	�|j
tji�|j
tjd�|j|j
t�dS(NR*R[RZR(R.RRRLR(R*R[RZRRgRRKRhRRO(RR.((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestRunTestsOldRunnerClass�s							
cs�tjd��j���fd�}�j|�t�_�fd�}|�_�j}t|_t	|_
|j��j�j�dS(Ns
unittest.maincs
��_dS(N(tinstallHandler((R6toriginal(s2/usr/lib64/python2.7/unittest/test/test_program.pytrestore�scs
t�_dS(N(Rt	installed((R(s2/usr/lib64/python2.7/unittest/test/test_program.pytfakeInstallHandler�s(
tsystmodulesRlR,RRoR.RR]RR(RgR(RRnRpR.((R6RmRs2/usr/lib64/python2.7/unittest/test/test_program.pyttestCatchBreakInstallsHandler�s
	
					
(
RRRRRXRYRfRiRjRkRs(((s2/usr/lib64/python2.7/unittest/test/test_program.pyRP}s			
				t__main__(t	cStringIORR
RqRt
unittest.testRERRRFR+RORRPRR=(((s2/usr/lib64/python2.7/unittest/test/test_program.pyt<module>sW	�PK��[
�pa����test/test_loader.pynu�[���import sys
import types


import unittest


class Test_TestLoader(unittest.TestCase):

    ### Tests for TestLoader.loadTestsFromTestCase
    ################################################################

    # "Return a suite of all test cases contained in the TestCase-derived
    # class testCaseClass"
    def test_loadTestsFromTestCase(self):
        class Foo(unittest.TestCase):
            def test_1(self): pass
            def test_2(self): pass
            def foo_bar(self): pass

        tests = unittest.TestSuite([Foo('test_1'), Foo('test_2')])

        loader = unittest.TestLoader()
        self.assertEqual(loader.loadTestsFromTestCase(Foo), tests)

    # "Return a suite of all test cases contained in the TestCase-derived
    # class testCaseClass"
    #
    # Make sure it does the right thing even if no tests were found
    def test_loadTestsFromTestCase__no_matches(self):
        class Foo(unittest.TestCase):
            def foo_bar(self): pass

        empty_suite = unittest.TestSuite()

        loader = unittest.TestLoader()
        self.assertEqual(loader.loadTestsFromTestCase(Foo), empty_suite)

    # "Return a suite of all test cases contained in the TestCase-derived
    # class testCaseClass"
    #
    # What happens if loadTestsFromTestCase() is given an object
    # that isn't a subclass of TestCase? Specifically, what happens
    # if testCaseClass is a subclass of TestSuite?
    #
    # This is checked for specifically in the code, so we better add a
    # test for it.
    def test_loadTestsFromTestCase__TestSuite_subclass(self):
        class NotATestCase(unittest.TestSuite):
            pass

        loader = unittest.TestLoader()
        try:
            loader.loadTestsFromTestCase(NotATestCase)
        except TypeError:
            pass
        else:
            self.fail('Should raise TypeError')

    # "Return a suite of all test cases contained in the TestCase-derived
    # class testCaseClass"
    #
    # Make sure loadTestsFromTestCase() picks up the default test method
    # name (as specified by TestCase), even though the method name does
    # not match the default TestLoader.testMethodPrefix string
    def test_loadTestsFromTestCase__default_method_name(self):
        class Foo(unittest.TestCase):
            def runTest(self):
                pass

        loader = unittest.TestLoader()
        # This has to be false for the test to succeed
        self.assertFalse('runTest'.startswith(loader.testMethodPrefix))

        suite = loader.loadTestsFromTestCase(Foo)
        self.assertIsInstance(suite, loader.suiteClass)
        self.assertEqual(list(suite), [Foo('runTest')])

    ################################################################
    ### /Tests for TestLoader.loadTestsFromTestCase

    ### Tests for TestLoader.loadTestsFromModule
    ################################################################

    # "This method searches `module` for classes derived from TestCase"
    def test_loadTestsFromModule__TestCase_subclass(self):
        m = types.ModuleType('m')
        class MyTestCase(unittest.TestCase):
            def test(self):
                pass
        m.testcase_1 = MyTestCase

        loader = unittest.TestLoader()
        suite = loader.loadTestsFromModule(m)
        self.assertIsInstance(suite, loader.suiteClass)

        expected = [loader.suiteClass([MyTestCase('test')])]
        self.assertEqual(list(suite), expected)

    # "This method searches `module` for classes derived from TestCase"
    #
    # What happens if no tests are found (no TestCase instances)?
    def test_loadTestsFromModule__no_TestCase_instances(self):
        m = types.ModuleType('m')

        loader = unittest.TestLoader()
        suite = loader.loadTestsFromModule(m)
        self.assertIsInstance(suite, loader.suiteClass)
        self.assertEqual(list(suite), [])

    # "This method searches `module` for classes derived from TestCase"
    #
    # What happens if no tests are found (TestCases instances, but no tests)?
    def test_loadTestsFromModule__no_TestCase_tests(self):
        m = types.ModuleType('m')
        class MyTestCase(unittest.TestCase):
            pass
        m.testcase_1 = MyTestCase

        loader = unittest.TestLoader()
        suite = loader.loadTestsFromModule(m)
        self.assertIsInstance(suite, loader.suiteClass)

        self.assertEqual(list(suite), [loader.suiteClass()])

    # "This method searches `module` for classes derived from TestCase"s
    #
    # What happens if loadTestsFromModule() is given something other
    # than a module?
    #
    # XXX Currently, it succeeds anyway. This flexibility
    # should either be documented or loadTestsFromModule() should
    # raise a TypeError
    #
    # XXX Certain people are using this behaviour. We'll add a test for it
    def test_loadTestsFromModule__not_a_module(self):
        class MyTestCase(unittest.TestCase):
            def test(self):
                pass

        class NotAModule(object):
            test_2 = MyTestCase

        loader = unittest.TestLoader()
        suite = loader.loadTestsFromModule(NotAModule)

        reference = [unittest.TestSuite([MyTestCase('test')])]
        self.assertEqual(list(suite), reference)


    # Check that loadTestsFromModule honors (or not) a module
    # with a load_tests function.
    def test_loadTestsFromModule__load_tests(self):
        m = types.ModuleType('m')
        class MyTestCase(unittest.TestCase):
            def test(self):
                pass
        m.testcase_1 = MyTestCase

        load_tests_args = []
        def load_tests(loader, tests, pattern):
            self.assertIsInstance(tests, unittest.TestSuite)
            load_tests_args.extend((loader, tests, pattern))
            return tests
        m.load_tests = load_tests

        loader = unittest.TestLoader()
        suite = loader.loadTestsFromModule(m)
        self.assertIsInstance(suite, unittest.TestSuite)
        self.assertEqual(load_tests_args, [loader, suite, None])

        load_tests_args = []
        suite = loader.loadTestsFromModule(m, use_load_tests=False)
        self.assertEqual(load_tests_args, [])

    def test_loadTestsFromModule__faulty_load_tests(self):
        m = types.ModuleType('m')

        def load_tests(loader, tests, pattern):
            raise TypeError('some failure')
        m.load_tests = load_tests

        loader = unittest.TestLoader()
        suite = loader.loadTestsFromModule(m)
        self.assertIsInstance(suite, unittest.TestSuite)
        self.assertEqual(suite.countTestCases(), 1)
        test = list(suite)[0]

        self.assertRaisesRegexp(TypeError, "some failure", test.m)

    ################################################################
    ### /Tests for TestLoader.loadTestsFromModule()

    ### Tests for TestLoader.loadTestsFromName()
    ################################################################

    # "The specifier name is a ``dotted name'' that may resolve either to
    # a module, a test case class, a TestSuite instance, a test method
    # within a test case class, or a callable object which returns a
    # TestCase or TestSuite instance."
    #
    # Is ValueError raised in response to an empty name?
    def test_loadTestsFromName__empty_name(self):
        loader = unittest.TestLoader()

        try:
            loader.loadTestsFromName('')
        except ValueError, e:
            self.assertEqual(str(e), "Empty module name")
        else:
            self.fail("TestLoader.loadTestsFromName failed to raise ValueError")

    # "The specifier name is a ``dotted name'' that may resolve either to
    # a module, a test case class, a TestSuite instance, a test method
    # within a test case class, or a callable object which returns a
    # TestCase or TestSuite instance."
    #
    # What happens when the name contains invalid characters?
    def test_loadTestsFromName__malformed_name(self):
        loader = unittest.TestLoader()

        # XXX Should this raise ValueError or ImportError?
        try:
            loader.loadTestsFromName('abc () //')
        except ValueError:
            pass
        except ImportError:
            pass
        else:
            self.fail("TestLoader.loadTestsFromName failed to raise ValueError")

    # "The specifier name is a ``dotted name'' that may resolve ... to a
    # module"
    #
    # What happens when a module by that name can't be found?
    def test_loadTestsFromName__unknown_module_name(self):
        loader = unittest.TestLoader()

        try:
            loader.loadTestsFromName('sdasfasfasdf')
        except ImportError, e:
            self.assertEqual(str(e), "No module named sdasfasfasdf")
        else:
            self.fail("TestLoader.loadTestsFromName failed to raise ImportError")

    # "The specifier name is a ``dotted name'' that may resolve either to
    # a module, a test case class, a TestSuite instance, a test method
    # within a test case class, or a callable object which returns a
    # TestCase or TestSuite instance."
    #
    # What happens when the module is found, but the attribute can't?
    def test_loadTestsFromName__unknown_attr_name(self):
        loader = unittest.TestLoader()

        try:
            loader.loadTestsFromName('unittest.sdasfasfasdf')
        except AttributeError, e:
            self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
        else:
            self.fail("TestLoader.loadTestsFromName failed to raise AttributeError")

    # "The specifier name is a ``dotted name'' that may resolve either to
    # a module, a test case class, a TestSuite instance, a test method
    # within a test case class, or a callable object which returns a
    # TestCase or TestSuite instance."
    #
    # What happens when we provide the module, but the attribute can't be
    # found?
    def test_loadTestsFromName__relative_unknown_name(self):
        loader = unittest.TestLoader()

        try:
            loader.loadTestsFromName('sdasfasfasdf', unittest)
        except AttributeError, e:
            self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
        else:
            self.fail("TestLoader.loadTestsFromName failed to raise AttributeError")

    # "The specifier name is a ``dotted name'' that may resolve either to
    # a module, a test case class, a TestSuite instance, a test method
    # within a test case class, or a callable object which returns a
    # TestCase or TestSuite instance."
    # ...
    # "The method optionally resolves name relative to the given module"
    #
    # Does loadTestsFromName raise ValueError when passed an empty
    # name relative to a provided module?
    #
    # XXX Should probably raise a ValueError instead of an AttributeError
    def test_loadTestsFromName__relative_empty_name(self):
        loader = unittest.TestLoader()

        try:
            loader.loadTestsFromName('', unittest)
        except AttributeError:
            pass
        else:
            self.fail("Failed to raise AttributeError")

    # "The specifier name is a ``dotted name'' that may resolve either to
    # a module, a test case class, a TestSuite instance, a test method
    # within a test case class, or a callable object which returns a
    # TestCase or TestSuite instance."
    # ...
    # "The method optionally resolves name relative to the given module"
    #
    # What happens when an impossible name is given, relative to the provided
    # `module`?
    def test_loadTestsFromName__relative_malformed_name(self):
        loader = unittest.TestLoader()

        # XXX Should this raise AttributeError or ValueError?
        try:
            loader.loadTestsFromName('abc () //', unittest)
        except ValueError:
            pass
        except AttributeError:
            pass
        else:
            self.fail("TestLoader.loadTestsFromName failed to raise ValueError")

    # "The method optionally resolves name relative to the given module"
    #
    # Does loadTestsFromName raise TypeError when the `module` argument
    # isn't a module object?
    #
    # XXX Accepts the not-a-module object, ignoring the object's type
    # This should raise an exception or the method name should be changed
    #
    # XXX Some people are relying on this, so keep it for now
    def test_loadTestsFromName__relative_not_a_module(self):
        class MyTestCase(unittest.TestCase):
            def test(self):
                pass

        class NotAModule(object):
            test_2 = MyTestCase

        loader = unittest.TestLoader()
        suite = loader.loadTestsFromName('test_2', NotAModule)

        reference = [MyTestCase('test')]
        self.assertEqual(list(suite), reference)

    # "The specifier name is a ``dotted name'' that may resolve either to
    # a module, a test case class, a TestSuite instance, a test method
    # within a test case class, or a callable object which returns a
    # TestCase or TestSuite instance."
    #
    # Does it raise an exception if the name resolves to an invalid
    # object?
    def test_loadTestsFromName__relative_bad_object(self):
        m = types.ModuleType('m')
        m.testcase_1 = object()

        loader = unittest.TestLoader()
        try:
            loader.loadTestsFromName('testcase_1', m)
        except TypeError:
            pass
        else:
            self.fail("Should have raised TypeError")

    # "The specifier name is a ``dotted name'' that may
    # resolve either to ... a test case class"
    def test_loadTestsFromName__relative_TestCase_subclass(self):
        m = types.ModuleType('m')
        class MyTestCase(unittest.TestCase):
            def test(self):
                pass
        m.testcase_1 = MyTestCase

        loader = unittest.TestLoader()
        suite = loader.loadTestsFromName('testcase_1', m)
        self.assertIsInstance(suite, loader.suiteClass)
        self.assertEqual(list(suite), [MyTestCase('test')])

    # "The specifier name is a ``dotted name'' that may resolve either to
    # a module, a test case class, a TestSuite instance, a test method
    # within a test case class, or a callable object which returns a
    # TestCase or TestSuite instance."
    def test_loadTestsFromName__relative_TestSuite(self):
        m = types.ModuleType('m')
        class MyTestCase(unittest.TestCase):
            def test(self):
                pass
        m.testsuite = unittest.TestSuite([MyTestCase('test')])

        loader = unittest.TestLoader()
        suite = loader.loadTestsFromName('testsuite', m)
        self.assertIsInstance(suite, loader.suiteClass)

        self.assertEqual(list(suite), [MyTestCase('test')])

    # "The specifier name is a ``dotted name'' that may resolve ... to
    # ... a test method within a test case class"
    def test_loadTestsFromName__relative_testmethod(self):
        m = types.ModuleType('m')
        class MyTestCase(unittest.TestCase):
            def test(self):
                pass
        m.testcase_1 = MyTestCase

        loader = unittest.TestLoader()
        suite = loader.loadTestsFromName('testcase_1.test', m)
        self.assertIsInstance(suite, loader.suiteClass)

        self.assertEqual(list(suite), [MyTestCase('test')])

    # "The specifier name is a ``dotted name'' that may resolve either to
    # a module, a test case class, a TestSuite instance, a test method
    # within a test case class, or a callable object which returns a
    # TestCase or TestSuite instance."
    #
    # Does loadTestsFromName() raise the proper exception when trying to
    # resolve "a test method within a test case class" that doesn't exist
    # for the given name (relative to a provided module)?
    def test_loadTestsFromName__relative_invalid_testmethod(self):
        m = types.ModuleType('m')
        class MyTestCase(unittest.TestCase):
            def test(self):
                pass
        m.testcase_1 = MyTestCase

        loader = unittest.TestLoader()
        try:
            loader.loadTestsFromName('testcase_1.testfoo', m)
        except AttributeError, e:
            self.assertEqual(str(e), "type object 'MyTestCase' has no attribute 'testfoo'")
        else:
            self.fail("Failed to raise AttributeError")

    # "The specifier name is a ``dotted name'' that may resolve ... to
    # ... a callable object which returns a ... TestSuite instance"
    def test_loadTestsFromName__callable__TestSuite(self):
        m = types.ModuleType('m')
        testcase_1 = unittest.FunctionTestCase(lambda: None)
        testcase_2 = unittest.FunctionTestCase(lambda: None)
        def return_TestSuite():
            return unittest.TestSuite([testcase_1, testcase_2])
        m.return_TestSuite = return_TestSuite

        loader = unittest.TestLoader()
        suite = loader.loadTestsFromName('return_TestSuite', m)
        self.assertIsInstance(suite, loader.suiteClass)
        self.assertEqual(list(suite), [testcase_1, testcase_2])

    # "The specifier name is a ``dotted name'' that may resolve ... to
    # ... a callable object which returns a TestCase ... instance"
    def test_loadTestsFromName__callable__TestCase_instance(self):
        m = types.ModuleType('m')
        testcase_1 = unittest.FunctionTestCase(lambda: None)
        def return_TestCase():
            return testcase_1
        m.return_TestCase = return_TestCase

        loader = unittest.TestLoader()
        suite = loader.loadTestsFromName('return_TestCase', m)
        self.assertIsInstance(suite, loader.suiteClass)
        self.assertEqual(list(suite), [testcase_1])

    # "The specifier name is a ``dotted name'' that may resolve ... to
    # ... a callable object which returns a TestCase ... instance"
    #*****************************************************************
    #Override the suiteClass attribute to ensure that the suiteClass
    #attribute is used
    def test_loadTestsFromName__callable__TestCase_instance_ProperSuiteClass(self):
        class SubTestSuite(unittest.TestSuite):
            pass
        m = types.ModuleType('m')
        testcase_1 = unittest.FunctionTestCase(lambda: None)
        def return_TestCase():
            return testcase_1
        m.return_TestCase = return_TestCase

        loader = unittest.TestLoader()
        loader.suiteClass = SubTestSuite
        suite = loader.loadTestsFromName('return_TestCase', m)
        self.assertIsInstance(suite, loader.suiteClass)
        self.assertEqual(list(suite), [testcase_1])

    # "The specifier name is a ``dotted name'' that may resolve ... to
    # ... a test method within a test case class"
    #*****************************************************************
    #Override the suiteClass attribute to ensure that the suiteClass
    #attribute is used
    def test_loadTestsFromName__relative_testmethod_ProperSuiteClass(self):
        class SubTestSuite(unittest.TestSuite):
            pass
        m = types.ModuleType('m')
        class MyTestCase(unittest.TestCase):
            def test(self):
                pass
        m.testcase_1 = MyTestCase

        loader = unittest.TestLoader()
        loader.suiteClass=SubTestSuite
        suite = loader.loadTestsFromName('testcase_1.test', m)
        self.assertIsInstance(suite, loader.suiteClass)

        self.assertEqual(list(suite), [MyTestCase('test')])

    # "The specifier name is a ``dotted name'' that may resolve ... to
    # ... a callable object which returns a TestCase or TestSuite instance"
    #
    # What happens if the callable returns something else?
    def test_loadTestsFromName__callable__wrong_type(self):
        m = types.ModuleType('m')
        def return_wrong():
            return 6
        m.return_wrong = return_wrong

        loader = unittest.TestLoader()
        try:
            loader.loadTestsFromName('return_wrong', m)
        except TypeError:
            pass
        else:
            self.fail("TestLoader.loadTestsFromName failed to raise TypeError")

    # "The specifier can refer to modules and packages which have not been
    # imported; they will be imported as a side-effect"
    def test_loadTestsFromName__module_not_loaded(self):
        # We're going to try to load this module as a side-effect, so it
        # better not be loaded before we try.
        #
        module_name = 'unittest.test.dummy'
        sys.modules.pop(module_name, None)

        loader = unittest.TestLoader()
        try:
            suite = loader.loadTestsFromName(module_name)

            self.assertIsInstance(suite, loader.suiteClass)
            self.assertEqual(list(suite), [])

            # module should now be loaded, thanks to loadTestsFromName()
            self.assertIn(module_name, sys.modules)
        finally:
            if module_name in sys.modules:
                del sys.modules[module_name]

    ################################################################
    ### Tests for TestLoader.loadTestsFromName()

    ### Tests for TestLoader.loadTestsFromNames()
    ################################################################

    # "Similar to loadTestsFromName(), but takes a sequence of names rather
    # than a single name."
    #
    # What happens if that sequence of names is empty?
    def test_loadTestsFromNames__empty_name_list(self):
        loader = unittest.TestLoader()

        suite = loader.loadTestsFromNames([])
        self.assertIsInstance(suite, loader.suiteClass)
        self.assertEqual(list(suite), [])

    # "Similar to loadTestsFromName(), but takes a sequence of names rather
    # than a single name."
    # ...
    # "The method optionally resolves name relative to the given module"
    #
    # What happens if that sequence of names is empty?
    #
    # XXX Should this raise a ValueError or just return an empty TestSuite?
    def test_loadTestsFromNames__relative_empty_name_list(self):
        loader = unittest.TestLoader()

        suite = loader.loadTestsFromNames([], unittest)
        self.assertIsInstance(suite, loader.suiteClass)
        self.assertEqual(list(suite), [])

    # "The specifier name is a ``dotted name'' that may resolve either to
    # a module, a test case class, a TestSuite instance, a test method
    # within a test case class, or a callable object which returns a
    # TestCase or TestSuite instance."
    #
    # Is ValueError raised in response to an empty name?
    def test_loadTestsFromNames__empty_name(self):
        loader = unittest.TestLoader()

        try:
            loader.loadTestsFromNames([''])
        except ValueError, e:
            self.assertEqual(str(e), "Empty module name")
        else:
            self.fail("TestLoader.loadTestsFromNames failed to raise ValueError")

    # "The specifier name is a ``dotted name'' that may resolve either to
    # a module, a test case class, a TestSuite instance, a test method
    # within a test case class, or a callable object which returns a
    # TestCase or TestSuite instance."
    #
    # What happens when presented with an impossible module name?
    def test_loadTestsFromNames__malformed_name(self):
        loader = unittest.TestLoader()

        # XXX Should this raise ValueError or ImportError?
        try:
            loader.loadTestsFromNames(['abc () //'])
        except ValueError:
            pass
        except ImportError:
            pass
        else:
            self.fail("TestLoader.loadTestsFromNames failed to raise ValueError")

    # "The specifier name is a ``dotted name'' that may resolve either to
    # a module, a test case class, a TestSuite instance, a test method
    # within a test case class, or a callable object which returns a
    # TestCase or TestSuite instance."
    #
    # What happens when no module can be found for the given name?
    def test_loadTestsFromNames__unknown_module_name(self):
        loader = unittest.TestLoader()

        try:
            loader.loadTestsFromNames(['sdasfasfasdf'])
        except ImportError, e:
            self.assertEqual(str(e), "No module named sdasfasfasdf")
        else:
            self.fail("TestLoader.loadTestsFromNames failed to raise ImportError")

    # "The specifier name is a ``dotted name'' that may resolve either to
    # a module, a test case class, a TestSuite instance, a test method
    # within a test case class, or a callable object which returns a
    # TestCase or TestSuite instance."
    #
    # What happens when the module can be found, but not the attribute?
    def test_loadTestsFromNames__unknown_attr_name(self):
        loader = unittest.TestLoader()

        try:
            loader.loadTestsFromNames(['unittest.sdasfasfasdf', 'unittest'])
        except AttributeError, e:
            self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
        else:
            self.fail("TestLoader.loadTestsFromNames failed to raise AttributeError")

    # "The specifier name is a ``dotted name'' that may resolve either to
    # a module, a test case class, a TestSuite instance, a test method
    # within a test case class, or a callable object which returns a
    # TestCase or TestSuite instance."
    # ...
    # "The method optionally resolves name relative to the given module"
    #
    # What happens when given an unknown attribute on a specified `module`
    # argument?
    def test_loadTestsFromNames__unknown_name_relative_1(self):
        loader = unittest.TestLoader()

        try:
            loader.loadTestsFromNames(['sdasfasfasdf'], unittest)
        except AttributeError, e:
            self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
        else:
            self.fail("TestLoader.loadTestsFromName failed to raise AttributeError")

    # "The specifier name is a ``dotted name'' that may resolve either to
    # a module, a test case class, a TestSuite instance, a test method
    # within a test case class, or a callable object which returns a
    # TestCase or TestSuite instance."
    # ...
    # "The method optionally resolves name relative to the given module"
    #
    # Do unknown attributes (relative to a provided module) still raise an
    # exception even in the presence of valid attribute names?
    def test_loadTestsFromNames__unknown_name_relative_2(self):
        loader = unittest.TestLoader()

        try:
            loader.loadTestsFromNames(['TestCase', 'sdasfasfasdf'], unittest)
        except AttributeError, e:
            self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
        else:
            self.fail("TestLoader.loadTestsFromName failed to raise AttributeError")

    # "The specifier name is a ``dotted name'' that may resolve either to
    # a module, a test case class, a TestSuite instance, a test method
    # within a test case class, or a callable object which returns a
    # TestCase or TestSuite instance."
    # ...
    # "The method optionally resolves name relative to the given module"
    #
    # What happens when faced with the empty string?
    #
    # XXX This currently raises AttributeError, though ValueError is probably
    # more appropriate
    def test_loadTestsFromNames__relative_empty_name(self):
        loader = unittest.TestLoader()

        try:
            loader.loadTestsFromNames([''], unittest)
        except AttributeError:
            pass
        else:
            self.fail("Failed to raise ValueError")

    # "The specifier name is a ``dotted name'' that may resolve either to
    # a module, a test case class, a TestSuite instance, a test method
    # within a test case class, or a callable object which returns a
    # TestCase or TestSuite instance."
    # ...
    # "The method optionally resolves name relative to the given module"
    #
    # What happens when presented with an impossible attribute name?
    def test_loadTestsFromNames__relative_malformed_name(self):
        loader = unittest.TestLoader()

        # XXX Should this raise AttributeError or ValueError?
        try:
            loader.loadTestsFromNames(['abc () //'], unittest)
        except AttributeError:
            pass
        except ValueError:
            pass
        else:
            self.fail("TestLoader.loadTestsFromNames failed to raise ValueError")

    # "The method optionally resolves name relative to the given module"
    #
    # Does loadTestsFromNames() make sure the provided `module` is in fact
    # a module?
    #
    # XXX This validation is currently not done. This flexibility should
    # either be documented or a TypeError should be raised.
    def test_loadTestsFromNames__relative_not_a_module(self):
        class MyTestCase(unittest.TestCase):
            def test(self):
                pass

        class NotAModule(object):
            test_2 = MyTestCase

        loader = unittest.TestLoader()
        suite = loader.loadTestsFromNames(['test_2'], NotAModule)

        reference = [unittest.TestSuite([MyTestCase('test')])]
        self.assertEqual(list(suite), reference)

    # "The specifier name is a ``dotted name'' that may resolve either to
    # a module, a test case class, a TestSuite instance, a test method
    # within a test case class, or a callable object which returns a
    # TestCase or TestSuite instance."
    #
    # Does it raise an exception if the name resolves to an invalid
    # object?
    def test_loadTestsFromNames__relative_bad_object(self):
        m = types.ModuleType('m')
        m.testcase_1 = object()

        loader = unittest.TestLoader()
        try:
            loader.loadTestsFromNames(['testcase_1'], m)
        except TypeError:
            pass
        else:
            self.fail("Should have raised TypeError")

    # "The specifier name is a ``dotted name'' that may resolve ... to
    # ... a test case class"
    def test_loadTestsFromNames__relative_TestCase_subclass(self):
        m = types.ModuleType('m')
        class MyTestCase(unittest.TestCase):
            def test(self):
                pass
        m.testcase_1 = MyTestCase

        loader = unittest.TestLoader()
        suite = loader.loadTestsFromNames(['testcase_1'], m)
        self.assertIsInstance(suite, loader.suiteClass)

        expected = loader.suiteClass([MyTestCase('test')])
        self.assertEqual(list(suite), [expected])

    # "The specifier name is a ``dotted name'' that may resolve ... to
    # ... a TestSuite instance"
    def test_loadTestsFromNames__relative_TestSuite(self):
        m = types.ModuleType('m')
        class MyTestCase(unittest.TestCase):
            def test(self):
                pass
        m.testsuite = unittest.TestSuite([MyTestCase('test')])

        loader = unittest.TestLoader()
        suite = loader.loadTestsFromNames(['testsuite'], m)
        self.assertIsInstance(suite, loader.suiteClass)

        self.assertEqual(list(suite), [m.testsuite])

    # "The specifier name is a ``dotted name'' that may resolve ... to ... a
    # test method within a test case class"
    def test_loadTestsFromNames__relative_testmethod(self):
        m = types.ModuleType('m')
        class MyTestCase(unittest.TestCase):
            def test(self):
                pass
        m.testcase_1 = MyTestCase

        loader = unittest.TestLoader()
        suite = loader.loadTestsFromNames(['testcase_1.test'], m)
        self.assertIsInstance(suite, loader.suiteClass)

        ref_suite = unittest.TestSuite([MyTestCase('test')])
        self.assertEqual(list(suite), [ref_suite])

    # "The specifier name is a ``dotted name'' that may resolve ... to ... a
    # test method within a test case class"
    #
    # Does the method gracefully handle names that initially look like they
    # resolve to "a test method within a test case class" but don't?
    def test_loadTestsFromNames__relative_invalid_testmethod(self):
        m = types.ModuleType('m')
        class MyTestCase(unittest.TestCase):
            def test(self):
                pass
        m.testcase_1 = MyTestCase

        loader = unittest.TestLoader()
        try:
            loader.loadTestsFromNames(['testcase_1.testfoo'], m)
        except AttributeError, e:
            self.assertEqual(str(e), "type object 'MyTestCase' has no attribute 'testfoo'")
        else:
            self.fail("Failed to raise AttributeError")

    # "The specifier name is a ``dotted name'' that may resolve ... to
    # ... a callable object which returns a ... TestSuite instance"
    def test_loadTestsFromNames__callable__TestSuite(self):
        m = types.ModuleType('m')
        testcase_1 = unittest.FunctionTestCase(lambda: None)
        testcase_2 = unittest.FunctionTestCase(lambda: None)
        def return_TestSuite():
            return unittest.TestSuite([testcase_1, testcase_2])
        m.return_TestSuite = return_TestSuite

        loader = unittest.TestLoader()
        suite = loader.loadTestsFromNames(['return_TestSuite'], m)
        self.assertIsInstance(suite, loader.suiteClass)

        expected = unittest.TestSuite([testcase_1, testcase_2])
        self.assertEqual(list(suite), [expected])

    # "The specifier name is a ``dotted name'' that may resolve ... to
    # ... a callable object which returns a TestCase ... instance"
    def test_loadTestsFromNames__callable__TestCase_instance(self):
        m = types.ModuleType('m')
        testcase_1 = unittest.FunctionTestCase(lambda: None)
        def return_TestCase():
            return testcase_1
        m.return_TestCase = return_TestCase

        loader = unittest.TestLoader()
        suite = loader.loadTestsFromNames(['return_TestCase'], m)
        self.assertIsInstance(suite, loader.suiteClass)

        ref_suite = unittest.TestSuite([testcase_1])
        self.assertEqual(list(suite), [ref_suite])

    # "The specifier name is a ``dotted name'' that may resolve ... to
    # ... a callable object which returns a TestCase or TestSuite instance"
    #
    # Are staticmethods handled correctly?
    def test_loadTestsFromNames__callable__call_staticmethod(self):
        m = types.ModuleType('m')
        class Test1(unittest.TestCase):
            def test(self):
                pass

        testcase_1 = Test1('test')
        class Foo(unittest.TestCase):
            @staticmethod
            def foo():
                return testcase_1
        m.Foo = Foo

        loader = unittest.TestLoader()
        suite = loader.loadTestsFromNames(['Foo.foo'], m)
        self.assertIsInstance(suite, loader.suiteClass)

        ref_suite = unittest.TestSuite([testcase_1])
        self.assertEqual(list(suite), [ref_suite])

    # "The specifier name is a ``dotted name'' that may resolve ... to
    # ... a callable object which returns a TestCase or TestSuite instance"
    #
    # What happens when the callable returns something else?
    def test_loadTestsFromNames__callable__wrong_type(self):
        m = types.ModuleType('m')
        def return_wrong():
            return 6
        m.return_wrong = return_wrong

        loader = unittest.TestLoader()
        try:
            loader.loadTestsFromNames(['return_wrong'], m)
        except TypeError:
            pass
        else:
            self.fail("TestLoader.loadTestsFromNames failed to raise TypeError")

    # "The specifier can refer to modules and packages which have not been
    # imported; they will be imported as a side-effect"
    def test_loadTestsFromNames__module_not_loaded(self):
        # We're going to try to load this module as a side-effect, so it
        # better not be loaded before we try.
        #
        module_name = 'unittest.test.dummy'
        sys.modules.pop(module_name, None)

        loader = unittest.TestLoader()
        try:
            suite = loader.loadTestsFromNames([module_name])

            self.assertIsInstance(suite, loader.suiteClass)
            self.assertEqual(list(suite), [unittest.TestSuite()])

            # module should now be loaded, thanks to loadTestsFromName()
            self.assertIn(module_name, sys.modules)
        finally:
            if module_name in sys.modules:
                del sys.modules[module_name]

    ################################################################
    ### /Tests for TestLoader.loadTestsFromNames()

    ### Tests for TestLoader.getTestCaseNames()
    ################################################################

    # "Return a sorted sequence of method names found within testCaseClass"
    #
    # Test.foobar is defined to make sure getTestCaseNames() respects
    # loader.testMethodPrefix
    def test_getTestCaseNames(self):
        class Test(unittest.TestCase):
            def test_1(self): pass
            def test_2(self): pass
            def foobar(self): pass

        loader = unittest.TestLoader()

        self.assertEqual(loader.getTestCaseNames(Test), ['test_1', 'test_2'])

    # "Return a sorted sequence of method names found within testCaseClass"
    #
    # Does getTestCaseNames() behave appropriately if no tests are found?
    def test_getTestCaseNames__no_tests(self):
        class Test(unittest.TestCase):
            def foobar(self): pass

        loader = unittest.TestLoader()

        self.assertEqual(loader.getTestCaseNames(Test), [])

    # "Return a sorted sequence of method names found within testCaseClass"
    #
    # Are not-TestCases handled gracefully?
    #
    # XXX This should raise a TypeError, not return a list
    #
    # XXX It's too late in the 2.5 release cycle to fix this, but it should
    # probably be revisited for 2.6
    def test_getTestCaseNames__not_a_TestCase(self):
        class BadCase(int):
            def test_foo(self):
                pass

        loader = unittest.TestLoader()
        names = loader.getTestCaseNames(BadCase)

        self.assertEqual(names, ['test_foo'])

    # "Return a sorted sequence of method names found within testCaseClass"
    #
    # Make sure inherited names are handled.
    #
    # TestP.foobar is defined to make sure getTestCaseNames() respects
    # loader.testMethodPrefix
    def test_getTestCaseNames__inheritance(self):
        class TestP(unittest.TestCase):
            def test_1(self): pass
            def test_2(self): pass
            def foobar(self): pass

        class TestC(TestP):
            def test_1(self): pass
            def test_3(self): pass

        loader = unittest.TestLoader()

        names = ['test_1', 'test_2', 'test_3']
        self.assertEqual(loader.getTestCaseNames(TestC), names)

    ################################################################
    ### /Tests for TestLoader.getTestCaseNames()

    ### Tests for TestLoader.testMethodPrefix
    ################################################################

    # "String giving the prefix of method names which will be interpreted as
    # test methods"
    #
    # Implicit in the documentation is that testMethodPrefix is respected by
    # all loadTestsFrom* methods.
    def test_testMethodPrefix__loadTestsFromTestCase(self):
        class Foo(unittest.TestCase):
            def test_1(self): pass
            def test_2(self): pass
            def foo_bar(self): pass

        tests_1 = unittest.TestSuite([Foo('foo_bar')])
        tests_2 = unittest.TestSuite([Foo('test_1'), Foo('test_2')])

        loader = unittest.TestLoader()
        loader.testMethodPrefix = 'foo'
        self.assertEqual(loader.loadTestsFromTestCase(Foo), tests_1)

        loader.testMethodPrefix = 'test'
        self.assertEqual(loader.loadTestsFromTestCase(Foo), tests_2)

    # "String giving the prefix of method names which will be interpreted as
    # test methods"
    #
    # Implicit in the documentation is that testMethodPrefix is respected by
    # all loadTestsFrom* methods.
    def test_testMethodPrefix__loadTestsFromModule(self):
        m = types.ModuleType('m')
        class Foo(unittest.TestCase):
            def test_1(self): pass
            def test_2(self): pass
            def foo_bar(self): pass
        m.Foo = Foo

        tests_1 = [unittest.TestSuite([Foo('foo_bar')])]
        tests_2 = [unittest.TestSuite([Foo('test_1'), Foo('test_2')])]

        loader = unittest.TestLoader()
        loader.testMethodPrefix = 'foo'
        self.assertEqual(list(loader.loadTestsFromModule(m)), tests_1)

        loader.testMethodPrefix = 'test'
        self.assertEqual(list(loader.loadTestsFromModule(m)), tests_2)

    # "String giving the prefix of method names which will be interpreted as
    # test methods"
    #
    # Implicit in the documentation is that testMethodPrefix is respected by
    # all loadTestsFrom* methods.
    def test_testMethodPrefix__loadTestsFromName(self):
        m = types.ModuleType('m')
        class Foo(unittest.TestCase):
            def test_1(self): pass
            def test_2(self): pass
            def foo_bar(self): pass
        m.Foo = Foo

        tests_1 = unittest.TestSuite([Foo('foo_bar')])
        tests_2 = unittest.TestSuite([Foo('test_1'), Foo('test_2')])

        loader = unittest.TestLoader()
        loader.testMethodPrefix = 'foo'
        self.assertEqual(loader.loadTestsFromName('Foo', m), tests_1)

        loader.testMethodPrefix = 'test'
        self.assertEqual(loader.loadTestsFromName('Foo', m), tests_2)

    # "String giving the prefix of method names which will be interpreted as
    # test methods"
    #
    # Implicit in the documentation is that testMethodPrefix is respected by
    # all loadTestsFrom* methods.
    def test_testMethodPrefix__loadTestsFromNames(self):
        m = types.ModuleType('m')
        class Foo(unittest.TestCase):
            def test_1(self): pass
            def test_2(self): pass
            def foo_bar(self): pass
        m.Foo = Foo

        tests_1 = unittest.TestSuite([unittest.TestSuite([Foo('foo_bar')])])
        tests_2 = unittest.TestSuite([Foo('test_1'), Foo('test_2')])
        tests_2 = unittest.TestSuite([tests_2])

        loader = unittest.TestLoader()
        loader.testMethodPrefix = 'foo'
        self.assertEqual(loader.loadTestsFromNames(['Foo'], m), tests_1)

        loader.testMethodPrefix = 'test'
        self.assertEqual(loader.loadTestsFromNames(['Foo'], m), tests_2)

    # "The default value is 'test'"
    def test_testMethodPrefix__default_value(self):
        loader = unittest.TestLoader()
        self.assertTrue(loader.testMethodPrefix == 'test')

    ################################################################
    ### /Tests for TestLoader.testMethodPrefix

    ### Tests for TestLoader.sortTestMethodsUsing
    ################################################################

    # "Function to be used to compare method names when sorting them in
    # getTestCaseNames() and all the loadTestsFromX() methods"
    def test_sortTestMethodsUsing__loadTestsFromTestCase(self):
        def reversed_cmp(x, y):
            return -cmp(x, y)

        class Foo(unittest.TestCase):
            def test_1(self): pass
            def test_2(self): pass

        loader = unittest.TestLoader()
        loader.sortTestMethodsUsing = reversed_cmp

        tests = loader.suiteClass([Foo('test_2'), Foo('test_1')])
        self.assertEqual(loader.loadTestsFromTestCase(Foo), tests)

    # "Function to be used to compare method names when sorting them in
    # getTestCaseNames() and all the loadTestsFromX() methods"
    def test_sortTestMethodsUsing__loadTestsFromModule(self):
        def reversed_cmp(x, y):
            return -cmp(x, y)

        m = types.ModuleType('m')
        class Foo(unittest.TestCase):
            def test_1(self): pass
            def test_2(self): pass
        m.Foo = Foo

        loader = unittest.TestLoader()
        loader.sortTestMethodsUsing = reversed_cmp

        tests = [loader.suiteClass([Foo('test_2'), Foo('test_1')])]
        self.assertEqual(list(loader.loadTestsFromModule(m)), tests)

    # "Function to be used to compare method names when sorting them in
    # getTestCaseNames() and all the loadTestsFromX() methods"
    def test_sortTestMethodsUsing__loadTestsFromName(self):
        def reversed_cmp(x, y):
            return -cmp(x, y)

        m = types.ModuleType('m')
        class Foo(unittest.TestCase):
            def test_1(self): pass
            def test_2(self): pass
        m.Foo = Foo

        loader = unittest.TestLoader()
        loader.sortTestMethodsUsing = reversed_cmp

        tests = loader.suiteClass([Foo('test_2'), Foo('test_1')])
        self.assertEqual(loader.loadTestsFromName('Foo', m), tests)

    # "Function to be used to compare method names when sorting them in
    # getTestCaseNames() and all the loadTestsFromX() methods"
    def test_sortTestMethodsUsing__loadTestsFromNames(self):
        def reversed_cmp(x, y):
            return -cmp(x, y)

        m = types.ModuleType('m')
        class Foo(unittest.TestCase):
            def test_1(self): pass
            def test_2(self): pass
        m.Foo = Foo

        loader = unittest.TestLoader()
        loader.sortTestMethodsUsing = reversed_cmp

        tests = [loader.suiteClass([Foo('test_2'), Foo('test_1')])]
        self.assertEqual(list(loader.loadTestsFromNames(['Foo'], m)), tests)

    # "Function to be used to compare method names when sorting them in
    # getTestCaseNames()"
    #
    # Does it actually affect getTestCaseNames()?
    def test_sortTestMethodsUsing__getTestCaseNames(self):
        def reversed_cmp(x, y):
            return -cmp(x, y)

        class Foo(unittest.TestCase):
            def test_1(self): pass
            def test_2(self): pass

        loader = unittest.TestLoader()
        loader.sortTestMethodsUsing = reversed_cmp

        test_names = ['test_2', 'test_1']
        self.assertEqual(loader.getTestCaseNames(Foo), test_names)

    # "The default value is the built-in cmp() function"
    def test_sortTestMethodsUsing__default_value(self):
        loader = unittest.TestLoader()
        self.assertTrue(loader.sortTestMethodsUsing is cmp)

    # "it can be set to None to disable the sort."
    #
    # XXX How is this different from reassigning cmp? Are the tests returned
    # in a random order or something? This behaviour should die
    def test_sortTestMethodsUsing__None(self):
        class Foo(unittest.TestCase):
            def test_1(self): pass
            def test_2(self): pass

        loader = unittest.TestLoader()
        loader.sortTestMethodsUsing = None

        test_names = ['test_2', 'test_1']
        self.assertEqual(set(loader.getTestCaseNames(Foo)), set(test_names))

    ################################################################
    ### /Tests for TestLoader.sortTestMethodsUsing

    ### Tests for TestLoader.suiteClass
    ################################################################

    # "Callable object that constructs a test suite from a list of tests."
    def test_suiteClass__loadTestsFromTestCase(self):
        class Foo(unittest.TestCase):
            def test_1(self): pass
            def test_2(self): pass
            def foo_bar(self): pass

        tests = [Foo('test_1'), Foo('test_2')]

        loader = unittest.TestLoader()
        loader.suiteClass = list
        self.assertEqual(loader.loadTestsFromTestCase(Foo), tests)

    # It is implicit in the documentation for TestLoader.suiteClass that
    # all TestLoader.loadTestsFrom* methods respect it. Let's make sure
    def test_suiteClass__loadTestsFromModule(self):
        m = types.ModuleType('m')
        class Foo(unittest.TestCase):
            def test_1(self): pass
            def test_2(self): pass
            def foo_bar(self): pass
        m.Foo = Foo

        tests = [[Foo('test_1'), Foo('test_2')]]

        loader = unittest.TestLoader()
        loader.suiteClass = list
        self.assertEqual(loader.loadTestsFromModule(m), tests)

    # It is implicit in the documentation for TestLoader.suiteClass that
    # all TestLoader.loadTestsFrom* methods respect it. Let's make sure
    def test_suiteClass__loadTestsFromName(self):
        m = types.ModuleType('m')
        class Foo(unittest.TestCase):
            def test_1(self): pass
            def test_2(self): pass
            def foo_bar(self): pass
        m.Foo = Foo

        tests = [Foo('test_1'), Foo('test_2')]

        loader = unittest.TestLoader()
        loader.suiteClass = list
        self.assertEqual(loader.loadTestsFromName('Foo', m), tests)

    # It is implicit in the documentation for TestLoader.suiteClass that
    # all TestLoader.loadTestsFrom* methods respect it. Let's make sure
    def test_suiteClass__loadTestsFromNames(self):
        m = types.ModuleType('m')
        class Foo(unittest.TestCase):
            def test_1(self): pass
            def test_2(self): pass
            def foo_bar(self): pass
        m.Foo = Foo

        tests = [[Foo('test_1'), Foo('test_2')]]

        loader = unittest.TestLoader()
        loader.suiteClass = list
        self.assertEqual(loader.loadTestsFromNames(['Foo'], m), tests)

    # "The default value is the TestSuite class"
    def test_suiteClass__default_value(self):
        loader = unittest.TestLoader()
        self.assertIs(loader.suiteClass, unittest.TestSuite)

    # Make sure the dotted name resolution works even if the actual
    # function doesn't have the same name as is used to find it.
    def test_loadTestsFromName__function_with_different_name_than_method(self):
        # lambdas have the name '<lambda>'.
        m = types.ModuleType('m')
        class MyTestCase(unittest.TestCase):
            test = lambda: 1
        m.testcase_1 = MyTestCase

        loader = unittest.TestLoader()
        suite = loader.loadTestsFromNames(['testcase_1.test'], m)
        self.assertIsInstance(suite, loader.suiteClass)

        ref_suite = unittest.TestSuite([MyTestCase('test')])
        self.assertEqual(list(suite), [ref_suite])

if __name__ == '__main__':
    unittest.main()
PK��[aDϗS�Stest/test_result.pycnu�[����
|fc@s>ddlZddlZddlmZddlmZddlZddlZdejfd��YZe	ej
j�Zx!dddd	fD]
Z
ee
=q�Weeed
�Zeed	<edefe�Zdejfd
��YZdefd��YZd�Zdejfd��YZedkr:ej�ndS(i����N(tStringIO(ttest_supporttTest_TestResultcBs�eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
eje
jjd	kd
�d��Zeje
jjd	kd
�d��Zd
�Zd�Zd�ZRS(cCs�tj�}|j|j��|jt|j�d�|jt|j�d�|j|jd�|j|j	t
�|j|j�|j|j
�dS(Ni(tunittestt
TestResultt
assertTruet
wasSuccessfultassertEqualtlenterrorstfailuresttestsRunt
shouldStoptFalsetassertIsNonet_stdout_buffert_stderr_buffer(tselftresult((s1/usr/lib64/python2.7/unittest/test/test_result.pyt	test_initscCs-tj�}|j�|j|jt�dS(N(RRtstopRRtTrue(RR((s1/usr/lib64/python2.7/unittest/test/test_result.pyt	test_stop#s
cCs�dtjfd��Y}|d�}tj�}|j|�|j|j��|jt|j�d�|jt|j	�d�|j|j
d�|j|jt�|j
|�dS(NtFoocBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttest_1.s(t__name__t
__module__R(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR-sRii(RtTestCaseRt	startTestRRRRR	R
RRR
tstopTest(RRttestR((s1/usr/lib64/python2.7/unittest/test/test_result.pyttest_startTest,s
cCs%dtjfd��Y}|d�}tj�}|j|�|j|j��|jt|j�d�|jt|j	�d�|j|j
d�|j|jt�|j
|�|j|j��|jt|j�d�|jt|j	�d�|j|j
d�|j|jt�dS(NRcBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyRCs(RRR(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRBsRii(RRRRRRRRR	R
RRR
R(RRRR((s1/usr/lib64/python2.7/unittest/test/test_result.pyt
test_stopTestAs

cCs$tj�}|j�|j�dS(N(RRtstartTestRuntstopTestRun(RR((s1/usr/lib64/python2.7/unittest/test/test_result.pyttest_startTestRun_stopTestRun\s
cCs�dtjfd��Y}|d�}tj�}|j|�|j|�|j|�|j|j��|jt	|j
�d�|jt	|j�d�|j|jd�|j|j
t�dS(NRcBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyRvs(RRR(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRusRii(RRRRt
addSuccessRRRRRR	R
RRR
(RRRR((s1/usr/lib64/python2.7/unittest/test/test_result.pyttest_addSuccessts


cCs$dtjfd��Y}|d�}y|jd�Wntj�}nXtj�}|j|�|j||�|j|�|j	|j
��|jt|j
�d�|jt|j�d�|j|jd�|j|jt�|jd\}}|j||�|j|t�dS(NRcBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyR�s(RRR(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR�sRtfooii(RRtfailtsystexc_infoRRt
addFailureRtassertFalseRRRR	R
RRR
tassertIstassertIsInstancetstr(RRRtexc_info_tupleRt	test_caset
formatted_exc((s1/usr/lib64/python2.7/unittest/test/test_result.pyttest_addFailure�s$

cCs dtjfd��Y}|d�}y
t��Wntj�}nXtj�}|j|�|j||�|j|�|j	|j
��|jt|j
�d�|jt|j�d�|j|jd�|j|jt�|j
d\}}|j||�|j|t�dS(NRcBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyR�s(RRR(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR�sRii(RRt	TypeErrorR(R)RRtaddErrorRR+RRRR	R
RRR
R,R-R.(RRRR/RR0R1((s1/usr/lib64/python2.7/unittest/test/test_result.pyt
test_addError�s$


cCs:tjdtd�}|j|j|�dtd�dS(Nis$testGetDescriptionWithoutDocstring (s.Test_TestResult)(RtTextTestResulttNoneRRtgetDescriptionR(RR((s1/usr/lib64/python2.7/unittest/test/test_result.pyt"testGetDescriptionWithoutDocstring�s
is)Docstrings are omitted with -O2 and abovecCs:tjdtd�}|j|j|�dtd�dS(s5Tests getDescription() for a method with a docstring.is(testGetDescriptionWithOneLineDocstring (sG.Test_TestResult)
Tests getDescription() for a method with a docstring.N(RR6R7RRR8R(RR((s1/usr/lib64/python2.7/unittest/test/test_result.pyt&testGetDescriptionWithOneLineDocstring�scCs:tjdtd�}|j|j|�dtd�dS(soTests getDescription() for a method with a longer docstring.
        The second line of the docstring.
        is*testGetDescriptionWithMultiLineDocstring (sN.Test_TestResult)
Tests getDescription() for a method with a longer docstring.N(RR6R7RRR8R(RR((s1/usr/lib64/python2.7/unittest/test/test_result.pyt(testGetDescriptionWithMultiLineDocstring�scCsbdtfd��Y}tj�}|j|j|��t|jjd<|j|j|��dS(NtFramecBseZdefd��YZRS(ttb_framecBseZiZRS((RRt	f_globals(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR=s(RRtobjectR=(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR<st
__unittest(	R?RRR+t_is_relevant_tb_levelRR=R>R(RR<R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestStackFrameTrimmings
cCs�tj�}d�|_t|_|jdd�|j|j�tj�}d�|_t|_|j	dd�|j|j�tj�}d�|_t|_|j
d�|j|j�dS(NcWsdS(Nt((t_((s1/usr/lib64/python2.7/unittest/test/test_result.pyt<lambda>RCcWsdS(NRC((RD((s1/usr/lib64/python2.7/unittest/test/test_result.pyRERCcWsdS(NRC((RD((s1/usr/lib64/python2.7/unittest/test/test_result.pyRERC(RRt_exc_info_to_stringRtfailfastR4R7RRR*taddUnexpectedSuccess(RR((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestFailFasts			
cs;tjdt�dt�}�fd�}|j|�dS(NtstreamRGcs�j|j�dS(N(RRG(R(R(s1/usr/lib64/python2.7/unittest/test/test_result.pyR%s(RtTextTestRunnerRRtrun(RtrunnerR((Rs1/usr/lib64/python2.7/unittest/test/test_result.pyttestFailFastSetByRunner#s(RRRRRR R#R%R2R5R9RtskipIfR(tflagstoptimizeR:R;RBRIRN(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR
s 
							'	0		

	
	taddSkiptaddExpectedFailureRHt__init__cCs1g|_g|_d|_t|_t|_dS(Ni(R
R	RR
Rtbuffer(RRJtdescriptionst	verbosity((s1/usr/lib64/python2.7/unittest/test/test_result.pyRT/s
				t	OldResulttTest_OldTestResultcBs5eZd�Zd�Zd�Zd�Zd�ZRS(cCsOtjdtf��4t�}|j|�|jt|j�|�WdQXdS(NsTestResult has no add.+ method,(Rtcheck_warningstRuntimeWarningRXRLRRR
(RRR
R((s1/usr/lib64/python2.7/unittest/test/test_result.pytassertOldResultWarning;s
	
	
cCsrdtjfd��Y}xRdtfdtfdtffD]/\}}||�}|j|t|��q;WdS(NtTestcBs5eZd�Zejd��Zejd��ZRS(cSs|jd�dS(Ntfoobar(tskipTest(R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestSkipDscSs
t�dS(N(R3(R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestExpectedFailFscSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestUnexpectedSuccessIs(RRR`RtexpectedFailureRaRb(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR]Cs	R`RaRb(RRRR
R\tint(RR]t	test_nametshould_passR((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestOldTestResultBs
	cCs3dtjfd��Y}|j|d�d�dS(NR]cBseZd�Zd�ZRS(cSs|jd�dS(Ns	no reason(R_(R((s1/usr/lib64/python2.7/unittest/test/test_result.pytsetUpUscSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestFooWs(RRRhRi(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR]Ts	Rii(RRR\(RR]((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestOldTestTesultSetupSscCsBtjd�dtjfd��Y�}|j|d�d�dS(Ns	no reasonR]cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyRi^s(RRRi(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR]\sRii(RtskipRR\(RR]((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestOldTestResultClass[scCsKdtjfd��Y}tjdtdt��}|j|d��dS(NR]cBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyRids(RRRi(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR]cstresultclassRJRi(RRRKRXRRL(RR]RM((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestOldResultWithRunnerbs(RRR\RgRjRlRn(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRY9s
				t
MockTracebackcBseZed��ZRS(cGsdgS(NsA traceback((RD((s1/usr/lib64/python2.7/unittest/test/test_result.pytformat_exceptionns(RRtstaticmethodRp(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRomscCsttj_dS(N(t	tracebackRR(((s1/usr/lib64/python2.7/unittest/test/test_result.pytrestore_tracebackrstTestOutputBufferingcBsbeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�ZRS(
cCstj|_tj|_dS(N(R(tstdoutt	_real_outtstderrt	_real_err(R((s1/usr/lib64/python2.7/unittest/test/test_result.pyRhxscCs|jt_|jt_dS(N(RvR(RuRxRw(R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttearDown|scCs�|j}|j}tj�}|j|j�|j|tj�|j|tj	�|j
|�|j|tj�|j|tj	�dS(N(RvRxRRR+RUR,R(RuRwR(Rtreal_outtreal_errR((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestBufferOutputOff�s		
cCs|j}|j}tj�}|j|j�t|_|j|tj	�|j|tj
�|j|�|j|tj	�|j|tj
�|j
tj	t�|j
tj
t�|jtj	tj
�tj	}tj
}t�|_t�|_dGHtj
dIJ|j|j�d�|j|j�d�|j|jj�d�|j|jj�d�|j|�|j|�|jtj	|j�|jtj
|j�|j|jj�d�|j|jj�d�|j|j�d�|j|j�d�dS(NR&tbarsfoo
sbar
RC(RvRxRRR+RURR,R(RuRwRtassertIsNotR-Rt_original_stdoutt_original_stderrRtgetvalueR$R(RRzR{Rt
out_streamt
err_stream((s1/usr/lib64/python2.7/unittest/test/test_result.pyt#testBufferOutputStartTestAddSuccess�s>			
		


cCs&tj�}t|_|j|�|S(N(RRRRUR(RR((s1/usr/lib64/python2.7/unittest/test/test_result.pytgetStartedResult�s	
cCs�ttj_|jt�x�ddtfddtfddtfddtfgD]U\}}}|j�}t	j
}t	j}t�|_
t�|_t	j
dIJ|r�t	jdIJnt||�}||d
�|j|�t||�}|jt|�d�|d\}	}
tjd	�}d
}|rCtjd�}nd||f}
|j|	|�|j|j
j�|�|j|jj�|�|j|
|
�qPWdS(NR	R4R
R*R&R}iis9
                Stdout:
                foo
            RCs9
                Stderr:
                bar
            sA traceback%s%s(NNN(RoRRRrt
addCleanupRsRR
R�R(RuRwRRR�tgetattrR7RRRttextwraptdedentR,R�tassertMultiLineEqual(Rtmessage_attrtadd_attrt
include_errorRtbuffered_outtbuffered_errtaddFunctiontresult_listRtmessagetexpectedOutMessagetexpectedErrMessagetexpectedFullMessage((s1/usr/lib64/python2.7/unittest/test/test_result.pyt!testBufferOutputAddErrorOrFailure�s@
		


	cCsmtj�}t|_dtjfd��Y}tj|d�g�}||�|jt|j�d�dS(NRcBs eZed��Zd�ZRS(cSsdddS(Nii((tcls((s1/usr/lib64/python2.7/unittest/test/test_result.pyt
setUpClass�scSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyttest_foo�s(RRtclassmethodR�R�(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR�sR�i(	RRRRURt	TestSuiteRRR	(RRRtsuite((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestBufferSetupClass�s	
cCsmtj�}t|_dtjfd��Y}tj|d�g�}||�|jt|j�d�dS(NRcBs eZed��Zd�ZRS(cSsdddS(Nii((R�((s1/usr/lib64/python2.7/unittest/test/test_result.pyt
tearDownClassscSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyR�	s(RRR�R�R�(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRsR�i(	RRRRURR�RRR	(RRRR�((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestBufferTearDownClasss	
cCs�tj�}t|_dtjfd��Y}dtfd��Y}d|_|tjd<|j	tjj
d�tj|d�g�}||�|jt
|j�d�dS(NRcBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyR�s(RRR�(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRstModulecBseZed��ZRS(cSsdddS(Nii((((s1/usr/lib64/python2.7/unittest/test/test_result.pytsetUpModules(RRRqR�(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR�sR�i(RRRRURR?RR(tmodulesR�tpopR�RRR	(RRRR�R�((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestBufferSetUpModules		

cCs�tj�}t|_dtjfd��Y}dtfd��Y}d|_|tjd<|j	tjj
d�tj|d�g�}||�|jt
|j�d�dS(NRcBseZd�ZRS(cSsdS(N((R((s1/usr/lib64/python2.7/unittest/test/test_result.pyR�'s(RRR�(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR&sR�cBseZed��ZRS(cSsdddS(Nii((((s1/usr/lib64/python2.7/unittest/test/test_result.pyttearDownModule*s(RRRqR�(((s1/usr/lib64/python2.7/unittest/test/test_result.pyR�)sR�i(RRRRURR?RR(R�R�R�R�RRR	(RRRR�R�((s1/usr/lib64/python2.7/unittest/test/test_result.pyttestBufferTearDownModule"s		

(RRRhRyR|R�R�R�R�R�R�R�(((s1/usr/lib64/python2.7/unittest/test/test_result.pyRtvs				0		.			t__main__(R(R�RRRRrRRRtdictRt__dict__t	classDicttmR7RTttypeR?RXRYRoRsRtRtmain(((s1/usr/lib64/python2.7/unittest/test/test_result.pyt<module>s(�!

4	�PK��[�ú��(�(test/test_program.pycnu�[����
|fc@s�ddlmZddlZddlZddlZddlZdejfd��YZdejfd��YZ	e
�Zde
fd��YZd	ejfd
��YZ
edkr�ej�ndS(i����(tStringIONtTest_TestProgramcBsgeZd�Zd�Zdejfd��YZdejfd��YZd�Z	d�Z
d�ZRS(	cs�tj�}�g�tjjtjjtjj���t�_	���fd�}||_
|jd�}�j�j	��j
|j��dS(Ncst�_�j|���S(N(tTruetwasRuntassertEqual(t	start_dirtpattern(texpectedPathtselfttests(s2/usr/lib64/python2.7/unittest/test/test_program.pyt_find_testss	s
unittest.test(tunittestt
TestLoadertostpathtabspathtdirnamettestt__file__tFalseRR
tdiscovert
assertTrueRt_tests(RtloaderR
tsuite((RRR	s2/usr/lib64/python2.7/unittest/test/test_program.pyttest_discovery_from_dotted_paths	$		cs�t��t�}dtf�fd��Y}|�}tjj��fd�}d�tj_|j|�d�}|tj_|j|�tjd|dtdd	�}|j|j��|j|j|�|j|j	d	�dS(
Nt
FakeRunnercseZ�fd�ZRS(cs
||_�S(N(R(RR(tresult(s2/usr/lib64/python2.7/unittest/test/test_program.pytrun!s	(t__name__t
__module__R((R(s2/usr/lib64/python2.7/unittest/test/test_program.pyR scs�tj_dS(N(RtTestProgramt	parseArgs((toldParseArgs(s2/usr/lib64/python2.7/unittest/test/test_program.pytrestoreParseArgs(scWsdS(N(tNone(targs((s2/usr/lib64/python2.7/unittest/test/test_program.pyt<lambda>*tcSs
tj`dS(N(RRR(((s2/usr/lib64/python2.7/unittest/test/test_program.pyt
removeTest-st
testRunnertexitt	verbosityi(
tobjectRRR t
addCleanupRRRRR*(RRRtrunnerR"R'tprogram((R!Rs2/usr/lib64/python2.7/unittest/test/test_program.pyt
testNoExits			
	
tFooBarcBseZd�Zd�ZRS(cCstst�dS(N(RtAssertionError(R((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestPass9scCstst�dS(N(RR1(R((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestFail;s(RRR2R3(((s2/usr/lib64/python2.7/unittest/test/test_program.pyR08s	tFooBarLoadercBseZdZd�ZRS(s3Test loader that returns a suite containing FooBar.cCs|j|jtj�g�S(N(t
suiteClasstloadTestsFromTestCaseRR0(Rtmodule((s2/usr/lib64/python2.7/unittest/test/test_program.pytloadTestsFromModule@s(RRt__doc__R8(((s2/usr/lib64/python2.7/unittest/test/test_program.pyR4>sc	CsVtjdtddgdtjdt��d|j��}|jt|d��dS(NR)targvtfoobarR(tstreamt
testLoaderR(RtmainRtTextTestRunnerRR4Rthasattr(RR.((s2/usr/lib64/python2.7/unittest/test/test_program.pyttest_NonExitEs
	cCsG|jttjddgdtjdt��dtd|j��dS(NR:R;R(R<R)R=(tassertRaisest
SystemExitRR>R?RRR4(R((s2/usr/lib64/python2.7/unittest/test/test_program.pyt	test_ExitMs		c	CsA|jttjddgdtjdt��d|j��dS(NR:R;R(R<R=(RBRCRR>R?RR4(R((s2/usr/lib64/python2.7/unittest/test/test_program.pyttest_ExitAsDefaultWs		(RRRR/RtTestCaseR0RR4RARDRE(((s2/usr/lib64/python2.7/unittest/test/test_program.pyR	s				
tInitialisableProgramcBsDeZeZdZdZdZdZe	j
ZdZdZ
d�ZRS(iRcGsdS(N((RR$((s2/usr/lib64/python2.7/unittest/test/test_program.pyt__init__isN(RRRR)R#RR*tdefaultTestR(RtdefaultTestLoaderR=tprogNameRRH(((s2/usr/lib64/python2.7/unittest/test/test_program.pyRG`s	RcBs,eZdZdZeZd�Zd�ZRS(cKs(|t_tjr$tt_t�ndS(N(RtinitArgst
raiseErrorRt	TypeError(Rtkwargs((s2/usr/lib64/python2.7/unittest/test/test_program.pyRHss			cCs
|t_tS(N(RRtRESULT(RR((s2/usr/lib64/python2.7/unittest/test/test_program.pyRys	N(	RRR#RLRRRMRHR(((s2/usr/lib64/python2.7/unittest/test/test_program.pyRns
	tTestCommandLineArgscBsPeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(cCs:t�|_d�|j_dt_dt_tt_dS(NcSsdS(N(R#(((s2/usr/lib64/python2.7/unittest/test/test_program.pyR%�R&(	RGR.tcreateTestsR#RRLRRRM(R((s2/usr/lib64/python2.7/unittest/test/test_program.pytsetUps
		cs�|j�d�fd�}|�_xJdD]B}t�_�jd|g�|j�j�|j�j�q+W�jddg�|j�j�|j	�j�dS(Ncs|�_t�_dS(N(tmsgRR)(RT(R.(s2/usr/lib64/python2.7/unittest/test/test_program.pyt	usageExit�s	s-hs-Hs--helps-$(s-hs-Hs--help(
R.R#RURR)R RtassertIsNoneRTtassertIsNotNone(RRUtopt((R.s2/usr/lib64/python2.7/unittest/test/test_program.pyttestHelpAndUnknown�s		
	cCs�|j}x=dD]5}d|_|jd|g�|j|jd�qWx=d	D]5}d|_|jd|g�|j|jd�qPWdS(
Ns-qs--quietiis-vs	--verbosei(s-qs--quiet(s-vs	--verbose(R.R*R R#R(RR.RX((s2/usr/lib64/python2.7/unittest/test/test_program.pyt
testVerbosity�s	
	
	cCs
|j}x�dd	d
fD]�\}}|dkr>tr>qnd|d}d|}xM||fD]?}t||d�|jd|g�|jt||��qcWxY||fD]K}t�}t|||�|jd|g�|jt||�|�q�WqWdS(Ntbuffertfailfasttcatcht
catchbreaks-%sis--%s(R[R[(R\R\(R]R^(	R.thasInstallHandlertsetattrR#R RtgetattrR+R(RR.targtattrt	short_opttlong_optRXtnot_none((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestBufferCatchFailfast�s 		
	cCs�|j}t|_d|_d|_d|_|j�|jtjidd6dd6dd6�|jtj	d�|j
|jt�dS(NR*R\R[R(
R.RR(R*R\R[trunTestsRRLRtassertIsRRP(RR.((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestRunTestsRunnerClass�s					
cCsb|j}t�|_dt_|j�|jtj�|jtjd�|j	|j
t�dS(NR(R.RR(R#RLRhRVRRRiRRP(RR.((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestRunTestsRunnerInstance�s		
cCs�|j}tt_t|_d|_d|_d|_d|_|j	�|j
tji�|j
tjd�|j|j
t�dS(NR*R\R[R(R.RRRMR(R*R\R[RRhRRLRiRRP(RR.((s2/usr/lib64/python2.7/unittest/test/test_program.pyttestRunTestsOldRunnerClass�s							
cs�tjd��j���fd�}�j|�t�_�fd�}|�_�j}t|_t	|_
|j��j�j�dS(Ns
unittest.maincs
��_dS(N(tinstallHandler((R7toriginal(s2/usr/lib64/python2.7/unittest/test/test_program.pytrestore�scs
t�_dS(N(Rt	installed((R(s2/usr/lib64/python2.7/unittest/test/test_program.pytfakeInstallHandler�s(
tsystmodulesRmR,RRpR.RR^RR(RhR(RRoRqR.((R7RnRs2/usr/lib64/python2.7/unittest/test/test_program.pyttestCatchBreakInstallsHandler�s
	
					
(
RRRSRYRZRgRjRkRlRt(((s2/usr/lib64/python2.7/unittest/test/test_program.pyRQ}s			
				t__main__(t	cStringIORR
RrRt
unittest.testRFRRRGR+RPRRQRR>(((s2/usr/lib64/python2.7/unittest/test/test_program.pyt<module>sW	�PK��[CV�EEtest/test_discovery.pycnu�[����
{fc@srddlZddlZddlZddlZddlZdejfd��YZedkrnej�ndS(i����Nt
TestDiscoverycBs}eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�ZRS(
cCsetj�}d|_|jd�}|j|d�ts>dS|jt��|jd�WdQXdS(Ns/foos/foo/bar/baz.pysbar.bazs/bar/baz.py(tunittestt
TestLoadert_top_level_dirt_get_name_from_pathtassertEqualt	__debug__tassertRaisestAssertionError(tselftloadertname((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_get_name_from_paths	cs�tj�}tj��fd�}tjj��fd�}tjj��fd�}dddddd	d
gddgg��fd
�t_|j|�d�}|tj_|j|�d�}|tj_|j|�d�|_d�|_	tjj
d�}||_t|j
|d��}gdD]}	|	d^q6}
|
jgdD]}	d|	d^qY�|j||
�dS(Ncs
�t_dS(N(tostlistdir((toriginal_listdir(s4/usr/lib64/python2.7/unittest/test/test_discovery.pytrestore_listdirscs�tj_dS(N(R
tpathtisfile((toriginal_isfile(s4/usr/lib64/python2.7/unittest/test/test_discovery.pytrestore_isfile!scs�tj_dS(N(R
Rtisdir((toriginal_isdir(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt
restore_isdir$sstest1.pystest2.pys
not_a_test.pyttest_dirstest.foostest-not-a-module.pytanother_dirstest3.pystest4.pycs
�jd�S(Ni(tpop(R(t
path_lists(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt<lambda>*tcSs
|jd�S(Ntdir(tendswith(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR-scSs|jd�od|kS(NRR(R(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR2scSs|dS(Ns module((R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR8RcSs|dS(Ns tests((tmodule((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR9Rs/foostest*.pyttest1ttest2s
 module teststtest3ttest4stest_dir.%s(R!R"(R#R$(RRR
RRRRt
addCleanupt_get_module_from_nametloadTestsFromModuletabspathRtlistt_find_teststextendR(R	R
RRRRRt	top_leveltsuiteRtexpected((RRRRs4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_find_testss8	
	
	
		cs�tj�}tj��fd�}tjj��fd�}tjj��fd�}dddg��gggg��fd�t_�j|�d�tj_�j|��fd	�tj_�j|�d
tfd��Y��fd�|_	�fd
�}||_
d|_t|j
dd��}�j|dddg��j�jddg��j�j|dddfg�dS(Ncs
�t_dS(N(R
R((R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRIscs�tj_dS(N(R
RR((R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRLscs�tj_dS(N(R
RR((R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyROsta_directoryttest_directoryttest_directory2cs
�jd�S(Ni(R(R(R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRTRcSstS(N(tTrue(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRWRcstjj|��kS(N(R
Rtbasename(R(tdirectories(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRZRtModulecBs,eZgZgZd�Zd�ZdZRS(csP|�_�jj|�tjj|�dkrL�fd�}|�_ndS(NR1cs�jj|||f�dS(Nt
load_tests(tload_tests_argstappend(R
tteststpattern(R	(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR7es(RtpathsR9R
R4R7(R	RR7((R	s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt__init__as
	cSs|j|jkS(N(R(R	tother((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt__eq__jsN(t__name__t
__module__R<R8R=R?tNonet__hash__(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR6]s
			cs
�|�S(N((R(R6(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRpRcs#|r�jd��n|jdS(Ns+use_load_tests should be False for packagess
 module tests(tfailureExceptionR(R tuse_load_tests(R	(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR'qss/foostest*R7s
 module tests(RRR
RRRRR%tobjectR&R'RR)R*RR<R8(R	R
RRRR'R-((R6R5RRRRR	s4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_find_tests_with_packageEs4	


			c
s�tj�}tjj�tjj��fd�}d�tj_|j|�tj��fd�}|j|�tjjtjj	d��}|j
t��|jddd�WdQX|j
|j|�|j|tj�d�tj_d�tj_�fd	�}|j|�g��fd
�}||_t|_|jddd�}tjjd�}tjjd�}	|j
|d
�|j
|j|�|j
�|	dfg�|j|tj�dS(Ncs�tj_dS(N(R
RR((R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR�scSstS(N(tFalse(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR�Rcs�tj(dS(N(tsysR((t
orig_sys_path(s4/usr/lib64/python2.7/unittest/test/test_discovery.pytrestore_path�ss/foos/foo/bart
top_level_dircSstS(N(R3(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR�RcSstS(N(R3(R((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR�Rcs�tj_dS(N(R
RR((R(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR�scs�j||f�dgS(NR:(R9(t	start_dirR;(t_find_tests_args(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR*�ss/foo/bar/bazR;s	['tests'](RRR
RRRR%RIR(tnormpathRtImportErrortdiscoverRRtassertInR*tstrt
suiteClass(
R	R
RRKt	full_pathRR*R-RLRM((RNRJRRs4/usr/lib64/python2.7/unittest/test/test_discovery.pyt
test_discover�s:



		cs�tj�}tj�d�t_tjj�d�tj_tj����fd�}|j|�|jd�}|j	tj
�tj�|j|j�d�t
t
|�d�d}|jt��|j�WdQXdS(NcSsdgS(Nstest_this_does_not_exist.py((t_((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR�RcSstS(N(R3(RW((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR�Rcs#�tj_�t_�tj(dS(N(R
RRRRI((RRRJ(s4/usr/lib64/python2.7/unittest/test/test_discovery.pytrestore�s	t.ii(RRR
RRRRIR%RQRRtgetcwdRtcountTestCasesR)RRPttest_this_does_not_exist(R	R
RXR-ttest((RRRJs4/usr/lib64/python2.7/unittest/test/test_discovery.pyt.test_discover_with_modules_that_fail_to_import�s	

cs�tjtj�}g��fd�}||_|jddg�|j�g�|jddddg�|j�ddg�dS(Ncs�j|�dS(N(R+(targv(targs(s4/usr/lib64/python2.7/unittest/test/test_discovery.pytdo_discovery�st	somethingRQtfootbar(RFt__new__RtTestProgramt
_do_discoveryt	parseArgsR(R	tprogramRa((R`s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt$test_command_line_handling_parseArgs�s	c	s|dtfd��Y��fd�}tjtj�}||_d|_|j���|j	ddddg�WdQXdS(NtStopcBseZRS((R@RA(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRk�scs
��dS(N(((Rk(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt	usageExit�stonettwotthreetfour(
t	ExceptionRFReRRfRlRBt
testLoaderRRg(R	RlRi((Rks4/usr/lib64/python2.7/unittest/test/test_discovery.pyt:test_command_line_handling_do_discovery_too_many_arguments�s		cCs^tjtj�}dtfd��Y}|�|_|jdg�|j|jdg�dS(NtLoadercBseZgZd�ZRS(cSs|jj|||f�dS(NR:(R`R9(R	RMR;RL((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRQ�s(R@RAR`RQ(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRt�ss-vRYstest*.py(RYstest*.pyN(	RFReRRfRrRgRR`RB(R	RiRt((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt;test_command_line_handling_do_discovery_uses_default_loader�s
cCstjtj�}dtfd��Y}|jdgd|�|j|jd�|j|jd�|j|jdg�g|_tjtj�}|jdgd|�|j|jd�|j|jdg�g|_tjtj�}|jgd|�|j|jd�|j|jdg�g|_tjtj�}|jd	gd|�|j|jd�|j|jdg�g|_tjtj�}|jd	d
gd|�|j|jd�|j|jdg�g|_tjtj�}|jd	d
dgd|�|j|jd�|j|jdg�g|_tjtj�}|jdd	gd|�|j|jd�|j|jdg�g|_tjtj�}|jd
d	gd|�|j|jd�|j|jdg�g|_tjtj�}|jdd	gd|�|j|jd�|j|jdg�|j
|j�|j
|j�g|_tjtj�}|jdd
dd	dddgd|�|j|jd�|j|jdg�|j|jd�|j
|j�|j
|j�dS(NRtcBseZgZd�ZRS(cSs|jj|||f�dS(NR:(R`R9(R	RMR;RL((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRQ�s(R@RAR`RQ(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRt�ss-viR:RYstest*.pys	--verbosetfishteggsthams-ss-ts-ps-fs-c(RYstest*.pyN(RYstest*.pyN(RYstest*.pyN(Rvstest*.pyN(RvRwN(RvRwRx(Rvstest*.pyN(RYstest*.pyRv(RYRvN(RvRwN(RFReRRfRgRt	verbosityR]R`RBtassertFalsetfailfastt
catchbreakt
assertTrue(R	RiRt((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt4test_command_line_handling_do_discovery_calls_loader�sr									!cs�dtfd��Y}|tjd<tjjd��tj�tjj�tjj�����fd�}|j	|�d�}d�}d�}|t_|tj_|tj_�S(NR6cBseZdZRS(s
bar/foo.py(R@RAt__file__(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR6?sRccsQ�t_�tj_�tj_tjd=�tjkrMtjj��ndS(NRc(R
RRRRRItmodulestremove((RURRR(s4/usr/lib64/python2.7/unittest/test/test_discovery.pytcleanupGs	
cSsdgS(Nsfoo.py((RW((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRPscSstS(N(R3(RW((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRRscSstS(N(R3(RW((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyRTs(
RFRIR�R
RR(RRRR%(R	R6R�RRR((RURRRs4/usr/lib64/python2.7/unittest/test/test_discovery.pytsetup_module_clash>s
	
				cCs�|j�}tj�}tjjd�}tjjd�}tjd||f�}|jt	d||j
dddd�|jtjd|�dS(	NRdRcsZ'foo' module incorrectly imported from %r. Expected %r. Is this module globally installed?s^%s$RMR;sfoo.pyi(
R�RRR
RR(tretescapetassertRaisesRegexpRPRQRRI(R	RUR
tmod_dirtexpected_dirtmsg((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_detect_module_clash[s	
cs�|j�}tjj�tjjd��tjjd���fd�}|j|���fd�}|tj_tj�}|jdddd�dS(NRdRccs�tj_dS(N(R
Rtrealpath((toriginal_realpath(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR�qscs2|tjj�d�kr.tjj�d�S|S(Nsfoo.py(R
Rtjoin(R(R�R�(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR�usRMR;sfoo.py(	R�R
RR�R(R%RRRQ(R	RUR�R�R
((R�R�R�s4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_module_symlink_okis
cs�tj�}�g�tjjtjjtjj���t�_	���fd�}||_
|jd�}�j�j	��j
|j��dS(Ncst�_�j|���S(N(R3twasRunR(RMR;(texpectedPathR	R:(s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR*�s	s
unittest.test(RRR
RR(tdirnameR]RRHR�R*RQR}Rt_tests(R	R
R*R-((R�R	R:s4/usr/lib64/python2.7/unittest/test/test_discovery.pyttest_discovery_from_dotted_path}s	$		(R@RARR/RGRVR^RjRsRuR~R�R�R�R�(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyR	s		+	A	.				
	J			t__main__(	R
R�RIRt
unittest.testtTestCaseRR@tmain(((s4/usr/lib64/python2.7/unittest/test/test_discovery.pyt<module>s��PK��[�Fcw�!�!test/test_runner.pynu�[���import unittest

from cStringIO import StringIO
import pickle

from unittest.test.support import (LoggingResult,
                                   ResultWithNoStartTestRunStopTestRun)


class TestCleanUp(unittest.TestCase):

    def testCleanUp(self):
        class TestableTest(unittest.TestCase):
            def testNothing(self):
                pass

        test = TestableTest('testNothing')
        self.assertEqual(test._cleanups, [])

        cleanups = []

        def cleanup1(*args, **kwargs):
            cleanups.append((1, args, kwargs))

        def cleanup2(*args, **kwargs):
            cleanups.append((2, args, kwargs))

        test.addCleanup(cleanup1, 1, 2, 3, four='hello', five='goodbye')
        test.addCleanup(cleanup2)

        self.assertEqual(test._cleanups,
                         [(cleanup1, (1, 2, 3), dict(four='hello', five='goodbye')),
                          (cleanup2, (), {})])

        result = test.doCleanups()
        self.assertTrue(result)

        self.assertEqual(cleanups, [(2, (), {}), (1, (1, 2, 3),
                                    dict(four='hello', five='goodbye'))])

    def testCleanUpWithErrors(self):
        class TestableTest(unittest.TestCase):
            def testNothing(self):
                pass

        class MockResult(object):
            errors = []
            def addError(self, test, exc_info):
                self.errors.append((test, exc_info))

        result = MockResult()
        test = TestableTest('testNothing')
        test._resultForDoCleanups = result

        exc1 = Exception('foo')
        exc2 = Exception('bar')
        def cleanup1():
            raise exc1

        def cleanup2():
            raise exc2

        test.addCleanup(cleanup1)
        test.addCleanup(cleanup2)

        self.assertFalse(test.doCleanups())

        (test1, (Type1, instance1, _)), (test2, (Type2, instance2, _)) = reversed(MockResult.errors)
        self.assertEqual((test1, Type1, instance1), (test, Exception, exc1))
        self.assertEqual((test2, Type2, instance2), (test, Exception, exc2))

    def testCleanupInRun(self):
        blowUp = False
        ordering = []

        class TestableTest(unittest.TestCase):
            def setUp(self):
                ordering.append('setUp')
                if blowUp:
                    raise Exception('foo')

            def testNothing(self):
                ordering.append('test')

            def tearDown(self):
                ordering.append('tearDown')

        test = TestableTest('testNothing')

        def cleanup1():
            ordering.append('cleanup1')
        def cleanup2():
            ordering.append('cleanup2')
        test.addCleanup(cleanup1)
        test.addCleanup(cleanup2)

        def success(some_test):
            self.assertEqual(some_test, test)
            ordering.append('success')

        result = unittest.TestResult()
        result.addSuccess = success

        test.run(result)
        self.assertEqual(ordering, ['setUp', 'test', 'tearDown',
                                    'cleanup2', 'cleanup1', 'success'])

        blowUp = True
        ordering = []
        test = TestableTest('testNothing')
        test.addCleanup(cleanup1)
        test.run(result)
        self.assertEqual(ordering, ['setUp', 'cleanup1'])

    def testTestCaseDebugExecutesCleanups(self):
        ordering = []

        class TestableTest(unittest.TestCase):
            def setUp(self):
                ordering.append('setUp')
                self.addCleanup(cleanup1)

            def testNothing(self):
                ordering.append('test')

            def tearDown(self):
                ordering.append('tearDown')

        test = TestableTest('testNothing')

        def cleanup1():
            ordering.append('cleanup1')
            test.addCleanup(cleanup2)
        def cleanup2():
            ordering.append('cleanup2')

        test.debug()
        self.assertEqual(ordering, ['setUp', 'test', 'tearDown', 'cleanup1', 'cleanup2'])


class Test_TextTestRunner(unittest.TestCase):
    """Tests for TextTestRunner."""

    def test_init(self):
        runner = unittest.TextTestRunner()
        self.assertFalse(runner.failfast)
        self.assertFalse(runner.buffer)
        self.assertEqual(runner.verbosity, 1)
        self.assertTrue(runner.descriptions)
        self.assertEqual(runner.resultclass, unittest.TextTestResult)


    def test_multiple_inheritance(self):
        class AResult(unittest.TestResult):
            def __init__(self, stream, descriptions, verbosity):
                super(AResult, self).__init__(stream, descriptions, verbosity)

        class ATextResult(unittest.TextTestResult, AResult):
            pass

        # This used to raise an exception due to TextTestResult not passing
        # on arguments in its __init__ super call
        ATextResult(None, None, 1)


    def testBufferAndFailfast(self):
        class Test(unittest.TestCase):
            def testFoo(self):
                pass
        result = unittest.TestResult()
        runner = unittest.TextTestRunner(stream=StringIO(), failfast=True,
                                           buffer=True)
        # Use our result object
        runner._makeResult = lambda: result
        runner.run(Test('testFoo'))

        self.assertTrue(result.failfast)
        self.assertTrue(result.buffer)

    def testRunnerRegistersResult(self):
        class Test(unittest.TestCase):
            def testFoo(self):
                pass
        originalRegisterResult = unittest.runner.registerResult
        def cleanup():
            unittest.runner.registerResult = originalRegisterResult
        self.addCleanup(cleanup)

        result = unittest.TestResult()
        runner = unittest.TextTestRunner(stream=StringIO())
        # Use our result object
        runner._makeResult = lambda: result

        self.wasRegistered = 0
        def fakeRegisterResult(thisResult):
            self.wasRegistered += 1
            self.assertEqual(thisResult, result)
        unittest.runner.registerResult = fakeRegisterResult

        runner.run(unittest.TestSuite())
        self.assertEqual(self.wasRegistered, 1)

    def test_works_with_result_without_startTestRun_stopTestRun(self):
        class OldTextResult(ResultWithNoStartTestRunStopTestRun):
            separator2 = ''
            def printErrors(self):
                pass

        class Runner(unittest.TextTestRunner):
            def __init__(self):
                super(Runner, self).__init__(StringIO())

            def _makeResult(self):
                return OldTextResult()

        runner = Runner()
        runner.run(unittest.TestSuite())

    def test_startTestRun_stopTestRun_called(self):
        class LoggingTextResult(LoggingResult):
            separator2 = ''
            def printErrors(self):
                pass

        class LoggingRunner(unittest.TextTestRunner):
            def __init__(self, events):
                super(LoggingRunner, self).__init__(StringIO())
                self._events = events

            def _makeResult(self):
                return LoggingTextResult(self._events)

        events = []
        runner = LoggingRunner(events)
        runner.run(unittest.TestSuite())
        expected = ['startTestRun', 'stopTestRun']
        self.assertEqual(events, expected)

    def test_pickle_unpickle(self):
        # Issue #7197: a TextTestRunner should be (un)pickleable. This is
        # required by test_multiprocessing under Windows (in verbose mode).
        from StringIO import StringIO as PickleableIO
        # cStringIO objects are not pickleable, but StringIO objects are.
        stream = PickleableIO("foo")
        runner = unittest.TextTestRunner(stream)
        for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
            s = pickle.dumps(runner, protocol=protocol)
            obj = pickle.loads(s)
            # StringIO objects never compare equal, a cheap test instead.
            self.assertEqual(obj.stream.getvalue(), stream.getvalue())

    def test_resultclass(self):
        def MockResultClass(*args):
            return args
        STREAM = object()
        DESCRIPTIONS = object()
        VERBOSITY = object()
        runner = unittest.TextTestRunner(STREAM, DESCRIPTIONS, VERBOSITY,
                                         resultclass=MockResultClass)
        self.assertEqual(runner.resultclass, MockResultClass)

        expectedresult = (runner.stream, DESCRIPTIONS, VERBOSITY)
        self.assertEqual(runner._makeResult(), expectedresult)


if __name__ == '__main__':
    unittest.main()
PK��[����pJpJtest/test_result.pynu�[���import sys
import textwrap
from StringIO import StringIO
from test import test_support

import traceback
import unittest


class Test_TestResult(unittest.TestCase):
    # Note: there are not separate tests for TestResult.wasSuccessful(),
    # TestResult.errors, TestResult.failures, TestResult.testsRun or
    # TestResult.shouldStop because these only have meaning in terms of
    # other TestResult methods.
    #
    # Accordingly, tests for the aforenamed attributes are incorporated
    # in with the tests for the defining methods.
    ################################################################

    def test_init(self):
        result = unittest.TestResult()

        self.assertTrue(result.wasSuccessful())
        self.assertEqual(len(result.errors), 0)
        self.assertEqual(len(result.failures), 0)
        self.assertEqual(result.testsRun, 0)
        self.assertEqual(result.shouldStop, False)
        self.assertIsNone(result._stdout_buffer)
        self.assertIsNone(result._stderr_buffer)


    # "This method can be called to signal that the set of tests being
    # run should be aborted by setting the TestResult's shouldStop
    # attribute to True."
    def test_stop(self):
        result = unittest.TestResult()

        result.stop()

        self.assertEqual(result.shouldStop, True)

    # "Called when the test case test is about to be run. The default
    # implementation simply increments the instance's testsRun counter."
    def test_startTest(self):
        class Foo(unittest.TestCase):
            def test_1(self):
                pass

        test = Foo('test_1')

        result = unittest.TestResult()

        result.startTest(test)

        self.assertTrue(result.wasSuccessful())
        self.assertEqual(len(result.errors), 0)
        self.assertEqual(len(result.failures), 0)
        self.assertEqual(result.testsRun, 1)
        self.assertEqual(result.shouldStop, False)

        result.stopTest(test)

    # "Called after the test case test has been executed, regardless of
    # the outcome. The default implementation does nothing."
    def test_stopTest(self):
        class Foo(unittest.TestCase):
            def test_1(self):
                pass

        test = Foo('test_1')

        result = unittest.TestResult()

        result.startTest(test)

        self.assertTrue(result.wasSuccessful())
        self.assertEqual(len(result.errors), 0)
        self.assertEqual(len(result.failures), 0)
        self.assertEqual(result.testsRun, 1)
        self.assertEqual(result.shouldStop, False)

        result.stopTest(test)

        # Same tests as above; make sure nothing has changed
        self.assertTrue(result.wasSuccessful())
        self.assertEqual(len(result.errors), 0)
        self.assertEqual(len(result.failures), 0)
        self.assertEqual(result.testsRun, 1)
        self.assertEqual(result.shouldStop, False)

    # "Called before and after tests are run. The default implementation does nothing."
    def test_startTestRun_stopTestRun(self):
        result = unittest.TestResult()
        result.startTestRun()
        result.stopTestRun()

    # "addSuccess(test)"
    # ...
    # "Called when the test case test succeeds"
    # ...
    # "wasSuccessful() - Returns True if all tests run so far have passed,
    # otherwise returns False"
    # ...
    # "testsRun - The total number of tests run so far."
    # ...
    # "errors - A list containing 2-tuples of TestCase instances and
    # formatted tracebacks. Each tuple represents a test which raised an
    # unexpected exception. Contains formatted
    # tracebacks instead of sys.exc_info() results."
    # ...
    # "failures - A list containing 2-tuples of TestCase instances and
    # formatted tracebacks. Each tuple represents a test where a failure was
    # explicitly signalled using the TestCase.fail*() or TestCase.assert*()
    # methods. Contains formatted tracebacks instead
    # of sys.exc_info() results."
    def test_addSuccess(self):
        class Foo(unittest.TestCase):
            def test_1(self):
                pass

        test = Foo('test_1')

        result = unittest.TestResult()

        result.startTest(test)
        result.addSuccess(test)
        result.stopTest(test)

        self.assertTrue(result.wasSuccessful())
        self.assertEqual(len(result.errors), 0)
        self.assertEqual(len(result.failures), 0)
        self.assertEqual(result.testsRun, 1)
        self.assertEqual(result.shouldStop, False)

    # "addFailure(test, err)"
    # ...
    # "Called when the test case test signals a failure. err is a tuple of
    # the form returned by sys.exc_info(): (type, value, traceback)"
    # ...
    # "wasSuccessful() - Returns True if all tests run so far have passed,
    # otherwise returns False"
    # ...
    # "testsRun - The total number of tests run so far."
    # ...
    # "errors - A list containing 2-tuples of TestCase instances and
    # formatted tracebacks. Each tuple represents a test which raised an
    # unexpected exception. Contains formatted
    # tracebacks instead of sys.exc_info() results."
    # ...
    # "failures - A list containing 2-tuples of TestCase instances and
    # formatted tracebacks. Each tuple represents a test where a failure was
    # explicitly signalled using the TestCase.fail*() or TestCase.assert*()
    # methods. Contains formatted tracebacks instead
    # of sys.exc_info() results."
    def test_addFailure(self):
        class Foo(unittest.TestCase):
            def test_1(self):
                pass

        test = Foo('test_1')
        try:
            test.fail("foo")
        except:
            exc_info_tuple = sys.exc_info()

        result = unittest.TestResult()

        result.startTest(test)
        result.addFailure(test, exc_info_tuple)
        result.stopTest(test)

        self.assertFalse(result.wasSuccessful())
        self.assertEqual(len(result.errors), 0)
        self.assertEqual(len(result.failures), 1)
        self.assertEqual(result.testsRun, 1)
        self.assertEqual(result.shouldStop, False)

        test_case, formatted_exc = result.failures[0]
        self.assertIs(test_case, test)
        self.assertIsInstance(formatted_exc, str)

    # "addError(test, err)"
    # ...
    # "Called when the test case test raises an unexpected exception err
    # is a tuple of the form returned by sys.exc_info():
    # (type, value, traceback)"
    # ...
    # "wasSuccessful() - Returns True if all tests run so far have passed,
    # otherwise returns False"
    # ...
    # "testsRun - The total number of tests run so far."
    # ...
    # "errors - A list containing 2-tuples of TestCase instances and
    # formatted tracebacks. Each tuple represents a test which raised an
    # unexpected exception. Contains formatted
    # tracebacks instead of sys.exc_info() results."
    # ...
    # "failures - A list containing 2-tuples of TestCase instances and
    # formatted tracebacks. Each tuple represents a test where a failure was
    # explicitly signalled using the TestCase.fail*() or TestCase.assert*()
    # methods. Contains formatted tracebacks instead
    # of sys.exc_info() results."
    def test_addError(self):
        class Foo(unittest.TestCase):
            def test_1(self):
                pass

        test = Foo('test_1')
        try:
            raise TypeError()
        except:
            exc_info_tuple = sys.exc_info()

        result = unittest.TestResult()

        result.startTest(test)
        result.addError(test, exc_info_tuple)
        result.stopTest(test)

        self.assertFalse(result.wasSuccessful())
        self.assertEqual(len(result.errors), 1)
        self.assertEqual(len(result.failures), 0)
        self.assertEqual(result.testsRun, 1)
        self.assertEqual(result.shouldStop, False)

        test_case, formatted_exc = result.errors[0]
        self.assertIs(test_case, test)
        self.assertIsInstance(formatted_exc, str)

    def testGetDescriptionWithoutDocstring(self):
        result = unittest.TextTestResult(None, True, 1)
        self.assertEqual(
                result.getDescription(self),
                'testGetDescriptionWithoutDocstring (' + __name__ +
                '.Test_TestResult)')

    @unittest.skipIf(sys.flags.optimize >= 2,
                     "Docstrings are omitted with -O2 and above")
    def testGetDescriptionWithOneLineDocstring(self):
        """Tests getDescription() for a method with a docstring."""
        result = unittest.TextTestResult(None, True, 1)
        self.assertEqual(
                result.getDescription(self),
               ('testGetDescriptionWithOneLineDocstring '
                '(' + __name__ + '.Test_TestResult)\n'
                'Tests getDescription() for a method with a docstring.'))

    @unittest.skipIf(sys.flags.optimize >= 2,
                     "Docstrings are omitted with -O2 and above")
    def testGetDescriptionWithMultiLineDocstring(self):
        """Tests getDescription() for a method with a longer docstring.
        The second line of the docstring.
        """
        result = unittest.TextTestResult(None, True, 1)
        self.assertEqual(
                result.getDescription(self),
               ('testGetDescriptionWithMultiLineDocstring '
                '(' + __name__ + '.Test_TestResult)\n'
                'Tests getDescription() for a method with a longer '
                'docstring.'))

    def testStackFrameTrimming(self):
        class Frame(object):
            class tb_frame(object):
                f_globals = {}
        result = unittest.TestResult()
        self.assertFalse(result._is_relevant_tb_level(Frame))

        Frame.tb_frame.f_globals['__unittest'] = True
        self.assertTrue(result._is_relevant_tb_level(Frame))

    def testFailFast(self):
        result = unittest.TestResult()
        result._exc_info_to_string = lambda *_: ''
        result.failfast = True
        result.addError(None, None)
        self.assertTrue(result.shouldStop)

        result = unittest.TestResult()
        result._exc_info_to_string = lambda *_: ''
        result.failfast = True
        result.addFailure(None, None)
        self.assertTrue(result.shouldStop)

        result = unittest.TestResult()
        result._exc_info_to_string = lambda *_: ''
        result.failfast = True
        result.addUnexpectedSuccess(None)
        self.assertTrue(result.shouldStop)

    def testFailFastSetByRunner(self):
        runner = unittest.TextTestRunner(stream=StringIO(), failfast=True)
        def test(result):
            self.assertTrue(result.failfast)
        runner.run(test)


classDict = dict(unittest.TestResult.__dict__)
for m in ('addSkip', 'addExpectedFailure', 'addUnexpectedSuccess',
           '__init__'):
    del classDict[m]

def __init__(self, stream=None, descriptions=None, verbosity=None):
    self.failures = []
    self.errors = []
    self.testsRun = 0
    self.shouldStop = False
    self.buffer = False

classDict['__init__'] = __init__
OldResult = type('OldResult', (object,), classDict)

class Test_OldTestResult(unittest.TestCase):

    def assertOldResultWarning(self, test, failures):
        with test_support.check_warnings(("TestResult has no add.+ method,",
                                          RuntimeWarning)):
            result = OldResult()
            test.run(result)
            self.assertEqual(len(result.failures), failures)

    def testOldTestResult(self):
        class Test(unittest.TestCase):
            def testSkip(self):
                self.skipTest('foobar')
            @unittest.expectedFailure
            def testExpectedFail(self):
                raise TypeError
            @unittest.expectedFailure
            def testUnexpectedSuccess(self):
                pass

        for test_name, should_pass in (('testSkip', True),
                                       ('testExpectedFail', True),
                                       ('testUnexpectedSuccess', False)):
            test = Test(test_name)
            self.assertOldResultWarning(test, int(not should_pass))

    def testOldTestTesultSetup(self):
        class Test(unittest.TestCase):
            def setUp(self):
                self.skipTest('no reason')
            def testFoo(self):
                pass
        self.assertOldResultWarning(Test('testFoo'), 0)

    def testOldTestResultClass(self):
        @unittest.skip('no reason')
        class Test(unittest.TestCase):
            def testFoo(self):
                pass
        self.assertOldResultWarning(Test('testFoo'), 0)

    def testOldResultWithRunner(self):
        class Test(unittest.TestCase):
            def testFoo(self):
                pass
        runner = unittest.TextTestRunner(resultclass=OldResult,
                                          stream=StringIO())
        # This will raise an exception if TextTestRunner can't handle old
        # test result objects
        runner.run(Test('testFoo'))


class MockTraceback(object):
    @staticmethod
    def format_exception(*_):
        return ['A traceback']

def restore_traceback():
    unittest.result.traceback = traceback


class TestOutputBuffering(unittest.TestCase):

    def setUp(self):
        self._real_out = sys.stdout
        self._real_err = sys.stderr

    def tearDown(self):
        sys.stdout = self._real_out
        sys.stderr = self._real_err

    def testBufferOutputOff(self):
        real_out = self._real_out
        real_err = self._real_err

        result = unittest.TestResult()
        self.assertFalse(result.buffer)

        self.assertIs(real_out, sys.stdout)
        self.assertIs(real_err, sys.stderr)

        result.startTest(self)

        self.assertIs(real_out, sys.stdout)
        self.assertIs(real_err, sys.stderr)

    def testBufferOutputStartTestAddSuccess(self):
        real_out = self._real_out
        real_err = self._real_err

        result = unittest.TestResult()
        self.assertFalse(result.buffer)

        result.buffer = True

        self.assertIs(real_out, sys.stdout)
        self.assertIs(real_err, sys.stderr)

        result.startTest(self)

        self.assertIsNot(real_out, sys.stdout)
        self.assertIsNot(real_err, sys.stderr)
        self.assertIsInstance(sys.stdout, StringIO)
        self.assertIsInstance(sys.stderr, StringIO)
        self.assertIsNot(sys.stdout, sys.stderr)

        out_stream = sys.stdout
        err_stream = sys.stderr

        result._original_stdout = StringIO()
        result._original_stderr = StringIO()

        print 'foo'
        print >> sys.stderr, 'bar'

        self.assertEqual(out_stream.getvalue(), 'foo\n')
        self.assertEqual(err_stream.getvalue(), 'bar\n')

        self.assertEqual(result._original_stdout.getvalue(), '')
        self.assertEqual(result._original_stderr.getvalue(), '')

        result.addSuccess(self)
        result.stopTest(self)

        self.assertIs(sys.stdout, result._original_stdout)
        self.assertIs(sys.stderr, result._original_stderr)

        self.assertEqual(result._original_stdout.getvalue(), '')
        self.assertEqual(result._original_stderr.getvalue(), '')

        self.assertEqual(out_stream.getvalue(), '')
        self.assertEqual(err_stream.getvalue(), '')


    def getStartedResult(self):
        result = unittest.TestResult()
        result.buffer = True
        result.startTest(self)
        return result

    def testBufferOutputAddErrorOrFailure(self):
        unittest.result.traceback = MockTraceback
        self.addCleanup(restore_traceback)

        for message_attr, add_attr, include_error in [
            ('errors', 'addError', True),
            ('failures', 'addFailure', False),
            ('errors', 'addError', True),
            ('failures', 'addFailure', False)
        ]:
            result = self.getStartedResult()
            buffered_out = sys.stdout
            buffered_err = sys.stderr
            result._original_stdout = StringIO()
            result._original_stderr = StringIO()

            print >> sys.stdout, 'foo'
            if include_error:
                print >> sys.stderr, 'bar'


            addFunction = getattr(result, add_attr)
            addFunction(self, (None, None, None))
            result.stopTest(self)

            result_list = getattr(result, message_attr)
            self.assertEqual(len(result_list), 1)

            test, message = result_list[0]
            expectedOutMessage = textwrap.dedent("""
                Stdout:
                foo
            """)
            expectedErrMessage = ''
            if include_error:
                expectedErrMessage = textwrap.dedent("""
                Stderr:
                bar
            """)
            expectedFullMessage = 'A traceback%s%s' % (expectedOutMessage, expectedErrMessage)

            self.assertIs(test, self)
            self.assertEqual(result._original_stdout.getvalue(), expectedOutMessage)
            self.assertEqual(result._original_stderr.getvalue(), expectedErrMessage)
            self.assertMultiLineEqual(message, expectedFullMessage)

    def testBufferSetupClass(self):
        result = unittest.TestResult()
        result.buffer = True

        class Foo(unittest.TestCase):
            @classmethod
            def setUpClass(cls):
                1//0
            def test_foo(self):
                pass
        suite = unittest.TestSuite([Foo('test_foo')])
        suite(result)
        self.assertEqual(len(result.errors), 1)

    def testBufferTearDownClass(self):
        result = unittest.TestResult()
        result.buffer = True

        class Foo(unittest.TestCase):
            @classmethod
            def tearDownClass(cls):
                1//0
            def test_foo(self):
                pass
        suite = unittest.TestSuite([Foo('test_foo')])
        suite(result)
        self.assertEqual(len(result.errors), 1)

    def testBufferSetUpModule(self):
        result = unittest.TestResult()
        result.buffer = True

        class Foo(unittest.TestCase):
            def test_foo(self):
                pass
        class Module(object):
            @staticmethod
            def setUpModule():
                1//0

        Foo.__module__ = 'Module'
        sys.modules['Module'] = Module
        self.addCleanup(sys.modules.pop, 'Module')
        suite = unittest.TestSuite([Foo('test_foo')])
        suite(result)
        self.assertEqual(len(result.errors), 1)

    def testBufferTearDownModule(self):
        result = unittest.TestResult()
        result.buffer = True

        class Foo(unittest.TestCase):
            def test_foo(self):
                pass
        class Module(object):
            @staticmethod
            def tearDownModule():
                1//0

        Foo.__module__ = 'Module'
        sys.modules['Module'] = Module
        self.addCleanup(sys.modules.pop, 'Module')
        suite = unittest.TestSuite([Foo('test_foo')])
        suite(result)
        self.assertEqual(len(result.errors), 1)


if __name__ == '__main__':
    unittest.main()
PK��[�}'��test/test_functiontestcase.pycnu�[����
|fc@sRddlZddlmZdejfd��YZedkrNej�ndS(i����N(t
LoggingResulttTest_FunctionTestCasecBsPeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(cCs,tjd��}|j|j�d�dS(NcSsdS(N(tNone(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt<lambda>ti(tunittesttFunctionTestCasetassertEqualtcountTestCases(tselfttest((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyttest_countTestCases
scs�g�t��}�fd�}�fd�}�fd�}ddddg}tj|||�j|�|j�|�dS(Ncs�jd�td��dS(NtsetUpsraised by setUp(tappendtRuntimeError((tevents(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyRs
cs�jd�dS(NR
(R
((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR
scs�jd�dS(NttearDown(R
((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR!st	startTestRtaddErrortstopTest(RRRtrunR(R	tresultRR
Rtexpected((Rs;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt#test_run_call_order__error_in_setUpscs�g�t��}�fd�}�fd�}�fd�}dddddd	g}tj|||�j|�|j�|�dS(
Ncs�jd�dS(NR(R
((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR3scs�jd�td��dS(NR
sraised by test(R
R((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR
6s
cs�jd�dS(NR(R
((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR:sRRR
RRR(RRRRR(R	RRR
RR((Rs;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt"test_run_call_order__error_in_test/s	cs�g�t��}�fd�}��fd�}�fd�}dddddd	g}tj|||�j|��j�|�dS(
Ncs�jd�dS(NR(R
((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyRMscs�jd��jd�dS(NR
sraised by test(R
tfail((RR	(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR
Ps
cs�jd�dS(NR(R
((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyRTsRRR
t
addFailureRR(RRRRR(R	RRR
RR((RR	s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt$test_run_call_order__failure_in_testIs	cs�g�t��}�fd�}�fd�}�fd�}dddddd	g}tj|||�j|�|j�|�dS(
Ncs�jd�dS(NR(R
((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyRgscs�jd�dS(NR
(R
((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR
jscs�jd�td��dS(NRsraised by tearDown(R
R((R(s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyRms
RRR
RRR(RRRRR(R	RRR
RR((Rs;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt&test_run_call_order__error_in_tearDowncs	cCs,tjd��}|j|j�t�dS(NcSsdS(N(R(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR}R(RRtassertIsInstancetidt
basestring(R	R
((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyttest_id|scCs,tjd��}|j|j�d�dS(NcSsdS(N(R(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR�R(RRRtshortDescriptionR(R	R
((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt#test_shortDescription__no_docstring�scCs8d}tjd�d|�}|j|j�d�dS(Nsthis tests foocSsdS(N(R(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyR�Rtdescription(RRRR!(R	tdescR
((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt+test_shortDescription__singleline_docstring�s(
t__name__t
__module__RRRRRR R"R%(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyRs							t__main__(Rtunittest.test.supportRtTestCaseRR&tmain(((s;/usr/lib64/python2.7/unittest/test/test_functiontestcase.pyt<module>s�PK��[D����test/dummy.pyonu�[����
{fc@sdS(N((((s+/usr/lib64/python2.7/unittest/test/dummy.pyt<module>tPK��[���7�7test/test_discovery.pynu�[���import os
import re
import sys

import unittest
import unittest.test


class TestDiscovery(unittest.TestCase):

    # Heavily mocked tests so I can avoid hitting the filesystem
    def test_get_name_from_path(self):
        loader = unittest.TestLoader()

        loader._top_level_dir = '/foo'
        name = loader._get_name_from_path('/foo/bar/baz.py')
        self.assertEqual(name, 'bar.baz')

        if not __debug__:
            # asserts are off
            return

        with self.assertRaises(AssertionError):
            loader._get_name_from_path('/bar/baz.py')

    def test_find_tests(self):
        loader = unittest.TestLoader()

        original_listdir = os.listdir
        def restore_listdir():
            os.listdir = original_listdir
        original_isfile = os.path.isfile
        def restore_isfile():
            os.path.isfile = original_isfile
        original_isdir = os.path.isdir
        def restore_isdir():
            os.path.isdir = original_isdir

        path_lists = [['test1.py', 'test2.py', 'not_a_test.py', 'test_dir',
                       'test.foo', 'test-not-a-module.py', 'another_dir'],
                      ['test3.py', 'test4.py', ]]
        os.listdir = lambda path: path_lists.pop(0)
        self.addCleanup(restore_listdir)

        def isdir(path):
            return path.endswith('dir')
        os.path.isdir = isdir
        self.addCleanup(restore_isdir)

        def isfile(path):
            # another_dir is not a package and so shouldn't be recursed into
            return not path.endswith('dir') and not 'another_dir' in path
        os.path.isfile = isfile
        self.addCleanup(restore_isfile)

        loader._get_module_from_name = lambda path: path + ' module'
        loader.loadTestsFromModule = lambda module: module + ' tests'

        top_level = os.path.abspath('/foo')
        loader._top_level_dir = top_level
        suite = list(loader._find_tests(top_level, 'test*.py'))

        expected = [name + ' module tests' for name in
                    ('test1', 'test2')]
        expected.extend([('test_dir.%s' % name) + ' module tests' for name in
                    ('test3', 'test4')])
        self.assertEqual(suite, expected)

    def test_find_tests_with_package(self):
        loader = unittest.TestLoader()

        original_listdir = os.listdir
        def restore_listdir():
            os.listdir = original_listdir
        original_isfile = os.path.isfile
        def restore_isfile():
            os.path.isfile = original_isfile
        original_isdir = os.path.isdir
        def restore_isdir():
            os.path.isdir = original_isdir

        directories = ['a_directory', 'test_directory', 'test_directory2']
        path_lists = [directories, [], [], []]
        os.listdir = lambda path: path_lists.pop(0)
        self.addCleanup(restore_listdir)

        os.path.isdir = lambda path: True
        self.addCleanup(restore_isdir)

        os.path.isfile = lambda path: os.path.basename(path) not in directories
        self.addCleanup(restore_isfile)

        class Module(object):
            paths = []
            load_tests_args = []

            def __init__(self, path):
                self.path = path
                self.paths.append(path)
                if os.path.basename(path) == 'test_directory':
                    def load_tests(loader, tests, pattern):
                        self.load_tests_args.append((loader, tests, pattern))
                        return 'load_tests'
                    self.load_tests = load_tests

            def __eq__(self, other):
                return self.path == other.path

            # Silence py3k warning
            __hash__ = None

        loader._get_module_from_name = lambda name: Module(name)
        def loadTestsFromModule(module, use_load_tests):
            if use_load_tests:
                raise self.failureException('use_load_tests should be False for packages')
            return module.path + ' module tests'
        loader.loadTestsFromModule = loadTestsFromModule

        loader._top_level_dir = '/foo'
        # this time no '.py' on the pattern so that it can match
        # a test package
        suite = list(loader._find_tests('/foo', 'test*'))

        # We should have loaded tests from the test_directory package by calling load_tests
        # and directly from the test_directory2 package
        self.assertEqual(suite,
                         ['load_tests', 'test_directory2' + ' module tests'])
        self.assertEqual(Module.paths, ['test_directory', 'test_directory2'])

        # load_tests should have been called once with loader, tests and pattern
        self.assertEqual(Module.load_tests_args,
                         [(loader, 'test_directory' + ' module tests', 'test*')])

    def test_discover(self):
        loader = unittest.TestLoader()

        original_isfile = os.path.isfile
        original_isdir = os.path.isdir
        def restore_isfile():
            os.path.isfile = original_isfile

        os.path.isfile = lambda path: False
        self.addCleanup(restore_isfile)

        orig_sys_path = sys.path[:]
        def restore_path():
            sys.path[:] = orig_sys_path
        self.addCleanup(restore_path)

        full_path = os.path.abspath(os.path.normpath('/foo'))
        with self.assertRaises(ImportError):
            loader.discover('/foo/bar', top_level_dir='/foo')

        self.assertEqual(loader._top_level_dir, full_path)
        self.assertIn(full_path, sys.path)

        os.path.isfile = lambda path: True
        os.path.isdir = lambda path: True

        def restore_isdir():
            os.path.isdir = original_isdir
        self.addCleanup(restore_isdir)

        _find_tests_args = []
        def _find_tests(start_dir, pattern):
            _find_tests_args.append((start_dir, pattern))
            return ['tests']
        loader._find_tests = _find_tests
        loader.suiteClass = str

        suite = loader.discover('/foo/bar/baz', 'pattern', '/foo/bar')

        top_level_dir = os.path.abspath('/foo/bar')
        start_dir = os.path.abspath('/foo/bar/baz')
        self.assertEqual(suite, "['tests']")
        self.assertEqual(loader._top_level_dir, top_level_dir)
        self.assertEqual(_find_tests_args, [(start_dir, 'pattern')])
        self.assertIn(top_level_dir, sys.path)

    def test_discover_with_modules_that_fail_to_import(self):
        loader = unittest.TestLoader()

        listdir = os.listdir
        os.listdir = lambda _: ['test_this_does_not_exist.py']
        isfile = os.path.isfile
        os.path.isfile = lambda _: True
        orig_sys_path = sys.path[:]
        def restore():
            os.path.isfile = isfile
            os.listdir = listdir
            sys.path[:] = orig_sys_path
        self.addCleanup(restore)

        suite = loader.discover('.')
        self.assertIn(os.getcwd(), sys.path)
        self.assertEqual(suite.countTestCases(), 1)
        test = list(list(suite)[0])[0] # extract test from suite

        with self.assertRaises(ImportError):
            test.test_this_does_not_exist()

    def test_command_line_handling_parseArgs(self):
        # Haha - take that uninstantiable class
        program = object.__new__(unittest.TestProgram)

        args = []
        def do_discovery(argv):
            args.extend(argv)
        program._do_discovery = do_discovery
        program.parseArgs(['something', 'discover'])
        self.assertEqual(args, [])

        program.parseArgs(['something', 'discover', 'foo', 'bar'])
        self.assertEqual(args, ['foo', 'bar'])

    def test_command_line_handling_do_discovery_too_many_arguments(self):
        class Stop(Exception):
            pass
        def usageExit():
            raise Stop

        program = object.__new__(unittest.TestProgram)
        program.usageExit = usageExit
        program.testLoader = None

        with self.assertRaises(Stop):
            # too many args
            program._do_discovery(['one', 'two', 'three', 'four'])


    def test_command_line_handling_do_discovery_uses_default_loader(self):
        program = object.__new__(unittest.TestProgram)

        class Loader(object):
            args = []
            def discover(self, start_dir, pattern, top_level_dir):
                self.args.append((start_dir, pattern, top_level_dir))
                return 'tests'

        program.testLoader = Loader()
        program._do_discovery(['-v'])
        self.assertEqual(Loader.args, [('.', 'test*.py', None)])

    def test_command_line_handling_do_discovery_calls_loader(self):
        program = object.__new__(unittest.TestProgram)

        class Loader(object):
            args = []
            def discover(self, start_dir, pattern, top_level_dir):
                self.args.append((start_dir, pattern, top_level_dir))
                return 'tests'

        program._do_discovery(['-v'], Loader=Loader)
        self.assertEqual(program.verbosity, 2)
        self.assertEqual(program.test, 'tests')
        self.assertEqual(Loader.args, [('.', 'test*.py', None)])

        Loader.args = []
        program = object.__new__(unittest.TestProgram)
        program._do_discovery(['--verbose'], Loader=Loader)
        self.assertEqual(program.test, 'tests')
        self.assertEqual(Loader.args, [('.', 'test*.py', None)])

        Loader.args = []
        program = object.__new__(unittest.TestProgram)
        program._do_discovery([], Loader=Loader)
        self.assertEqual(program.test, 'tests')
        self.assertEqual(Loader.args, [('.', 'test*.py', None)])

        Loader.args = []
        program = object.__new__(unittest.TestProgram)
        program._do_discovery(['fish'], Loader=Loader)
        self.assertEqual(program.test, 'tests')
        self.assertEqual(Loader.args, [('fish', 'test*.py', None)])

        Loader.args = []
        program = object.__new__(unittest.TestProgram)
        program._do_discovery(['fish', 'eggs'], Loader=Loader)
        self.assertEqual(program.test, 'tests')
        self.assertEqual(Loader.args, [('fish', 'eggs', None)])

        Loader.args = []
        program = object.__new__(unittest.TestProgram)
        program._do_discovery(['fish', 'eggs', 'ham'], Loader=Loader)
        self.assertEqual(program.test, 'tests')
        self.assertEqual(Loader.args, [('fish', 'eggs', 'ham')])

        Loader.args = []
        program = object.__new__(unittest.TestProgram)
        program._do_discovery(['-s', 'fish'], Loader=Loader)
        self.assertEqual(program.test, 'tests')
        self.assertEqual(Loader.args, [('fish', 'test*.py', None)])

        Loader.args = []
        program = object.__new__(unittest.TestProgram)
        program._do_discovery(['-t', 'fish'], Loader=Loader)
        self.assertEqual(program.test, 'tests')
        self.assertEqual(Loader.args, [('.', 'test*.py', 'fish')])

        Loader.args = []
        program = object.__new__(unittest.TestProgram)
        program._do_discovery(['-p', 'fish'], Loader=Loader)
        self.assertEqual(program.test, 'tests')
        self.assertEqual(Loader.args, [('.', 'fish', None)])
        self.assertFalse(program.failfast)
        self.assertFalse(program.catchbreak)

        Loader.args = []
        program = object.__new__(unittest.TestProgram)
        program._do_discovery(['-p', 'eggs', '-s', 'fish', '-v', '-f', '-c'],
                              Loader=Loader)
        self.assertEqual(program.test, 'tests')
        self.assertEqual(Loader.args, [('fish', 'eggs', None)])
        self.assertEqual(program.verbosity, 2)
        self.assertTrue(program.failfast)
        self.assertTrue(program.catchbreak)

    def setup_module_clash(self):
        class Module(object):
            __file__ = 'bar/foo.py'
        sys.modules['foo'] = Module
        full_path = os.path.abspath('foo')
        original_listdir = os.listdir
        original_isfile = os.path.isfile
        original_isdir = os.path.isdir

        def cleanup():
            os.listdir = original_listdir
            os.path.isfile = original_isfile
            os.path.isdir = original_isdir
            del sys.modules['foo']
            if full_path in sys.path:
                sys.path.remove(full_path)
        self.addCleanup(cleanup)

        def listdir(_):
            return ['foo.py']
        def isfile(_):
            return True
        def isdir(_):
            return True
        os.listdir = listdir
        os.path.isfile = isfile
        os.path.isdir = isdir
        return full_path

    def test_detect_module_clash(self):
        full_path = self.setup_module_clash()
        loader = unittest.TestLoader()

        mod_dir = os.path.abspath('bar')
        expected_dir = os.path.abspath('foo')
        msg = re.escape(r"'foo' module incorrectly imported from %r. Expected %r. "
                "Is this module globally installed?" % (mod_dir, expected_dir))
        self.assertRaisesRegexp(
            ImportError, '^%s$' % msg, loader.discover,
            start_dir='foo', pattern='foo.py'
        )
        self.assertEqual(sys.path[0], full_path)

    def test_module_symlink_ok(self):
        full_path = self.setup_module_clash()

        original_realpath = os.path.realpath

        mod_dir = os.path.abspath('bar')
        expected_dir = os.path.abspath('foo')

        def cleanup():
            os.path.realpath = original_realpath
        self.addCleanup(cleanup)

        def realpath(path):
            if path == os.path.join(mod_dir, 'foo.py'):
                return os.path.join(expected_dir, 'foo.py')
            return path
        os.path.realpath = realpath
        loader = unittest.TestLoader()
        loader.discover(start_dir='foo', pattern='foo.py')

    def test_discovery_from_dotted_path(self):
        loader = unittest.TestLoader()

        tests = [self]
        expectedPath = os.path.abspath(os.path.dirname(unittest.test.__file__))

        self.wasRun = False
        def _find_tests(start_dir, pattern):
            self.wasRun = True
            self.assertEqual(start_dir, expectedPath)
            return tests
        loader._find_tests = _find_tests
        suite = loader.discover('unittest.test')
        self.assertTrue(self.wasRun)
        self.assertEqual(suite._tests, tests)


if __name__ == '__main__':
    unittest.main()
PK��[L�B2test/__init__.pynu�[���import os
import sys
import unittest


here = os.path.dirname(__file__)
loader = unittest.defaultTestLoader

def suite():
    suite = unittest.TestSuite()
    for fn in os.listdir(here):
        if fn.startswith("test") and fn.endswith(".py"):
            modname = "unittest.test." + fn[:-3]
            __import__(modname)
            module = sys.modules[modname]
            suite.addTest(loader.loadTestsFromModule(module))
    return suite


if __name__ == "__main__":
    unittest.main(defaultTest="suite")
PK��[%v
�tttest/support.pycnu�[����
{fc@skddlZdefd��YZdefd��YZdejfd��YZdefd	��YZdS(
i����NtTestHashingcBseZdZd�ZRS(sUsed as a mixin for TestCasecCs*x�|jD]�\}}y6t|�t|�ksK|jd||f�nWq
tk
rb�q
tk
r�}|jd|||f�q
Xq
Wx�|jD]�\}}y6t|�t|�kr�|jd||f�nWq�tk
r��q�tk
r!}|jd|||f�q�Xq�WdS(Ns%r and %r do not hash equalsProblem hashing %r and %r: %ss#%s and %s hash equal, but shouldn'tsProblem hashing %s and %s: %s(teq_pairsthashtfailtKeyboardInterruptt	Exceptiontne_pairs(tselftobj_1tobj_2te((s-/usr/lib64/python2.7/unittest/test/support.pyt	test_hashs"
"	
(t__name__t
__module__t__doc__R(((s-/usr/lib64/python2.7/unittest/test/support.pyRstTestEqualitycBs eZdZd�Zd�ZRS(sUsed as a mixin for TestCasecCs>x7|jD],\}}|j||�|j||�q
WdS(N(RtassertEqual(RRR	((s-/usr/lib64/python2.7/unittest/test/support.pyttest_eq!scCs>x7|jD],\}}|j||�|j||�q
WdS(N(RtassertNotEqual(RRR	((s-/usr/lib64/python2.7/unittest/test/support.pyttest_ne's(RR
RRR(((s-/usr/lib64/python2.7/unittest/test/support.pyRs	t
LoggingResultcBskeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�ZRS(cCs ||_tt|�j�dS(N(t_eventstsuperRt__init__(Rtlog((s-/usr/lib64/python2.7/unittest/test/support.pyR.s	cCs*|jjd�tt|�j|�dS(Nt	startTest(RtappendRRR(Rttest((s-/usr/lib64/python2.7/unittest/test/support.pyR2scCs'|jjd�tt|�j�dS(NtstartTestRun(RRRRR(R((s-/usr/lib64/python2.7/unittest/test/support.pyR6scCs*|jjd�tt|�j|�dS(NtstopTest(RRRRR(RR((s-/usr/lib64/python2.7/unittest/test/support.pyR:scCs'|jjd�tt|�j�dS(NtstopTestRun(RRRRR(R((s-/usr/lib64/python2.7/unittest/test/support.pyR>scGs*|jjd�tt|�j|�dS(Nt
addFailure(RRRRR(Rtargs((s-/usr/lib64/python2.7/unittest/test/support.pyRBscGs*|jjd�tt|�j|�dS(Nt
addSuccess(RRRRR!(RR ((s-/usr/lib64/python2.7/unittest/test/support.pyR!FscGs*|jjd�tt|�j|�dS(NtaddError(RRRRR"(RR ((s-/usr/lib64/python2.7/unittest/test/support.pyR"JscGs*|jjd�tt|�j|�dS(NtaddSkip(RRRRR#(RR ((s-/usr/lib64/python2.7/unittest/test/support.pyR#NscGs*|jjd�tt|�j|�dS(NtaddExpectedFailure(RRRRR$(RR ((s-/usr/lib64/python2.7/unittest/test/support.pyR$RscGs*|jjd�tt|�j|�dS(NtaddUnexpectedSuccess(RRRRR%(RR ((s-/usr/lib64/python2.7/unittest/test/support.pyR%Vs(
RR
RRRRRRR!R"R#R$R%(((s-/usr/lib64/python2.7/unittest/test/support.pyR-s										t#ResultWithNoStartTestRunStopTestRuncBsMeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(s?An object honouring TestResult before startTestRun/stopTestRun.cCsCg|_g|_d|_g|_g|_g|_t|_dS(Ni(tfailuresterrorsttestsRuntskippedtexpectedFailurestunexpectedSuccessestFalset
shouldStop(R((s-/usr/lib64/python2.7/unittest/test/support.pyR^s						cCsdS(N((RR((s-/usr/lib64/python2.7/unittest/test/support.pyRgscCsdS(N((RR((s-/usr/lib64/python2.7/unittest/test/support.pyRjscCsdS(N((RR((s-/usr/lib64/python2.7/unittest/test/support.pyR"mscCsdS(N((RR((s-/usr/lib64/python2.7/unittest/test/support.pyRpscCsdS(N((RR((s-/usr/lib64/python2.7/unittest/test/support.pyR!sscCstS(N(tTrue(R((s-/usr/lib64/python2.7/unittest/test/support.pyt
wasSuccessfulvs(
RR
RRRRR"RR!R0(((s-/usr/lib64/python2.7/unittest/test/support.pyR&[s							(tunittesttobjectRRt
TestResultRR&(((s-/usr/lib64/python2.7/unittest/test/support.pyt<module>s.PK��[Ij̟'�'test/test_break.pyonu�[����
{fc@s�ddlZddlZddlZddlZddlZddlmZddlZeje	ed�d�ej
ejdkd�ej
ejdkd�d	ejfd
��Y���Z
eje	ed�d�ej
ejdkd�ej
ejdkd�de
fd��Y���Zeje	ed�d�ej
ejdkd�ej
ejdkd�d
e
fd��Y���Zeje	ed�d�ej
ejdkd�ej
ejdkd�de
fd��Y���ZdS(i����N(tStringIOtkillsTest requires os.killtwin32sTest cannot run on Windowstfreebsd6s9Test kills regrtest on freebsd6 if threads have been usedt	TestBreakcBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�Zd
�ZRS(cCsAtjtj�|_|jdk	r=tjtj|j�ndS(N(tsignalt	getsignaltSIGINTt_default_handlertint_handlertNone(tself((s0/usr/lib64/python2.7/unittest/test/test_break.pytsetUpscCs8tjtj|j�tj�tj_dtj_	dS(N(
RRRtweakreftWeakKeyDictionarytunittesttsignalst_resultsR
t_interrupt_handler(R((s0/usr/lib64/python2.7/unittest/test/test_break.pyttearDownscCs�tjtj�}tj�|jtjtj�|�y#tj�}tj|tj�Wnt	k
r{|j
d�nX|jtjj
j�dS(NsKeyboardInterrupt not handled(RRRRtinstallHandlertassertNotEqualtostgetpidRtKeyboardInterrupttfailt
assertTrueRRtcalled(Rtdefault_handlertpid((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestInstallHandlers

cCsmtj�}tj|�xMtjjD]2}||kr<Pq&||k	r&|jd�q&q&W|jd�dS(Nsodd object in result setsresult not found(Rt
TestResulttregisterResultRRR(Rtresulttref((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestRegisterResult,s
cs�tjtj�}tj�}tj�tj|��jtjtj�|��fd�}y||�Wntk
r��j	d�nX�j
|j�dS(Ncs<tj�}tj|tj�t|_�j|j�dS(N(	RRRRRtTruetbreakCaughtRt
shouldStop(R!R(R(s0/usr/lib64/python2.7/unittest/test/test_break.pyttestBs	sKeyboardInterrupt not handled(RRRRRRR RRRRR%(RRR!R'((Rs0/usr/lib64/python2.7/unittest/test/test_break.pyttestInterruptCaught9s


cs�tjtj�tjkr+�jd�ntj�}tj�tj|��fd�}y||�Wnt	k
r~nX�j
d��j|j�dS(Ns&test requires SIGINT to not be ignoredcs\tj�}tj|tj�t|_�j|j�tj|tj��j	d�dS(Ns#Second KeyboardInterrupt not raised(
RRRRRR$R%RR&R(R!R(R(s0/usr/lib64/python2.7/unittest/test/test_break.pyR'Xs	s#Second KeyboardInterrupt not raised(
RRRtSIG_IGNtskipTestRRRR RRRR%(RR!R'((Rs0/usr/lib64/python2.7/unittest/test/test_break.pyttestSecondInterruptOs



cCs�tj�tj�}tj|�tjtj�}tj�}tj|�|jtjtj�|�tj�}d�}y||�Wntk
r�|j	d�nX|j
|j�|j
|j�|j|j�dS(NcSs#tj�}tj|tj�dS(N(RRRRR(R!R((s0/usr/lib64/python2.7/unittest/test/test_break.pyR'vssKeyboardInterrupt not handled(
RRRR RRRtassertEqualRRRR&tassertFalse(RR!tnew_handlertresult2tresult3R'((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestTwoResultsis 


	
cs�tjtj�tjkr+|jd�ntj�tjtj���fd�}tjtj|�y#tj�}tj	|tj�Wnt
k
r�nX|jd�dS(Ns&test requires SIGINT to not be ignoredcs�||�dS(N((tframetsignum(thandler(s0/usr/lib64/python2.7/unittest/test/test_break.pyR.�ss6replaced but delegated handler doesn't raise interrupt(RRRR)R*RRRRRRR(RR.R((R4s0/usr/lib64/python2.7/unittest/test/test_break.pyttestHandlerReplacedButCalled�s

cCsDtjdt��}|jtj��}|j|tjj�dS(Ntstream(RtTextTestRunnerRtrunt	TestSuitetassertInRR(RtrunnerR!((s0/usr/lib64/python2.7/unittest/test/test_break.pyt
testRunner�scCsStj�}tj|�tj|�}~tj�tj�|j|��dS(N(RRR R
R"tgctcollecttassertIsNone(RR!R"((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestWeakReferences�s


cCs�tj�}tj|�tj�|jtj|��|jtjtj���y#tj�}tj	|t
j�Wntk
r�nX|j|j
�dS(N(RRR RRtremoveResultR-RRRRRRR&(RR!R((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestRemoveResult�s


cs�t��t��t��t��tjtj�}dtf�fd��Y�dtjf����fd��Y}|t�}|j�|j�j	didd6�d6�d6fg�|j�j�g�|j|j��|jtjtj�|�g�_	g�_|t
�}|j�|j�j	d	idd6�d6�d6fg�|j�j�g�|j|j��|jtjtj�|�dS(
Nt
FakeRunnercs,eZgZgZd�Z�fd�ZRS(c_s|jj||f�dS(N(tinitArgstappend(Rtargstkwargs((s0/usr/lib64/python2.7/unittest/test/test_break.pyt__init__�scs|jj|��S(N(trunArgsRE(RR'(R!(s0/usr/lib64/python2.7/unittest/test/test_break.pyR8�s(t__name__t
__module__RDRIRHR8((R!(s0/usr/lib64/python2.7/unittest/test/test_break.pyRC�s	tProgramcs eZ����fd�ZRS(csCt|_�|_�|_||_�|_�|_d|_dS(N(	tFalsetexitt	verbositytfailfastt
catchbreakR<R'R
R!(RRQ(RCRPR'RO(s0/usr/lib64/python2.7/unittest/test/test_break.pyRH�s						(RJRKRH((RCRPR'RO(s0/usr/lib64/python2.7/unittest/test/test_break.pyRL�stbufferRORP(((tobjectRRRRtTestProgramRMtrunTestsR,RDR
RIR!R$R(RRRLtp((RCRPR!R'ROs0/usr/lib64/python2.7/unittest/test/test_break.pyttestMainInstallsHandler�s2					(

		
cCsltjtj�}tj�tj�|jtjtj�|�tj�|jtjtj�|�dS(N(RRRRRt
removeHandlerR,(RR((s0/usr/lib64/python2.7/unittest/test/test_break.pyttestRemoveHandler�s


cs^tjtj��tj�tj��fd��}|��jtjtj���dS(Ncs �jtjtj���dS(N(R,RRR((RR(s0/usr/lib64/python2.7/unittest/test/test_break.pyR's(RRRRRRXR(RR'((RRs0/usr/lib64/python2.7/unittest/test/test_break.pyttestRemoveHandlerAsDecorator�s

N(RJRKR
R	RRRR#R(R+R1R5R<R@RBRWRYRZ(((s0/usr/lib64/python2.7/unittest/test/test_break.pyR
s			
	
						
		2	
tTestBreakDefaultIntHandlercBseZejZRS((RJRKRtdefault_int_handlerR	(((s0/usr/lib64/python2.7/unittest/test/test_break.pyR[	stTestBreakSignalIgnoredcBseZejZRS((RJRKRR)R	(((s0/usr/lib64/python2.7/unittest/test/test_break.pyR]stTestBreakSignalDefaultcBseZejZRS((RJRKRtSIG_DFLR	(((s0/usr/lib64/python2.7/unittest/test/test_break.pyR^s(R=RtsysRR
t	cStringIORRt
skipUnlessthasattrtskipIftplatformtTestCaseRR[R]R^(((s0/usr/lib64/python2.7/unittest/test/test_break.pyt<module>s,�PK��[z#���test/__init__.pycnu�[����
{fc@skddlZddlZddlZejje�ZejZd�Z	e
dkrgejdd�ndS(i����NcCs�tj�}xstjt�D]b}|jd�r|jd�rd|d }t|�tj	|}|j
tj|��qqW|S(Nttests.pysunittest.test.i����(
tunittestt	TestSuitetostlistdirtheret
startswithtendswitht
__import__tsystmodulestaddTesttloadertloadTestsFromModule(tsuitetfntmodnametmodule((s./usr/lib64/python2.7/unittest/test/__init__.pyR	s

t__main__tdefaultTestR(RR	Rtpathtdirnamet__file__RtdefaultTestLoaderRRt__name__tmain(((s./usr/lib64/python2.7/unittest/test/__init__.pyt<module>s		PK��[S.#Ď<�<test/test_suite.pycnu�[����
|fc@s�ddlZddlZddlmZmZdefd��YZd�Zdejefd��YZ	e
dkr�ej�ndS(	i����N(t
LoggingResulttTestEqualitytTestcBs!eZdejfd��YZRS(tFoocBs,eZd�Zd�Zd�Zd�ZRS(cCsdS(N((tself((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_1tcCsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_2
RcCsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_3RcCsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pytrunTestR(t__name__t
__module__RRRR	(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRs			(R
RtunittesttTestCaseR(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR
scGstjd�|D��S(Ncss|]}tj|�VqdS(N(RR(t.0tn((s0/usr/lib64/python2.7/unittest/test/test_suite.pys	<genexpr>s(Rt	TestSuite(tnames((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt
_mk_TestSuitestTest_TestSuitecBsyeZej�ej�fej�ejg�fed�ed�fgZej�ed�fejg�ed�fedd�edd�fed�ed�fgZd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(RRRcCs&tj�}|j|j�d�dS(Ni(RRtassertEqualtcountTestCases(Rtsuite((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_init__tests_optional0scCs)tjg�}|j|j�d�dS(Ni(RRRR(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_init__empty_tests<scCs�d�}tj|��}|j|j�d�tj|�}|j|j�d�tjt|��}|j|j�d�dS(Ncss&tjd��Vtjd��VdS(NcSsdS(N(tNone(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt<lambda>IRcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRJR(RtFunctionTestCase(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttestsHsi(RRRRtset(RRtsuite_1tsuite_2tsuite_3((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt"test_init__tests_from_any_iterableGs	cCs5d�}tj|��}|j|j�d�dS(Ncss8tjd��}tj|g�Vtjd��VdS(NcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR^RcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR`R(RRR(tftc((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR]si(RRRR(RRR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt'test_init__TestSuite_instances_in_tests\s	cCsYtjd��}tjd��}tj||f�}|jt|�||g�dS(NcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRjRcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRkR(RRRRtlist(Rttest1ttest2R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt	test_iteriscCs&tj�}|j|j�d�dS(Ni(RRRR(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_countTestCases_zero_simpleuscCsKdtjfd��Y}tjtj�g�}|j|j�d�dS(NtTest1cBseZd�ZRS(cSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest�s(R
RR*(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR)�si(RR
RRR(RR)R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_countTestCases_zero_nested�scCsStjd��}tjd��}tj||f�}|j|j�d�dS(NcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR�RcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR�Ri(RRRRR(RR%R&R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_countTestCases_simple�scCs�dtjfd��Y}tjd��}tjd��}tj|d�|f�}tj|||d�f�}|j|j�d�dS(NR)cBseZd�Zd�ZRS(cSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR%�RcSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR&�R(R
RR%R&(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR)�s	cSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR�RcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR�RR&R%i(RR
RRRR(RR)R&ttest3tchildtparent((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_countTestCases_nested�scCs?g}t|�}tj�}|j|�|j|g�dS(N(RRRtrunR(RteventstresultR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_run__empty_suite�s

cCs?tj�}y|j�Wntk
r-nX|jd�dS(NsFailed to raise TypeError(RRR1t	TypeErrortfail(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_run__requires_result�s
csyg�t��}dtjf�fd��Y}|d�|d�g}tj|�j|�|j�ddg�dS(NtLoggingCasecs)eZ�fd�Zd�Zd�ZRS(cs�jd|j�dS(Nsrun %s(tappendt_testMethodName(RR3(R2(s0/usr/lib64/python2.7/unittest/test/test_suite.pyR1�scSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR%�RcSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR&�R(R
RR1R%R&((R2(s0/usr/lib64/python2.7/unittest/test/test_suite.pyR8�s	R%R&s	run test1s	run test2(RRR
RR1R(RR3R8R((R2s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_run�scCsqdtjfd��Y}|d�}tj�}|j|�|j|j�d�|jt|�|g�dS(NRcBseZd�ZRS(cSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR*�R(R
RR*(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR�sR*i(RR
RtaddTestRRR$(RRR*R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTest__TestCase�s
cCs}dtjfd��Y}tj|d�g�}tj�}|j|�|j|j�d�|jt|�|g�dS(NRcBseZd�ZRS(cSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR*�R(R
RR*(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR�sR*i(RR
RR<RRR$(RRRR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTest__TestSuite�s
cs�dtjfd��Y}|d��|d��tj�g�����fd�}tj�}|j|��|jt|�t|���tj�}x|�D]}|j|�q�W|j||�dS(NRcBseZd�Zd�ZRS(cSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR�RcSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR�R(R
RRR(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR�s	RRc3s�V�V�VdS(N(((tinner_suiteRR(s0/usr/lib64/python2.7/unittest/test/test_suite.pytgen�s(RR
RtaddTestsRR$R<(RRR@RRtt((R?RRs0/usr/lib64/python2.7/unittest/test/test_suite.pyt
test_addTests�scCsBtj�}y|jd�Wntk
r0nX|jd�dS(NisFailed to raise TypeError(RRRAR5R6(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTest__noniterables
cCs&tj�}|jt|jd�dS(Ni(RRtassertRaisesR5R<(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTest__noncallablescCs?tj�}|jt|jt�|jt|jtj�dS(N(RRRER5R<R(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTest__casesuiteclassscCs&tj�}|jt|jd�dS(Ntfoo(RRRER5RA(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTests__string"scCs9d�}tj�}|j|�|jtj��dS(NcSsdS(N((t_((s0/usr/lib64/python2.7/unittest/test/test_suite.pytf's(RRR<R1t
TestResult(RRKR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_function_in_suite&s	
csDdtjfd��Y}dtf�fd��Y�d|_�tjd<|jtjjd�tj�}|j	|d�|d�g�|j
|j�d�tj�}|j
|�|j�j�|j�j�|j|j�|j|j�|j
t|j�d�|j
t|j�d	�|j
|jd�dS(
NRcBsDeZeZeZed��Zed��Zd�Zd�Z	RS(cSs
t|_dS(N(tTruetwasSetUp(tcls((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt
setUpClass5scSs
t|_dS(N(RNtwasTornDown(RP((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt
tearDownClass8scSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttestPass;scSstdS(N(R6(R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttestFail=s(
R
RtFalseRORRtclassmethodRQRSRTRU(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR2s	tModulecs>eZeZeZe�fd��Ze�fd��ZRS(cs
t�_dS(N(RNRO((RX(s0/usr/lib64/python2.7/unittest/test/test_suite.pytsetUpModuleBscs
t�_dS(N(RNRR((RX(s0/usr/lib64/python2.7/unittest/test/test_suite.pyttearDownModuleEs(R
RRVRORRtstaticmethodRYRZ((RX(s0/usr/lib64/python2.7/unittest/test/test_suite.pyRX?sRTRUiii(RR
tobjectRtsystmodulest
addCleanuptpopt
BaseTestSuiteRARRRLR1tassertFalseRORRtlenterrorstfailuresttestsRun(RRRR3((RXs0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_basetestsuite1s"

	

cCsudtjfd��Y}|�}tj�}tj�}|j|�||�|j|j�|j|j�dS(NtMySuitecBseZeZd�ZRS(c_s#t|_tjj|||�dS(N(RNtcalledRRt__call__(Rtargstkw((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRj_s	(R
RRVRiRj(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRh]s(RRRLR<t
assertTrueRiRbt_testRunEntered(RRhRR3twrapper((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_overriding_call\s	

(R
RRRRteq_pairstne_pairsRRR!R#R'R(R+R,R0R4R7R;R=R>RCRDRFRGRIRMRgRp(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRs:				
									
			
					+t__main__(RR]tunittest.test.supportRRR\RRR
RR
tmain(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt<module>s	�XPK��[\�p�q�qtest/test_setups.pycnu�[����
|fc@sgddlZddlmZddlZd�Zdejfd��YZedkrcej�ndS(i����N(tStringIOcGs
tj�S(N(tunittestt
TestResult(t_((s1/usr/lib64/python2.7/unittest/test/test_setups.pyt
resultFactoryst
TestSetupscBs�eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�ZRS(cCstjdtdt��S(Ntresultclasststream(RtTextTestRunnerRR(tself((s1/usr/lib64/python2.7/unittest/test/test_setups.pyt	getRunnerscGs�tj�}x-|D]%}tjj|�}|j|�qW|j�}tj�}|j|�|jtj��|jtj��|j|�S(N(Rt	TestSuitetdefaultTestLoadertloadTestsFromTestCasetaddTestsR
taddTesttrun(R	tcasestsuitetcasetteststrunnert	realSuite((s1/usr/lib64/python2.7/unittest/test/test_setups.pytrunTestss

csqdtjf�fd��Y�|j��}|j�jd�|j|jd�|jt|j�d�dS(NtTestcs5eZdZe�fd��Zd�Zd�ZRS(ics �jd7_tjj�dS(Ni(tsetUpCalledRtTestCaset
setUpClass(tcls(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR$scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_one(scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_two*s(t__name__t
__module__RtclassmethodRRR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR"s	iii(RRRtassertEqualRttestsRuntlenterrors(R	tresult((Rs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_setup_class!s
csqdtjf�fd��Y�|j��}|j�jd�|j|jd�|jt|j�d�dS(NRcs5eZdZe�fd��Zd�Zd�ZRS(ics �jd7_tjj�dS(Ni(ttearDownCalledRRt
tearDownClass(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)6scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR:scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR<s(RR R(R!R)RR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR4s	iii(RRRR"R(R#R$R%(R	R&((Rs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_teardown_class3s
cs�dtjf�fd��Y�dtjf�fd��Y�|j���}|j�jd�|j�jd�|j|jd�|jt|j�d�dS(NRcs5eZdZe�fd��Zd�Zd�ZRS(ics �jd7_tjj�dS(Ni(R(RRR)(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)HscSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRLscSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRNs(RR R(R!R)RR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRFs	tTest2cs5eZdZe�fd��Zd�Zd�ZRS(ics �jd7_tjj�dS(Ni(R(RRR)(R(R+(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)SscSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRWscSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRYs(RR R(R!R)RR((R+(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR+Qs	iii(RRRR"R(R#R$R%(R	R&((RR+s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_teardown_class_two_classesEscCs�dtjfd��Y}|j|�}|j|jd�|jt|j�d�|jd\}}|jt|�dt�dS(Nt
BrokenTestcBs)eZed��Zd�Zd�ZRS(cSstd��dS(Ntfoo(t	TypeError(R((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRescSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRhscSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRjs(RR R!RRR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR-ds	iissetUpClass (%s.BrokenTest)(	RRRR"R#R$R%tstrR(R	R-R&terrorR((s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_error_in_setupclasscs	cs�dtjf�fd��Y�dtjf�fd��Y�|j���}|j|jd�|jt|j�d�|j�jd�|j�jd�|jd\}}|jt|�d	t	�dS(
NRcs5eZdZe�fd��Zd�Zd�ZRS(ics�jd7_td��dS(NiR.(ttornDownR/(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)xscSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR|scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR~s(RR R3R!R)RR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRvs	R+cs5eZdZe�fd��Zd�Zd�ZRS(ics�jd7_td��dS(NiR.(R3R/(R(R+(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)�scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�s(RR R3R!R)RR((R+(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR+�s	iiiistearDownClass (%s.Test)(
RRRR"R#R$R%R3R0R(R	R&R1R((RR+s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_error_in_teardown_classuscs@dtjf�fd��Y�|j��|j�j�dS(NRcs;eZeZed��Ze�fd��Zd�ZRS(cSs
t�dS(N(R/(R((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scst�_td��dS(NR.(tTrueR3R/(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)�s	cSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�s(RR tFalseR3R!RR)R((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�s(RRRtassertFalseR3(R	((Rs1/usr/lib64/python2.7/unittest/test/test_setups.pyt(test_class_not_torndown_when_setup_fails�s
csedtjf�fd��Y�tjd����|j��|j�j�|j�j�dS(NRcsGeZeZeZe�fd��Ze�fd��Zd�ZRS(cs
t�_dS(N(R5t
classSetUp(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scs
t�_dS(N(R5R3(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)�scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�s(	RR R6R9R3R!RR)R((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�s
thop(RRtskipRR7R9R3(R	((Rs1/usr/lib64/python2.7/unittest/test/test_setups.pyt-test_class_not_setup_or_torndown_when_skipped�s

cs
g�dtf�fd��Y}dtf�fd��Y}dtjf�fd��Y}dtjf�fd��Y}d	tjf�fd
��Y}d|_|_d|_|tjd<|tjd<tj|d�f�}tj|d
�f�}tj|d�f�}tj|d
�f�}	tj|d�f�}
tj|d
�f�}tj||||	|
|f�}|j�}
|
j|�}|j	|j
d�|j	t|j�d�|j	�ddddddddddddddddg�dS( NtModule1cs2eZe�fd��Ze�fd��ZRS(cs�jd�dS(NsModule1.setUpModule(tappend((tresults(s1/usr/lib64/python2.7/unittest/test/test_setups.pytsetUpModule�scs�jd�dS(NsModule1.tearDownModule(R>((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyttearDownModule�s(RR tstaticmethodR@RA((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR=�stModule2cs2eZe�fd��Ze�fd��ZRS(cs�jd�dS(NsModule2.setUpModule(R>((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR@�scs�jd�dS(NsModule2.tearDownModule(R>((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRA�s(RR RBR@RA((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRC�stTest1csPeZe�fd��Ze�fd��Z�fd�Z�fd�ZRS(cs�jd�dS(Nssetup 1(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scs�jd�dS(Ns
teardown 1(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)�scs�jd�dS(Ns
Test1.testOne(R>(R	(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyttestOne�scs�jd�dS(Ns
Test1.testTwo(R>(R	(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyttestTwo�s(RR R!RR)RERF((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRD�sR+csPeZe�fd��Ze�fd��Z�fd�Z�fd�ZRS(cs�jd�dS(Nssetup 2(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scs�jd�dS(Ns
teardown 2(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)�scs�jd�dS(Ns
Test2.testOne(R>(R	(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRE�scs�jd�dS(Ns
Test2.testTwo(R>(R	(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRF�s(RR R!RR)RERF((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR+�stTest3csPeZe�fd��Ze�fd��Z�fd�Z�fd�ZRS(cs�jd�dS(Nssetup 3(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scs�jd�dS(Ns
teardown 3(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)�scs�jd�dS(Ns
Test3.testOne(R>(R	(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRE�scs�jd�dS(Ns
Test3.testTwo(R>(R	(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRF�s(RR R!RR)RERF((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRG�stModuleRERFiisModule1.setUpModulessetup 1s
Test1.testOnes
Test1.testTwos
teardown 1ssetup 2s
Test2.testOnes
Test2.testTwos
teardown 2sModule1.tearDownModulesModule2.setUpModulessetup 3s
Test3.testOnes
Test3.testTwos
teardown 3sModule2.tearDownModule(
tobjectRRR tsystmodulesRR
RR"R#R$R%(R	R=RCRDR+RGtfirsttsecondtthirdtfourthtfifthtsixthRRR&((R?s1/usr/lib64/python2.7/unittest/test/test_setups.pyt1test_setup_teardown_order_with_pathological_suite�s:	

!			cs�dtf�fd��Y�dtjfd��Y}d|_�tjd<|j|�}|j�jd�|j|j	d�|jt
|j�d�dS(NRHcs#eZdZe�fd��ZRS(ics�jd7_dS(Ni(tmoduleSetup((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR@
s(RR RSRBR@((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRHsRcBseZd�Zd�ZRS(cSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs	iii(RIRRR RJRKRR"RSR#R$R%(R	RR&((RHs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_setup_module
s	
cs$dtf�fd��Y�dtjf�fd��Y�dtjfd��Y}d�_d|_�tjd<|j�|�}|j�jd�|j�j	d�|j|j
d�|j�j�|j�j
�|jt|j�d�|jd\}}|jt|�d	�dS(
NRHcs>eZdZdZe�fd��Ze�fd��ZRS(ics�jd7_td��dS(NiR.(RSR/((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR@"scs�jd7_dS(Ni(tmoduleTornDown((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRA&s(RR RSRURBR@RA((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRHsRcsPeZeZeZe�fd��Ze�fd��Zd�Zd�Z	RS(cs
t�_dS(N(R5R9(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR-scs
t�_dS(N(R5t
classTornDown(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)0scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR3scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR5s(
RR R6R9RVR!RR)RR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR*s	R+cBseZd�Zd�ZRS(cSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR9scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR;s(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR+8s	iissetUpModule (Module)(RIRRR RJRKRR"RSRUR#R7R9RVR$R%R0(R	R+R&R1R((RHRs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_error_in_setup_modules		
cCs[dtjfd��Y}d|_tjjdd�|j|�}|j|j	d�dS(NRcBseZd�Zd�ZRS(cSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRMscSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyROs(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRLs	RHi(
RRR RJRKtpoptNoneRR"R#(R	RR&((s1/usr/lib64/python2.7/unittest/test/test_setups.pyt!test_testcase_with_missing_moduleKs
	cs�dtf�fd��Y�dtjfd��Y}d|_�tjd<|j|�}|j�jd�|j|j	d�|jt
|j�d�dS(NRHcs#eZdZe�fd��ZRS(ics�jd7_dS(Ni(RU((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRAZs(RR RURBRA((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRHXsRcBseZd�Zd�ZRS(cSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR_scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRas(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR^s	iii(RIRRR RJRKRR"RUR#R$R%(R	RR&((RHs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_teardown_moduleWs	
csdtf�fd��Y�dtjf�fd��Y�dtjfd��Y}d�_d|_�tjd<|j�|�}|j�jd�|j|j	d�|j
�j�|j
�j�|jt
|j�d�|jd	\}}|jt|�d
�dS(NRHcs#eZdZe�fd��ZRS(ics�jd7_td��dS(NiR.(RUR/((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRAns(RR RURBRA((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRHlsRcsPeZeZeZe�fd��Ze�fd��Zd�Zd�Z	RS(cs
t�_dS(N(R5R9(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRvscs
t�_dS(N(R5RV(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)yscSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR|scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR~s(
RR R6R9RVR!RR)RR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRss	R+cBseZd�Zd�ZRS(cSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�s(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR+�s	iiistearDownModule (Module)(RIRRR RJRKRR"RUR#t
assertTrueR9RVR$R%R0(R	R+R&R1R((RHRs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_error_in_teardown_moduleks		
cCs�dtjfd��Y}|j|�}|j|jd�|jt|j�d�|jt|j�d�|jdd}|jt|�dt	�dS(NRcBs)eZed��Zd�Zd�ZRS(cSstjd��dS(NR.(RtSkipTest(R((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�s(RR R!RRR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�s	iissetUpClass (%s.Test)(
RRRR"R#R$R%tskippedR0R(R	RR&R_((s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_skiptest_in_setupclass�s	cCs�dtjfd��Y}dtfd��Y}d|_|tjd<|j|�}|j|jd�|jt	|j
�d�|jt	|j�d�|jdd}|jt|�d�dS(NRcBseZd�Zd�ZRS(cSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�s(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�s	RHcBseZed��ZRS(cSstjd��dS(NR.(RR^(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR@�s(RR RBR@(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRH�siissetUpModule (Module)(
RRRIR RJRKRR"R#R$R%R_R0(R	RRHR&R_((s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_skiptest_in_setupmodule�s	
cs�g�dtf�fd��Y}dtjf�fd��Y}d|_|tjd<tjj|�}|j�ddddd	g}|j	�|�dS(
NRHcs2eZe�fd��Ze�fd��ZRS(cs�jd�dS(NR@(R>((tordering(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR@�scs�jd�dS(NRA(R>((Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRA�s(RR RBR@RA((Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRH�sRcsAeZe�fd��Ze�fd��Z�fd�ZRS(cs�jd�dS(NR(R>(R(Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scs�jd�dS(NR)(R>(R(Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)�scs�jd�dS(Nttest_something(R>(R	(Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRc�s(RR R!RR)Rc((Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�sR@RRcR)RA(
RIRRR RJRKRR
tdebugR"(R	RHRRt
expectedOrder((Rbs1/usr/lib64/python2.7/unittest/test/test_setups.pyt.test_suite_debug_executes_setups_and_teardowns�s
	

cs�dtf�fd��Y}dtjf�fd��Y}d|_|tjd<tjj|�}tj�}|j	|�d
}x=t
|�D]/\�}|jt|��|j
�WdQXq�WdS(NRHcs2eZe�fd��Ze�fd��ZRS(cs�dkrtd��ndS(NiR@(t	Exception((tphase(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR@�scs�dkrtd��ndS(NiRA(Rg((Rh(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRA�s(RR RBR@RA((Rh(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRH�sRcsAeZe�fd��Ze�fd��Z�fd�ZRS(cs�dkrtd��ndS(NiR(Rg(R(Rh(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scs�dkrtd��ndS(NiR)(Rg(R(Rh(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)�scs�dkrtd��ndS(NiRc(Rg(R	(Rh(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRc�s(RR R!RR)Rc((Rh(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�sR@RARR)Rc(R@RARR)Rc(RIRRR RJRKRR
RRt	enumeratetassertRaisesRegexpRgRd(R	RHRt_suiteRtmessagestmsg((Rhs1/usr/lib64/python2.7/unittest/test/test_setups.pyt&test_suite_debug_propagates_exceptions�s

	

(RR R
RR'R*R,R2R4R8R<RRRTRWRZR[R]R`RaRfRn(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs&							!			R		-			(			t__main__(	RJt	cStringIORRRRRRtmain(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyt<module>s	��PK��[o5��z4z4test/test_assertions.pyonu�[����
{fc@sgddlZddlZdejfd��YZdejfd��YZedkrcej�ndS(i����NtTest_AssertionscBs,eZd�Zd�Zd�Zd�ZRS(cCsH|jdd�|jdd�|j|j|jdd�|j|j|jdd�|jdddd�|j|j|jdddd�|jdddd�|jdddd�|j|j|jdd
dd�|j|j|jdddd�|jtd
�td
��|j|j|jtd
�td
��dS(Ng�1��?g�?g����?g�������?tplacesiig�������?y�������?tinfy�������?�������?y�������?�������?y�������?�������?y�������?�������?(tassertAlmostEqualtassertNotAlmostEqualtassertRaisestfailureExceptiontfloat(tself((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttest_AlmostEquals$c	Cs�|jdddd�|jdddd�|jdddd�|jdddd�|jdddd�|j|j|jdddd�|j|j|jdddd�|j|j|jdddd�|jt|jdddddd�|jt|jdddddd�tjj�}|tjdd	�}|j||dtjdd
��|j||dtjdd��dS(Ng�������?g�?tdeltag�?g�������?Ritsecondsi
ii(RRRRt	TypeErrortdatetimetnowt	timedelta(Rtfirsttsecond((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttest_AmostEqualWithDeltas*c	Cs�d�}|jt|t�|jt|td��y|jtd��Wn)|jk
rw}|jd|j�nX|jd�y|jt|t�Wntk
r�nX|jd�|jt��*}y
t�Wntk
r�}�nXWdQX|j|j	|�|jt��td��WdQXy|jt��WdQXWn)|jk
rr}|jd|j�nX|jd�y |jt��t�WdQXWntk
r�nX|jd�dS(NcSs
|�dS(N((te((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt_raise:stkeycSsdS(N(tNone(((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt<lambda>?tsKeyError not raisedsassertRaises() didn't fails0assertRaises() didn't let exception pass through(
RtKeyErrorRtassertIntargstfailt
ValueErrort	ExceptiontassertIst	exception(RRRtcm((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttest_assertRaises9sB	







cCs|jdd�y|jddd�WnD|jk
rm}|jd|jd�|jd|jd�nX|jd�dS(NsAla ma kotasr+sk.ttMessages'kot'is*assertNotRegexpMatches should have failed.(tassertNotRegexpMatchesRRRR(RR((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertNotRegexpMatchesbs(t__name__t
__module__R	RR"R%(((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyRs			)tTestLongMessagecBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(s�Test that the individual asserts honour longMessage.
    This actually tests all the message behaviour for
    asserts that use longMessage.cs`dtjf�fd��Y}dtjf�fd��Y}|d��_|d��_dS(NtTestableTestFalsecs eZeZ�jZd�ZRS(cSsdS(N((R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestTestws(R&R'tFalsetlongMessageRR*((R(s5/usr/lib64/python2.7/unittest/test/test_assertions.pyR)ss	tTestableTestTruecs eZeZ�jZd�ZRS(cSsdS(N((R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyR*~s(R&R'tTrueR,RR*((R(s5/usr/lib64/python2.7/unittest/test/test_assertions.pyR-zs	R*(tunittesttTestCasettestableTruet
testableFalse(RR)R-((Rs5/usr/lib64/python2.7/unittest/test/test_assertions.pytsetUprscCs|jtjj�dS(N(tassertFalseR/R0R,(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestDefault�scCs�|j|jjdd�d�|j|jjdd�d�|j|jjdd�d�|j|jjdd�d�|jjt�d�dS(Ntfootbars	bar : foo(tassertEqualR2t_formatMessageRR1tobject(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttest_formatMsg�s
cCs6djd�td�D��}|jj|d�dS(NRcss|]}t|�VqdS(N(tchr(t.0ti((s5/usr/lib64/python2.7/unittest/test/test_assertions.pys	<genexpr>�si�u�(tjointrangeR1R9(Rtone((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt test_formatMessage_unicode_error�sc
s���fd�}xxt|�D]j\}}||�}i}|d}	|	r]idd6}n�j�jd|��|||�WdQXqWdS(Ncs4|dk}|r�j}n	�j}t|��S(Ni(R2R1tgetattr(R>tuseTestableFalsettest(t
methodNameR(s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt	getMethod�s
	itoopstmsgtexpected_regexp(t	enumeratetassertRaisesRegexpR(
RRFRterrorsRGR>RJt
testMethodtkwargstwithMsg((RFRs5/usr/lib64/python2.7/unittest/test/test_assertions.pytassertMessages�s

cCs&|jdtfddddg�dS(Nt
assertTrues^False is not true$s^oops$s^False is not true : oops$(RQR+(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertTrue�s	cCs&|jdtfddddg�dS(NR4s^True is not false$s^oops$s^True is not false : oops$(RQR.(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertFalse�s	cCs#|jddddddg�dS(NtassertNotEqualis^1 == 1$s^oops$s^1 == 1 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestNotEqual�s	cCs#|jddddddg�dS(NRiis^1 != 2 within 7 places$s^oops$s^1 != 2 within 7 places : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAlmostEqual�scCs#|jddddddg�dS(NRis^1 == 1 within 7 places$s^oops$s^1 == 1 within 7 places : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestNotAlmostEqual�scCs#|jddddddg�dS(Nt_baseAssertEqualiis^1 != 2$s^oops$s^1 != 2 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttest_baseAssertEqual�scCs,|jdgdgfddddg�dS(NtassertSequenceEquals\+ \[None\]$s^oops$s\+ \[None\] : oops$(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertSequenceEqual�s	cCs5|jdt�tdg�fddddg�dS(NtassertSetEqualsNone$s^oops$sNone : oops$(RQtsetR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertSetEqual�s	cCs)|jddgfddddg�dS(NRs^None not found in \[\]$s^oops$s^None not found in \[\] : oops$(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertIn�scCs,|jdddgfddddg�dS(NtassertNotIns%^None unexpectedly found in \[None\]$s^oops$s,^None unexpectedly found in \[None\] : oops$(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertNotIn�scCs0|jdiidd6fddddg�dS(NtassertDictEqualtvalueRs\+ \{'key': 'value'\}$s^oops$s\+ \{'key': 'value'\} : oops$(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertDictEqual�scCs0|jdidd6ifddddg�dS(NtassertDictContainsSubsetRdRs^Missing: 'key'$s^oops$s^Missing: 'key' : oops$(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertDictContainsSubset�scCs#|jddddddg�dS(NtassertMultiLineEqualRR6s\+ foo$s^oops$s\+ foo : oops$(RR6(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertMultiLineEqual�scCs#|jddddddg�dS(Nt
assertLessiis^2 not less than 1$s^oops$s^2 not less than 1 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertLess�scCs#|jddddddg�dS(NtassertLessEqualiis^2 not less than or equal to 1$s^oops$s&^2 not less than or equal to 1 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertLessEqual�scCs#|jddddddg�dS(Nt
assertGreateriis^1 not greater than 2$s^oops$s^1 not greater than 2 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertGreater�scCs#|jddddddg�dS(NtassertGreaterEqualiis"^1 not greater than or equal to 2$s^oops$s)^1 not greater than or equal to 2 : oops$(ii(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertGreaterEqualscCs#|jddddddg�dS(NtassertIsNonesnot Nones^'not None' is not None$s^oops$s^'not None' is not None : oops$(snot None(RQ(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertIsNonescCs#|jddddddg�dS(NtassertIsNotNones^unexpectedly None$s^oops$s^unexpectedly None : oops$(N(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertIsNotNonescCs#|jddddddg�dS(NRR6s^None is not 'foo'$s^oops$s^None is not 'foo' : oops$(NR6(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertIsscCs#|jddddddg�dS(NtassertIsNots^unexpectedly identical: None$s^oops$s%^unexpectedly identical: None : oops$(NN(RQR(R((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyttestAssertIsNots(R&R't__doc__R3R5R;RBRQRSRTRVRWRXRZR\R_R`RbReRgRiRkRmRoRqRsRuRvRx(((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyR(ms6			
																						t__main__(R
R/R0RR(R&tmain(((s5/usr/lib64/python2.7/unittest/test/test_assertions.pyt<module>s
g�PK��[x�'Ә�test/test_program.pynu�[���from cStringIO import StringIO

import os
import sys
import unittest
import unittest.test


class Test_TestProgram(unittest.TestCase):

    def test_discovery_from_dotted_path(self):
        loader = unittest.TestLoader()

        tests = [self]
        expectedPath = os.path.abspath(os.path.dirname(unittest.test.__file__))

        self.wasRun = False
        def _find_tests(start_dir, pattern):
            self.wasRun = True
            self.assertEqual(start_dir, expectedPath)
            return tests
        loader._find_tests = _find_tests
        suite = loader.discover('unittest.test')
        self.assertTrue(self.wasRun)
        self.assertEqual(suite._tests, tests)

    # Horrible white box test
    def testNoExit(self):
        result = object()
        test = object()

        class FakeRunner(object):
            def run(self, test):
                self.test = test
                return result

        runner = FakeRunner()

        oldParseArgs = unittest.TestProgram.parseArgs
        def restoreParseArgs():
            unittest.TestProgram.parseArgs = oldParseArgs
        unittest.TestProgram.parseArgs = lambda *args: None
        self.addCleanup(restoreParseArgs)

        def removeTest():
            del unittest.TestProgram.test
        unittest.TestProgram.test = test
        self.addCleanup(removeTest)

        program = unittest.TestProgram(testRunner=runner, exit=False, verbosity=2)

        self.assertEqual(program.result, result)
        self.assertEqual(runner.test, test)
        self.assertEqual(program.verbosity, 2)

    class FooBar(unittest.TestCase):
        def testPass(self):
            assert True
        def testFail(self):
            assert False

    class FooBarLoader(unittest.TestLoader):
        """Test loader that returns a suite containing FooBar."""
        def loadTestsFromModule(self, module):
            return self.suiteClass(
                [self.loadTestsFromTestCase(Test_TestProgram.FooBar)])


    def test_NonExit(self):
        program = unittest.main(exit=False,
                                argv=["foobar"],
                                testRunner=unittest.TextTestRunner(stream=StringIO()),
                                testLoader=self.FooBarLoader())
        self.assertTrue(hasattr(program, 'result'))


    def test_Exit(self):
        self.assertRaises(
            SystemExit,
            unittest.main,
            argv=["foobar"],
            testRunner=unittest.TextTestRunner(stream=StringIO()),
            exit=True,
            testLoader=self.FooBarLoader())


    def test_ExitAsDefault(self):
        self.assertRaises(
            SystemExit,
            unittest.main,
            argv=["foobar"],
            testRunner=unittest.TextTestRunner(stream=StringIO()),
            testLoader=self.FooBarLoader())


class InitialisableProgram(unittest.TestProgram):
    exit = False
    result = None
    verbosity = 1
    defaultTest = None
    testRunner = None
    testLoader = unittest.defaultTestLoader
    progName = 'test'
    test = 'test'
    def __init__(self, *args):
        pass

RESULT = object()

class FakeRunner(object):
    initArgs = None
    test = None
    raiseError = False

    def __init__(self, **kwargs):
        FakeRunner.initArgs = kwargs
        if FakeRunner.raiseError:
            FakeRunner.raiseError = False
            raise TypeError

    def run(self, test):
        FakeRunner.test = test
        return RESULT

class TestCommandLineArgs(unittest.TestCase):

    def setUp(self):
        self.program = InitialisableProgram()
        self.program.createTests = lambda: None
        FakeRunner.initArgs = None
        FakeRunner.test = None
        FakeRunner.raiseError = False

    def testHelpAndUnknown(self):
        program = self.program
        def usageExit(msg=None):
            program.msg = msg
            program.exit = True
        program.usageExit = usageExit

        for opt in '-h', '-H', '--help':
            program.exit = False
            program.parseArgs([None, opt])
            self.assertTrue(program.exit)
            self.assertIsNone(program.msg)

        program.parseArgs([None, '-$'])
        self.assertTrue(program.exit)
        self.assertIsNotNone(program.msg)

    def testVerbosity(self):
        program = self.program

        for opt in '-q', '--quiet':
            program.verbosity = 1
            program.parseArgs([None, opt])
            self.assertEqual(program.verbosity, 0)

        for opt in '-v', '--verbose':
            program.verbosity = 1
            program.parseArgs([None, opt])
            self.assertEqual(program.verbosity, 2)

    def testBufferCatchFailfast(self):
        program = self.program
        for arg, attr in (('buffer', 'buffer'), ('failfast', 'failfast'),
                      ('catch', 'catchbreak')):
            if attr == 'catch' and not hasInstallHandler:
                continue

            short_opt = '-%s' % arg[0]
            long_opt = '--%s' % arg
            for opt in short_opt, long_opt:
                setattr(program, attr, None)

                program.parseArgs([None, opt])
                self.assertTrue(getattr(program, attr))

            for opt in short_opt, long_opt:
                not_none = object()
                setattr(program, attr, not_none)

                program.parseArgs([None, opt])
                self.assertEqual(getattr(program, attr), not_none)

    def testRunTestsRunnerClass(self):
        program = self.program

        program.testRunner = FakeRunner
        program.verbosity = 'verbosity'
        program.failfast = 'failfast'
        program.buffer = 'buffer'

        program.runTests()

        self.assertEqual(FakeRunner.initArgs, {'verbosity': 'verbosity',
                                                'failfast': 'failfast',
                                                'buffer': 'buffer'})
        self.assertEqual(FakeRunner.test, 'test')
        self.assertIs(program.result, RESULT)

    def testRunTestsRunnerInstance(self):
        program = self.program

        program.testRunner = FakeRunner()
        FakeRunner.initArgs = None

        program.runTests()

        # A new FakeRunner should not have been instantiated
        self.assertIsNone(FakeRunner.initArgs)

        self.assertEqual(FakeRunner.test, 'test')
        self.assertIs(program.result, RESULT)

    def testRunTestsOldRunnerClass(self):
        program = self.program

        FakeRunner.raiseError = True
        program.testRunner = FakeRunner
        program.verbosity = 'verbosity'
        program.failfast = 'failfast'
        program.buffer = 'buffer'
        program.test = 'test'

        program.runTests()

        # If initializing raises a type error it should be retried
        # without the new keyword arguments
        self.assertEqual(FakeRunner.initArgs, {})
        self.assertEqual(FakeRunner.test, 'test')
        self.assertIs(program.result, RESULT)

    def testCatchBreakInstallsHandler(self):
        module = sys.modules['unittest.main']
        original = module.installHandler
        def restore():
            module.installHandler = original
        self.addCleanup(restore)

        self.installed = False
        def fakeInstallHandler():
            self.installed = True
        module.installHandler = fakeInstallHandler

        program = self.program
        program.catchbreak = True

        program.testRunner = FakeRunner

        program.runTests()
        self.assertTrue(self.installed)


if __name__ == '__main__':
    unittest.main()
PK��[\�p�q�qtest/test_setups.pyonu�[����
|fc@sgddlZddlmZddlZd�Zdejfd��YZedkrcej�ndS(i����N(tStringIOcGs
tj�S(N(tunittestt
TestResult(t_((s1/usr/lib64/python2.7/unittest/test/test_setups.pyt
resultFactoryst
TestSetupscBs�eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�ZRS(cCstjdtdt��S(Ntresultclasststream(RtTextTestRunnerRR(tself((s1/usr/lib64/python2.7/unittest/test/test_setups.pyt	getRunnerscGs�tj�}x-|D]%}tjj|�}|j|�qW|j�}tj�}|j|�|jtj��|jtj��|j|�S(N(Rt	TestSuitetdefaultTestLoadertloadTestsFromTestCasetaddTestsR
taddTesttrun(R	tcasestsuitetcasetteststrunnert	realSuite((s1/usr/lib64/python2.7/unittest/test/test_setups.pytrunTestss

csqdtjf�fd��Y�|j��}|j�jd�|j|jd�|jt|j�d�dS(NtTestcs5eZdZe�fd��Zd�Zd�ZRS(ics �jd7_tjj�dS(Ni(tsetUpCalledRtTestCaset
setUpClass(tcls(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR$scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_one(scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_two*s(t__name__t
__module__RtclassmethodRRR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR"s	iii(RRRtassertEqualRttestsRuntlenterrors(R	tresult((Rs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_setup_class!s
csqdtjf�fd��Y�|j��}|j�jd�|j|jd�|jt|j�d�dS(NRcs5eZdZe�fd��Zd�Zd�ZRS(ics �jd7_tjj�dS(Ni(ttearDownCalledRRt
tearDownClass(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)6scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR:scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR<s(RR R(R!R)RR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR4s	iii(RRRR"R(R#R$R%(R	R&((Rs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_teardown_class3s
cs�dtjf�fd��Y�dtjf�fd��Y�|j���}|j�jd�|j�jd�|j|jd�|jt|j�d�dS(NRcs5eZdZe�fd��Zd�Zd�ZRS(ics �jd7_tjj�dS(Ni(R(RRR)(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)HscSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRLscSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRNs(RR R(R!R)RR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRFs	tTest2cs5eZdZe�fd��Zd�Zd�ZRS(ics �jd7_tjj�dS(Ni(R(RRR)(R(R+(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)SscSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRWscSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRYs(RR R(R!R)RR((R+(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR+Qs	iii(RRRR"R(R#R$R%(R	R&((RR+s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_teardown_class_two_classesEscCs�dtjfd��Y}|j|�}|j|jd�|jt|j�d�|jd\}}|jt|�dt�dS(Nt
BrokenTestcBs)eZed��Zd�Zd�ZRS(cSstd��dS(Ntfoo(t	TypeError(R((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRescSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRhscSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRjs(RR R!RRR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR-ds	iissetUpClass (%s.BrokenTest)(	RRRR"R#R$R%tstrR(R	R-R&terrorR((s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_error_in_setupclasscs	cs�dtjf�fd��Y�dtjf�fd��Y�|j���}|j|jd�|jt|j�d�|j�jd�|j�jd�|jd\}}|jt|�d	t	�dS(
NRcs5eZdZe�fd��Zd�Zd�ZRS(ics�jd7_td��dS(NiR.(ttornDownR/(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)xscSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR|scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR~s(RR R3R!R)RR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRvs	R+cs5eZdZe�fd��Zd�Zd�ZRS(ics�jd7_td��dS(NiR.(R3R/(R(R+(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)�scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�s(RR R3R!R)RR((R+(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR+�s	iiiistearDownClass (%s.Test)(
RRRR"R#R$R%R3R0R(R	R&R1R((RR+s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_error_in_teardown_classuscs@dtjf�fd��Y�|j��|j�j�dS(NRcs;eZeZed��Ze�fd��Zd�ZRS(cSs
t�dS(N(R/(R((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scst�_td��dS(NR.(tTrueR3R/(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)�s	cSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�s(RR tFalseR3R!RR)R((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�s(RRRtassertFalseR3(R	((Rs1/usr/lib64/python2.7/unittest/test/test_setups.pyt(test_class_not_torndown_when_setup_fails�s
csedtjf�fd��Y�tjd����|j��|j�j�|j�j�dS(NRcsGeZeZeZe�fd��Ze�fd��Zd�ZRS(cs
t�_dS(N(R5t
classSetUp(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scs
t�_dS(N(R5R3(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)�scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�s(	RR R6R9R3R!RR)R((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�s
thop(RRtskipRR7R9R3(R	((Rs1/usr/lib64/python2.7/unittest/test/test_setups.pyt-test_class_not_setup_or_torndown_when_skipped�s

cs
g�dtf�fd��Y}dtf�fd��Y}dtjf�fd��Y}dtjf�fd��Y}d	tjf�fd
��Y}d|_|_d|_|tjd<|tjd<tj|d�f�}tj|d
�f�}tj|d�f�}tj|d
�f�}	tj|d�f�}
tj|d
�f�}tj||||	|
|f�}|j�}
|
j|�}|j	|j
d�|j	t|j�d�|j	�ddddddddddddddddg�dS( NtModule1cs2eZe�fd��Ze�fd��ZRS(cs�jd�dS(NsModule1.setUpModule(tappend((tresults(s1/usr/lib64/python2.7/unittest/test/test_setups.pytsetUpModule�scs�jd�dS(NsModule1.tearDownModule(R>((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyttearDownModule�s(RR tstaticmethodR@RA((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR=�stModule2cs2eZe�fd��Ze�fd��ZRS(cs�jd�dS(NsModule2.setUpModule(R>((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR@�scs�jd�dS(NsModule2.tearDownModule(R>((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRA�s(RR RBR@RA((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRC�stTest1csPeZe�fd��Ze�fd��Z�fd�Z�fd�ZRS(cs�jd�dS(Nssetup 1(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scs�jd�dS(Ns
teardown 1(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)�scs�jd�dS(Ns
Test1.testOne(R>(R	(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyttestOne�scs�jd�dS(Ns
Test1.testTwo(R>(R	(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyttestTwo�s(RR R!RR)RERF((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRD�sR+csPeZe�fd��Ze�fd��Z�fd�Z�fd�ZRS(cs�jd�dS(Nssetup 2(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scs�jd�dS(Ns
teardown 2(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)�scs�jd�dS(Ns
Test2.testOne(R>(R	(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRE�scs�jd�dS(Ns
Test2.testTwo(R>(R	(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRF�s(RR R!RR)RERF((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR+�stTest3csPeZe�fd��Ze�fd��Z�fd�Z�fd�ZRS(cs�jd�dS(Nssetup 3(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scs�jd�dS(Ns
teardown 3(R>(R(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)�scs�jd�dS(Ns
Test3.testOne(R>(R	(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRE�scs�jd�dS(Ns
Test3.testTwo(R>(R	(R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRF�s(RR R!RR)RERF((R?(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRG�stModuleRERFiisModule1.setUpModulessetup 1s
Test1.testOnes
Test1.testTwos
teardown 1ssetup 2s
Test2.testOnes
Test2.testTwos
teardown 2sModule1.tearDownModulesModule2.setUpModulessetup 3s
Test3.testOnes
Test3.testTwos
teardown 3sModule2.tearDownModule(
tobjectRRR tsystmodulesRR
RR"R#R$R%(R	R=RCRDR+RGtfirsttsecondtthirdtfourthtfifthtsixthRRR&((R?s1/usr/lib64/python2.7/unittest/test/test_setups.pyt1test_setup_teardown_order_with_pathological_suite�s:	

!			cs�dtf�fd��Y�dtjfd��Y}d|_�tjd<|j|�}|j�jd�|j|j	d�|jt
|j�d�dS(NRHcs#eZdZe�fd��ZRS(ics�jd7_dS(Ni(tmoduleSetup((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR@
s(RR RSRBR@((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRHsRcBseZd�Zd�ZRS(cSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRscSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs	iii(RIRRR RJRKRR"RSR#R$R%(R	RR&((RHs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_setup_module
s	
cs$dtf�fd��Y�dtjf�fd��Y�dtjfd��Y}d�_d|_�tjd<|j�|�}|j�jd�|j�j	d�|j|j
d�|j�j�|j�j
�|jt|j�d�|jd\}}|jt|�d	�dS(
NRHcs>eZdZdZe�fd��Ze�fd��ZRS(ics�jd7_td��dS(NiR.(RSR/((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR@"scs�jd7_dS(Ni(tmoduleTornDown((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRA&s(RR RSRURBR@RA((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRHsRcsPeZeZeZe�fd��Ze�fd��Zd�Zd�Z	RS(cs
t�_dS(N(R5R9(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR-scs
t�_dS(N(R5t
classTornDown(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)0scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR3scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR5s(
RR R6R9RVR!RR)RR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR*s	R+cBseZd�Zd�ZRS(cSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR9scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR;s(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR+8s	iissetUpModule (Module)(RIRRR RJRKRR"RSRUR#R7R9RVR$R%R0(R	R+R&R1R((RHRs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_error_in_setup_modules		
cCs[dtjfd��Y}d|_tjjdd�|j|�}|j|j	d�dS(NRcBseZd�Zd�ZRS(cSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRMscSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyROs(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRLs	RHi(
RRR RJRKtpoptNoneRR"R#(R	RR&((s1/usr/lib64/python2.7/unittest/test/test_setups.pyt!test_testcase_with_missing_moduleKs
	cs�dtf�fd��Y�dtjfd��Y}d|_�tjd<|j|�}|j�jd�|j|j	d�|jt
|j�d�dS(NRHcs#eZdZe�fd��ZRS(ics�jd7_dS(Ni(RU((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRAZs(RR RURBRA((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRHXsRcBseZd�Zd�ZRS(cSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR_scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRas(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR^s	iii(RIRRR RJRKRR"RUR#R$R%(R	RR&((RHs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_teardown_moduleWs	
csdtf�fd��Y�dtjf�fd��Y�dtjfd��Y}d�_d|_�tjd<|j�|�}|j�jd�|j|j	d�|j
�j�|j
�j�|jt
|j�d�|jd	\}}|jt|�d
�dS(NRHcs#eZdZe�fd��ZRS(ics�jd7_td��dS(NiR.(RUR/((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRAns(RR RURBRA((RH(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRHlsRcsPeZeZeZe�fd��Ze�fd��Zd�Zd�Z	RS(cs
t�_dS(N(R5R9(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRvscs
t�_dS(N(R5RV(R(R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)yscSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR|scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR~s(
RR R6R9RVR!RR)RR((R(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRss	R+cBseZd�Zd�ZRS(cSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�s(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR+�s	iiistearDownModule (Module)(RIRRR RJRKRR"RUR#t
assertTrueR9RVR$R%R0(R	R+R&R1R((RHRs1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_error_in_teardown_moduleks		
cCs�dtjfd��Y}|j|�}|j|jd�|jt|j�d�|jt|j�d�|jdd}|jt|�dt	�dS(NRcBs)eZed��Zd�Zd�ZRS(cSstjd��dS(NR.(RtSkipTest(R((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�s(RR R!RRR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�s	iissetUpClass (%s.Test)(
RRRR"R#R$R%tskippedR0R(R	RR&R_((s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_skiptest_in_setupclass�s	cCs�dtjfd��Y}dtfd��Y}d|_|tjd<|j|�}|j|jd�|jt	|j
�d�|jt	|j�d�|jdd}|jt|�d�dS(NRcBseZd�Zd�ZRS(cSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scSsdS(N((R	((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�s(RR RR(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�s	RHcBseZed��ZRS(cSstjd��dS(NR.(RR^(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyR@�s(RR RBR@(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRH�siissetUpModule (Module)(
RRRIR RJRKRR"R#R$R%R_R0(R	RRHR&R_((s1/usr/lib64/python2.7/unittest/test/test_setups.pyttest_skiptest_in_setupmodule�s	
cs�g�dtf�fd��Y}dtjf�fd��Y}d|_|tjd<tjj|�}|j�ddddd	g}|j	�|�dS(
NRHcs2eZe�fd��Ze�fd��ZRS(cs�jd�dS(NR@(R>((tordering(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR@�scs�jd�dS(NRA(R>((Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRA�s(RR RBR@RA((Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRH�sRcsAeZe�fd��Ze�fd��Z�fd�ZRS(cs�jd�dS(NR(R>(R(Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scs�jd�dS(NR)(R>(R(Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)�scs�jd�dS(Nttest_something(R>(R	(Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRc�s(RR R!RR)Rc((Rb(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�sR@RRcR)RA(
RIRRR RJRKRR
tdebugR"(R	RHRRt
expectedOrder((Rbs1/usr/lib64/python2.7/unittest/test/test_setups.pyt.test_suite_debug_executes_setups_and_teardowns�s
	

cs�dtf�fd��Y}dtjf�fd��Y}d|_|tjd<tjj|�}tj�}|j	|�d
}x=t
|�D]/\�}|jt|��|j
�WdQXq�WdS(NRHcs2eZe�fd��Ze�fd��ZRS(cs�dkrtd��ndS(NiR@(t	Exception((tphase(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR@�scs�dkrtd��ndS(NiRA(Rg((Rh(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRA�s(RR RBR@RA((Rh(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRH�sRcsAeZe�fd��Ze�fd��Z�fd�ZRS(cs�dkrtd��ndS(NiR(Rg(R(Rh(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�scs�dkrtd��ndS(NiR)(Rg(R(Rh(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR)�scs�dkrtd��ndS(NiRc(Rg(R	(Rh(s1/usr/lib64/python2.7/unittest/test/test_setups.pyRc�s(RR R!RR)Rc((Rh(s1/usr/lib64/python2.7/unittest/test/test_setups.pyR�sR@RARR)Rc(R@RARR)Rc(RIRRR RJRKRR
RRt	enumeratetassertRaisesRegexpRgRd(R	RHRt_suiteRtmessagestmsg((Rhs1/usr/lib64/python2.7/unittest/test/test_setups.pyt&test_suite_debug_propagates_exceptions�s

	

(RR R
RR'R*R,R2R4R8R<RRRTRWRZR[R]R`RaRfRn(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyRs&							!			R		-			(			t__main__(	RJt	cStringIORRRRRRtmain(((s1/usr/lib64/python2.7/unittest/test/test_setups.pyt<module>s	��PK��[S.#Ď<�<test/test_suite.pyonu�[����
|fc@s�ddlZddlZddlmZmZdefd��YZd�Zdejefd��YZ	e
dkr�ej�ndS(	i����N(t
LoggingResulttTestEqualitytTestcBs!eZdejfd��YZRS(tFoocBs,eZd�Zd�Zd�Zd�ZRS(cCsdS(N((tself((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_1tcCsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_2
RcCsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_3RcCsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pytrunTestR(t__name__t
__module__RRRR	(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRs			(R
RtunittesttTestCaseR(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR
scGstjd�|D��S(Ncss|]}tj|�VqdS(N(RR(t.0tn((s0/usr/lib64/python2.7/unittest/test/test_suite.pys	<genexpr>s(Rt	TestSuite(tnames((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt
_mk_TestSuitestTest_TestSuitecBsyeZej�ej�fej�ejg�fed�ed�fgZej�ed�fejg�ed�fedd�edd�fed�ed�fgZd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(RRRcCs&tj�}|j|j�d�dS(Ni(RRtassertEqualtcountTestCases(Rtsuite((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_init__tests_optional0scCs)tjg�}|j|j�d�dS(Ni(RRRR(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_init__empty_tests<scCs�d�}tj|��}|j|j�d�tj|�}|j|j�d�tjt|��}|j|j�d�dS(Ncss&tjd��Vtjd��VdS(NcSsdS(N(tNone(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt<lambda>IRcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRJR(RtFunctionTestCase(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttestsHsi(RRRRtset(RRtsuite_1tsuite_2tsuite_3((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt"test_init__tests_from_any_iterableGs	cCs5d�}tj|��}|j|j�d�dS(Ncss8tjd��}tj|g�Vtjd��VdS(NcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR^RcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR`R(RRR(tftc((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR]si(RRRR(RRR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt'test_init__TestSuite_instances_in_tests\s	cCsYtjd��}tjd��}tj||f�}|jt|�||g�dS(NcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRjRcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRkR(RRRRtlist(Rttest1ttest2R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt	test_iteriscCs&tj�}|j|j�d�dS(Ni(RRRR(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_countTestCases_zero_simpleuscCsKdtjfd��Y}tjtj�g�}|j|j�d�dS(NtTest1cBseZd�ZRS(cSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest�s(R
RR*(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR)�si(RR
RRR(RR)R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_countTestCases_zero_nested�scCsStjd��}tjd��}tj||f�}|j|j�d�dS(NcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR�RcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR�Ri(RRRRR(RR%R&R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_countTestCases_simple�scCs�dtjfd��Y}tjd��}tjd��}tj|d�|f�}tj|||d�f�}|j|j�d�dS(NR)cBseZd�Zd�ZRS(cSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR%�RcSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR&�R(R
RR%R&(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR)�s	cSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR�RcSsdS(N(R(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR�RR&R%i(RR
RRRR(RR)R&ttest3tchildtparent((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_countTestCases_nested�scCs?g}t|�}tj�}|j|�|j|g�dS(N(RRRtrunR(RteventstresultR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_run__empty_suite�s

cCs?tj�}y|j�Wntk
r-nX|jd�dS(NsFailed to raise TypeError(RRR1t	TypeErrortfail(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_run__requires_result�s
csyg�t��}dtjf�fd��Y}|d�|d�g}tj|�j|�|j�ddg�dS(NtLoggingCasecs)eZ�fd�Zd�Zd�ZRS(cs�jd|j�dS(Nsrun %s(tappendt_testMethodName(RR3(R2(s0/usr/lib64/python2.7/unittest/test/test_suite.pyR1�scSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR%�RcSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR&�R(R
RR1R%R&((R2(s0/usr/lib64/python2.7/unittest/test/test_suite.pyR8�s	R%R&s	run test1s	run test2(RRR
RR1R(RR3R8R((R2s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_run�scCsqdtjfd��Y}|d�}tj�}|j|�|j|j�d�|jt|�|g�dS(NRcBseZd�ZRS(cSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR*�R(R
RR*(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR�sR*i(RR
RtaddTestRRR$(RRR*R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTest__TestCase�s
cCs}dtjfd��Y}tj|d�g�}tj�}|j|�|j|j�d�|jt|�|g�dS(NRcBseZd�ZRS(cSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR*�R(R
RR*(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR�sR*i(RR
RR<RRR$(RRRR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTest__TestSuite�s
cs�dtjfd��Y}|d��|d��tj�g�����fd�}tj�}|j|��|jt|�t|���tj�}x|�D]}|j|�q�W|j||�dS(NRcBseZd�Zd�ZRS(cSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR�RcSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR�R(R
RRR(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR�s	RRc3s�V�V�VdS(N(((tinner_suiteRR(s0/usr/lib64/python2.7/unittest/test/test_suite.pytgen�s(RR
RtaddTestsRR$R<(RRR@RRtt((R?RRs0/usr/lib64/python2.7/unittest/test/test_suite.pyt
test_addTests�scCsBtj�}y|jd�Wntk
r0nX|jd�dS(NisFailed to raise TypeError(RRRAR5R6(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTest__noniterables
cCs&tj�}|jt|jd�dS(Ni(RRtassertRaisesR5R<(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTest__noncallablescCs?tj�}|jt|jt�|jt|jtj�dS(N(RRRER5R<R(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTest__casesuiteclassscCs&tj�}|jt|jd�dS(Ntfoo(RRRER5RA(RR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_addTests__string"scCs9d�}tj�}|j|�|jtj��dS(NcSsdS(N((t_((s0/usr/lib64/python2.7/unittest/test/test_suite.pytf's(RRR<R1t
TestResult(RRKR((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_function_in_suite&s	
csDdtjfd��Y}dtf�fd��Y�d|_�tjd<|jtjjd�tj�}|j	|d�|d�g�|j
|j�d�tj�}|j
|�|j�j�|j�j�|j|j�|j|j�|j
t|j�d�|j
t|j�d	�|j
|jd�dS(
NRcBsDeZeZeZed��Zed��Zd�Zd�Z	RS(cSs
t|_dS(N(tTruetwasSetUp(tcls((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt
setUpClass5scSs
t|_dS(N(RNtwasTornDown(RP((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt
tearDownClass8scSsdS(N((R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttestPass;scSstdS(N(R6(R((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttestFail=s(
R
RtFalseRORRtclassmethodRQRSRTRU(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyR2s	tModulecs>eZeZeZe�fd��Ze�fd��ZRS(cs
t�_dS(N(RNRO((RX(s0/usr/lib64/python2.7/unittest/test/test_suite.pytsetUpModuleBscs
t�_dS(N(RNRR((RX(s0/usr/lib64/python2.7/unittest/test/test_suite.pyttearDownModuleEs(R
RRVRORRtstaticmethodRYRZ((RX(s0/usr/lib64/python2.7/unittest/test/test_suite.pyRX?sRTRUiii(RR
tobjectRtsystmodulest
addCleanuptpopt
BaseTestSuiteRARRRLR1tassertFalseRORRtlenterrorstfailuresttestsRun(RRRR3((RXs0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_basetestsuite1s"

	

cCsudtjfd��Y}|�}tj�}tj�}|j|�||�|j|j�|j|j�dS(NtMySuitecBseZeZd�ZRS(c_s#t|_tjj|||�dS(N(RNtcalledRRt__call__(Rtargstkw((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRj_s	(R
RRVRiRj(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRh]s(RRRLR<t
assertTrueRiRbt_testRunEntered(RRhRR3twrapper((s0/usr/lib64/python2.7/unittest/test/test_suite.pyttest_overriding_call\s	

(R
RRRRteq_pairstne_pairsRRR!R#R'R(R+R,R0R4R7R;R=R>RCRDRFRGRIRMRgRp(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyRs:				
									
			
					+t__main__(RR]tunittest.test.supportRRR\RRR
RR
tmain(((s0/usr/lib64/python2.7/unittest/test/test_suite.pyt<module>s	�XPK��[FE���__main__.pyonu�[����
{fc@stdZddlZejdjd�r8dejd<neZddlmZmZmZee_	edd�dS(	sMain entry pointi����Nis__main__.pyspython -m unittesti(tmaintTestProgramt
USAGE_AS_MAINtmodule(t__doc__tsystargvtendswithtTruet
__unittestRRRtUSAGEtNone(((s)/usr/lib64/python2.7/unittest/__main__.pyt<module>s	PK��[�A���__init__.pyonu�[����
{fc@sDdZddddddddd	d
ddd
dddddgZejdddg�eZddlmZddlmZm	Z	m
Z
mZmZm
Z
mZmZmZddlmZmZddlmZmZmZmZmZddlmZmZddlmZmZddlm Z m!Z!m"Z"m#Z#eZ$dS(s�
Python unit testing framework, based on Erich Gamma's JUnit and Kent Beck's
Smalltalk testing framework.

This module contains the core framework classes that form the basis of
specific test cases and suites (TestCase, TestSuite etc.), and also a
text-based utility class for running the tests and reporting the results
 (TextTestRunner).

Simple usage:

    import unittest

    class IntegerArithmeticTestCase(unittest.TestCase):
        def testAdd(self):  ## test method names begin 'test*'
            self.assertEqual((1 + 2), 3)
            self.assertEqual(0 + 1, 1)
        def testMultiply(self):
            self.assertEqual((0 * 10), 0)
            self.assertEqual((5 * 8), 40)

    if __name__ == '__main__':
        unittest.main()

Further information is available in the bundled documentation, and from

  http://docs.python.org/library/unittest.html

Copyright (c) 1999-2003 Steve Purcell
Copyright (c) 2003-2010 Python Software Foundation
This module is free software, and you may redistribute it and/or modify
it under the same terms as Python itself, so long as this copyright message
and disclaimer are retained in their original form.

IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.

THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE.  THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
t
TestResulttTestCaset	TestSuitetTextTestRunnert
TestLoadertFunctionTestCasetmaintdefaultTestLoadertSkipTesttskiptskipIft
skipUnlesstexpectedFailuretTextTestResulttinstallHandlertregisterResulttremoveResultt
removeHandlertgetTestCaseNamest	makeSuitet
findTestCasesi(R(	RRRR	R
RRt_skipInRpmBuildt_expectedFailureInRpmBuild(t
BaseTestSuiteR(RRRRR(tTestProgramR(RR
(RRRRN(%t__doc__t__all__textendtTruet
__unittesttresultRtcaseRRRR	R
RRRRtsuiteRRtloaderRRRRRRRtrunnerRR
tsignalsRRRRt_TextTestResult(((s)/usr/lib64/python2.7/unittest/__init__.pyt<module>-s		@("PK��[�X���
�
signals.pycnu�[����
{fc@s�ddlZddlZddlmZeZdefd��YZej�Z	d�Z
d�Zda
d�Zdd�ZdS(	i����N(twrapst_InterruptHandlercBseZd�Zd�ZRS(cCsyt|_||_t|ttf�rl|tjkrBtj}ql|tj	kr]d�}qlt
d��n||_dS(NcSsdS(N((t
unused_signumtunused_frame((s(/usr/lib64/python2.7/unittest/signals.pytdefault_handlerssYexpected SIGINT signal handler to be signal.SIG_IGN, signal.SIG_DFL, or a callable object(tFalsetcalledtoriginal_handlert
isinstancetinttlongtsignaltSIG_DFLtdefault_int_handlertSIG_IGNt	TypeErrorR(tselfR((s(/usr/lib64/python2.7/unittest/signals.pyt__init__
s		cCs{tjtj�}||k	r1|j||�n|jrM|j||�nt|_xtj�D]}|j�qcWdS(N(	Rt	getsignaltSIGINTRRtTruet_resultstkeyststop(Rtsignumtframetinstalled_handlertresult((s(/usr/lib64/python2.7/unittest/signals.pyt__call__s		(t__name__t
__module__RR(((s(/usr/lib64/python2.7/unittest/signals.pyR	s	cCsdt|<dS(Ni(R(R((s(/usr/lib64/python2.7/unittest/signals.pytregisterResult*scCsttj|d��S(N(tboolRtpoptNone(R((s(/usr/lib64/python2.7/unittest/signals.pytremoveResult-scCsDtdkr@tjtj�}t|�atjtjt�ndS(N(t_interrupt_handlerR"RRRR(R((s(/usr/lib64/python2.7/unittest/signals.pytinstallHandler1scsT�dk	r+t���fd��}|Stdk	rPtjtjtj�ndS(NcsEtjtj�}t�z�||�SWdtjtj|�XdS(N(RRRt
removeHandler(targstkwargstinitial(tmethod(s(/usr/lib64/python2.7/unittest/signals.pytinner;s
(R"RR$RRR(R*R+((R*s(/usr/lib64/python2.7/unittest/signals.pyR&9s
(Rtweakreft	functoolsRRt
__unittesttobjectRtWeakKeyDictionaryRRR#R"R$R%R&(((s(/usr/lib64/python2.7/unittest/signals.pyt<module>s 			PK��[u<�΢΢case.pyonu�[����
{fc@s}dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
mZmZmZmZeZdZdefd��YZd	efd
��YZdefd��YZd
�Zd�Zd�Zd�Zd�Zd�Zd�Zde fd��YZ!de fd��YZ"de"fd��YZ#dS(sTest case implementationi����Ni(tresult(tstrclasst	safe_reprtunorderable_list_differencet_count_diff_all_purposet_count_diff_hashables@
Diff is %s characters long. Set self.maxDiff to None to see it.tSkipTestcBseZdZRS(s�
    Raise this exception in a test to skip it.

    Usually you can use TestCase.skipTest() or one of the skipping decorators
    instead of raising this directly.
    (t__name__t
__module__t__doc__(((s%/usr/lib64/python2.7/unittest/case.pyRst_ExpectedFailurecBseZdZd�ZRS(s\
    Raise this when a test is expected to fail.

    This is an implementation detail.
    cCs tt|�j�||_dS(N(tsuperR
t__init__texc_info(tselfR
((s%/usr/lib64/python2.7/unittest/case.pyR*s(RRR	R(((s%/usr/lib64/python2.7/unittest/case.pyR
#st_UnexpectedSuccesscBseZdZRS(s7
    The test was supposed to fail, but it didn't!
    (RRR	(((s%/usr/lib64/python2.7/unittest/case.pyR.scCs|S(N((tobj((s%/usr/lib64/python2.7/unittest/case.pyt_id4scs�fd�}|S(s&
    Unconditionally skip a test.
    csUt|ttjf�s?tj|��fd��}|}nt|_�|_|S(Ncst���dS(N(R(targstkwargs(treason(s%/usr/lib64/python2.7/unittest/case.pytskip_wrapper=s(	t
isinstancettypettypest	ClassTypet	functoolstwrapstTruet__unittest_skip__t__unittest_skip_why__(t	test_itemR(R(s%/usr/lib64/python2.7/unittest/case.pyt	decorator;s			((RR ((Rs%/usr/lib64/python2.7/unittest/case.pytskip7s
cCs|rt|�StS(s/
    Skip a test if the condition is true.
    (R!R(t	conditionR((s%/usr/lib64/python2.7/unittest/case.pytskipIfGs
cCs|st|�StS(s3
    Skip a test unless the condition is true.
    (R!R(R"R((s%/usr/lib64/python2.7/unittest/case.pyt
skipUnlessOs
cs"tj���fd��}|S(NcsAy�||�Wn#tk
r6ttj���nXt�dS(N(t	ExceptionR
tsysR
R(RR(tfunc(s%/usr/lib64/python2.7/unittest/case.pytwrapperYs

(RR(R'R(((R's%/usr/lib64/python2.7/unittest/case.pytexpectedFailureXscCs!dtjkrt|�StSdS(s
    Non-standard/downstream-only decorator for marking a specific unit test
    to be skipped when run within the %check of an rpmbuild.

    Specifically, this takes effect when WITHIN_PYTHON_RPM_BUILD is set within
    the environment, and has no effect otherwise.
    tWITHIN_PYTHON_RPM_BUILDN(tostenvironR!R(R((s%/usr/lib64/python2.7/unittest/case.pyt_skipInRpmBuildfs
cs"tj���fd��}|S(s

    Non-standard/downstream-only decorator for marking a specific unit test
    as expected to fail within the %check of an rpmbuild.

    Specifically, this takes effect when WITHIN_PYTHON_RPM_BUILD is set within
    the environment, and has no effect otherwise.
    cs`dtjkrOy�||�Wn#tk
rEttj���nXt�n
�||�dS(NR*(R+R,R%R
R&R
R(RR(R'(s%/usr/lib64/python2.7/unittest/case.pyR({s
	(RR(R'R(((R's%/usr/lib64/python2.7/unittest/case.pyt_expectedFailureInRpmBuildsst_AssertRaisesContextcBs,eZdZdd�Zd�Zd�ZRS(sCA context manager used to implement TestCase.assertRaises* methods.cCs"||_|j|_||_dS(N(texpectedtfailureExceptiontexpected_regexp(RR0t	test_caseR2((s%/usr/lib64/python2.7/unittest/case.pyR�s	cCs|S(N((R((s%/usr/lib64/python2.7/unittest/case.pyt	__enter__�scCs�|dkrZy|jj}Wn tk
r>t|j�}nX|jdj|���nt||j�sptS||_	|j
dkr�tS|j
}|jt|��s�|jd|j
t|�f��ntS(Ns{0} not raiseds"%s" does not match "%s"(tNoneR0RtAttributeErrortstrR1tformatt
issubclasstFalset	exceptionR2Rtsearchtpattern(Rtexc_typet	exc_valuettbtexc_nameR2((s%/usr/lib64/python2.7/unittest/case.pyt__exit__�s"
			N(RRR	R5RR4RB(((s%/usr/lib64/python2.7/unittest/case.pyR/�s	tTestCasecBs)eZdZeZeZd@ZdAZeZ	dd�Z
d�Zd�Zd	�Z
d
�Zed��Zed��Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdBd�Zd�Zd�Zd�Z d�Z!dBd�Z"dBd�Z#dBd�Z$d�Z%dBd �Z&d!�Z'dBd"�Z(dBd#�Z)dBd$�Z*dBdBdBd%�Z+dBdBdBd&�Z,e)Z-e*Z.e+Z/e,Z0e$Z1d'�Z2e2e)�Z3e2e*�Z4e2e+�Z5e2e,�Z6e2e$�Z7e2e&�Z8e2e#�Z9dBdBd(�Z:d)�Z;dBd*�Z<dBd+�Z=dBd,�Z>dBd-�Z?dBd.�Z@dBd/�ZAdBd0�ZBdBd1�ZCdBd2�ZDdBd3�ZEdBd4�ZFdBd5�ZGdBd6�ZHdBd7�ZIdBd8�ZJdBd9�ZKdBd:�ZLdBd;�ZMdBd<�ZNdBd=�ZOdBd>�ZPdBd?�ZQRS(CsWA class whose instances are single test cases.

    By default, the test code itself should be placed in a method named
    'runTest'.

    If the fixture may be used for many test cases, create as
    many test methods as are needed. When instantiating such a TestCase
    subclass, specify in the constructor arguments the name of the test method
    that the instance is to execute.

    Test authors should subclass TestCase for their own tests. Construction
    and deconstruction of the test's environment ('fixture') can be
    implemented by overriding the 'setUp' and 'tearDown' methods respectively.

    If it is necessary to override the __init__ method, the base class
    __init__ method must always be called. It is important that subclasses
    should not change the signature of their __init__ method, since instances
    of the classes are instantiated automatically by parts of the framework
    in order to be run.

    When subclassing TestCase, you can set these attributes:
    * failureException: determines which exception will be raised when
        the instance's assertion methods fail; test methods raising this
        exception will be deemed to have 'failed' rather than 'errored'.
    * longMessage: determines whether long messages (including repr of
        objects used in assert methods) will be printed on failure in *addition*
        to any explicit message passed.
    * maxDiff: sets the maximum length of a diff in failure messages
        by assert methods using difflib. It is looked up as an instance
        attribute so can be configured by individual tests if required.
    iPiiitrunTestcCs�||_d|_yt||�}Wn*tk
rQtd|j|f��nX|j|_g|_	i|_
|jtd�|jt
d�|jtd�|jtd�|jtd�y|jtd�Wntk
r�nXdS(s�Create an instance of the class that will use the named test
           method when executed. Raises a ValueError if the instance does
           not have a method with the specified name.
        sno such test method in %s: %stassertDictEqualtassertListEqualtassertTupleEqualtassertSetEqualtassertMultiLineEqualN(t_testMethodNameR5t_resultForDoCleanupstgetattrR6t
ValueErrort	__class__R	t_testMethodDoct	_cleanupst_type_equality_funcstaddTypeEqualityFunctdicttlistttupletsett	frozensettunicodet	NameError(Rt
methodNamet
testMethod((s%/usr/lib64/python2.7/unittest/case.pyR�s&		
		
cCs||j|<dS(s[Add a type specific assertEqual style function to compare a type.

        This method is for use by TestCase subclasses that need to register
        their own type equality functions to provide nicer error messages.

        Args:
            typeobj: The data type to call this function on when both values
                    are of the same type in assertEqual().
            function: The callable taking two arguments and an optional
                    msg= argument that raises self.failureException with a
                    useful error message when the two arguments are not equal.
        N(RQ(Rttypeobjtfunction((s%/usr/lib64/python2.7/unittest/case.pyRR�s
cOs|jj|||f�dS(sAdd a function, with arguments, to be called when the test is
        completed. Functions added are called on a LIFO basis and are
        called after tearDown on test failure or success.

        Cleanup items are called even if setUp fails (unlike tearDown).N(RPtappend(RR]RR((s%/usr/lib64/python2.7/unittest/case.pyt
addCleanupscCsdS(sAHook method for setting up the test fixture before exercising it.N((R((s%/usr/lib64/python2.7/unittest/case.pytsetUp
scCsdS(sAHook method for deconstructing the test fixture after testing it.N((R((s%/usr/lib64/python2.7/unittest/case.pyttearDownscCsdS(sKHook method for setting up class fixture before running tests in the class.N((tcls((s%/usr/lib64/python2.7/unittest/case.pyt
setUpClasstcCsdS(sVHook method for deconstructing the class fixture after running all tests in the class.N((Rb((s%/usr/lib64/python2.7/unittest/case.pyt
tearDownClassRdcCsdS(Ni((R((s%/usr/lib64/python2.7/unittest/case.pytcountTestCasesscCs
tj�S(N(Rt
TestResult(R((s%/usr/lib64/python2.7/unittest/case.pytdefaultTestResult scCs,|j}|r(|jd�dj�p+dS(s�Returns a one-line description of the test, or None if no
        description has been provided.

        The default implementation of this method returns the first line of
        the specified test method's docstring.
        s
iN(ROtsplittstripR5(Rtdoc((s%/usr/lib64/python2.7/unittest/case.pytshortDescription#s	cCsdt|j�|jfS(Ns%s.%s(RRNRJ(R((s%/usr/lib64/python2.7/unittest/case.pytid.scCs,t|�t|�k	rtS|j|jkS(N(RtNotImplementedRJ(Rtother((s%/usr/lib64/python2.7/unittest/case.pyt__eq__1scCs||kS(N((RRo((s%/usr/lib64/python2.7/unittest/case.pyt__ne__7scCstt|�|jf�S(N(thashRRJ(R((s%/usr/lib64/python2.7/unittest/case.pyt__hash__:scCsd|jt|j�fS(Ns%s (%s)(RJRRN(R((s%/usr/lib64/python2.7/unittest/case.pyt__str__=scCsdt|j�|jfS(Ns<%s testMethod=%s>(RRNRJ(R((s%/usr/lib64/python2.7/unittest/case.pyt__repr__@scCsRt|dd�}|dk	r.|||�n tjdtd�|j|�dS(NtaddSkips4TestResult has no addSkip method, skips not reportedi(RLR5twarningstwarntRuntimeWarningt
addSuccess(RRRRv((s%/usr/lib64/python2.7/unittest/case.pyt_addSkipDs	
cCsr|}|dkrI|j�}t|dd�}|dk	rI|�qIn||_|j|�t||j�}t|jdt�s�t|dt�r�z;t|jdd�p�t|dd�}|j||�Wd|j	|�XdSz>t}y|j
�WnXtk
r*}|j|t|��n�t
k
r=�n�|j|tj��n�Xy|�WnBt
k
r{�n5|jk
r�|j|tj��ntk
r}t|dd�}|dk	r�|||j�q�tjdt�|j|�n�tk
ret|dd�}	|	dk	r<|	|�q�tjdt�|j|tj��nKtk
r�}|j|t|��n#|j|tj��nXt}y|j�Wn6t
k
r��n#|j|tj��t}nX|j�}
|o|
}|r%|j|�nWd|j	|�|dkrmt|d	d�}|dk	rm|�qmnXdS(
NtstartTestRunRRRdtaddExpectedFailures@TestResult has no addExpectedFailure method, reporting as passestaddUnexpectedSuccesssDTestResult has no addUnexpectedSuccess method, reporting as failureststopTestRun(R5RhRLRKt	startTestRJRNR:R{tstopTestR`RR7tKeyboardInterrupttaddErrorR&R
R1t
addFailureR
RwRxRyRzRRRat
doCleanups(RRtorig_resultR|R[tskip_whytsuccessteR}R~tcleanUpSuccessR((s%/usr/lib64/python2.7/unittest/case.pytrunMs�
	


	

	


cCs�|j}t}xr|jr�|jjd�\}}}y|||�Wqtk
r]�qt}|j|tj��qXqW|S(sNExecute all cleanup functions. Normally called for you after
        tearDown.i����(	RKRRPtpopR�R:R�R&R
(RRtokR]RR((s%/usr/lib64/python2.7/unittest/case.pyR��s	
cOs|j||�S(N(R�(RRtkwds((s%/usr/lib64/python2.7/unittest/case.pyt__call__�scCsc|j�t||j��|j�x5|jr^|jjd�\}}}|||�q*WdS(s6Run the test without collecting errors in a TestResulti����N(R`RLRJRaRPR�(RR]RR((s%/usr/lib64/python2.7/unittest/case.pytdebug�s

cCst|��dS(sSkip this test.N(R(RR((s%/usr/lib64/python2.7/unittest/case.pytskipTest�scCs|j|��dS(s)Fail immediately, with the given message.N(R1(Rtmsg((s%/usr/lib64/python2.7/unittest/case.pytfail�scCs8|r4|j|dt|��}|j|��ndS(s#Check that the expression is false.s%s is not falseN(t_formatMessageRR1(RtexprR�((s%/usr/lib64/python2.7/unittest/case.pytassertFalse�scCs8|s4|j|dt|��}|j|��ndS(s"Check that the expression is true.s%s is not trueN(R�RR1(RR�R�((s%/usr/lib64/python2.7/unittest/case.pyt
assertTrue�scCsd|js|p|S|dkr#|Syd||fSWn(tk
r_dt|�t|�fSXdS(s�Honour the longMessage attribute when generating failure messages.
        If longMessage is False this means:
        * Use only an explicit message if it is provided
        * Otherwise use the standard message for the assert

        If longMessage is True:
        * Use the standard message
        * If an explicit message is provided, plus ' : ' and the explicit message
        s%s : %sN(tlongMessageR5tUnicodeDecodeErrorR(RR�tstandardMsg((s%/usr/lib64/python2.7/unittest/case.pyR��s
	

cOs=t||�}|dkr|S|�|||�WdQXdS(s�Fail unless an exception of class excClass is raised
           by callableObj when invoked with arguments args and keyword
           arguments kwargs. If a different type of exception is
           raised, it will not be caught, and the test case will be
           deemed to have suffered an error, exactly as for an
           unexpected exception.

           If called with callableObj omitted or None, will return a
           context object used like this::

                with self.assertRaises(SomeException):
                    do_something()

           The context manager keeps a reference to the exception as
           the 'exception' attribute. This allows you to inspect the
           exception after the assertion::

               with self.assertRaises(SomeException) as cm:
                   do_something()
               the_exception = cm.exception
               self.assertEqual(the_exception.error_code, 3)
        N(R/R5(RtexcClasstcallableObjRRtcontext((s%/usr/lib64/python2.7/unittest/case.pytassertRaises�s
cCskt|�t|�krd|jjt|��}|dk	rdt|t�r]t||�}n|Sn|jS(sGet a detailed comparison function for the types of the two args.

        Returns: A callable accepting (first, second, msg=None) that will
        raise a failure exception if first != second with a useful human
        readable error message for those types.
        N(RRQtgetR5Rt
basestringRLt_baseAssertEqual(Rtfirsttsecondtasserter((s%/usr/lib64/python2.7/unittest/case.pyt_getAssertEqualityFuncscCsP||ksLdt|�t|�f}|j||�}|j|��ndS(s:The default assertEqual implementation, not type specific.s%s != %sN(RR�R1(RR�R�R�R�((s%/usr/lib64/python2.7/unittest/case.pyR�scCs)|j||�}|||d|�dS(s[Fail if the two objects are unequal as determined by the '=='
           operator.
        R�N(R�(RR�R�R�tassertion_func((s%/usr/lib64/python2.7/unittest/case.pytassertEqual"scCsJ||ksF|j|dt|�t|�f�}|j|��ndS(sYFail if the two objects are equal as determined by the '!='
           operator.
        s%s == %sN(R�RR1(RR�R�R�((s%/usr/lib64/python2.7/unittest/case.pytassertNotEqual)scCs||krdS|dk	r7|dk	r7td��n|dk	r�t||�|kr]dSdt|�t|�t|�f}nW|dkr�d}ntt||�|�dkr�dSdt|�t|�|f}|j||�}|j|��dS(s'Fail if the two objects are unequal as determined by their
           difference rounded to the given number of decimal places
           (default 7) and comparing to zero, or by comparing that the
           difference between the two objects is more than the given
           delta.

           Note that decimal places (from zero) are usually not the same
           as significant digits (measured from the most significant digit).

           If the two objects compare equal then they will automatically
           compare almost equal.
        Ns specify delta or places not boths%s != %s within %s deltaiis%s != %s within %r places(R5t	TypeErrortabsRtroundR�R1(RR�R�tplacesR�tdeltaR�((s%/usr/lib64/python2.7/unittest/case.pytassertAlmostEqual3s&
			
cCs|dk	r'|dk	r'td��n|dk	r�||krZt||�|krZdSdt|�t|�t|�f}nd|dkr�d}n||kr�tt||�|�dkr�dSdt|�t|�|f}|j||�}|j|��dS(s�Fail if the two objects are equal as determined by their
           difference rounded to the given number of decimal places
           (default 7) and comparing to zero, or by comparing that the
           difference between the two objects is less than the given delta.

           Note that decimal places (from zero) are usually not the same
           as significant digits (measured from the most significant digit).

           Objects that are equal automatically fail.
        s specify delta or places not bothNs%s == %s within %s deltaiis%s == %s within %r places(R5R�R�RR�R�R1(RR�R�R�R�R�R�((s%/usr/lib64/python2.7/unittest/case.pytassertNotAlmostEqualZs"#		,	
cs�fd�}|S(Ncs,tjdj�j�td��||�S(NsPlease use {0} instead.i(RwRxR8RtPendingDeprecationWarning(RR(t
original_func(s%/usr/lib64/python2.7/unittest/case.pytdeprecated_func�s
((R�R�((R�s%/usr/lib64/python2.7/unittest/case.pyt
_deprecate�scCs|dk	rz|j}t||�sF|jd|t|�f��nt||�s�|jd|t|�f��q�nd}d}yt|�}Wn!ttfk
r�d|}nX|dkr�yt|�}Wq�ttfk
r�d|}q�Xn|dkr�||krdSt|�}	t|�}
t|	�dkrT|	d d}	nt|
�dkrw|
d d}
n|j�|	|
f}d	|}xt	t
||��D]�}y||}
Wn/tttfk
r�|d
||f7}PnXy||}Wn/tttfk
r1|d||f7}PnX|
|kr�|d|t|
�t|�f7}Pq�q�W||kr�|dkr�t|�t|�kr�dS||kr|d
|||f7}y"|d|t||�f7}Wq�tttfk
r|d||f7}q�Xq�||kr�|d|||f7}y"|d|t||�f7}Wq�tttfk
r�|d||f7}q�Xq�n|}ddj
tjtj|�j�tj|�j���}|j||�}|j||�}|j|�dS(sAAn equality assertion for ordered sequences (like lists and tuples).

        For the purposes of this function, a valid ordered sequence type is one
        which can be indexed, has a length, and has an equality operator.

        Args:
            seq1: The first sequence to compare.
            seq2: The second sequence to compare.
            seq_type: The expected datatype of the sequences, or None if no
                    datatype should be enforced.
            msg: Optional message to use on failure instead of a list of
                    differences.
        sFirst sequence is not a %s: %ssSecond sequence is not a %s: %stsequences(First %s has no length.    Non-sequence?s)Second %s has no length.    Non-sequence?Nis...s%ss differ: %s != %s
s(
Unable to index element %d of first %s
s)
Unable to index element %d of second %s
s#
First differing element %d:
%s
%s
s+
First %s contains %d additional elements.
sFirst extra element %d:
%s
s'Unable to index element %d of first %s
s,
Second %s contains %d additional elements.
s(Unable to index element %d of second %s
s
(R5RRR1RtlenR�tNotImplementedErrort
capitalizetxrangetmint
IndexErrorRtjointdifflibtndifftpprinttpformatt
splitlinest_truncateMessageR�R�(Rtseq1tseq2R�tseq_typet
seq_type_namet	differingtlen1tlen2t	seq1_reprt	seq2_reprtelementstititem1titem2R�tdiffMsg((s%/usr/lib64/python2.7/unittest/case.pytassertSequenceEqual�s�			
	cCsA|j}|dks't|�|kr/||S|tt|�S(N(tmaxDiffR5R�tDIFF_OMITTED(Rtmessagetdifftmax_diff((s%/usr/lib64/python2.7/unittest/case.pyR��s	cCs|j|||dt�dS(sA list-specific equality assertion.

        Args:
            list1: The first list to compare.
            list2: The second list to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.

        R�N(R�RT(Rtlist1tlist2R�((s%/usr/lib64/python2.7/unittest/case.pyRFs
cCs|j|||dt�dS(sA tuple-specific equality assertion.

        Args:
            tuple1: The first tuple to compare.
            tuple2: The second tuple to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.
        R�N(R�RU(Rttuple1ttuple2R�((s%/usr/lib64/python2.7/unittest/case.pyRGs	c
Cspy|j|�}WnGtk
r9}|jd|�n$tk
r\}|jd|�nXy|j|�}WnGtk
r�}|jd|�n$tk
r�}|jd|�nX|p�|s�dSg}|r
|jd�x$|D]}|jt|��q�Wn|rD|jd�x$|D]}|jt|��q$Wndj|�}	|j|j||	��dS(s�A set-specific equality assertion.

        Args:
            set1: The first set to compare.
            set2: The second set to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.

        assertSetEqual uses ducktyping to support different types of sets, and
        is optimized for sets specifically (parameters must support a
        difference method).
        s/invalid type when attempting set difference: %ss2first argument does not support set difference: %ss3second argument does not support set difference: %sNs*Items in the first set but not the second:s*Items in the second set but not the first:s
(t
differenceR�R�R6R^treprR�R�(
Rtset1tset2R�tdifference1R�tdifference2tlinestitemR�((s%/usr/lib64/python2.7/unittest/case.pyRHs2




cCsH||krDdt|�t|�f}|j|j||��ndS(sDJust like self.assertTrue(a in b), but with a nicer default message.s%s not found in %sN(RR�R�(Rtmembert	containerR�R�((s%/usr/lib64/python2.7/unittest/case.pytassertInEscCsH||krDdt|�t|�f}|j|j||��ndS(sHJust like self.assertTrue(a not in b), but with a nicer default message.s%s unexpectedly found in %sN(RR�R�(RR�R�R�R�((s%/usr/lib64/python2.7/unittest/case.pytassertNotInLscCsH||k	rDdt|�t|�f}|j|j||��ndS(sDJust like self.assertTrue(a is b), but with a nicer default message.s%s is not %sN(RR�R�(Rtexpr1texpr2R�R�((s%/usr/lib64/python2.7/unittest/case.pytassertIsSscCs?||kr;dt|�f}|j|j||��ndS(sHJust like self.assertTrue(a is not b), but with a nicer default message.sunexpectedly identical: %sN(RR�R�(RR�R�R�R�((s%/usr/lib64/python2.7/unittest/case.pytassertIsNotZscCs�|j|td�|j|td�||kr�dt|t�t|t�f}ddjtjtj|�j	�tj|�j	���}|j
||�}|j|j||��ndS(Ns"First argument is not a dictionarys#Second argument is not a dictionarys%s != %ss
(
tassertIsInstanceRSRRR�R�R�R�R�R�R�R�R�(Rtd1td2R�R�R�((s%/usr/lib64/python2.7/unittest/case.pyRE`s"c	Csg}g}xy|j�D]k\}}||krA|j|�q|||kr|jdt|�t|�t||�f�qqW|p�|s�dSd}|r�ddjd�|D��}n|r�|r�|d7}n|ddj|�7}n|j|j||��dS(	s0Checks whether actual is a superset of expected.s%s, expected: %s, actual: %sNRdsMissing: %st,css|]}t|�VqdS(N(R(t.0tm((s%/usr/lib64/python2.7/unittest/case.pys	<genexpr>}ss; sMismatched values: %s(t	iteritemsR^RR�R�R�(	RR0tactualR�tmissingt
mismatchedtkeytvalueR�((s%/usr/lib64/python2.7/unittest/case.pytassertDictContainsSubsetls(	
c	Cs9t|�t|�}}tj���tjr_x-dddgD]}tjd|t�q?Wny"tj|�}tj|�}Wn t	k
r�t
||�}	n X||kr�dSt||�}	WdQX|	r5d}
g|	D]}d|^q�}dj|�}
|j
|
|
�}
|j||
�}|j|�ndS(	s�An unordered sequence specific comparison. It asserts that
        actual_seq and expected_seq have the same element counts.
        Equivalent to::

            self.assertEqual(Counter(iter(actual_seq)),
                             Counter(iter(expected_seq)))

        Asserts that each element has the same count in both sequences.
        Example:
            - [0, 1, 1] and [1, 0, 1] compare equal.
            - [0, 0, 1] and [0, 1] compare unequal.
        s'(code|dict|type) inequality comparisonss,builtin_function_or_method order comparisonsscomparing unequal typestignoreNsElement counts were not equal:
s First has %d, Second has %d:  %rs
(RTRwtcatch_warningsR&tpy3kwarningtfilterwarningstDeprecationWarningtcollectionstCounterR�RRR�R�R�R�(Rtexpected_seqt
actual_seqR�t	first_seqt
second_seqt_msgR�R�tdifferencesR�R�R�R�((s%/usr/lib64/python2.7/unittest/case.pytassertItemsEqual�s,

	

cCsG|j|td�|j|td�||krCt|�|jks\t|�|jkrr|j|||�n|jt�}|jt�}t|�dkr�|jd�|kr�|dg}|dg}ndt|t�t|t�f}ddj	t
j||��}|j||�}|j
|j||��ndS(	s-Assert that two multi-line strings are equal.sFirst argument is not a stringsSecond argument is not a stringis
s
s%s != %sRdN(R�R�R�t_diffThresholdR�R�RRjRR�R�R�R�R�R�(RR�R�R�t
firstlinestsecondlinesR�R�((s%/usr/lib64/python2.7/unittest/case.pyRI�s$'
cCsH||ksDdt|�t|�f}|j|j||��ndS(sCJust like self.assertTrue(a < b), but with a nicer default message.s%s not less than %sN(RR�R�(RtatbR�R�((s%/usr/lib64/python2.7/unittest/case.pyt
assertLess�scCsH||ksDdt|�t|�f}|j|j||��ndS(sDJust like self.assertTrue(a <= b), but with a nicer default message.s%s not less than or equal to %sN(RR�R�(RRR	R�R�((s%/usr/lib64/python2.7/unittest/case.pytassertLessEqual�scCsH||ksDdt|�t|�f}|j|j||��ndS(sCJust like self.assertTrue(a > b), but with a nicer default message.s%s not greater than %sN(RR�R�(RRR	R�R�((s%/usr/lib64/python2.7/unittest/case.pyt
assertGreater�scCsH||ksDdt|�t|�f}|j|j||��ndS(sDJust like self.assertTrue(a >= b), but with a nicer default message.s"%s not greater than or equal to %sN(RR�R�(RRR	R�R�((s%/usr/lib64/python2.7/unittest/case.pytassertGreaterEqual�scCs?|dk	r;dt|�f}|j|j||��ndS(sCSame as self.assertTrue(obj is None), with a nicer default message.s%s is not NoneN(R5RR�R�(RRR�R�((s%/usr/lib64/python2.7/unittest/case.pytassertIsNone�scCs2|dkr.d}|j|j||��ndS(s(Included for symmetry with assertIsNone.sunexpectedly NoneN(R5R�R�(RRR�R�((s%/usr/lib64/python2.7/unittest/case.pytassertIsNotNone�scCsEt||�sAdt|�|f}|j|j||��ndS(sTSame as self.assertTrue(isinstance(obj, cls)), with a nicer
        default message.s%s is not an instance of %rN(RRR�R�(RRRbR�R�((s%/usr/lib64/python2.7/unittest/case.pyR��scCsEt||�rAdt|�|f}|j|j||��ndS(s,Included for symmetry with assertIsInstance.s%s is an instance of %rN(RRR�R�(RRRbR�R�((s%/usr/lib64/python2.7/unittest/case.pytassertNotIsInstance�scOs^|dk	rtj|�}nt|||�}|dkr@|S|�|||�WdQXdS(s�Asserts that the message in a raised exception matches a regexp.

        Args:
            expected_exception: Exception class expected to be raised.
            expected_regexp: Regexp (re pattern object or string) expected
                    to be found in error message.
            callable_obj: Function to be called.
            args: Extra args.
            kwargs: Extra kwargs.
        N(R5tretcompileR/(Rtexpected_exceptionR2tcallable_objRRR�((s%/usr/lib64/python2.7/unittest/case.pytassertRaisesRegexp�scCsht|t�r!tj|�}n|j|�sd|p9d}d||j|f}|j|��ndS(s=Fail the test unless the text matches the regular expression.sRegexp didn't matchs%s: %r not found in %rN(RR�RRR<R=R1(RttextR2R�((s%/usr/lib64/python2.7/unittest/case.pytassertRegexpMatches
scCs�t|t�r!tj|�}n|j|�}|r�|p?d}d|||j�|j�!|j|f}|j|��ndS(s9Fail the test if the text matches the regular expression.sRegexp matcheds%s: %r matches %r in %rN(	RR�RRR<tstarttendR=R1(RRtunexpected_regexpR�tmatch((s%/usr/lib64/python2.7/unittest/case.pytassertNotRegexpMatchess
i�iN(RRRR	tAssertionErrorR1R:R�R�Rt_classSetupFailedRRRR_R`RatclassmethodRcReRfRhRlRmRpRqRsRtRuR{R5R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�tassertEqualstassertNotEqualstassertAlmostEqualstassertNotAlmostEqualstassert_R�tfailUnlessEqualtfailIfEqualtfailUnlessAlmostEqualtfailIfAlmostEqualt
failUnlesstfailUnlessRaisestfailIfR�R�RFRGRHR�R�R�R�RER�RRIR
RRR
RRR�RRRR(((s%/usr/lib64/python2.7/unittest/case.pyRC�s�															Q							
'$	g	+(	tFunctionTestCasecBszeZdZdddd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�ZRS(
sIA test case that wraps a test function.

    This is useful for slipping pre-existing test functions into the
    unittest framework. Optionally, set-up and tidy-up functions can be
    supplied. As with TestCase, the tidy-up ('tearDown') function will
    always be called if the set-up ('setUp') function ran successfully.
    cCs;tt|�j�||_||_||_||_dS(N(RR,Rt
_setUpFunct
_tearDownFunct	_testFunct_description(RttestFuncR`Ratdescription((s%/usr/lib64/python2.7/unittest/case.pyR*s
			cCs |jdk	r|j�ndS(N(R-R5(R((s%/usr/lib64/python2.7/unittest/case.pyR`1scCs |jdk	r|j�ndS(N(R.R5(R((s%/usr/lib64/python2.7/unittest/case.pyRa5scCs|j�dS(N(R/(R((s%/usr/lib64/python2.7/unittest/case.pyRD9scCs
|jjS(N(R/R(R((s%/usr/lib64/python2.7/unittest/case.pyRm<scCs\t||j�stS|j|jko[|j|jko[|j|jko[|j|jkS(N(RRNRnR-R.R/R0(RRo((s%/usr/lib64/python2.7/unittest/case.pyRp?scCs||kS(N((RRo((s%/usr/lib64/python2.7/unittest/case.pyRqHscCs+tt|�|j|j|j|jf�S(N(RrRR-R.R/R0(R((s%/usr/lib64/python2.7/unittest/case.pyRsKscCsdt|j�|jjfS(Ns%s (%s)(RRNR/R(R((s%/usr/lib64/python2.7/unittest/case.pyRtOscCsdt|j�|jfS(Ns<%s tec=%s>(RRNR/(R((s%/usr/lib64/python2.7/unittest/case.pyRuSscCsE|jdk	r|jS|jj}|rA|jd�dj�pDdS(Ns
i(R0R5R/R	RiRj(RRk((s%/usr/lib64/python2.7/unittest/case.pyRlWsN(RRR	R5RR`RaRDRmRpRqRsRtRuRl(((s%/usr/lib64/python2.7/unittest/case.pyR,!s										($R	R�R+R&RR�R�RRRwRdRtutilRRRRRRt
__unittestR�R%RR
RRR!R#R$R)R-R.tobjectR/RCR,(((s%/usr/lib64/python2.7/unittest/case.pyt<module>s:(								
	!���{PK��['�y9*)*)	suite.pycnu�[����
{fc@s�dZddlZddlmZddlmZeZd�Zdefd��YZ	de	fd	��YZ
d
efd��YZd�Zd
efd��YZ
dS(t	TestSuitei����Ni(tcase(tutilcCs t||d��}|�dS(NcSsdS(N(tNone(((s&/usr/lib64/python2.7/unittest/suite.pyt<lambda>t(tgetattr(tparenttattrtfunc((s&/usr/lib64/python2.7/unittest/suite.pyt_call_if_existsst
BaseTestSuitecBszeZdZdd�Zd�Zd�Zd�Zd
Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�ZRS(sNA simple test suite that doesn't provide class or module shared fixtures.
    cCsg|_|j|�dS(N(t_teststaddTests(tselfttests((s&/usr/lib64/python2.7/unittest/suite.pyt__init__s	cCs dtj|j�t|�fS(Ns
<%s tests=%s>(Rtstrclasst	__class__tlist(R((s&/usr/lib64/python2.7/unittest/suite.pyt__repr__scCs,t||j�stSt|�t|�kS(N(t
isinstanceRtNotImplementedR(Rtother((s&/usr/lib64/python2.7/unittest/suite.pyt__eq__scCs||kS(N((RR((s&/usr/lib64/python2.7/unittest/suite.pyt__ne__scCs
t|j�S(N(titerR(R((s&/usr/lib64/python2.7/unittest/suite.pyt__iter__%scCs+d}x|D]}||j�7}q
W|S(Ni(tcountTestCases(Rtcasesttest((s&/usr/lib64/python2.7/unittest/suite.pyR(s
cCswt|d�s-tdjt|����nt|t�rct|tjt	f�rctd��n|j
j|�dS(Nt__call__s{} is not callablesNTestCases and TestSuites must be instantiated before passing them to addTest()(thasattrt	TypeErrortformattreprRttypet
issubclassRtTestCaseRRtappend(RR((s&/usr/lib64/python2.7/unittest/suite.pytaddTest.scCs@t|t�rtd��nx|D]}|j|�q%WdS(Ns0tests must be an iterable of tests, not a string(Rt
basestringR!R((RRR((s&/usr/lib64/python2.7/unittest/suite.pyR
8s
cCs,x%|D]}|jrPn||�qW|S(N(t
shouldStop(RtresultR((s&/usr/lib64/python2.7/unittest/suite.pytrun>s

	cOs|j||�S(N(R,(Rtargstkwds((s&/usr/lib64/python2.7/unittest/suite.pyREscCsx|D]}|j�qWdS(s7Run the tests without collecting errors in a TestResultN(tdebug(RR((s&/usr/lib64/python2.7/unittest/suite.pyR/Hs
(N(t__name__t
__module__t__doc__RRRRRt__hash__RRR(R
R,RR/(((s&/usr/lib64/python2.7/unittest/suite.pyRs						
			cBsYeZdZed�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�ZRS(	s�A test suite is a composite test consisting of a number of TestCases.

    For use, create an instance of TestSuite, then add test case instances.
    When all tests have been added, the suite can be passed to a test
    runner, such as TextTestRunner. It will run the individual test cases
    in the order in which they were added, aggregating the results. When
    subclassing, do not forget to call the base class constructor.
    cCst}t|dt�tkr.t|_}nx�|D]�}|jrHPnt|�r�|j||�|j||�|j||�|j	|_
t|j	dt�s5t|dt�r�q5q�n|s�||�q5|j�q5W|r|jd|�|j
|�t|_n|S(Nt_testRunEnteredt_classSetupFailedt_moduleSetUpFailed(tFalseRtTrueR4R*t_isnotsuitet_tearDownPreviousClasst_handleModuleFixturet_handleClassSetUpRt_previousTestClassR/Rt_handleModuleTearDown(RR+R/ttopLevelR((s&/usr/lib64/python2.7/unittest/suite.pyR,Xs,
		

cCst�}|j|t�dS(s7Run the tests without collecting errors in a TestResultN(t_DebugResultR,R8(RR/((s&/usr/lib64/python2.7/unittest/suite.pyR/vs	c	Cs!t|dd�}|j}||kr+dS|jr8dSt|dt�rNdSy
t|_Wntk
rnnXt|dd�}|dk	rt|d�zoy|�Wn]tk
r}t	|t
�r��nt|_tj
|�}d|}|j|||�nXWdt|d�XndS(NR=t__unittest_skip__t
setUpClasst_setupStdoutssetUpClass (%s)t_restoreStdout(RRRR6R7R5R!R
t	ExceptionRR@R8RRt_addClassOrModuleLevelException(	RRR+t
previousClasstcurrentClassRBtet	classNamet	errorName((s&/usr/lib64/python2.7/unittest/suite.pyR<}s4		


	
cCs4d}t|dd�}|dk	r0|j}n|S(NR=(RRR1(RR+tpreviousModuleRG((s&/usr/lib64/python2.7/unittest/suite.pyt_get_previous_module�s
c	Cs
|j|�}|jj}||kr+dS|j|�t|_ytj|}Wntk
rfdSXt	|dd�}|dk	rt|d�z`y|�WnNtk
r�}t
|t�r��nt|_d|}|j|||�nXWdt|d�XndS(NtsetUpModuleRCssetUpModule (%s)RD(RMRR1R>R7R6tsystmodulestKeyErrorRRR
RERR@R8RF(	RRR+RLt
currentModuletmoduleRNRIRK((s&/usr/lib64/python2.7/unittest/suite.pyR;�s.
	

	
cCslt|�}t|dd�}|dk	rRt|tj�rR||t|��n|j|tj	��dS(NtaddSkip(
t_ErrorHolderRRRRtSkipTesttstrtaddErrorROtexc_info(RR+t	exceptionRKterrorRT((s&/usr/lib64/python2.7/unittest/suite.pyRF�s
cCs�|j|�}|dkrdS|jr,dSytj|}Wntk
rQdSXt|dd�}|dk	r�t|d�zWy|�WnEtk
r�}t	|t
�r��nd|}|j|||�nXWdt|d�XndS(NttearDownModuleRCstearDownModule (%s)RD(RMRR6RORPRQRR
RERR@RF(RR+RLRSR\RIRK((s&/usr/lib64/python2.7/unittest/suite.pyR>�s*	


c	Cst|dd�}|j}||kr+dSt|dt�rAdSt|dt�rWdSt|dt�rmdSt|dd�}|dk	rt|d�zfy|�WnTtk
r�}t|t�r��ntj	|�}d|}|j
|||�nXWdt|d�XndS(	NR=R5R6RAt
tearDownClassRCstearDownClass (%s)RD(RRRR7R
RERR@RRRF(	RRR+RGRHR]RIRJRK((s&/usr/lib64/python2.7/unittest/suite.pyR:�s.	

(R0R1R2R7R,R/R<RMR;RFR>R:(((s&/usr/lib64/python2.7/unittest/suite.pyRNs		 				RUcBs\eZdZd	Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd�ZRS(
s�
    Placeholder for a TestCase inside a result. As far as a TestResult
    is concerned, this looks exactly like a unit test. Used to insert
    arbitrary errors into a test suite run.
    cCs
||_dS(N(tdescription(RR^((s&/usr/lib64/python2.7/unittest/suite.pyRscCs|jS(N(R^(R((s&/usr/lib64/python2.7/unittest/suite.pytidscCsdS(N(R(R((s&/usr/lib64/python2.7/unittest/suite.pytshortDescriptionscCsd|jfS(Ns<ErrorHolder description=%r>(R^(R((s&/usr/lib64/python2.7/unittest/suite.pyRscCs
|j�S(N(R_(R((s&/usr/lib64/python2.7/unittest/suite.pyt__str__scCsdS(N((RR+((s&/usr/lib64/python2.7/unittest/suite.pyR,scCs
|j|�S(N(R,(RR+((s&/usr/lib64/python2.7/unittest/suite.pyRscCsdS(Ni((R((s&/usr/lib64/python2.7/unittest/suite.pyRsN(
R0R1R2RtfailureExceptionRR_R`RRaR,RR(((s&/usr/lib64/python2.7/unittest/suite.pyRU�s							cCs'yt|�Wntk
r"tSXtS(s?A crude way to tell apart testcases and suites with duck-typing(RR!R8R7(R((s&/usr/lib64/python2.7/unittest/suite.pyR9"s

R@cBs eZdZdZeZeZRS(sCUsed by the TestSuite to hold previous class when running in debug.N(R0R1R2RR=R7R6R*(((s&/usr/lib64/python2.7/unittest/suite.pyR@+s(R2RORRRR8t
__unittestR
tobjectRRRUR9R@(((s&/usr/lib64/python2.7/unittest/suite.pyt<module>s	>�&		PK��[�����
result.pyonu�[����
{fc@s�dZddlZddlZddlZddlmZddlmZddlmZe	Z
d�ZdZd	Z
d
efd��YZdS(sTest result objecti����N(tStringIOi(tutil(twrapscst���fd��}|S(Ncs/t|dt�r|j�n�|||�S(Ntfailfast(tgetattrtFalsetstop(tselftargstkw(tmethod(s'/usr/lib64/python2.7/unittest/result.pytinners
(R(R
R((R
s'/usr/lib64/python2.7/unittest/result.pyRss
Stdout:
%ss
Stderr:
%st
TestResultcBs�eZdZdZeZeZdddd�Zd�Z	d�Z
d�Zd�Zd�Z
d�Zd�Zed	��Zed
��Zd�Zd�Zd
�Zed��Zd�Zd�Zd�Zd�Zd�Zd�ZRS(s�Holder for test result information.

    Test results are automatically managed by the TestCase and TestSuite
    classes, and do not need to be explicitly manipulated by writers of tests.

    Each instance holds the total number of tests run, and collections of
    failures and errors that occurred among those test runs. The collections
    contain tuples of (testcase, exceptioninfo), where exceptioninfo is the
    formatted traceback of the error that occurred.
    cCs�t|_g|_g|_d|_g|_g|_g|_t|_t|_	d|_d|_t
j|_t
j|_t|_dS(Ni(RRtfailuresterrorsttestsRuntskippedtexpectedFailurestunexpectedSuccessest
shouldStoptbuffertNonet_stdout_buffert_stderr_buffertsyststdoutt_original_stdouttstderrt_original_stderrt
_mirrorOutput(Rtstreamtdescriptionst	verbosity((s'/usr/lib64/python2.7/unittest/result.pyt__init__(s											cCsdS(s#Called by TestRunner after test runN((R((s'/usr/lib64/python2.7/unittest/result.pytprintErrors8tcCs&|jd7_t|_|j�dS(s-Called when the given test is about to be runiN(RRRt_setupStdout(Rttest((s'/usr/lib64/python2.7/unittest/result.pyt	startTest;s	cCsR|jrN|jdkr3t�|_t�|_n|jt_|jt_ndS(N(RRRRRRRR(R((s'/usr/lib64/python2.7/unittest/result.pyR$As	cCsdS(spCalled once before any tests are executed.

        See startTest for a method called before each test.
        N((R((s'/usr/lib64/python2.7/unittest/result.pytstartTestRunIR#cCs|j�t|_dS(s'Called when the given test has been runN(t_restoreStdoutRR(RR%((s'/usr/lib64/python2.7/unittest/result.pytstopTestOs
cCs�|jr�|jr�tjj�}tjj�}|ri|jd�sR|d7}n|jjt	|�n|r�|jd�s�|d7}n|j
jt|�q�n|jt_|j
t_|jj
d�|jj�|jj
d�|jj�ndS(Ns
i(RRRRtgetvalueRtendswithRtwritetSTDOUT_LINERtSTDERR_LINERtseekttruncateR(Rtoutputterror((s'/usr/lib64/python2.7/unittest/result.pyR(Ts$		


cCsdS(smCalled once after all tests are executed.

        See stopTest for a method called after each test.
        N((R((s'/usr/lib64/python2.7/unittest/result.pytstopTestRuniR#cCs/|jj||j||�f�t|_dS(smCalled when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info().
        N(Rtappendt_exc_info_to_stringtTrueR(RR%terr((s'/usr/lib64/python2.7/unittest/result.pytaddErroros"cCs/|jj||j||�f�t|_dS(sdCalled when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info().N(R
R4R5R6R(RR%R7((s'/usr/lib64/python2.7/unittest/result.pyt
addFailurews"cCsdS(s-Called when a test has completed successfullyN((RR%((s'/usr/lib64/python2.7/unittest/result.pyt
addSuccess~scCs|jj||f�dS(sCalled when a test is skipped.N(RR4(RR%treason((s'/usr/lib64/python2.7/unittest/result.pytaddSkip�scCs&|jj||j||�f�dS(s/Called when an expected failure/error occurred.N(RR4R5(RR%R7((s'/usr/lib64/python2.7/unittest/result.pytaddExpectedFailure�s	cCs|jj|�dS(s5Called when a test was expected to fail, but succeed.N(RR4(RR%((s'/usr/lib64/python2.7/unittest/result.pytaddUnexpectedSuccess�scCs*t|j�t|j�ko'dkSS(s.Tells whether or not this result was a successi(tlenR
R(R((s'/usr/lib64/python2.7/unittest/result.pyt
wasSuccessful�scCs
t|_dS(s*Indicates that the tests should be abortedN(R6R(R((s'/usr/lib64/python2.7/unittest/result.pyR�sc
Cs%|\}}}x"|r3|j|�r3|j}qW||jkrm|j|�}tj||||�}ntj|||�}|jrtjj	�}tj
j	�}	|r�|jd�s�|d7}n|jt
|�n|	r|	jd�s|	d7}	n|jt|	�qndj|�S(s>Converts a sys.exc_info()-style tuple of values into a string.s
R#(t_is_relevant_tb_levelttb_nexttfailureExceptiont_count_relevant_tb_levelst	tracebacktformat_exceptionRRRR*RR+R4R-R.tjoin(
RR7R%texctypetvaluettbtlengthtmsgLinesR1R2((s'/usr/lib64/python2.7/unittest/result.pyR5�s&
	

cCsd|jjkS(Nt
__unittest(ttb_framet	f_globals(RRJ((s'/usr/lib64/python2.7/unittest/result.pyRA�scCs:d}x-|r5|j|�r5|d7}|j}q	W|S(Nii(RARB(RRJRK((s'/usr/lib64/python2.7/unittest/result.pyRD�s


cCs5dtj|j�|jt|j�t|j�fS(Ns!<%s run=%i errors=%i failures=%i>(Rtstrclasst	__class__RR?RR
(R((s'/usr/lib64/python2.7/unittest/result.pyt__repr__�s!N(t__name__t
__module__t__doc__Rt_previousTestClassRt_testRunEnteredt_moduleSetUpFailedR!R"R&R$R'R)R(R3RR8R9R:R<R=R>R@RR5RARDRR(((s'/usr/lib64/python2.7/unittest/result.pyRs0
															(RUtosRRERR#Rt	functoolsRR6RMRR-R.tobjectR(((s'/usr/lib64/python2.7/unittest/result.pyt<module>s	PK��[�X���
�
signals.pyonu�[����
{fc@s�ddlZddlZddlmZeZdefd��YZej�Z	d�Z
d�Zda
d�Zdd�ZdS(	i����N(twrapst_InterruptHandlercBseZd�Zd�ZRS(cCsyt|_||_t|ttf�rl|tjkrBtj}ql|tj	kr]d�}qlt
d��n||_dS(NcSsdS(N((t
unused_signumtunused_frame((s(/usr/lib64/python2.7/unittest/signals.pytdefault_handlerssYexpected SIGINT signal handler to be signal.SIG_IGN, signal.SIG_DFL, or a callable object(tFalsetcalledtoriginal_handlert
isinstancetinttlongtsignaltSIG_DFLtdefault_int_handlertSIG_IGNt	TypeErrorR(tselfR((s(/usr/lib64/python2.7/unittest/signals.pyt__init__
s		cCs{tjtj�}||k	r1|j||�n|jrM|j||�nt|_xtj�D]}|j�qcWdS(N(	Rt	getsignaltSIGINTRRtTruet_resultstkeyststop(Rtsignumtframetinstalled_handlertresult((s(/usr/lib64/python2.7/unittest/signals.pyt__call__s		(t__name__t
__module__RR(((s(/usr/lib64/python2.7/unittest/signals.pyR	s	cCsdt|<dS(Ni(R(R((s(/usr/lib64/python2.7/unittest/signals.pytregisterResult*scCsttj|d��S(N(tboolRtpoptNone(R((s(/usr/lib64/python2.7/unittest/signals.pytremoveResult-scCsDtdkr@tjtj�}t|�atjtjt�ndS(N(t_interrupt_handlerR"RRRR(R((s(/usr/lib64/python2.7/unittest/signals.pytinstallHandler1scsT�dk	r+t���fd��}|Stdk	rPtjtjtj�ndS(NcsEtjtj�}t�z�||�SWdtjtj|�XdS(N(RRRt
removeHandler(targstkwargstinitial(tmethod(s(/usr/lib64/python2.7/unittest/signals.pytinner;s
(R"RR$RRR(R*R+((R*s(/usr/lib64/python2.7/unittest/signals.pyR&9s
(Rtweakreft	functoolsRRt
__unittesttobjectRtWeakKeyDictionaryRRR#R"R$R%R&(((s(/usr/lib64/python2.7/unittest/signals.pyt<module>s 			PK��[u<�΢΢case.pycnu�[����
{fc@s}dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
mZmZmZmZeZdZdefd��YZd	efd
��YZdefd��YZd
�Zd�Zd�Zd�Zd�Zd�Zd�Zde fd��YZ!de fd��YZ"de"fd��YZ#dS(sTest case implementationi����Ni(tresult(tstrclasst	safe_reprtunorderable_list_differencet_count_diff_all_purposet_count_diff_hashables@
Diff is %s characters long. Set self.maxDiff to None to see it.tSkipTestcBseZdZRS(s�
    Raise this exception in a test to skip it.

    Usually you can use TestCase.skipTest() or one of the skipping decorators
    instead of raising this directly.
    (t__name__t
__module__t__doc__(((s%/usr/lib64/python2.7/unittest/case.pyRst_ExpectedFailurecBseZdZd�ZRS(s\
    Raise this when a test is expected to fail.

    This is an implementation detail.
    cCs tt|�j�||_dS(N(tsuperR
t__init__texc_info(tselfR
((s%/usr/lib64/python2.7/unittest/case.pyR*s(RRR	R(((s%/usr/lib64/python2.7/unittest/case.pyR
#st_UnexpectedSuccesscBseZdZRS(s7
    The test was supposed to fail, but it didn't!
    (RRR	(((s%/usr/lib64/python2.7/unittest/case.pyR.scCs|S(N((tobj((s%/usr/lib64/python2.7/unittest/case.pyt_id4scs�fd�}|S(s&
    Unconditionally skip a test.
    csUt|ttjf�s?tj|��fd��}|}nt|_�|_|S(Ncst���dS(N(R(targstkwargs(treason(s%/usr/lib64/python2.7/unittest/case.pytskip_wrapper=s(	t
isinstancettypettypest	ClassTypet	functoolstwrapstTruet__unittest_skip__t__unittest_skip_why__(t	test_itemR(R(s%/usr/lib64/python2.7/unittest/case.pyt	decorator;s			((RR ((Rs%/usr/lib64/python2.7/unittest/case.pytskip7s
cCs|rt|�StS(s/
    Skip a test if the condition is true.
    (R!R(t	conditionR((s%/usr/lib64/python2.7/unittest/case.pytskipIfGs
cCs|st|�StS(s3
    Skip a test unless the condition is true.
    (R!R(R"R((s%/usr/lib64/python2.7/unittest/case.pyt
skipUnlessOs
cs"tj���fd��}|S(NcsAy�||�Wn#tk
r6ttj���nXt�dS(N(t	ExceptionR
tsysR
R(RR(tfunc(s%/usr/lib64/python2.7/unittest/case.pytwrapperYs

(RR(R'R(((R's%/usr/lib64/python2.7/unittest/case.pytexpectedFailureXscCs!dtjkrt|�StSdS(s
    Non-standard/downstream-only decorator for marking a specific unit test
    to be skipped when run within the %check of an rpmbuild.

    Specifically, this takes effect when WITHIN_PYTHON_RPM_BUILD is set within
    the environment, and has no effect otherwise.
    tWITHIN_PYTHON_RPM_BUILDN(tostenvironR!R(R((s%/usr/lib64/python2.7/unittest/case.pyt_skipInRpmBuildfs
cs"tj���fd��}|S(s

    Non-standard/downstream-only decorator for marking a specific unit test
    as expected to fail within the %check of an rpmbuild.

    Specifically, this takes effect when WITHIN_PYTHON_RPM_BUILD is set within
    the environment, and has no effect otherwise.
    cs`dtjkrOy�||�Wn#tk
rEttj���nXt�n
�||�dS(NR*(R+R,R%R
R&R
R(RR(R'(s%/usr/lib64/python2.7/unittest/case.pyR({s
	(RR(R'R(((R's%/usr/lib64/python2.7/unittest/case.pyt_expectedFailureInRpmBuildsst_AssertRaisesContextcBs,eZdZdd�Zd�Zd�ZRS(sCA context manager used to implement TestCase.assertRaises* methods.cCs"||_|j|_||_dS(N(texpectedtfailureExceptiontexpected_regexp(RR0t	test_caseR2((s%/usr/lib64/python2.7/unittest/case.pyR�s	cCs|S(N((R((s%/usr/lib64/python2.7/unittest/case.pyt	__enter__�scCs�|dkrZy|jj}Wn tk
r>t|j�}nX|jdj|���nt||j�sptS||_	|j
dkr�tS|j
}|jt|��s�|jd|j
t|�f��ntS(Ns{0} not raiseds"%s" does not match "%s"(tNoneR0RtAttributeErrortstrR1tformatt
issubclasstFalset	exceptionR2Rtsearchtpattern(Rtexc_typet	exc_valuettbtexc_nameR2((s%/usr/lib64/python2.7/unittest/case.pyt__exit__�s"
			N(RRR	R5RR4RB(((s%/usr/lib64/python2.7/unittest/case.pyR/�s	tTestCasecBs)eZdZeZeZd@ZdAZeZ	dd�Z
d�Zd�Zd	�Z
d
�Zed��Zed��Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdBd�Zd�Zd�Zd�Z d�Z!dBd�Z"dBd�Z#dBd�Z$d�Z%dBd �Z&d!�Z'dBd"�Z(dBd#�Z)dBd$�Z*dBdBdBd%�Z+dBdBdBd&�Z,e)Z-e*Z.e+Z/e,Z0e$Z1d'�Z2e2e)�Z3e2e*�Z4e2e+�Z5e2e,�Z6e2e$�Z7e2e&�Z8e2e#�Z9dBdBd(�Z:d)�Z;dBd*�Z<dBd+�Z=dBd,�Z>dBd-�Z?dBd.�Z@dBd/�ZAdBd0�ZBdBd1�ZCdBd2�ZDdBd3�ZEdBd4�ZFdBd5�ZGdBd6�ZHdBd7�ZIdBd8�ZJdBd9�ZKdBd:�ZLdBd;�ZMdBd<�ZNdBd=�ZOdBd>�ZPdBd?�ZQRS(CsWA class whose instances are single test cases.

    By default, the test code itself should be placed in a method named
    'runTest'.

    If the fixture may be used for many test cases, create as
    many test methods as are needed. When instantiating such a TestCase
    subclass, specify in the constructor arguments the name of the test method
    that the instance is to execute.

    Test authors should subclass TestCase for their own tests. Construction
    and deconstruction of the test's environment ('fixture') can be
    implemented by overriding the 'setUp' and 'tearDown' methods respectively.

    If it is necessary to override the __init__ method, the base class
    __init__ method must always be called. It is important that subclasses
    should not change the signature of their __init__ method, since instances
    of the classes are instantiated automatically by parts of the framework
    in order to be run.

    When subclassing TestCase, you can set these attributes:
    * failureException: determines which exception will be raised when
        the instance's assertion methods fail; test methods raising this
        exception will be deemed to have 'failed' rather than 'errored'.
    * longMessage: determines whether long messages (including repr of
        objects used in assert methods) will be printed on failure in *addition*
        to any explicit message passed.
    * maxDiff: sets the maximum length of a diff in failure messages
        by assert methods using difflib. It is looked up as an instance
        attribute so can be configured by individual tests if required.
    iPiiitrunTestcCs�||_d|_yt||�}Wn*tk
rQtd|j|f��nX|j|_g|_	i|_
|jtd�|jt
d�|jtd�|jtd�|jtd�y|jtd�Wntk
r�nXdS(s�Create an instance of the class that will use the named test
           method when executed. Raises a ValueError if the instance does
           not have a method with the specified name.
        sno such test method in %s: %stassertDictEqualtassertListEqualtassertTupleEqualtassertSetEqualtassertMultiLineEqualN(t_testMethodNameR5t_resultForDoCleanupstgetattrR6t
ValueErrort	__class__R	t_testMethodDoct	_cleanupst_type_equality_funcstaddTypeEqualityFunctdicttlistttupletsett	frozensettunicodet	NameError(Rt
methodNamet
testMethod((s%/usr/lib64/python2.7/unittest/case.pyR�s&		
		
cCs||j|<dS(s[Add a type specific assertEqual style function to compare a type.

        This method is for use by TestCase subclasses that need to register
        their own type equality functions to provide nicer error messages.

        Args:
            typeobj: The data type to call this function on when both values
                    are of the same type in assertEqual().
            function: The callable taking two arguments and an optional
                    msg= argument that raises self.failureException with a
                    useful error message when the two arguments are not equal.
        N(RQ(Rttypeobjtfunction((s%/usr/lib64/python2.7/unittest/case.pyRR�s
cOs|jj|||f�dS(sAdd a function, with arguments, to be called when the test is
        completed. Functions added are called on a LIFO basis and are
        called after tearDown on test failure or success.

        Cleanup items are called even if setUp fails (unlike tearDown).N(RPtappend(RR]RR((s%/usr/lib64/python2.7/unittest/case.pyt
addCleanupscCsdS(sAHook method for setting up the test fixture before exercising it.N((R((s%/usr/lib64/python2.7/unittest/case.pytsetUp
scCsdS(sAHook method for deconstructing the test fixture after testing it.N((R((s%/usr/lib64/python2.7/unittest/case.pyttearDownscCsdS(sKHook method for setting up class fixture before running tests in the class.N((tcls((s%/usr/lib64/python2.7/unittest/case.pyt
setUpClasstcCsdS(sVHook method for deconstructing the class fixture after running all tests in the class.N((Rb((s%/usr/lib64/python2.7/unittest/case.pyt
tearDownClassRdcCsdS(Ni((R((s%/usr/lib64/python2.7/unittest/case.pytcountTestCasesscCs
tj�S(N(Rt
TestResult(R((s%/usr/lib64/python2.7/unittest/case.pytdefaultTestResult scCs,|j}|r(|jd�dj�p+dS(s�Returns a one-line description of the test, or None if no
        description has been provided.

        The default implementation of this method returns the first line of
        the specified test method's docstring.
        s
iN(ROtsplittstripR5(Rtdoc((s%/usr/lib64/python2.7/unittest/case.pytshortDescription#s	cCsdt|j�|jfS(Ns%s.%s(RRNRJ(R((s%/usr/lib64/python2.7/unittest/case.pytid.scCs,t|�t|�k	rtS|j|jkS(N(RtNotImplementedRJ(Rtother((s%/usr/lib64/python2.7/unittest/case.pyt__eq__1scCs||kS(N((RRo((s%/usr/lib64/python2.7/unittest/case.pyt__ne__7scCstt|�|jf�S(N(thashRRJ(R((s%/usr/lib64/python2.7/unittest/case.pyt__hash__:scCsd|jt|j�fS(Ns%s (%s)(RJRRN(R((s%/usr/lib64/python2.7/unittest/case.pyt__str__=scCsdt|j�|jfS(Ns<%s testMethod=%s>(RRNRJ(R((s%/usr/lib64/python2.7/unittest/case.pyt__repr__@scCsRt|dd�}|dk	r.|||�n tjdtd�|j|�dS(NtaddSkips4TestResult has no addSkip method, skips not reportedi(RLR5twarningstwarntRuntimeWarningt
addSuccess(RRRRv((s%/usr/lib64/python2.7/unittest/case.pyt_addSkipDs	
cCsr|}|dkrI|j�}t|dd�}|dk	rI|�qIn||_|j|�t||j�}t|jdt�s�t|dt�r�z;t|jdd�p�t|dd�}|j||�Wd|j	|�XdSz>t}y|j
�WnXtk
r*}|j|t|��n�t
k
r=�n�|j|tj��n�Xy|�WnBt
k
r{�n5|jk
r�|j|tj��ntk
r}t|dd�}|dk	r�|||j�q�tjdt�|j|�n�tk
ret|dd�}	|	dk	r<|	|�q�tjdt�|j|tj��nKtk
r�}|j|t|��n#|j|tj��nXt}y|j�Wn6t
k
r��n#|j|tj��t}nX|j�}
|o|
}|r%|j|�nWd|j	|�|dkrmt|d	d�}|dk	rm|�qmnXdS(
NtstartTestRunRRRdtaddExpectedFailures@TestResult has no addExpectedFailure method, reporting as passestaddUnexpectedSuccesssDTestResult has no addUnexpectedSuccess method, reporting as failureststopTestRun(R5RhRLRKt	startTestRJRNR:R{tstopTestR`RR7tKeyboardInterrupttaddErrorR&R
R1t
addFailureR
RwRxRyRzRRRat
doCleanups(RRtorig_resultR|R[tskip_whytsuccessteR}R~tcleanUpSuccessR((s%/usr/lib64/python2.7/unittest/case.pytrunMs�
	


	

	


cCs�|j}t}xr|jr�|jjd�\}}}y|||�Wqtk
r]�qt}|j|tj��qXqW|S(sNExecute all cleanup functions. Normally called for you after
        tearDown.i����(	RKRRPtpopR�R:R�R&R
(RRtokR]RR((s%/usr/lib64/python2.7/unittest/case.pyR��s	
cOs|j||�S(N(R�(RRtkwds((s%/usr/lib64/python2.7/unittest/case.pyt__call__�scCsc|j�t||j��|j�x5|jr^|jjd�\}}}|||�q*WdS(s6Run the test without collecting errors in a TestResulti����N(R`RLRJRaRPR�(RR]RR((s%/usr/lib64/python2.7/unittest/case.pytdebug�s

cCst|��dS(sSkip this test.N(R(RR((s%/usr/lib64/python2.7/unittest/case.pytskipTest�scCs|j|��dS(s)Fail immediately, with the given message.N(R1(Rtmsg((s%/usr/lib64/python2.7/unittest/case.pytfail�scCs8|r4|j|dt|��}|j|��ndS(s#Check that the expression is false.s%s is not falseN(t_formatMessageRR1(RtexprR�((s%/usr/lib64/python2.7/unittest/case.pytassertFalse�scCs8|s4|j|dt|��}|j|��ndS(s"Check that the expression is true.s%s is not trueN(R�RR1(RR�R�((s%/usr/lib64/python2.7/unittest/case.pyt
assertTrue�scCsd|js|p|S|dkr#|Syd||fSWn(tk
r_dt|�t|�fSXdS(s�Honour the longMessage attribute when generating failure messages.
        If longMessage is False this means:
        * Use only an explicit message if it is provided
        * Otherwise use the standard message for the assert

        If longMessage is True:
        * Use the standard message
        * If an explicit message is provided, plus ' : ' and the explicit message
        s%s : %sN(tlongMessageR5tUnicodeDecodeErrorR(RR�tstandardMsg((s%/usr/lib64/python2.7/unittest/case.pyR��s
	

cOs=t||�}|dkr|S|�|||�WdQXdS(s�Fail unless an exception of class excClass is raised
           by callableObj when invoked with arguments args and keyword
           arguments kwargs. If a different type of exception is
           raised, it will not be caught, and the test case will be
           deemed to have suffered an error, exactly as for an
           unexpected exception.

           If called with callableObj omitted or None, will return a
           context object used like this::

                with self.assertRaises(SomeException):
                    do_something()

           The context manager keeps a reference to the exception as
           the 'exception' attribute. This allows you to inspect the
           exception after the assertion::

               with self.assertRaises(SomeException) as cm:
                   do_something()
               the_exception = cm.exception
               self.assertEqual(the_exception.error_code, 3)
        N(R/R5(RtexcClasstcallableObjRRtcontext((s%/usr/lib64/python2.7/unittest/case.pytassertRaises�s
cCskt|�t|�krd|jjt|��}|dk	rdt|t�r]t||�}n|Sn|jS(sGet a detailed comparison function for the types of the two args.

        Returns: A callable accepting (first, second, msg=None) that will
        raise a failure exception if first != second with a useful human
        readable error message for those types.
        N(RRQtgetR5Rt
basestringRLt_baseAssertEqual(Rtfirsttsecondtasserter((s%/usr/lib64/python2.7/unittest/case.pyt_getAssertEqualityFuncscCsP||ksLdt|�t|�f}|j||�}|j|��ndS(s:The default assertEqual implementation, not type specific.s%s != %sN(RR�R1(RR�R�R�R�((s%/usr/lib64/python2.7/unittest/case.pyR�scCs)|j||�}|||d|�dS(s[Fail if the two objects are unequal as determined by the '=='
           operator.
        R�N(R�(RR�R�R�tassertion_func((s%/usr/lib64/python2.7/unittest/case.pytassertEqual"scCsJ||ksF|j|dt|�t|�f�}|j|��ndS(sYFail if the two objects are equal as determined by the '!='
           operator.
        s%s == %sN(R�RR1(RR�R�R�((s%/usr/lib64/python2.7/unittest/case.pytassertNotEqual)scCs||krdS|dk	r7|dk	r7td��n|dk	r�t||�|kr]dSdt|�t|�t|�f}nW|dkr�d}ntt||�|�dkr�dSdt|�t|�|f}|j||�}|j|��dS(s'Fail if the two objects are unequal as determined by their
           difference rounded to the given number of decimal places
           (default 7) and comparing to zero, or by comparing that the
           difference between the two objects is more than the given
           delta.

           Note that decimal places (from zero) are usually not the same
           as significant digits (measured from the most significant digit).

           If the two objects compare equal then they will automatically
           compare almost equal.
        Ns specify delta or places not boths%s != %s within %s deltaiis%s != %s within %r places(R5t	TypeErrortabsRtroundR�R1(RR�R�tplacesR�tdeltaR�((s%/usr/lib64/python2.7/unittest/case.pytassertAlmostEqual3s&
			
cCs|dk	r'|dk	r'td��n|dk	r�||krZt||�|krZdSdt|�t|�t|�f}nd|dkr�d}n||kr�tt||�|�dkr�dSdt|�t|�|f}|j||�}|j|��dS(s�Fail if the two objects are equal as determined by their
           difference rounded to the given number of decimal places
           (default 7) and comparing to zero, or by comparing that the
           difference between the two objects is less than the given delta.

           Note that decimal places (from zero) are usually not the same
           as significant digits (measured from the most significant digit).

           Objects that are equal automatically fail.
        s specify delta or places not bothNs%s == %s within %s deltaiis%s == %s within %r places(R5R�R�RR�R�R1(RR�R�R�R�R�R�((s%/usr/lib64/python2.7/unittest/case.pytassertNotAlmostEqualZs"#		,	
cs�fd�}|S(Ncs,tjdj�j�td��||�S(NsPlease use {0} instead.i(RwRxR8RtPendingDeprecationWarning(RR(t
original_func(s%/usr/lib64/python2.7/unittest/case.pytdeprecated_func�s
((R�R�((R�s%/usr/lib64/python2.7/unittest/case.pyt
_deprecate�scCs|dk	rz|j}t||�sF|jd|t|�f��nt||�s�|jd|t|�f��q�nd}d}yt|�}Wn!ttfk
r�d|}nX|dkr�yt|�}Wq�ttfk
r�d|}q�Xn|dkr�||krdSt|�}	t|�}
t|	�dkrT|	d d}	nt|
�dkrw|
d d}
n|j�|	|
f}d	|}xt	t
||��D]�}y||}
Wn/tttfk
r�|d
||f7}PnXy||}Wn/tttfk
r1|d||f7}PnX|
|kr�|d|t|
�t|�f7}Pq�q�W||kr�|dkr�t|�t|�kr�dS||kr|d
|||f7}y"|d|t||�f7}Wq�tttfk
r|d||f7}q�Xq�||kr�|d|||f7}y"|d|t||�f7}Wq�tttfk
r�|d||f7}q�Xq�n|}ddj
tjtj|�j�tj|�j���}|j||�}|j||�}|j|�dS(sAAn equality assertion for ordered sequences (like lists and tuples).

        For the purposes of this function, a valid ordered sequence type is one
        which can be indexed, has a length, and has an equality operator.

        Args:
            seq1: The first sequence to compare.
            seq2: The second sequence to compare.
            seq_type: The expected datatype of the sequences, or None if no
                    datatype should be enforced.
            msg: Optional message to use on failure instead of a list of
                    differences.
        sFirst sequence is not a %s: %ssSecond sequence is not a %s: %stsequences(First %s has no length.    Non-sequence?s)Second %s has no length.    Non-sequence?Nis...s%ss differ: %s != %s
s(
Unable to index element %d of first %s
s)
Unable to index element %d of second %s
s#
First differing element %d:
%s
%s
s+
First %s contains %d additional elements.
sFirst extra element %d:
%s
s'Unable to index element %d of first %s
s,
Second %s contains %d additional elements.
s(Unable to index element %d of second %s
s
(R5RRR1RtlenR�tNotImplementedErrort
capitalizetxrangetmint
IndexErrorRtjointdifflibtndifftpprinttpformatt
splitlinest_truncateMessageR�R�(Rtseq1tseq2R�tseq_typet
seq_type_namet	differingtlen1tlen2t	seq1_reprt	seq2_reprtelementstititem1titem2R�tdiffMsg((s%/usr/lib64/python2.7/unittest/case.pytassertSequenceEqual�s�			
	cCsA|j}|dks't|�|kr/||S|tt|�S(N(tmaxDiffR5R�tDIFF_OMITTED(Rtmessagetdifftmax_diff((s%/usr/lib64/python2.7/unittest/case.pyR��s	cCs|j|||dt�dS(sA list-specific equality assertion.

        Args:
            list1: The first list to compare.
            list2: The second list to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.

        R�N(R�RT(Rtlist1tlist2R�((s%/usr/lib64/python2.7/unittest/case.pyRFs
cCs|j|||dt�dS(sA tuple-specific equality assertion.

        Args:
            tuple1: The first tuple to compare.
            tuple2: The second tuple to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.
        R�N(R�RU(Rttuple1ttuple2R�((s%/usr/lib64/python2.7/unittest/case.pyRGs	c
Cspy|j|�}WnGtk
r9}|jd|�n$tk
r\}|jd|�nXy|j|�}WnGtk
r�}|jd|�n$tk
r�}|jd|�nX|p�|s�dSg}|r
|jd�x$|D]}|jt|��q�Wn|rD|jd�x$|D]}|jt|��q$Wndj|�}	|j|j||	��dS(s�A set-specific equality assertion.

        Args:
            set1: The first set to compare.
            set2: The second set to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.

        assertSetEqual uses ducktyping to support different types of sets, and
        is optimized for sets specifically (parameters must support a
        difference method).
        s/invalid type when attempting set difference: %ss2first argument does not support set difference: %ss3second argument does not support set difference: %sNs*Items in the first set but not the second:s*Items in the second set but not the first:s
(t
differenceR�R�R6R^treprR�R�(
Rtset1tset2R�tdifference1R�tdifference2tlinestitemR�((s%/usr/lib64/python2.7/unittest/case.pyRHs2




cCsH||krDdt|�t|�f}|j|j||��ndS(sDJust like self.assertTrue(a in b), but with a nicer default message.s%s not found in %sN(RR�R�(Rtmembert	containerR�R�((s%/usr/lib64/python2.7/unittest/case.pytassertInEscCsH||krDdt|�t|�f}|j|j||��ndS(sHJust like self.assertTrue(a not in b), but with a nicer default message.s%s unexpectedly found in %sN(RR�R�(RR�R�R�R�((s%/usr/lib64/python2.7/unittest/case.pytassertNotInLscCsH||k	rDdt|�t|�f}|j|j||��ndS(sDJust like self.assertTrue(a is b), but with a nicer default message.s%s is not %sN(RR�R�(Rtexpr1texpr2R�R�((s%/usr/lib64/python2.7/unittest/case.pytassertIsSscCs?||kr;dt|�f}|j|j||��ndS(sHJust like self.assertTrue(a is not b), but with a nicer default message.sunexpectedly identical: %sN(RR�R�(RR�R�R�R�((s%/usr/lib64/python2.7/unittest/case.pytassertIsNotZscCs�|j|td�|j|td�||kr�dt|t�t|t�f}ddjtjtj|�j	�tj|�j	���}|j
||�}|j|j||��ndS(Ns"First argument is not a dictionarys#Second argument is not a dictionarys%s != %ss
(
tassertIsInstanceRSRRR�R�R�R�R�R�R�R�R�(Rtd1td2R�R�R�((s%/usr/lib64/python2.7/unittest/case.pyRE`s"c	Csg}g}xy|j�D]k\}}||krA|j|�q|||kr|jdt|�t|�t||�f�qqW|p�|s�dSd}|r�ddjd�|D��}n|r�|r�|d7}n|ddj|�7}n|j|j||��dS(	s0Checks whether actual is a superset of expected.s%s, expected: %s, actual: %sNRdsMissing: %st,css|]}t|�VqdS(N(R(t.0tm((s%/usr/lib64/python2.7/unittest/case.pys	<genexpr>}ss; sMismatched values: %s(t	iteritemsR^RR�R�R�(	RR0tactualR�tmissingt
mismatchedtkeytvalueR�((s%/usr/lib64/python2.7/unittest/case.pytassertDictContainsSubsetls(	
c	Cs9t|�t|�}}tj���tjr_x-dddgD]}tjd|t�q?Wny"tj|�}tj|�}Wn t	k
r�t
||�}	n X||kr�dSt||�}	WdQX|	r5d}
g|	D]}d|^q�}dj|�}
|j
|
|
�}
|j||
�}|j|�ndS(	s�An unordered sequence specific comparison. It asserts that
        actual_seq and expected_seq have the same element counts.
        Equivalent to::

            self.assertEqual(Counter(iter(actual_seq)),
                             Counter(iter(expected_seq)))

        Asserts that each element has the same count in both sequences.
        Example:
            - [0, 1, 1] and [1, 0, 1] compare equal.
            - [0, 0, 1] and [0, 1] compare unequal.
        s'(code|dict|type) inequality comparisonss,builtin_function_or_method order comparisonsscomparing unequal typestignoreNsElement counts were not equal:
s First has %d, Second has %d:  %rs
(RTRwtcatch_warningsR&tpy3kwarningtfilterwarningstDeprecationWarningtcollectionstCounterR�RRR�R�R�R�(Rtexpected_seqt
actual_seqR�t	first_seqt
second_seqt_msgR�R�tdifferencesR�R�R�R�((s%/usr/lib64/python2.7/unittest/case.pytassertItemsEqual�s,

	

cCsG|j|td�|j|td�||krCt|�|jks\t|�|jkrr|j|||�n|jt�}|jt�}t|�dkr�|jd�|kr�|dg}|dg}ndt|t�t|t�f}ddj	t
j||��}|j||�}|j
|j||��ndS(	s-Assert that two multi-line strings are equal.sFirst argument is not a stringsSecond argument is not a stringis
s
s%s != %sRdN(R�R�R�t_diffThresholdR�R�RRjRR�R�R�R�R�R�(RR�R�R�t
firstlinestsecondlinesR�R�((s%/usr/lib64/python2.7/unittest/case.pyRI�s$'
cCsH||ksDdt|�t|�f}|j|j||��ndS(sCJust like self.assertTrue(a < b), but with a nicer default message.s%s not less than %sN(RR�R�(RtatbR�R�((s%/usr/lib64/python2.7/unittest/case.pyt
assertLess�scCsH||ksDdt|�t|�f}|j|j||��ndS(sDJust like self.assertTrue(a <= b), but with a nicer default message.s%s not less than or equal to %sN(RR�R�(RRR	R�R�((s%/usr/lib64/python2.7/unittest/case.pytassertLessEqual�scCsH||ksDdt|�t|�f}|j|j||��ndS(sCJust like self.assertTrue(a > b), but with a nicer default message.s%s not greater than %sN(RR�R�(RRR	R�R�((s%/usr/lib64/python2.7/unittest/case.pyt
assertGreater�scCsH||ksDdt|�t|�f}|j|j||��ndS(sDJust like self.assertTrue(a >= b), but with a nicer default message.s"%s not greater than or equal to %sN(RR�R�(RRR	R�R�((s%/usr/lib64/python2.7/unittest/case.pytassertGreaterEqual�scCs?|dk	r;dt|�f}|j|j||��ndS(sCSame as self.assertTrue(obj is None), with a nicer default message.s%s is not NoneN(R5RR�R�(RRR�R�((s%/usr/lib64/python2.7/unittest/case.pytassertIsNone�scCs2|dkr.d}|j|j||��ndS(s(Included for symmetry with assertIsNone.sunexpectedly NoneN(R5R�R�(RRR�R�((s%/usr/lib64/python2.7/unittest/case.pytassertIsNotNone�scCsEt||�sAdt|�|f}|j|j||��ndS(sTSame as self.assertTrue(isinstance(obj, cls)), with a nicer
        default message.s%s is not an instance of %rN(RRR�R�(RRRbR�R�((s%/usr/lib64/python2.7/unittest/case.pyR��scCsEt||�rAdt|�|f}|j|j||��ndS(s,Included for symmetry with assertIsInstance.s%s is an instance of %rN(RRR�R�(RRRbR�R�((s%/usr/lib64/python2.7/unittest/case.pytassertNotIsInstance�scOs^|dk	rtj|�}nt|||�}|dkr@|S|�|||�WdQXdS(s�Asserts that the message in a raised exception matches a regexp.

        Args:
            expected_exception: Exception class expected to be raised.
            expected_regexp: Regexp (re pattern object or string) expected
                    to be found in error message.
            callable_obj: Function to be called.
            args: Extra args.
            kwargs: Extra kwargs.
        N(R5tretcompileR/(Rtexpected_exceptionR2tcallable_objRRR�((s%/usr/lib64/python2.7/unittest/case.pytassertRaisesRegexp�scCsht|t�r!tj|�}n|j|�sd|p9d}d||j|f}|j|��ndS(s=Fail the test unless the text matches the regular expression.sRegexp didn't matchs%s: %r not found in %rN(RR�RRR<R=R1(RttextR2R�((s%/usr/lib64/python2.7/unittest/case.pytassertRegexpMatches
scCs�t|t�r!tj|�}n|j|�}|r�|p?d}d|||j�|j�!|j|f}|j|��ndS(s9Fail the test if the text matches the regular expression.sRegexp matcheds%s: %r matches %r in %rN(	RR�RRR<tstarttendR=R1(RRtunexpected_regexpR�tmatch((s%/usr/lib64/python2.7/unittest/case.pytassertNotRegexpMatchess
i�iN(RRRR	tAssertionErrorR1R:R�R�Rt_classSetupFailedRRRR_R`RatclassmethodRcReRfRhRlRmRpRqRsRtRuR{R5R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�tassertEqualstassertNotEqualstassertAlmostEqualstassertNotAlmostEqualstassert_R�tfailUnlessEqualtfailIfEqualtfailUnlessAlmostEqualtfailIfAlmostEqualt
failUnlesstfailUnlessRaisestfailIfR�R�RFRGRHR�R�R�R�RER�RRIR
RRR
RRR�RRRR(((s%/usr/lib64/python2.7/unittest/case.pyRC�s�															Q							
'$	g	+(	tFunctionTestCasecBszeZdZdddd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�ZRS(
sIA test case that wraps a test function.

    This is useful for slipping pre-existing test functions into the
    unittest framework. Optionally, set-up and tidy-up functions can be
    supplied. As with TestCase, the tidy-up ('tearDown') function will
    always be called if the set-up ('setUp') function ran successfully.
    cCs;tt|�j�||_||_||_||_dS(N(RR,Rt
_setUpFunct
_tearDownFunct	_testFunct_description(RttestFuncR`Ratdescription((s%/usr/lib64/python2.7/unittest/case.pyR*s
			cCs |jdk	r|j�ndS(N(R-R5(R((s%/usr/lib64/python2.7/unittest/case.pyR`1scCs |jdk	r|j�ndS(N(R.R5(R((s%/usr/lib64/python2.7/unittest/case.pyRa5scCs|j�dS(N(R/(R((s%/usr/lib64/python2.7/unittest/case.pyRD9scCs
|jjS(N(R/R(R((s%/usr/lib64/python2.7/unittest/case.pyRm<scCs\t||j�stS|j|jko[|j|jko[|j|jko[|j|jkS(N(RRNRnR-R.R/R0(RRo((s%/usr/lib64/python2.7/unittest/case.pyRp?scCs||kS(N((RRo((s%/usr/lib64/python2.7/unittest/case.pyRqHscCs+tt|�|j|j|j|jf�S(N(RrRR-R.R/R0(R((s%/usr/lib64/python2.7/unittest/case.pyRsKscCsdt|j�|jjfS(Ns%s (%s)(RRNR/R(R((s%/usr/lib64/python2.7/unittest/case.pyRtOscCsdt|j�|jfS(Ns<%s tec=%s>(RRNR/(R((s%/usr/lib64/python2.7/unittest/case.pyRuSscCsE|jdk	r|jS|jj}|rA|jd�dj�pDdS(Ns
i(R0R5R/R	RiRj(RRk((s%/usr/lib64/python2.7/unittest/case.pyRlWsN(RRR	R5RR`RaRDRmRpRqRsRtRuRl(((s%/usr/lib64/python2.7/unittest/case.pyR,!s										($R	R�R+R&RR�R�RRRwRdRtutilRRRRRRt
__unittestR�R%RR
RRR!R#R$R)R-R.tobjectR/RCR,(((s%/usr/lib64/python2.7/unittest/case.pyt<module>s:(								
	!���{PK��[�A���__init__.pycnu�[����
{fc@sDdZddddddddd	d
ddd
dddddgZejdddg�eZddlmZddlmZm	Z	m
Z
mZmZm
Z
mZmZmZddlmZmZddlmZmZmZmZmZddlmZmZddlmZmZddlm Z m!Z!m"Z"m#Z#eZ$dS(s�
Python unit testing framework, based on Erich Gamma's JUnit and Kent Beck's
Smalltalk testing framework.

This module contains the core framework classes that form the basis of
specific test cases and suites (TestCase, TestSuite etc.), and also a
text-based utility class for running the tests and reporting the results
 (TextTestRunner).

Simple usage:

    import unittest

    class IntegerArithmeticTestCase(unittest.TestCase):
        def testAdd(self):  ## test method names begin 'test*'
            self.assertEqual((1 + 2), 3)
            self.assertEqual(0 + 1, 1)
        def testMultiply(self):
            self.assertEqual((0 * 10), 0)
            self.assertEqual((5 * 8), 40)

    if __name__ == '__main__':
        unittest.main()

Further information is available in the bundled documentation, and from

  http://docs.python.org/library/unittest.html

Copyright (c) 1999-2003 Steve Purcell
Copyright (c) 2003-2010 Python Software Foundation
This module is free software, and you may redistribute it and/or modify
it under the same terms as Python itself, so long as this copyright message
and disclaimer are retained in their original form.

IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.

THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE.  THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
t
TestResulttTestCaset	TestSuitetTextTestRunnert
TestLoadertFunctionTestCasetmaintdefaultTestLoadertSkipTesttskiptskipIft
skipUnlesstexpectedFailuretTextTestResulttinstallHandlertregisterResulttremoveResultt
removeHandlertgetTestCaseNamest	makeSuitet
findTestCasesi(R(	RRRR	R
RRt_skipInRpmBuildt_expectedFailureInRpmBuild(t
BaseTestSuiteR(RRRRR(tTestProgramR(RR
(RRRRN(%t__doc__t__all__textendtTruet
__unittesttresultRtcaseRRRR	R
RRRRtsuiteRRtloaderRRRRRRRtrunnerRR
tsignalsRRRRt_TextTestResult(((s)/usr/lib64/python2.7/unittest/__init__.pyt<module>-s		@("PK��[&�xK��
runner.pycnu�[����
{fc@s�dZddlZddlZddlmZddlmZeZde	fd��YZ
dejfd	��YZd
e	fd��YZ
dS(s
Running testsi����Ni(tresult(tregisterResultt_WritelnDecoratorcBs,eZdZd�Zd�Zdd�ZRS(s@Used to decorate file-like objects with a handy 'writeln' methodcCs
||_dS(N(tstream(tselfR((s'/usr/lib64/python2.7/unittest/runner.pyt__init__scCs+|dkrt|��nt|j|�S(NRt__getstate__(RR(tAttributeErrortgetattrR(Rtattr((s'/usr/lib64/python2.7/unittest/runner.pyt__getattr__scCs'|r|j|�n|jd�dS(Ns
(twrite(Rtarg((s'/usr/lib64/python2.7/unittest/runner.pytwritelnsN(t__name__t
__module__t__doc__RR
tNoneR
(((s'/usr/lib64/python2.7/unittest/runner.pyRs		tTextTestResultcBs�eZdZddZddZd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�ZRS(shA test result class that can print formatted text results to a stream.

    Used by TextTestRunner.
    t=iFt-cCsPtt|�j|||�||_|dk|_|dk|_||_dS(Ni(tsuperRRRtshowAlltdotstdescriptions(RRRt	verbosity((s'/usr/lib64/python2.7/unittest/runner.pyR$s
	cCsB|j�}|jr4|r4djt|�|f�St|�SdS(Ns
(tshortDescriptionRtjointstr(Rttesttdoc_first_line((s'/usr/lib64/python2.7/unittest/runner.pytgetDescription+scCs\tt|�j|�|jrX|jj|j|��|jjd�|jj�ndS(Ns ... (RRt	startTestRRRRtflush(RR((s'/usr/lib64/python2.7/unittest/runner.pyR 2s
	cCs_tt|�j|�|jr2|jjd�n)|jr[|jjd�|jj�ndS(Ntokt.(	RRt
addSuccessRRR
RRR!(RR((s'/usr/lib64/python2.7/unittest/runner.pyR$9s		cCsbtt|�j||�|jr5|jjd�n)|jr^|jjd�|jj�ndS(NtERRORtE(	RRtaddErrorRRR
RRR!(RRterr((s'/usr/lib64/python2.7/unittest/runner.pyR'As		cCsbtt|�j||�|jr5|jjd�n)|jr^|jjd�|jj�ndS(NtFAILtF(	RRt
addFailureRRR
RRR!(RRR(((s'/usr/lib64/python2.7/unittest/runner.pyR+Is		cCsktt|�j||�|jr>|jjdj|��n)|jrg|jjd�|jj	�ndS(Ns
skipped {0!r}ts(
RRtaddSkipRRR
tformatRRR!(RRtreason((s'/usr/lib64/python2.7/unittest/runner.pyR-Qs		cCsbtt|�j||�|jr5|jjd�n)|jr^|jjd�|jj�ndS(Nsexpected failuretx(	RRtaddExpectedFailureRRR
RRR!(RRR(((s'/usr/lib64/python2.7/unittest/runner.pyR1Ys		cCs_tt|�j|�|jr2|jjd�n)|jr[|jjd�|jj�ndS(Nsunexpected successtu(	RRtaddUnexpectedSuccessRRR
RRR!(RR((s'/usr/lib64/python2.7/unittest/runner.pyR3as		cCsL|js|jr"|jj�n|jd|j�|jd|j�dS(NR%R)(RRRR
tprintErrorListterrorstfailures(R((s'/usr/lib64/python2.7/unittest/runner.pytprintErrorsiscCsxxq|D]i\}}|jj|j�|jjd||j|�f�|jj|j�|jjd|�qWdS(Ns%s: %ss%s(RR
t
separator1Rt
separator2(RtflavourR5RR(((s'/usr/lib64/python2.7/unittest/runner.pyR4os
#(RRRR8R9RRR R$R'R+R-R1R3R7R4(((s'/usr/lib64/python2.7/unittest/runner.pyRs

										tTextTestRunnercBsDeZdZeZejedeedd�Z
d�Zd�ZRS(s�A test runner class that displays results in textual form.

    It prints out the names of tests as they are run, errors as they
    occur, and a summary of the results at the end of the test run.
    icCsOt|�|_||_||_||_||_|dk	rK||_ndS(N(RRRRtfailfasttbufferRtresultclass(RRRRR<R=R>((s'/usr/lib64/python2.7/unittest/runner.pyRs				cCs|j|j|j|j�S(N(R>RRR(R((s'/usr/lib64/python2.7/unittest/runner.pyt_makeResult�scCs�|j�}t|�|j|_|j|_tj�}t|dd�}|dk	rb|�nz||�Wdt|dd�}|dk	r�|�nXtj�}||}|j�t|d�r�|j	j
|j�n|j}|j	j
d||dkrdpd|f�|j	j
�d	}	}
}y%t
t|j|j|jf�}Wntk
rlnX|\}	}
}g}
|j�s�|j	jd
�t
t|j|jf�\}}|r�|
jd|�n|r|
jd|�qn|j	jd
�|r |
jd|�n|	r:|
jd|	�n|
rT|
jd|
�n|
r}|j	j
ddj|
�f�n|j	jd�|S(s&Run the given test case or test suite.tstartTestRunNtstopTestRunR9sRan %d test%s in %.3fsiR,titFAILEDsfailures=%ds	errors=%dtOKs
skipped=%dsexpected failures=%dsunexpected successes=%ds (%s)s, s
(R?RR<R=ttimeRRR7thasattrRR
R9ttestsRuntmaptlentexpectedFailurestunexpectedSuccessestskippedRt
wasSuccessfulRR6R5tappendR(RRRt	startTimeR@RAtstopTimet	timeTakentrunt
expectedFailsRKRLtresultstinfostfailedterrored((s'/usr/lib64/python2.7/unittest/runner.pyRR�sb



	#

!#N(
RRRRR>tsyststderrtTruetFalseRRR?RR(((s'/usr/lib64/python2.7/unittest/runner.pyR;ws		(RRXRERBRtsignalsRRZt
__unittesttobjectRt
TestResultRR;(((s'/usr/lib64/python2.7/unittest/runner.pyt<module>s[PK��[r�n��util.pycnu�[����
{fc@s�dZddlmZmZeZdZed�Zd�Z	d�Z
ed�Zedd	�Zd
�Z
d�Zd�Zd
S(sVarious utility functions.i����(t
namedtupletOrderedDictiPcCs\yt|�}Wn tk
r2tj|�}nX|sLt|�tkrP|S|t dS(Ns [truncated]...(treprt	Exceptiontobjectt__repr__tlent_MAX_LENGTH(tobjtshorttresult((s%/usr/lib64/python2.7/unittest/util.pyt	safe_reprs
cCsd|j|jfS(Ns%s.%s(t
__module__t__name__(tcls((s%/usr/lib64/python2.7/unittest/util.pytstrclassscCshd}}g}g}xEtr]y||}||}||kr}|j|�|d7}x�|||kry|d7}q\Wn�||kr�|j|�|d7}x|||kr�|d7}q�Wn^|d7}z%x|||kr�|d7}q�WWd|d7}x|||kr |d7}qWXWqtk
rY|j||�|j||�PqXqW||fS(srFinds elements in only one or the other of two, sorted input lists.

    Returns a two-element tuple of lists.    The first list contains those
    elements in the "expected" list but not in the "actual" list, and the
    second contains those elements in the "actual" list but not in the
    "expected" list.    Duplicate elements in either input list are ignored.
    iiN(tTruetappendt
IndexErrortextend(texpectedtactualtitjtmissingt
unexpectedteta((s%/usr/lib64/python2.7/unittest/util.pytsorted_list_differences:
	








	cCsg}g}x�|r�|j�}y|j|�Wntk
rR|j|�nX|rxI||fD]8}yxtr�|j|�qrWWqftk
r�qfXqfWqqW|rxU|r|j�}|j|�yxtr�|j|�q�WWq�tk
rq�Xq�W||fS||fS(s�Same behavior as sorted_list_difference but
    for lists of unorderable items (like dicts).

    As it does a linear search per item (remove) it
    has O(n*n) performance.
    (tpoptremovet
ValueErrorRR(RRtignore_duplicateRRtitemtlst((s%/usr/lib64/python2.7/unittest/util.pytunorderable_list_difference>s4	
	
	
	

tMismatchsactual expected valuecCs�t|�t|�}}t|�t|�}}t�}g}x�t|�D]�\}}	|	|krlqNnd}
}x>t||�D]-}|||	kr�|
d7}
|||<q�q�Wx=t|�D]/\}}
|
|	kr�|d7}|||<q�q�W|
|krNt|
||	�}|j|�qNqNWx�t|�D]�\}}	|	|krTq6nd}x>t||�D]-}|||	krj|d7}|||<qjqjWtd||	�}|j|�q6W|S(sHReturns list of (cnt_act, cnt_exp, elem) triples where the counts differii(tlistRRt	enumeratetranget	_MismatchR(RRtstttmtntNULLR
Rtelemtcnt_stcnt_tRt
other_elemtdiff((s%/usr/lib64/python2.7/unittest/util.pyt_count_diff_all_purposeds<	



cCs8t�}x(|D] }|j|d�d||<qW|S(s@Return dict of element counts, in the order they were first seenii(Rtget(titerabletcR.((s%/usr/lib64/python2.7/unittest/util.pyt_ordered_count�s	
c	Cs�t|�t|�}}g}xZ|j�D]L\}}|j|d�}||kr,t|||�}|j|�q,q,WxH|j�D]:\}}||kr�td||�}|j|�q�q�W|S(sHReturns list of (cnt_act, cnt_exp, elem) triples where the counts differi(R7titemsR4R(R(	RRR)R*R
R.R/R0R2((s%/usr/lib64/python2.7/unittest/util.pyt_count_diff_hashable�sN(t__doc__tcollectionsRRRt
__unittestRtFalseRRRR#R(R3R7R9(((s%/usr/lib64/python2.7/unittest/util.pyt<module>s
		)$	#	PKń[v�?��)__pycache__/__main__.cpython-36.opt-1.pycnu�[���3


 \��@sddZddlZejdjd�rBddlZejjej�Zedejd<[dZ	ddl
m
Z
mZe
dd�dS)	zMain entry point�Nz__main__.pyz -m unittestT�)�main�TestProgram)�module)�__doc__�sys�argv�endswithZos.path�os�path�basename�
executableZ
__unittestrr�rr�)/usr/lib64/python3.6/unittest/__main__.py�<module>sPKń[�l����)__pycache__/__init__.cpython-36.opt-1.pycnu�[���3

�\dhk�@s�dZddddddddd	d
ddd
dddddgZejdddg�dZddlmZddlmZmZm	Z	m
Z
mZmZm
Z
mZddlmZmZddlmZmZmZmZmZddlmZmZddlmZmZddlmZmZm Z m!Z!eZ"dd �Z#d!S)"a�
Python unit testing framework, based on Erich Gamma's JUnit and Kent Beck's
Smalltalk testing framework (used with permission).

This module contains the core framework classes that form the basis of
specific test cases and suites (TestCase, TestSuite etc.), and also a
text-based utility class for running the tests and reporting the results
 (TextTestRunner).

Simple usage:

    import unittest

    class IntegerArithmeticTestCase(unittest.TestCase):
        def testAdd(self):  # test method names begin with 'test'
            self.assertEqual((1 + 2), 3)
            self.assertEqual(0 + 1, 1)
        def testMultiply(self):
            self.assertEqual((0 * 10), 0)
            self.assertEqual((5 * 8), 40)

    if __name__ == '__main__':
        unittest.main()

Further information is available in the bundled documentation, and from

  http://docs.python.org/library/unittest.html

Copyright (c) 1999-2003 Steve Purcell
Copyright (c) 2003-2010 Python Software Foundation
This module is free software, and you may redistribute it and/or modify
it under the same terms as Python itself, so long as this copyright message
and disclaimer are retained in their original form.

IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.

THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE.  THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
�
TestResult�TestCase�	TestSuite�TextTestRunner�
TestLoader�FunctionTestCase�main�defaultTestLoader�SkipTest�skip�skipIf�
skipUnless�expectedFailure�TextTestResult�installHandler�registerResult�removeResult�
removeHandler�getTestCaseNames�	makeSuite�
findTestCasesT�)r)rrr	r
rrr
�_skipInRpmBuild)�
BaseTestSuiter)rrrrr)�TestProgramr)rr)rrrrcCs"ddl}|jjt�}|j||d�S)N�)Z	start_dir�pattern)Zos.path�path�dirname�__file__Zdiscover)�loaderZtestsr�osZthis_dir�r!�)/usr/lib64/python3.6/unittest/__init__.py�
load_testsKsr#N)$�__doc__�__all__�extendZ
__unittest�resultrZcaserrr	r
rrr
rZsuiterrrrrrrrrrZrunnerrrZsignalsrrrrZ_TextTestResultr#r!r!r!r"�<module>-s 

(PKń[��kH��'__pycache__/runner.cpython-36.opt-1.pycnu�[���3


 \G�@sndZddlZddlZddlZddlmZddlmZdZGdd�de	�Z
Gd	d
�d
ej�ZGdd�de	�Z
dS)
z
Running tests�N�)�result)�registerResultTc@s*eZdZdZdd�Zdd�Zd	dd�ZdS)
�_WritelnDecoratorz@Used to decorate file-like objects with a handy 'writeln' methodcCs
||_dS)N)�stream)�selfr�r�'/usr/lib64/python3.6/unittest/runner.py�__init__sz_WritelnDecorator.__init__cCs|dkrt|��t|j|�S)Nr�__getstate__)rr)�AttributeError�getattrr)r�attrrrr	�__getattr__sz_WritelnDecorator.__getattr__NcCs|r|j|�|jd�dS)N�
)�write)r�argrrr	�writelns
z_WritelnDecorator.writeln)N)�__name__�
__module__�__qualname__�__doc__r
rrrrrr	r
srcs�eZdZdZddZddZ�fdd�Zdd�Z�fd	d
�Z�fdd�Z	�fd
d�Z
�fdd�Z�fdd�Z�fdd�Z
�fdd�Zdd�Zdd�Z�ZS)�TextTestResultzhA test result class that can print formatted text results to a stream.

    Used by TextTestRunner.
    �=�F�-cs8tt|�j|||�||_|dk|_|dk|_||_dS)Nr)�superrr
r�showAll�dots�descriptions)rrr�	verbosity)�	__class__rr	r
%s


zTextTestResult.__init__cCs0|j�}|jr$|r$djt|�|f�St|�SdS)Nr)ZshortDescriptionr�join�str)r�testZdoc_first_linerrr	�getDescription,s
zTextTestResult.getDescriptioncsBtt|�j|�|jr>|jj|j|��|jjd�|jj�dS)Nz ... )rr�	startTestrrrr%�flush)rr$)r!rr	r&3s
zTextTestResult.startTestcsDtt|�j|�|jr$|jjd�n|jr@|jjd�|jj�dS)N�ok�.)	rr�
addSuccessrrrrrr')rr$)r!rr	r*:szTextTestResult.addSuccesscsFtt|�j||�|jr&|jjd�n|jrB|jjd�|jj�dS)N�ERROR�E)	rr�addErrorrrrrrr')rr$�err)r!rr	r-BszTextTestResult.addErrorcsFtt|�j||�|jr&|jjd�n|jrB|jjd�|jj�dS)N�FAIL�F)	rr�
addFailurerrrrrr')rr$r.)r!rr	r1JszTextTestResult.addFailurecsLtt|�j||�|jr,|jjdj|��n|jrH|jjd�|jj	�dS)Nz
skipped {0!r}�s)
rr�addSkiprrr�formatrrr')rr$�reason)r!rr	r3RszTextTestResult.addSkipcsFtt|�j||�|jr&|jjd�n|jrB|jjd�|jj�dS)Nzexpected failure�x)	rr�addExpectedFailurerrrrrr')rr$r.)r!rr	r7Zsz!TextTestResult.addExpectedFailurecsDtt|�j|�|jr$|jjd�n|jr@|jjd�|jj�dS)Nzunexpected success�u)	rr�addUnexpectedSuccessrrrrrr')rr$)r!rr	r9bsz#TextTestResult.addUnexpectedSuccesscCs6|js|jr|jj�|jd|j�|jd|j�dS)Nr+r/)rrrr�printErrorList�errors�failures)rrrr	�printErrorsjs
zTextTestResult.printErrorscCs\xV|D]N\}}|jj|j�|jjd||j|�f�|jj|j�|jjd|�qWdS)Nz%s: %sz%s)rr�
separator1r%�
separator2)rZflavourr;r$r.rrr	r:ps
zTextTestResult.printErrorList)rrrrr>r?r
r%r&r*r-r1r3r7r9r=r:�
__classcell__rr)r!r	rsrc@s4eZdZdZeZd
dd�dd�Zd	d
�Zdd�ZdS)�TextTestRunnerz�A test runner class that displays results in textual form.

    It prints out the names of tests as they are run, errors as they
    occur, and a summary of the results at the end of the test run.
    NTrF)�	tb_localsc	CsN|dkrtj}t|�|_||_||_||_||_||_||_	|dk	rJ||_
dS)z�Construct a TextTestRunner.

        Subclasses should accept **kwargs to ensure compatibility as the
        interface changes.
        N)�sys�stderrrrrr �failfast�bufferrB�warnings�resultclass)	rrrr rErFrHrGrBrrr	r
�s
zTextTestRunner.__init__cCs|j|j|j|j�S)N)rHrrr )rrrr	�_makeResult�szTextTestRunner._makeResultcCs4|j�}t|�|j|_|j|_|j|_tj���|jr^tj|j�|jdkr^tjdt	dd�t
j
�}t|dd�}|dk	r�|�z||�Wdt|dd�}|dk	r�|�Xt
j
�}WdQRX||}|j�t
|d	�r�|jj|j�|j}|jjd
||dk�rd�pd
|f�|jj�d}	}
}ytt|j|j|jf�}Wntk
�rVYnX|\}	}
}g}
|j��s�|jjd�t|j�t|j�}}|�r�|
jd|�|�r�|
jd|�n|jjd�|�r�|
jd|�|	�r�|
jd|	�|
�r|
jd|
�|
�r$|jjddj|
�f�n|jjd�|S)z&Run the given test case or test suite.�default�always�modulezPlease use assert\w+ instead.)�category�message�startTestRunN�stopTestRunr?zRan %d test%s in %.3fsrr2�rZFAILEDzfailures=%dz	errors=%dZOKz
skipped=%dzexpected failures=%dzunexpected successes=%dz (%s)z, r)rJrK)rIrrErFrBrG�catch_warnings�simplefilter�filterwarnings�DeprecationWarning�timer
r=�hasattrrrr?ZtestsRun�map�lenZexpectedFailures�unexpectedSuccesses�skippedrZ
wasSuccessfulrr<r;�appendr")rr$rZ	startTimerOrPZstopTimeZ	timeTaken�runZ
expectedFailsrZr[ZresultsZinfosZfailedZerroredrrr	r]�sr





zTextTestRunner.run)NTrFFNN)	rrrrrrHr
rIr]rrrr	rAxsrA)rrCrVrGrQrZsignalsrZ
__unittest�objectrZ
TestResultrrArrrr	�<module>s[PKń[�eg��%__pycache__/main.cpython-36.opt-2.pycnu�[���3


 \8)�@shddlZddlZddlZddlmZmZddlmZdZdZ	dZ
dd	�Zd
d�ZGdd
�d
e
�ZeZdS)�N�)�loader�runner)�installHandlerTaExamples:
  %(prog)s test_module               - run tests from test_module
  %(prog)s module.TestClass          - run tests from module.TestClass
  %(prog)s module.Class.test_method  - run specified test method
  %(prog)s path/to/test_file.py      - run tests from test_file.py
aFExamples:
  %(prog)s                           - run default set of tests
  %(prog)s MyTestSuite               - run suite 'MyTestSuite'
  %(prog)s MyTestCase.testSomething  - run MyTestCase.testSomething
  %(prog)s MyTestCase                - run all 'test*' test methods
                                       in MyTestCase
cCsxtjj|�rt|j�jd�rttjj|�rXtjj|tj��}tjj|�sP|jtj	�rT|S|}|dd�j
dd�j
dd�S|S)Nz.py��\�.�/���)�os�path�isfile�lower�endswith�isabs�relpath�getcwd�
startswith�pardir�replace)�nameZrel_path�r�%/usr/lib64/python3.6/unittest/main.py�
_convert_namesrcCsdd�|D�S)NcSsg|]}t|��qSr)r)�.0rrrr�
<listcomp>.sz"_convert_names.<locals>.<listcomp>r)�namesrrr�_convert_names-src@s�eZdZdZdZdZZZZZ	dZ
ddddejddddddfdd�dd�Z
dd	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zddd�Zdd�ZdS)�TestProgramNr�__main__TF)�	tb_localscCs�t|t�r@t|�|_x0|jd�dd�D]}
t|j|
�|_q(Wn||_|dkrTtj}||_||_	|	|_
||_|
|_||_
|dkr�tjr�d|_n||_||_||_||_tjj|d�|_|j|�|j�dS)Nrr�defaultr)�
isinstance�str�
__import__�module�split�getattr�sys�argv�exit�failfast�
catchbreak�	verbosity�bufferr �warnoptions�warnings�defaultTest�
testRunner�
testLoaderrr�basename�progName�	parseArgs�runTests)�selfr%r1r)r2r3r*r-r+r,r.r0r �partrrr�__init__;s,


zTestProgram.__init__cCs4|rt|�|jdkr|j�|j�tjd�dS)N�)�print�_discovery_parser�_initArgParsers�_print_helpr(r*)r8�msgrrr�	usageExitas
zTestProgram.usageExitcOsZ|jdkr6t|jj��ttd|ji�|jj�n t|jj��ttd|ji�dS)N�prog)	r%r<�_main_parserZformat_help�
MAIN_EXAMPLESr5r=�
print_help�MODULE_EXAMPLES)r8�args�kwargsrrrr?is
zTestProgram._print_helpcCs�|j�|jdkrpt|�dkrD|dj�dkrD|j|dd��dS|jj|dd�|�|js�|jg�dSn|jj|dd�|�|jr�t|j�|_	t
dkr�d|_n6|jdkr�d|_	n$t|jt
�r�|jf|_	nt|j�|_	|j�dS)Nr�discoverr;r)r>r%�lenr�
_do_discoveryrC�
parse_args�testsr�	testNames�__name__r1r"r#�list�createTests)r8r)rrrr6rs(


zTestProgram.parseArgscCs4|jdkr|jj|j�|_n|jj|j|j�|_dS)N)rNr3ZloadTestsFromModuler%�testZloadTestsFromNames)r8rrrrQ�s

zTestProgram.createTestscCs$|j�}|j|�|_|j|�|_dS)N)�_getParentArgParser�_getMainArgParserrC�_getDiscoveryArgParserr=)r8Z
parent_parserrrrr>�szTestProgram._initArgParserscCs�tjdd�}|jddddddd	�|jd
ddddd
d	�|jddddd�|jdkrn|jdddddd�d|_|jdkr�|jdddddd�d|_|jdkr�|jdddddd�d|_|S)NF)Zadd_helpz-vz	--verboser-Zstore_constr;zVerbose output)�dest�actionZconst�helpz-qz--quietrzQuiet outputz--localsr �
store_truez"Show local variables in tracebacks)rVrWrXz-fz
--failfastr+zStop on first fail or errorz-cz--catchr,z'Catch Ctrl-C and display results so farz-bz--bufferr.z%Buffer stdout and stderr during tests)�argparse�ArgumentParser�add_argumentr+r,r.)r8�parserrrrrS�s4







zTestProgram._getParentArgParsercCs2tj|gd�}|j|_|j|_|jdddd�|S)N)�parentsrM�*z?a list of any number of test modules, classes and test methods.)�nargsrX)rZr[r5rBr?rEr\)r8�parentr]rrrrT�szTestProgram._getMainArgParsercCs~tj|gd�}d|j|_d|_|jddddd�|jd	d
ddd�|jd
dddd�x"dD]}|j|dtjtjd�q\W|S)N)r^z%s discoverzcFor test discovery all test modules must be importable from the top level directory of the project.z-sz--start-directory�startz*Directory to start discovery ('.' default))rVrXz-pz	--pattern�patternz+Pattern to match tests ('test*.py' default)z-tz--top-level-directory�topz<Top level directory of project (defaults to start directory)�?)r`r!rX)rbrcrd)rZr[r5rBZepilogr\ZSUPPRESS)r8rar]�argrrrrU�s



z"TestProgram._getDiscoveryArgParsercCshd|_d|_d|_|dk	r:|jdkr,|j�|jj||�|dkrH|jn|�}|j|j|j|j�|_dS)Nrztest*.py)	rbrcrdr=r>rLr3rIrR)r8r)�LoaderrrrrrK�s
zTestProgram._do_discoverycCs�|jrt�|jdkrtj|_t|jt�r�yVy"|j|j|j|j	|j
|jd�}Wn.tk
r||j|j|j|j	|j
d�}YnXWq�tk
r�|j�}Yq�Xn|j}|j
|j�|_|jr�tj|jj��dS)N)r-r+r.r0r )r-r+r.r0)r,rr2rZTextTestRunnerr"�typer-r+r.r0r �	TypeErrorZrunrR�resultr*r(Z
wasSuccessful)r8r2rrrr7�s.
zTestProgram.runTests)N)N)rO�
__module__�__qualname__r%r-r+r,r.r5r0r=rZdefaultTestLoaderr:rAr?r6rQr>rSrTrUrKr7rrrrr1s$#
	
r)r(rZr�rrZsignalsrZ
__unittestrDrFrr�objectr�mainrrrr�<module>s	TPKń[F�k9�5�5'__pycache__/loader.cpython-36.opt-1.pycnu�[���3


 \�V�@sdZddlZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZmZdZ
ejdej�ZGdd	�d	e
j�Zd
d�Zdd
�Zdd�Zdd�Zdd�ZGdd�de�Ze�Zddd�Zejfdd�Zdejejfdd�Zdejejfdd�Z dS) zLoading unittests.�N)�fnmatch�)�case�suite�utilTz[_a-z]\w*\.py$cs,eZdZdZ�fdd�Z�fdd�Z�ZS)�_FailedTestNcs||_tt|�j|�dS)N)�
_exception�superr�__init__)�selfZmethod_name�	exception)�	__class__��'/usr/lib64/python3.6/unittest/loader.pyr
sz_FailedTest.__init__cs*|�jkrtt��j|�S�fdd�}|S)Ncs
�j�dS)N)rr)rrr�testFailure!sz,_FailedTest.__getattr__.<locals>.testFailure)�_testMethodNamer	r�__getattr__)r�namer)r
)rrrs
z_FailedTest.__getattr__)�__name__�
__module__�__qualname__rr
r�
__classcell__rr)r
rrsrcCs"d|tj�f}t|t|�||�S)Nz#Failed to import test module: %s
%s)�	traceback�
format_exc�_make_failed_test�ImportError)r�
suiteClass�messagerrr�_make_failed_import_test&srcCsdtj�f}t||||�S)NzFailed to call load_tests:
%s)rrr)rrrrrrr�_make_failed_load_tests+srcCst||�}||f�|fS)N)r)�
methodnamerrr�testrrrr0s
rcCs<tjt|��dd��}||i}tdtjf|�}|||�f�S)NcSsdS)Nr)rrrr�testSkipped5sz'_make_skipped_test.<locals>.testSkippedZ
ModuleSkipped)r�skip�str�type�TestCase)r rrr"ZattrsZ	TestClassrrr�_make_skipped_test4sr'cCs*|j�jd�r|dd�Stjj|�dS)Nz	$py.class�	ri����)�lower�endswith�os�path�splitext)r,rrr�_jython_aware_splitext<sr.cs�eZdZdZdZeej�Ze	j
ZdZ�fdd�Z
dd�Zdd�d	d
�Zd!dd�Zd"d
d�Zdd�Zd#dd�Zdd�Zdd�Zdd�Zdd�Zd$dd�Zd%dd �Z�ZS)&�
TestLoaderz�
    This class is responsible for loading tests according to various criteria
    and returning them wrapped in a TestSuite
    r!Ncs tt|�j�g|_t�|_dS)N)r	r/r
�errors�set�_loading_packages)r)r
rrr
LszTestLoader.__init__cCsHt|tj�rtd��|j|�}|r4t|d�r4dg}|jt||��}|S)z;Return a suite of all test cases contained in testCaseClasszYTest cases should not be derived from TestSuite. Maybe you meant to derive from TestCase?ZrunTest)�
issubclassr�	TestSuite�	TypeError�getTestCaseNames�hasattrr�map)r�
testCaseClassZ
testCaseNamesZloaded_suiterrr�loadTestsFromTestCaseSs
z TestLoader.loadTestsFromTestCase)�patternc
Os2t|�dksd|kr,tjdt�|jdd�t|�dkrRt|�d}tdj|���t|�dkrxt|�d}tdj|���g}x@t|�D]4}t	||�}t
|t�r�t|t
j�r�|j|j|��q�Wt	|dd�}	|j|�}|	dk	�r.y|	|||�Stk
�r,}
z$t|j|
|j�\}}|jj|�|Sd}
~
XnX|S)	z>Return a suite of all test cases contained in the given modulerZuse_load_testsz(use_load_tests is deprecated and ignoredNrzCloadTestsFromModule() takes 1 positional argument but {} were givenz=loadTestsFromModule() got an unexpected keyword argument '{}'�
load_tests)�len�warnings�warn�DeprecationWarning�popr5�format�sorted�dir�getattr�
isinstancer%r3rr&�appendr:r�	Exceptionrrr0)
r�moduler;�argsZkwsZ	complaint�testsr�objr<�e�
error_case�
error_messagerrr�loadTestsFromModuleas4


zTestLoader.loadTestsFromModulecCs>|jd�}d\}}|dkr�|dd�}xb|r�ydj|�}t|�}PWq(tk
r�|j�}t||j�\}}|s�|jj|�|SYq(Xq(W|dd�}|}	x�|D]�}
y|	t	|	|
�}}	Wq�t
k
�r2}z\t	|	dd�dk	r�|dk	r�|jj|�|St|
||jdtj
�f�\}}|jj|�|SWYdd}~Xq�Xq�Wt|	tj��rP|j|	�St|	t��rtt|	tj��rt|j|	�St|	tj��r�t|t��r�t|tj��r�|d	}||�}
tt	|
|�tj��s�|j|
g�Snt|	tj��r�|	St|	��r.|	�}t|tj��r|St|tj��r|j|g�Std|	|f��ntd|	��dS)
aSReturn a suite of all test cases given a string specifier.

        The name may resolve either to a module, a test case class, a
        test method within a test case class, or a callable object which
        returns a TestCase or TestSuite instance.

        The method optionally resolves the names relative to a given module.
        �.Nr�__path__zFailed to access attribute:
%sz"calling %s returned %s, not a testz$don't know how to make test from: %s)NN���)�split�join�
__import__rrArrr0rGrE�AttributeErrorrrrrF�types�
ModuleTyperPr%r3rr&r:�FunctionTyperr4�callabler5)rrrI�partsrNrOZ
parts_copy�module_nameZnext_attributerL�part�parentrMZinstr!rrr�loadTestsFromName�sl	





zTestLoader.loadTestsFromNamecs��fdd�|D�}�j|�S)z�Return a suite of all test cases found using the given sequence
        of string specifiers. See 'loadTestsFromName()'.
        csg|]}�j|���qSr)r`)�.0r)rIrrr�
<listcomp>�sz1TestLoader.loadTestsFromNames.<locals>.<listcomp>)r)r�namesrIZsuitesr)rIrr�loadTestsFromNames�szTestLoader.loadTestsFromNamescCs@||jfdd�}tt|t|���}|jr<|jtj|j�d�|S)zLReturn a sorted sequence of method names found within testCaseClass
        cSs|j|�ott||��S)N)�
startswithr[rE)Zattrnamer9�prefixrrr�isTestMethod�s
z1TestLoader.getTestCaseNames.<locals>.isTestMethod)�key)�testMethodPrefix�list�filterrD�sortTestMethodsUsing�sort�	functools�
cmp_to_key)rr9rgZtestFnNamesrrrr6�szTestLoader.getTestCaseNames�test*.pycCsRd}|dkr|jdk	r|j}n|dkr.d}|}tjj|�}|tjkrRtjjd|�||_d}d}g}tjjtjj|��r�tjj|�}||kr�tjjtjj|d��}�nxyt	|�Wnt
k
r�d}Y�nRXtj|}|jd�d}	ytjjtjj
|j��}Wn�tk
�r�y
|j}
Wntk
�r8d}
YnX|
�r�|
jdk�r�|
jdk	�r�d}x�|jD]T}|�r�|j|��r��qd|j|jjdtjj��d|_|j|j||dd���qdWn*|jtjk�r�td�d�ntd	j|��d�YnX|�r |�s|j|	�|_tjj|�ntjj|�|�r2t
d
|��|�sHt|j||��}|j |�S)a%Find and return all test modules from the specified start
        directory, recursing into subdirectories to find them and return all
        tests found within them. Only test files that match the pattern will
        be loaded. (Using shell style pattern matching.)

        All test modules must be importable from the top level of the project.
        If the start directory is not the top level directory then the top
        level directory must be specified separately.

        If a test package name (directory with '__init__.py') matches the
        pattern then the package will be checked for a 'load_tests' function. If
        this exists then it will be called with (loader, tests, pattern) unless
        the package has already had load_tests called from the same discovery
        invocation, in which case the package module object is not scanned for
        tests - this ensures that when a package uses discover to further
        discover child tests that infinite recursion does not happen.

        If load_tests exists then discovery does *not* recurse into the package,
        load_tests is responsible for loading all tests in the package.

        The pattern is deliberately not stored as a loader attribute so that
        packages can continue discovery themselves. top_level_dir is stored so
        load_tests does not need to pass this argument in to loader.discover().

        Paths are sorted before being imported to ensure reproducible execution
        order even on filesystems with non-alphabetical ordering like ext3/4.
        FNTrz__init__.pyrQ)�	namespacez2Can not use builtin modules as dotted module namesz$don't know how to discover from {!r}z%Start directory is not importable: %r)!�_top_level_dirr+r,�abspath�sys�insert�isdir�isfilerUrVr�modulesrT�dirname�__file__rW�__spec__�loader�submodule_search_locationsrRrer�replace�sep�extend�_find_tests�builtin_module_namesr5rB� _get_directory_containing_module�removerjr)r�	start_dirr;Z
top_level_dirZset_implicit_topZis_not_importable�is_namespacerKZ
the_moduleZtop_part�specr,rrr�discover�sv





zTestLoader.discovercCsRtj|}tjj|j�}tjj|�j�jd�rBtjj	tjj	|��Stjj	|�SdS)Nz__init__.py)
rtrxr+r,rsrz�basenamer)rery)rr]rI�	full_pathrrrr�Xs

z+TestLoader._get_directory_containing_modulecCsB||jkrdSttjj|��}tjj||j�}|jtjjd�}|S)NrQ)rrr.r+r,�normpath�relpathr~r)rr,Z_relpathrrrr�_get_name_from_pathds
zTestLoader._get_name_from_pathcCst|�tj|S)N)rVrtrx)rrrrr�_get_module_from_namepsz TestLoader._get_module_from_namecCs
t||�S)N)r)rr,r�r;rrr�_match_pathtszTestLoader._match_pathFc
cs�|j|�}|dkrD||jkrD|j|||�\}}|dk	r<|V|sDdSttj|��}x||D]t}tjj||�}	|j|	||�\}}|dk	r�|V|rX|j|	�}|jj|�z|j	|	||�EdHWd|jj
|�XqXWdS)z/Used by discovery. Yields test suites it loads.rQN)r�r2�_find_test_pathrCr+�listdirr,rU�addr��discard)
rr�r;rqrrKZshould_recurse�pathsr,r�rrrr�xs*


zTestLoader._find_testscCsPtjj|�}tjj|��rFtj|�s(d	S|j|||�s:d
S|j|�}y|j|�}WnXt	j
k
r�}zt|||j�dfSd}~Xn�t
||j�\}}	|jj|	�|dfStjjt|d|��}
ttjj|
��}ttjj|��}|j�|j�k�r0tjj|�}
ttjj|��}tjj|�}d}t|||
|f��|j||d�dfS�ntjj|��rH|�rztjjtjj|d���rzdSd}d}|j|�}y|j|�}WnZt	j
k
�r�}zt|||j�dfSd}~Xnzt
||j�\}}	|jj|	�|dfSt|dd�}|jj|�z(|j||d�}|dk	�r0|dfS|dfS|jj|�XndSdS)
z�Used by discovery.

        Loads tests from a single file, or a directories' __init__.py when
        passed the directory.

        Returns a tuple (None_or_tests_from_file, should_recurse).
        NFrzzW%r module incorrectly imported from %r. Expected %r. Is this module globally installed?)r;z__init__.pyr<T)NF)NF)NF)NF)r+r,r�rw�VALID_MODULE_NAME�matchr�r�r�rZSkipTestr'rrr0rGrsrEr.�realpathr)ryrrPrvrUr2r�r�)rr�r;rqr�rrIrMrNrOZmod_filer�Zfullpath_noextZ
module_dirZmod_nameZexpected_dir�msgr<rK�packagerrrr��sl



zTestLoader._find_test_path)N)N)rpN)F)F)rrr�__doc__ri�staticmethodr�
three_way_cmprlrr4rrrr
r:rPr`rdr6r�r�r�r�r�r�r�rrr)r
rr/Bs$
(
N

n
"r/cCs t�}||_||_|r||_|S)N)r/rlrir)rf�	sortUsingrr|rrr�_makeLoader�sr�cCst||�j|�S)N)r�r6)r9rfr�rrrr6�sr6r!cCst|||�j|�S)N)r�r:)r9rfr�rrrr�	makeSuite�sr�cCst|||�j|�S)N)r�rP)rIrfr�rrrr�
findTestCases�sr�)N)!r�r+�rertrrXrnr>r�rrrZ
__unittest�compile�
IGNORECASEr�r&rrrrr'r.�objectr/ZdefaultTestLoaderr�r�r6r4r�r�rrrr�<module>s8'
PKń[�ZS�PP%__pycache__/util.cpython-36.opt-1.pycnu�[���3


 \9�@s�dZddlmZmZddlmZdZdZdZdZ	dZ
dZee	eeee
Zdd	�Z
d
d�Zd d
d�Zdd�Zdd�Zdd�Zdd�Zedd�Zdd�Zdd�Zdd�ZdS)!zVarious utility functions.�)�
namedtuple�OrderedDict)�commonprefixT�P��cCsBt|�||}|tkr>d|d|�||t|�|d�f}|S)Nz%s[%d chars]%s)�len�_PLACEHOLDER_LEN)�s�	prefixlenZ	suffixlen�skip�r
�%/usr/lib64/python3.6/unittest/util.py�_shortens&rcs�ttt|��}ttt|��}|tkr(|St|��t���t|�tt}|t	krxt
�t|��t��fdd�|D��St
�tt	��t��fdd�|D��S)Nc3s|]}�|�d�VqdS)Nr
)�.0r
)�prefixrr
r�	<genexpr>'sz'_common_shorten_repr.<locals>.<genexpr>c3s&|]}�t|�d�tt�VqdS)N)r�
_MIN_DIFF_LEN�_MIN_END_LEN)rr
)rrr
rr*s)�tuple�map�	safe_repr�maxr�_MAX_LENGTHr�_MIN_BEGIN_LENr	�_MIN_COMMON_LENr)�args�maxlenZ
common_lenr
)rrr�_common_shorten_reprsrFcCsRyt|�}Wntk
r*tj|�}YnX|s>t|�tkrB|S|dt�dS)Nz [truncated]...)�repr�	Exception�object�__repr__rr)�objZshort�resultr
r
rr-srcCsd|j|jfS)Nz%s.%s)�
__module__�__qualname__)�clsr
r
r�strclass6sr(cCs*d}}g}g}�xy�||}||}||kr\|j|�|d7}x�|||krX|d7}qBWn�||kr�|j|�|d7}xf|||kr�|d7}qxWnL|d7}zx|||kr�|d7}q�WWd|d7}x|||kr�|d7}q�WXWqtk
�r|j||d��|j||d��PYqXqW||fS)arFinds elements in only one or the other of two, sorted input lists.

    Returns a two-element tuple of lists.    The first list contains those
    elements in the "expected" list but not in the "actual" list, and the
    second contains those elements in the "actual" list but not in the
    "expected" list.    Duplicate elements in either input list are ignored.
    r�N)�append�
IndexError�extend)�expected�actual�i�j�missingZ
unexpected�e�ar
r
r�sorted_list_difference9s:

r4cCsLg}x>|rB|j�}y|j|�Wqtk
r>|j|�YqXqW||fS)z�Same behavior as sorted_list_difference but
    for lists of unorderable items (like dicts).

    As it does a linear search per item (remove) it
    has O(n*n) performance.)�pop�remove�
ValueErrorr*)r-r.r1�itemr
r
r�unorderable_list_differencebsr9cCs||k||kS)z.Return -1 if x < y, 0 if x == y and 1 if x > yr
)�x�yr
r
r�
three_way_cmpssr<ZMismatchzactual expected valuecCsDt|�t|�}}t|�t|�}}t�}g}x�t|�D]�\}}	|	|krJq8d}
}x.t||�D] }|||	kr^|
d7}
|||<q^Wx,t|�D] \}}
|
|	kr�|d7}|||<q�W|
|kr8t|
||	�}|j|�q8Wxlt|�D]`\}}	|	|kr�q�d}x2t||�D]$}|||	k�r�|d7}|||<�q�Wtd||	�}|j|�q�W|S)zHReturns list of (cnt_act, cnt_exp, elem) triples where the counts differrr))�listrr!�	enumerate�range�	_Mismatchr*)r.r-r
�t�m�nZNULLr$r/�elem�cnt_s�cnt_tr0Z
other_elem�diffr
r
r�_count_diff_all_purposeys<rHcCs,t�}x |D]}|j|d�d||<qW|S)z@Return dict of element counts, in the order they were first seenrr))r�get)�iterable�crDr
r
r�_ordered_count�s
rLc	Cs�t|�t|�}}g}x>|j�D]2\}}|j|d�}||kr t|||�}|j|�q Wx2|j�D]&\}}||kr`td||�}|j|�q`W|S)zHReturns list of (cnt_act, cnt_exp, elem) triples where the counts differr)rL�itemsrIr@r*)	r.r-r
rAr$rDrErFrGr
r
r�_count_diff_hashable�srNN)F)�__doc__�collectionsrrZos.pathrZ
__unittestrr	rrrrrrrr(r4r9r<r@rHrLrNr
r
r
r�<module>s*
	)
#PKń[�E�8,6,6!__pycache__/loader.cpython-36.pycnu�[���3


 \�V�@sdZddlZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZmZdZ
ejdej�ZGdd	�d	e
j�Zd
d�Zdd
�Zdd�Zdd�Zdd�ZGdd�de�Ze�Zddd�Zejfdd�Zdejejfdd�Zdejejfdd�Z dS) zLoading unittests.�N)�fnmatch�)�case�suite�utilTz[_a-z]\w*\.py$cs,eZdZdZ�fdd�Z�fdd�Z�ZS)�_FailedTestNcs||_tt|�j|�dS)N)�
_exception�superr�__init__)�selfZmethod_name�	exception)�	__class__��'/usr/lib64/python3.6/unittest/loader.pyr
sz_FailedTest.__init__cs*|�jkrtt��j|�S�fdd�}|S)Ncs
�j�dS)N)rr)rrr�testFailure!sz,_FailedTest.__getattr__.<locals>.testFailure)�_testMethodNamer	r�__getattr__)r�namer)r
)rrrs
z_FailedTest.__getattr__)�__name__�
__module__�__qualname__rr
r�
__classcell__rr)r
rrsrcCs"d|tj�f}t|t|�||�S)Nz#Failed to import test module: %s
%s)�	traceback�
format_exc�_make_failed_test�ImportError)r�
suiteClass�messagerrr�_make_failed_import_test&srcCsdtj�f}t||||�S)NzFailed to call load_tests:
%s)rrr)rrrrrrr�_make_failed_load_tests+srcCst||�}||f�|fS)N)r)�
methodnamerrr�testrrrr0s
rcCs<tjt|��dd��}||i}tdtjf|�}|||�f�S)NcSsdS)Nr)rrrr�testSkipped5sz'_make_skipped_test.<locals>.testSkippedZ
ModuleSkipped)r�skip�str�type�TestCase)r rrr"�attrsZ	TestClassrrr�_make_skipped_test4sr(cCs*|j�jd�r|dd�Stjj|�dS)Nz	$py.class�	ri����)�lower�endswith�os�path�splitext)r-rrr�_jython_aware_splitext<sr/cs�eZdZdZdZeej�Ze	j
ZdZ�fdd�Z
dd�Zdd�d	d
�Zd!dd�Zd"d
d�Zdd�Zd#dd�Zdd�Zdd�Zdd�Zdd�Zd$dd�Zd%dd �Z�ZS)&�
TestLoaderz�
    This class is responsible for loading tests according to various criteria
    and returning them wrapped in a TestSuite
    r!Ncs tt|�j�g|_t�|_dS)N)r	r0r
�errors�set�_loading_packages)r)r
rrr
LszTestLoader.__init__cCsHt|tj�rtd��|j|�}|r4t|d�r4dg}|jt||��}|S)z;Return a suite of all test cases contained in testCaseClasszYTest cases should not be derived from TestSuite. Maybe you meant to derive from TestCase?ZrunTest)�
issubclassr�	TestSuite�	TypeError�getTestCaseNames�hasattrr�map)r�
testCaseClassZ
testCaseNamesZloaded_suiterrr�loadTestsFromTestCaseSs
z TestLoader.loadTestsFromTestCase)�patternc
Os2t|�dksd|kr,tjdt�|jdd�t|�dkrRt|�d}tdj|���t|�dkrxt|�d}tdj|���g}x@t|�D]4}t	||�}t
|t�r�t|t
j�r�|j|j|��q�Wt	|dd�}	|j|�}|	dk	�r.y|	|||�Stk
�r,}
z$t|j|
|j�\}}|jj|�|Sd}
~
XnX|S)	z>Return a suite of all test cases contained in the given modulerZuse_load_testsz(use_load_tests is deprecated and ignoredNrzCloadTestsFromModule() takes 1 positional argument but {} were givenz=loadTestsFromModule() got an unexpected keyword argument '{}'�
load_tests)�len�warnings�warn�DeprecationWarning�popr6�format�sorted�dir�getattr�
isinstancer%r4rr&�appendr;r�	Exceptionrrr1)
r�moduler<�argsZkwsZ	complaint�testsr�objr=�e�
error_case�
error_messagerrr�loadTestsFromModuleas4


zTestLoader.loadTestsFromModulecCs>|jd�}d\}}|dkr�|dd�}xb|r�ydj|�}t|�}PWq(tk
r�|j�}t||j�\}}|s�|jj|�|SYq(Xq(W|dd�}|}	x�|D]�}
y|	t	|	|
�}}	Wq�t
k
�r2}z\t	|	dd�dk	r�|dk	r�|jj|�|St|
||jdtj
�f�\}}|jj|�|SWYdd}~Xq�Xq�Wt|	tj��rP|j|	�St|	t��rtt|	tj��rt|j|	�St|	tj��r�t|t��r�t|tj��r�|d	}||�}
tt	|
|�tj��s�|j|
g�Snt|	tj��r�|	St|	��r.|	�}t|tj��r|St|tj��r|j|g�Std|	|f��ntd|	��dS)
aSReturn a suite of all test cases given a string specifier.

        The name may resolve either to a module, a test case class, a
        test method within a test case class, or a callable object which
        returns a TestCase or TestSuite instance.

        The method optionally resolves the names relative to a given module.
        �.Nr�__path__zFailed to access attribute:
%sz"calling %s returned %s, not a testz$don't know how to make test from: %s)NN���)�split�join�
__import__rrBrrr1rHrF�AttributeErrorrrrrG�types�
ModuleTyperQr%r4rr&r;�FunctionTyperr5�callabler6)rrrJ�partsrOrPZ
parts_copy�module_nameZnext_attributerM�part�parentrNZinstr!rrr�loadTestsFromName�sl	





zTestLoader.loadTestsFromNamecs��fdd�|D�}�j|�S)z�Return a suite of all test cases found using the given sequence
        of string specifiers. See 'loadTestsFromName()'.
        csg|]}�j|���qSr)ra)�.0r)rJrrr�
<listcomp>�sz1TestLoader.loadTestsFromNames.<locals>.<listcomp>)r)r�namesrJZsuitesr)rJrr�loadTestsFromNames�szTestLoader.loadTestsFromNamescCs@||jfdd�}tt|t|���}|jr<|jtj|j�d�|S)zLReturn a sorted sequence of method names found within testCaseClass
        cSs|j|�ott||��S)N)�
startswithr\rF)Zattrnamer:�prefixrrr�isTestMethod�s
z1TestLoader.getTestCaseNames.<locals>.isTestMethod)�key)�testMethodPrefix�list�filterrE�sortTestMethodsUsing�sort�	functools�
cmp_to_key)rr:rhZtestFnNamesrrrr7�szTestLoader.getTestCaseNames�test*.pycCsRd}|dkr|jdk	r|j}n|dkr.d}|}tjj|�}|tjkrRtjjd|�||_d}d}g}tjjtjj|��r�tjj|�}||kr�tjjtjj|d��}�nxyt	|�Wnt
k
r�d}Y�nRXtj|}|jd�d}	ytjjtjj
|j��}Wn�tk
�r�y
|j}
Wntk
�r8d}
YnX|
�r�|
jdk�r�|
jdk	�r�d}x�|jD]T}|�r�|j|��r��qd|j|jjdtjj��d|_|j|j||dd���qdWn*|jtjk�r�td�d�ntd	j|��d�YnX|�r |�s|j|	�|_tjj|�ntjj|�|�r2t
d
|��|�sHt|j||��}|j |�S)a%Find and return all test modules from the specified start
        directory, recursing into subdirectories to find them and return all
        tests found within them. Only test files that match the pattern will
        be loaded. (Using shell style pattern matching.)

        All test modules must be importable from the top level of the project.
        If the start directory is not the top level directory then the top
        level directory must be specified separately.

        If a test package name (directory with '__init__.py') matches the
        pattern then the package will be checked for a 'load_tests' function. If
        this exists then it will be called with (loader, tests, pattern) unless
        the package has already had load_tests called from the same discovery
        invocation, in which case the package module object is not scanned for
        tests - this ensures that when a package uses discover to further
        discover child tests that infinite recursion does not happen.

        If load_tests exists then discovery does *not* recurse into the package,
        load_tests is responsible for loading all tests in the package.

        The pattern is deliberately not stored as a loader attribute so that
        packages can continue discovery themselves. top_level_dir is stored so
        load_tests does not need to pass this argument in to loader.discover().

        Paths are sorted before being imported to ensure reproducible execution
        order even on filesystems with non-alphabetical ordering like ext3/4.
        FNTrz__init__.pyrR)�	namespacez2Can not use builtin modules as dotted module namesz$don't know how to discover from {!r}z%Start directory is not importable: %r)!�_top_level_dirr,r-�abspath�sys�insert�isdir�isfilerVrWr�modulesrU�dirname�__file__rX�__spec__�loader�submodule_search_locationsrSrfr�replace�sep�extend�_find_tests�builtin_module_namesr6rC� _get_directory_containing_module�removerkr)r�	start_dirr<Z
top_level_dirZset_implicit_topZis_not_importable�is_namespacerLZ
the_moduleZtop_part�specr-rrr�discover�sv





zTestLoader.discovercCsRtj|}tjj|j�}tjj|�j�jd�rBtjj	tjj	|��Stjj	|�SdS)Nz__init__.py)
ruryr,r-rtr{�basenamer*rfrz)rr^rJ�	full_pathrrrr�Xs

z+TestLoader._get_directory_containing_modulecCsl||jkrdSttjj|��}tjj||j�}tjj|�sDtd��|jd�sXtd��|j	tjj
d�}|S)NrRzPath must be within the projectz..)rsr/r,r-�normpath�relpath�isabs�AssertionErrorrfrr�)rr-Z_relpathrrrr�_get_name_from_pathds
zTestLoader._get_name_from_pathcCst|�tj|S)N)rWrury)rrrrr�_get_module_from_namepsz TestLoader._get_module_from_namecCs
t||�S)N)r)rr-r�r<rrr�_match_pathtszTestLoader._match_pathFc
cs�|j|�}|dkrD||jkrD|j|||�\}}|dk	r<|V|sDdSttj|��}x||D]t}tjj||�}	|j|	||�\}}|dk	r�|V|rX|j|	�}|jj|�z|j	|	||�EdHWd|jj
|�XqXWdS)z/Used by discovery. Yields test suites it loads.rRN)r�r3�_find_test_pathrDr,�listdirr-rV�addr��discard)
rr�r<rrrrLZshould_recurse�pathsr-r�rrrr�xs*


zTestLoader._find_testscCsPtjj|�}tjj|��rFtj|�s(d	S|j|||�s:d
S|j|�}y|j|�}WnXt	j
k
r�}zt|||j�dfSd}~Xn�t
||j�\}}	|jj|	�|dfStjjt|d|��}
ttjj|
��}ttjj|��}|j�|j�k�r0tjj|�}
ttjj|��}tjj|�}d}t|||
|f��|j||d�dfS�ntjj|��rH|�rztjjtjj|d���rzdSd}d}|j|�}y|j|�}WnZt	j
k
�r�}zt|||j�dfSd}~Xnzt
||j�\}}	|jj|	�|dfSt|dd�}|jj|�z(|j||d�}|dk	�r0|dfS|dfS|jj|�XndSdS)
z�Used by discovery.

        Loads tests from a single file, or a directories' __init__.py when
        passed the directory.

        Returns a tuple (None_or_tests_from_file, should_recurse).
        NFr{zW%r module incorrectly imported from %r. Expected %r. Is this module globally installed?)r<z__init__.pyr=T)NF)NF)NF)NF)r,r-r�rx�VALID_MODULE_NAME�matchr�r�r�rZSkipTestr(rrr1rHrtrFr/�realpathr*rzrrQrwrVr3r�r�)rr�r<rrr�rrJrNrOrPZmod_filer�Zfullpath_noextZ
module_dirZmod_nameZexpected_dir�msgr=rL�packagerrrr��sl



zTestLoader._find_test_path)N)N)rqN)F)F)rrr�__doc__rj�staticmethodr�
three_way_cmprmrr5rrsr
r;rQrarer7r�r�r�r�r�r�r�rrr)r
rr0Bs$
(
N

n
"r0cCs t�}||_||_|r||_|S)N)r0rmrjr)rg�	sortUsingrr}rrr�_makeLoader�sr�cCst||�j|�S)N)r�r7)r:rgr�rrrr7�sr7r!cCst|||�j|�S)N)r�r;)r:rgr�rrrr�	makeSuite�sr�cCst|||�j|�S)N)r�rQ)rJrgr�rrrr�
findTestCases�sr�)N)!r�r,�rerurrYror?r�rrrZ
__unittest�compile�
IGNORECASEr�r&rrrrr(r/�objectr0ZdefaultTestLoaderr�r�r7r5r�r�rrrr�<module>s8'
PKń[T`��aa'__pycache__/runner.cpython-36.opt-2.pycnu�[���3


 \G�@sjddlZddlZddlZddlmZddlmZdZGdd�de�Z	Gdd	�d	ej
�ZGd
d�de�ZdS)�N�)�result)�registerResultTc@s&eZdZdd�Zdd�Zddd�ZdS)	�_WritelnDecoratorcCs
||_dS)N)�stream)�selfr�r�'/usr/lib64/python3.6/unittest/runner.py�__init__sz_WritelnDecorator.__init__cCs|dkrt|��t|j|�S)Nr�__getstate__)rr)�AttributeError�getattrr)r�attrrrr	�__getattr__sz_WritelnDecorator.__getattr__NcCs|r|j|�|jd�dS)N�
)�write)r�argrrr	�writelns
z_WritelnDecorator.writeln)N)�__name__�
__module__�__qualname__r
rrrrrr	r
srcs�eZdZddZddZ�fdd�Zdd�Z�fdd	�Z�fd
d�Z�fdd
�Z	�fdd�Z
�fdd�Z�fdd�Z�fdd�Z
dd�Zdd�Z�ZS)�TextTestResult�=�F�-cs8tt|�j|||�||_|dk|_|dk|_||_dS)Nr)�superrr
r�showAll�dots�descriptions)rrr�	verbosity)�	__class__rr	r
%s


zTextTestResult.__init__cCs0|j�}|jr$|r$djt|�|f�St|�SdS)Nr)ZshortDescriptionr�join�str)r�testZdoc_first_linerrr	�getDescription,s
zTextTestResult.getDescriptioncsBtt|�j|�|jr>|jj|j|��|jjd�|jj�dS)Nz ... )rr�	startTestrrrr$�flush)rr#)r rr	r%3s
zTextTestResult.startTestcsDtt|�j|�|jr$|jjd�n|jr@|jjd�|jj�dS)N�ok�.)	rr�
addSuccessrrrrrr&)rr#)r rr	r):szTextTestResult.addSuccesscsFtt|�j||�|jr&|jjd�n|jrB|jjd�|jj�dS)N�ERROR�E)	rr�addErrorrrrrrr&)rr#�err)r rr	r,BszTextTestResult.addErrorcsFtt|�j||�|jr&|jjd�n|jrB|jjd�|jj�dS)N�FAIL�F)	rr�
addFailurerrrrrr&)rr#r-)r rr	r0JszTextTestResult.addFailurecsLtt|�j||�|jr,|jjdj|��n|jrH|jjd�|jj	�dS)Nz
skipped {0!r}�s)
rr�addSkiprrr�formatrrr&)rr#�reason)r rr	r2RszTextTestResult.addSkipcsFtt|�j||�|jr&|jjd�n|jrB|jjd�|jj�dS)Nzexpected failure�x)	rr�addExpectedFailurerrrrrr&)rr#r-)r rr	r6Zsz!TextTestResult.addExpectedFailurecsDtt|�j|�|jr$|jjd�n|jr@|jjd�|jj�dS)Nzunexpected success�u)	rr�addUnexpectedSuccessrrrrrr&)rr#)r rr	r8bsz#TextTestResult.addUnexpectedSuccesscCs6|js|jr|jj�|jd|j�|jd|j�dS)Nr*r.)rrrr�printErrorList�errors�failures)rrrr	�printErrorsjs
zTextTestResult.printErrorscCs\xV|D]N\}}|jj|j�|jjd||j|�f�|jj|j�|jjd|�qWdS)Nz%s: %sz%s)rr�
separator1r$�
separator2)rZflavourr:r#r-rrr	r9ps
zTextTestResult.printErrorList)rrrr=r>r
r$r%r)r,r0r2r6r8r<r9�
__classcell__rr)r r	rsrc@s0eZdZeZddd�dd�Zdd	�Zd
d�ZdS)
�TextTestRunnerNTrF)�	tb_localsc	CsN|dkrtj}t|�|_||_||_||_||_||_||_	|dk	rJ||_
dS)N)�sys�stderrrrrr�failfast�bufferrA�warnings�resultclass)	rrrrrDrErGrFrArrr	r
�s
zTextTestRunner.__init__cCs|j|j|j|j�S)N)rGrrr)rrrr	�_makeResult�szTextTestRunner._makeResultcCs4|j�}t|�|j|_|j|_|j|_tj���|jr^tj|j�|jdkr^tjdt	dd�t
j
�}t|dd�}|dk	r�|�z||�Wdt|dd�}|dk	r�|�Xt
j
�}WdQRX||}|j�t
|d�r�|jj|j�|j}|jjd	||d
k�rd�pd|f�|jj�d
}	}
}ytt|j|j|jf�}Wntk
�rVYnX|\}	}
}g}
|j��s�|jjd�t|j�t|j�}}|�r�|
jd|�|�r�|
jd|�n|jjd�|�r�|
jd|�|	�r�|
jd|	�|
�r|
jd|
�|
�r$|jjddj|
�f�n|jjd�|S)N�default�always�modulezPlease use assert\w+ instead.)�category�message�startTestRun�stopTestRunr>zRan %d test%s in %.3fsrr1�rZFAILEDzfailures=%dz	errors=%dZOKz
skipped=%dzexpected failures=%dzunexpected successes=%dz (%s)z, r)rIrJ)rHrrDrErArF�catch_warnings�simplefilter�filterwarnings�DeprecationWarning�timer
r<�hasattrrrr>ZtestsRun�map�lenZexpectedFailures�unexpectedSuccesses�skippedrZ
wasSuccessfulrr;r:�appendr!)rr#rZ	startTimerNrOZstopTimeZ	timeTaken�runZ
expectedFailsrYrZZresultsZinfosZfailedZerroredrrr	r\�sr





zTextTestRunner.run)NTrFFNN)rrrrrGr
rHr\rrrr	r@xsr@)
rBrUrFrPrZsignalsrZ
__unittest�objectrZ
TestResultrr@rrrr	�<module>s[PKń[nԀ<<'__pycache__/result.cpython-36.opt-1.pycnu�[���3


 \�@s\dZddlZddlZddlZddlmZddlmZdZdd�Z	d	Z
d
ZGdd�de�Z
dS)
zTest result object�N�)�util)�wrapsTcst���fdd��}|S)Ncs$t|dd�r|j��|f|�|�S)N�failfastF)�getattr�stop)�self�args�kw)�method��'/usr/lib64/python3.6/unittest/result.py�inner
szfailfast.<locals>.inner)r)rrr)rr
rsrz
Stdout:
%sz
Stderr:
%sc@s�eZdZdZdZdZdZd.dd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zedd��Zedd��Zdd�Zdd�Zdd�Zdd�Zed d!��Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�ZdS)/�
TestResulta�Holder for test result information.

    Test results are automatically managed by the TestCase and TestSuite
    classes, and do not need to be explicitly manipulated by writers of tests.

    Each instance holds the total number of tests run, and collections of
    failures and errors that occurred among those test runs. The collections
    contain tuples of (testcase, exceptioninfo), where exceptioninfo is the
    formatted traceback of the error that occurred.
    NFcCsbd|_g|_g|_d|_g|_g|_g|_d|_d|_d|_	d|_
d|_tj
|_tj|_d|_dS)NFr)r�failures�errors�testsRun�skipped�expectedFailures�unexpectedSuccesses�
shouldStop�buffer�	tb_locals�_stdout_buffer�_stderr_buffer�sys�stdout�_original_stdout�stderr�_original_stderr�
_mirrorOutput)r�streamZdescriptions�	verbosityrrr
�__init__&szTestResult.__init__cCsdS)z#Called by TestRunner after test runNr)rrrr
�printErrors7szTestResult.printErrorscCs |jd7_d|_|j�dS)z-Called when the given test is about to be runrFN)rr �_setupStdout)r�testrrr
�	startTest:szTestResult.startTestcCs8|jr4|jdkr$tj�|_tj�|_|jt_|jt_dS)N)rr�io�StringIOrrrr)rrrr
r%@s


zTestResult._setupStdoutcCsdS)zpCalled once before any tests are executed.

        See startTest for a method called before each test.
        Nr)rrrr
�startTestRunHszTestResult.startTestRuncCs|j�d|_dS)z'Called when the given test has been runFN)�_restoreStdoutr )rr&rrr
�stopTestNszTestResult.stopTestcCs�|jr�|jrltjj�}tjj�}|rF|jd�s6|d7}|jjt	|�|rl|jd�s\|d7}|j
jt|�|jt_|j
t_|jj
d�|jj�|jj
d�|jj�dS)N�
r)rr rr�getvaluer�endswithr�write�STDOUT_LINEr�STDERR_LINEr�seek�truncater)r�output�errorrrr
r+Ss$




zTestResult._restoreStdoutcCsdS)zmCalled once after all tests are executed.

        See stopTest for a method called after each test.
        Nr)rrrr
�stopTestRunhszTestResult.stopTestRuncCs"|jj||j||�f�d|_dS)zmCalled when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info().
        TN)r�append�_exc_info_to_stringr )rr&�errrrr
�addErrornszTestResult.addErrorcCs"|jj||j||�f�d|_dS)zdCalled when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info().TN)rr8r9r )rr&r:rrr
�
addFailurevszTestResult.addFailurecCsZ|dk	rVt|dd�r|j�t|d|j�r4|j}n|j}|j||j||�f�d|_dS)z�Called at the end of a subtest.
        'err' is None if the subtest ended successfully, otherwise it's a
        tuple of values as returned by sys.exc_info().
        NrFrT)	rr�
issubclass�failureExceptionrrr8r9r )rr&Zsubtestr:rrrr
�
addSubTest}szTestResult.addSubTestcCsdS)z-Called when a test has completed successfullyNr)rr&rrr
�
addSuccess�szTestResult.addSuccesscCs|jj||f�dS)zCalled when a test is skipped.N)rr8)rr&�reasonrrr
�addSkip�szTestResult.addSkipcCs|jj||j||�f�dS)z/Called when an expected failure/error occurred.N)rr8r9)rr&r:rrr
�addExpectedFailure�szTestResult.addExpectedFailurecCs|jj|�dS)z5Called when a test was expected to fail, but succeed.N)rr8)rr&rrr
�addUnexpectedSuccess�szTestResult.addUnexpectedSuccesscCs>t|j�t|j�kodkno<t|d�p<t|j�dkS)z/Tells whether or not this result was a success.rr)�lenrr�hasattrr)rrrr
�
wasSuccessful�s$zTestResult.wasSuccessfulcCs
d|_dS)z+Indicates that the tests should be aborted.TN)r)rrrr
r�szTestResult.stopcCs�|\}}}x|r"|j|�r"|j}qW||jkr:|j|�}nd}tj|||||jd�}t|j��}|j	r�t
jj�}	t
j
j�}
|	r�|	jd�s�|	d7}	|jt|	�|
r�|
jd�s�|
d7}
|jt|
�dj|�S)z>Converts a sys.exc_info()-style tuple of values into a string.N)�limit�capture_localsr-�)�_is_relevant_tb_level�tb_nextr>�_count_relevant_tb_levels�	traceback�TracebackExceptionr�list�formatrrrr.rr/r8r1r2�join)rr:r&�exctype�value�tb�lengthZtb_eZmsgLinesr5r6rrr
r9�s*






zTestResult._exc_info_to_stringcCsd|jjkS)N�
__unittest)�tb_frame�	f_globals)rrUrrr
rK�sz TestResult._is_relevant_tb_levelcCs,d}x"|r&|j|�r&|d7}|j}qW|S)Nrr)rKrL)rrUrVrrr
rM�s

z$TestResult._count_relevant_tb_levelscCs&dtj|j�|jt|j�t|j�fS)Nz!<%s run=%i errors=%i failures=%i>)rZstrclass�	__class__rrErr)rrrr
�__repr__�szTestResult.__repr__)NNN)�__name__�
__module__�__qualname__�__doc__Z_previousTestClassZ_testRunEnteredZ_moduleSetUpFailedr#r$r'r%r*r,r+r7rr;r<r?r@rBrCrDrGrr9rKrMr[rrrr
rs2

	r)r_r(rrNrJr�	functoolsrrWrr1r2�objectrrrrr
�<module>sPKń[���~~(__pycache__/signals.cpython-36.opt-1.pycnu�[���3


 \c	�@sbddlZddlZddlmZdZGdd�de�Zej�Zdd�Z	dd	�Z
dad
d�Zddd
�Z
dS)�N)�wrapsTc@seZdZdd�Zdd�ZdS)�_InterruptHandlercCsNd|_||_t|t�rD|tjkr(tj}n|tjkr<dd�}ntd��||_	dS)NFcSsdS)N�)Z
unused_signumZunused_framerr�(/usr/lib64/python3.6/unittest/signals.py�default_handlersz3_InterruptHandler.__init__.<locals>.default_handlerzYexpected SIGINT signal handler to be signal.SIG_IGN, signal.SIG_DFL, or a callable object)
�called�original_handler�
isinstance�int�signal�SIG_DFL�default_int_handler�SIG_IGN�	TypeErrorr)�selfrrrr�__init__
s



z_InterruptHandler.__init__cCsVtjtj�}||k	r |j||�|jr2|j||�d|_xtj�D]}|j�qBWdS)NT)r�	getsignal�SIGINTrr�_results�keys�stop)rZsignum�frameZinstalled_handler�resultrrr�__call__sz_InterruptHandler.__call__N)�__name__�
__module__�__qualname__rrrrrrr	srcCsdt|<dS)N�)r)rrrr�registerResult*srcCsttj|d��S)N)�boolr�pop)rrrr�removeResult-sr!cCs.tdkr*tjtj�}t|�atjtjt�dS)N)�_interrupt_handlerrrrr)rrrr�installHandler1sr#cs<�dk	r t���fdd��}|Stdk	r8tjtjtj�dS)Ncs2tjtj�}t�z
�||�Stjtj|�XdS)N)rrr�
removeHandler)�args�kwargs�initial)�methodrr�inner;s

zremoveHandler.<locals>.inner)rr"rrr)r(r)r)r(rr$9s
r$)N)r�weakref�	functoolsrZ
__unittest�objectr�WeakKeyDictionaryrrr!r"r#r$rrrr�<module>s PKń[�v��ff__pycache__/main.cpython-36.pycnu�[���3


 \8)�@sldZddlZddlZddlZddlmZmZddlmZdZ	dZ
dZd	d
�Zdd�Z
Gd
d�de�ZeZdS)zUnittest main program�N�)�loader�runner)�installHandlerTaExamples:
  %(prog)s test_module               - run tests from test_module
  %(prog)s module.TestClass          - run tests from module.TestClass
  %(prog)s module.Class.test_method  - run specified test method
  %(prog)s path/to/test_file.py      - run tests from test_file.py
aFExamples:
  %(prog)s                           - run default set of tests
  %(prog)s MyTestSuite               - run suite 'MyTestSuite'
  %(prog)s MyTestCase.testSomething  - run MyTestCase.testSomething
  %(prog)s MyTestCase                - run all 'test*' test methods
                                       in MyTestCase
cCsxtjj|�rt|j�jd�rttjj|�rXtjj|tj��}tjj|�sP|jtj	�rT|S|}|dd�j
dd�j
dd�S|S)Nz.py��\�.�/���)�os�path�isfile�lower�endswith�isabs�relpath�getcwd�
startswith�pardir�replace)�nameZrel_path�r�%/usr/lib64/python3.6/unittest/main.py�
_convert_namesrcCsdd�|D�S)NcSsg|]}t|��qSr)r)�.0rrrr�
<listcomp>.sz"_convert_names.<locals>.<listcomp>r)�namesrrr�_convert_names-src@s�eZdZdZdZdZdZZZZ	Z
dZddddej
ddddddfdd�dd	�Zdd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zddd�Zdd�ZdS) �TestProgramzA command-line program that runs a set of tests; this is primarily
       for making test modules conveniently executable.
    Nr�__main__TF)�	tb_localscCs�t|t�r@t|�|_x0|jd�dd�D]}
t|j|
�|_q(Wn||_|dkrTtj}||_||_	|	|_
||_|
|_||_
|dkr�tjr�d|_n||_||_||_||_tjj|d�|_|j|�|j�dS)Nrr�defaultr)�
isinstance�str�
__import__�module�split�getattr�sys�argv�exit�failfast�
catchbreak�	verbosity�bufferr �warnoptions�warnings�defaultTest�
testRunner�
testLoaderrr�basename�progName�	parseArgs�runTests)�selfr%r1r)r2r3r*r-r+r,r.r0r �partrrr�__init__;s,


zTestProgram.__init__cCs4|rt|�|jdkr|j�|j�tjd�dS)N�)�print�_discovery_parser�_initArgParsers�_print_helpr(r*)r8�msgrrr�	usageExitas
zTestProgram.usageExitcOsZ|jdkr6t|jj��ttd|ji�|jj�n t|jj��ttd|ji�dS)N�prog)	r%r<�_main_parserZformat_help�
MAIN_EXAMPLESr5r=�
print_help�MODULE_EXAMPLES)r8�args�kwargsrrrr?is
zTestProgram._print_helpcCs�|j�|jdkrpt|�dkrD|dj�dkrD|j|dd��dS|jj|dd�|�|js�|jg�dSn|jj|dd�|�|jr�t|j�|_	t
dkr�d|_n6|jdkr�d|_	n$t|jt
�r�|jf|_	nt|j�|_	|j�dS)Nr�discoverr;r)r>r%�lenr�
_do_discoveryrC�
parse_args�testsr�	testNames�__name__r1r"r#�list�createTests)r8r)rrrr6rs(


zTestProgram.parseArgscCs4|jdkr|jj|j�|_n|jj|j|j�|_dS)N)rNr3ZloadTestsFromModuler%�testZloadTestsFromNames)r8rrrrQ�s

zTestProgram.createTestscCs$|j�}|j|�|_|j|�|_dS)N)�_getParentArgParser�_getMainArgParserrC�_getDiscoveryArgParserr=)r8Z
parent_parserrrrr>�szTestProgram._initArgParserscCs�tjdd�}|jddddddd	�|jd
ddddd
d	�|jddddd�|jdkrn|jdddddd�d|_|jdkr�|jdddddd�d|_|jdkr�|jdddddd�d|_|S)NF)Zadd_helpz-vz	--verboser-Zstore_constr;zVerbose output)�dest�actionZconst�helpz-qz--quietrzQuiet outputz--localsr �
store_truez"Show local variables in tracebacks)rVrWrXz-fz
--failfastr+zStop on first fail or errorz-cz--catchr,z'Catch Ctrl-C and display results so farz-bz--bufferr.z%Buffer stdout and stderr during tests)�argparse�ArgumentParser�add_argumentr+r,r.)r8�parserrrrrS�s4







zTestProgram._getParentArgParsercCs2tj|gd�}|j|_|j|_|jdddd�|S)N)�parentsrM�*z?a list of any number of test modules, classes and test methods.)�nargsrX)rZr[r5rBr?rEr\)r8�parentr]rrrrT�szTestProgram._getMainArgParsercCs~tj|gd�}d|j|_d|_|jddddd�|jd	d
ddd�|jd
dddd�x"dD]}|j|dtjtjd�q\W|S)N)r^z%s discoverzcFor test discovery all test modules must be importable from the top level directory of the project.z-sz--start-directory�startz*Directory to start discovery ('.' default))rVrXz-pz	--pattern�patternz+Pattern to match tests ('test*.py' default)z-tz--top-level-directory�topz<Top level directory of project (defaults to start directory)�?)r`r!rX)rbrcrd)rZr[r5rBZepilogr\ZSUPPRESS)r8rar]�argrrrrU�s



z"TestProgram._getDiscoveryArgParsercCshd|_d|_d|_|dk	r:|jdkr,|j�|jj||�|dkrH|jn|�}|j|j|j|j�|_dS)Nrztest*.py)	rbrcrdr=r>rLr3rIrR)r8r)�LoaderrrrrrK�s
zTestProgram._do_discoverycCs�|jrt�|jdkrtj|_t|jt�r�yVy"|j|j|j|j	|j
|jd�}Wn.tk
r||j|j|j|j	|j
d�}YnXWq�tk
r�|j�}Yq�Xn|j}|j
|j�|_|jr�tj|jj��dS)N)r-r+r.r0r )r-r+r.r0)r,rr2rZTextTestRunnerr"�typer-r+r.r0r �	TypeErrorZrunrR�resultr*r(Z
wasSuccessful)r8r2rrrr7�s.
zTestProgram.runTests)N)N)rO�
__module__�__qualname__�__doc__r%r-r+r,r.r5r0r=rZdefaultTestLoaderr:rAr?r6rQr>rSrTrUrKr7rrrrr1s&#
	
r)rmr(rZr�rrZsignalsrZ
__unittestrDrFrr�objectr�mainrrrr�<module>s	TPKń[8��o����__pycache__/case.cpython-36.pycnu�[���3

�\dh���@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZmZmZmZmZdZe�ZdZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�ZGdd�de�Zdd�Zdd�Zdd�Zdd�Z dd�Z!dd�Z"Gdd�d�Z#dd�Z$Gd d!�d!e#�Z%Gd"d#�d#e%�Z&Gd$d%�d%e%�Z'e	j(d&d'd(g�Z)Gd)d*�d*ej*�Z+Gd+d,�d,e#�Z,Gd-d.�d.e�Z-Gd/d0�d0e-�Z.Gd1d2�d2e-�Z/dS)3zTest case implementation�N�)�result)�strclass�	safe_repr�_count_diff_all_purpose�_count_diff_hashable�_common_shorten_reprTz@
Diff is %s characters long. Set self.maxDiff to None to see it.c@seZdZdZdS)�SkipTestz�
    Raise this exception in a test to skip it.

    Usually you can use TestCase.skipTest() or one of the skipping decorators
    instead of raising this directly.
    N)�__name__�
__module__�__qualname__�__doc__�rr�%/usr/lib64/python3.6/unittest/case.pyr	sr	c@seZdZdZdS)�_ShouldStopz
    The test should stop.
    N)r
rrr
rrrrr"src@seZdZdZdS)�_UnexpectedSuccessz7
    The test was supposed to fail, but it didn't!
    N)r
rrr
rrrrr'src@s&eZdZddd�Zejddd��ZdS)	�_OutcomeNcCs4d|_||_t|d�|_d|_g|_d|_g|_dS)NF�
addSubTestT)�expecting_failurer�hasattr�result_supports_subtests�success�skipped�expectedFailure�errors)�selfrrrr�__init__.sz_Outcome.__init__Fccs�|j}d|_z�y
dVWn�tk
r.�Yn�tk
rh}z d|_|jj|t|�f�WYdd}~Xnjtk
rzYnXtj�}|j	r�||_
nd|_|jj||f�d}YnX|jr�|jr�|jj|df�Wd|jo�||_XdS)NTF)
r�KeyboardInterruptr	r�append�strr�sys�exc_inforrrr)r�	test_case�isTestZold_success�er!rrr�testPartExecutor7s*
$
z_Outcome.testPartExecutor)N)F)r
rrr�
contextlib�contextmanagerr%rrrrr-s
	rcCs|S)Nr)�objrrr�_idUsr)cs�fdd�}|S)z&
    Unconditionally skip a test.
    cs4t|t�s$tj|��fdd��}|}d|_�|_|S)Ncst���dS)N)r	)�args�kwargs)�reasonrr�skip_wrapper^sz-skip.<locals>.decorator.<locals>.skip_wrapperT)�
isinstance�type�	functools�wraps�__unittest_skip__�__unittest_skip_why__)�	test_itemr-)r,rr�	decorator\s
zskip.<locals>.decoratorr)r,r5r)r,r�skipXs
r6cCs|rt|�StS)z/
    Skip a test if the condition is true.
    )r6r))�	conditionr,rrr�skipIfhsr8cCs|st|�StS)z3
    Skip a test unless the condition is true.
    )r6r))r7r,rrr�
skipUnlesspsr9cCs
d|_|S)NT)�__unittest_expecting_failure__)r4rrrrxsrcs4t|t�r t�fdd�|D��St|t�o2t|��S)Nc3s|]}t|��VqdS)N)�_is_subtype)�.0r$)�basetyperr�	<genexpr>~sz_is_subtype.<locals>.<genexpr>)r.�tuple�allr/�
issubclass)�expectedr=r)r=rr;|s
r;c@seZdZdd�Zdd�ZdS)�_BaseTestCaseContextcCs
||_dS)N)r")rr"rrrr�sz_BaseTestCaseContext.__init__cCs |jj|j|�}|jj|��dS)N)r"�_formatMessage�msg�failureException)r�standardMsgrErrr�
_raiseFailure�sz"_BaseTestCaseContext._raiseFailureN)r
rrrrHrrrrrC�srCcCsdtjkrt|�StSdS)a
    Non-standard/downstream-only decorator for marking a specific unit test
    to be skipped when run within the %check of an rpmbuild.

    Specifically, this takes effect when WITHIN_PYTHON_RPM_BUILD is set within
    the environment, and has no effect otherwise.
    ZWITHIN_PYTHON_RPM_BUILDN)�os�environr6r))r,rrr�_skipInRpmBuild�s
rKc@seZdZddd�Zdd�ZdS)�_AssertRaisesBaseContextNcCs@tj||�||_||_|dk	r*tj|�}||_d|_d|_dS)N)	rCrrBr"�re�compile�expected_regex�obj_namerE)rrBr"rOrrrr�s
z!_AssertRaisesBaseContext.__init__cCs�z�t|j|j�s"td||jf��|rD|ddkrDtjdtd�f}|sx|jdd�|_	|rttjdt
t|��td�|S|^}}y|j|_
Wntk
r�t|�|_
YnX|�|||�WdQRXWdd}XdS)z�
        If args is empty, assertRaises/Warns is being used as a
        context manager, so check for a 'msg' kwarg and return self.
        If args is not empty, call a callable passing positional and keyword
        arguments.
        z%s() arg 1 must be %srNzcallable is None�rEz3%r is an invalid keyword argument for this function)r;rB�
_base_type�	TypeError�_base_type_str�warnings�warn�DeprecationWarning�poprE�next�iterr
rP�AttributeErrorr)r�namer*r+Zcallable_objrrr�handle�s.z_AssertRaisesBaseContext.handle)N)r
rrrr]rrrrrL�s

rLc@s(eZdZdZeZdZdd�Zdd�ZdS)�_AssertRaisesContextzCA context manager used to implement TestCase.assertRaises* methods.z-an exception type or tuple of exception typescCs|S)Nr)rrrr�	__enter__�sz_AssertRaisesContext.__enter__c
Cs�|dkrby|jj}Wntk
r2t|j�}YnX|jrP|jdj||j��ql|jdj|��n
tj|�t	||j�s|dS|j
d�|_|jdkr�dS|j}|j
t|��s�|jdj|jt|���dS)Nz{} not raised by {}z
{} not raisedFTz"{}" does not match "{}")rBr
r[rrPrH�format�	traceback�clear_framesrA�with_tracebackZ	exceptionrO�search�pattern)r�exc_type�	exc_value�tb�exc_namerOrrr�__exit__�s(


z_AssertRaisesContext.__exit__N)	r
rrr
�
BaseExceptionrRrTr_rjrrrrr^�s
r^c@s(eZdZdZeZdZdd�Zdd�ZdS)�_AssertWarnsContextzBA context manager used to implement TestCase.assertWarns* methods.z(a warning type or tuple of warning typescCsRx$tjj�D]}t|dd�ri|_qWtjdd�|_|jj�|_tj	d|j
�|S)N�__warningregistry__T)�record�always)r �modules�values�getattrrmrU�catch_warnings�warnings_managerr_�simplefilterrB)r�vrrrr_�s
z_AssertWarnsContext.__enter__c
Cs|jj|||�|dk	rdSy|jj}Wntk
rFt|j�}YnXd}xd|jD]Z}|j}t||j�slqT|dkrx|}|j	dk	r�|j	j
t|��r�qT||_|j|_|j
|_
dSW|dk	r�|jdj|j	jt|���|jr�|jdj||j��n|jdj|��dS)Nz"{}" does not match "{}"z{} not triggered by {}z{} not triggered)rtrjrBr
r[rrU�messager.rOrdZwarning�filename�linenorHr`rerP)rrfrgrhriZfirst_matching�m�wrrrrj�s8

z_AssertWarnsContext.__exit__N)	r
rrr
�WarningrRrTr_rjrrrrrl�s
rl�_LoggingWatcher�records�outputc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_CapturingHandlerzM
    A logging handler capturing all (raw and formatted) logging output.
    cCstjj|�tgg�|_dS)N)�logging�Handlerrr}�watcher)rrrrr,sz_CapturingHandler.__init__cCsdS)Nr)rrrr�flush0sz_CapturingHandler.flushcCs*|jjj|�|j|�}|jjj|�dS)N)r�r~rr`r)rrnrErrr�emit3s
z_CapturingHandler.emitN)r
rrr
rr�r�rrrrr�'sr�c@s,eZdZdZdZdd�Zdd�Zdd�Zd	S)
�_AssertLogsContextz:A context manager used to implement TestCase.assertLogs().z"%(levelname)s:%(name)s:%(message)scCs:tj||�||_|r(tjj||�|_ntj|_d|_dS)N)	rCr�logger_namer�Z_nameToLevel�get�level�INFOrE)rr"r�r�rrrr?sz_AssertLogsContext.__init__cCs�t|jtj�r|j}|_ntj|j�}|_tj|j�}t�}|j	|�|j
|_
|jdd�|_|j
|_|j|_|g|_|j|j
�d|_|j
S)NF)r.r�r�ZLogger�loggerZ	getLoggerZ	Formatter�LOGGING_FORMATr�ZsetFormatterr��handlers�old_handlersr��	old_level�	propagate�
old_propagate�setLevel)rr�Z	formatterZhandlerrrrr_Hs
z_AssertLogsContext.__enter__cCs`|j|j_|j|j_|jj|j�|dk	r.dSt|jj	�dkr\|j
djtj
|j�|jj��dS)NFrz-no logs of level {} or higher triggered on {})r�r�r�r�r�r�r��lenr�r~rHr`r�ZgetLevelNamer�r\)rrfrgrhrrrrjYs

z_AssertLogsContext.__exit__N)r
rrr
r�rr_rjrrrrr�:s
	r�c@s�eZdZdZeZdZd�Zd�ZdZ	d�d	d
�Z
dd�Zd
d�Zdd�Z
dd�Zedd��Zedd��Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zejefd)d*��Zd+d,�Zd-d.�Z d/d0�Z!d�d2d3�Z"d4d5�Z#d6d7�Z$d8d9�Z%d:d;�Z&d�d<d=�Z'd�d>d?�Z(d�d@dA�Z)dBdC�Z*dDdE�Z+dFdG�Z,d�dHdI�Z-dJdK�Z.d�dLdM�Z/d�dNdO�Z0d�dPdQ�Z1d�dRdS�Z2d�dTdU�Z3d�dVdW�Z4dXdY�Z5d�dZd[�Z6d�d\d]�Z7d�d^d_�Z8d�d`da�Z9d�dbdc�Z:d�ddde�Z;d�dfdg�Z<d�dhdi�Z=d�djdk�Z>d�dldm�Z?d�dndo�Z@d�dpdq�ZAd�drds�ZBd�dtdu�ZCd�dvdw�ZDd�dxdy�ZEd�dzd{�ZFd�d|d}�ZGd�d~d�ZHd�d��ZId�d��ZJd�d�d��ZKd�d�d��ZLd�d��ZMeMe0�ZNZOeMe1�ZPZQeMe2�ZRZSeMe3�ZTZUeMe)�ZVZWeMe+�ZXeMe(�ZYeMeI�ZZeMeK�Z[eMeL�Z\d1S)��TestCaseaWA class whose instances are single test cases.

    By default, the test code itself should be placed in a method named
    'runTest'.

    If the fixture may be used for many test cases, create as
    many test methods as are needed. When instantiating such a TestCase
    subclass, specify in the constructor arguments the name of the test method
    that the instance is to execute.

    Test authors should subclass TestCase for their own tests. Construction
    and deconstruction of the test's environment ('fixture') can be
    implemented by overriding the 'setUp' and 'tearDown' methods respectively.

    If it is necessary to override the __init__ method, the base class
    __init__ method must always be called. It is important that subclasses
    should not change the signature of their __init__ method, since instances
    of the classes are instantiated automatically by parts of the framework
    in order to be run.

    When subclassing TestCase, you can set these attributes:
    * failureException: determines which exception will be raised when
        the instance's assertion methods fail; test methods raising this
        exception will be deemed to have 'failed' rather than 'errored'.
    * longMessage: determines whether long messages (including repr of
        objects used in assert methods) will be printed on failure in *addition*
        to any explicit message passed.
    * maxDiff: sets the maximum length of a diff in failure messages
        by assert methods using difflib. It is looked up as an instance
        attribute so can be configured by individual tests if required.
    T�P���F�runTestcCs�||_d|_d|_yt||�}Wn.tk
rN|dkrJtd|j|f��Yn
X|j|_g|_d|_	i|_
|jtd�|jt
d�|jtd�|jtd�|jtd�|jtd	�dS)
z�Create an instance of the class that will use the named test
           method when executed. Raises a ValueError if the instance does
           not have a method with the specified name.
        NzNo testr�zno such test method in %s: %s�assertDictEqual�assertListEqual�assertTupleEqual�assertSetEqual�assertMultiLineEqual)�_testMethodName�_outcome�_testMethodDocrrr[�
ValueError�	__class__r
�	_cleanups�_subtest�_type_equality_funcs�addTypeEqualityFunc�dict�listr?�set�	frozensetr)rZ
methodName�
testMethodrrrr�s&zTestCase.__init__cCs||j|<dS)a[Add a type specific assertEqual style function to compare a type.

        This method is for use by TestCase subclasses that need to register
        their own type equality functions to provide nicer error messages.

        Args:
            typeobj: The data type to call this function on when both values
                    are of the same type in assertEqual().
            function: The callable taking two arguments and an optional
                    msg= argument that raises self.failureException with a
                    useful error message when the two arguments are not equal.
        N)r�)rZtypeobj�functionrrrr��s
zTestCase.addTypeEqualityFunccOs|jj|||f�dS)aAdd a function, with arguments, to be called when the test is
        completed. Functions added are called on a LIFO basis and are
        called after tearDown on test failure or success.

        Cleanup items are called even if setUp fails (unlike tearDown).N)r�r)rr�r*r+rrr�
addCleanup�szTestCase.addCleanupcCsdS)zAHook method for setting up the test fixture before exercising it.Nr)rrrr�setUp�szTestCase.setUpcCsdS)zAHook method for deconstructing the test fixture after testing it.Nr)rrrr�tearDown�szTestCase.tearDowncCsdS)zKHook method for setting up class fixture before running tests in the class.Nr)�clsrrr�
setUpClass�szTestCase.setUpClasscCsdS)zVHook method for deconstructing the class fixture after running all tests in the class.Nr)r�rrr�
tearDownClass�szTestCase.tearDownClasscCsdS)Nrr)rrrr�countTestCases�szTestCase.countTestCasescCstj�S)N)rZ
TestResult)rrrr�defaultTestResult�szTestCase.defaultTestResultcCs |j}|r|jd�dj�pdS)z�Returns a one-line description of the test, or None if no
        description has been provided.

        The default implementation of this method returns the first line of
        the specified test method's docstring.
        �
rN)r��split�strip)r�docrrr�shortDescription�szTestCase.shortDescriptioncCsdt|j�|jfS)Nz%s.%s)rr�r�)rrrr�id�szTestCase.idcCs t|�t|�k	rtS|j|jkS)N)r/�NotImplementedr�)r�otherrrr�__eq__�szTestCase.__eq__cCstt|�|jf�S)N)�hashr/r�)rrrr�__hash__�szTestCase.__hash__cCsd|jt|j�fS)Nz%s (%s))r�rr�)rrrr�__str__�szTestCase.__str__cCsdt|j�|jfS)Nz<%s testMethod=%s>)rr�r�)rrrr�__repr__�szTestCase.__repr__cCs<t|dd�}|dk	r |||�ntjdtd�|j|�dS)N�addSkipz4TestResult has no addSkip method, skips not reportedr�)rrrUrV�RuntimeWarning�
addSuccess)rrr"r,r�rrr�_addSkipszTestCase._addSkipcks�|jdks|jjrdVdS|j}|dkr8tj|�}n|jj|�}t|||�|_zX|jj|jdd��dVWdQRX|jj	s�|jj
}|dk	r�|jr�t�n|jj
r�t�Wd||_XdS)aPReturn a context manager that will return the enclosed block
        of code in a subtest identified by the optional message and
        keyword parameters.  A failure in the subtest marks the test
        case as failed but resumes execution at the end of the enclosed
        block, allowing further test code to be executed.
        NT)r#)r�rr��collections�ChainMap�params�	new_child�_SubTestr%rrZfailfastrr)rrEr��parentZ
params_maprrrr�subTest	s$zTestCase.subTestcCsdx^|D]V\}}t|t�r*|j|j||�q|dk	rt|d|j�rP|j||�q|j||�qWdS)Nr)r.r�rr"rArF�
addFailureZaddError)rrr�testr!rrr�_feedErrorsToResult(s
zTestCase._feedErrorsToResultcCsDy
|j}Wn*tk
r4tjdt�|j|�YnX|||�dS)Nz@TestResult has no addExpectedFailure method, reporting as passes)�addExpectedFailurer[rUrVr�r�)rrr!r�rrr�_addExpectedFailure2s
zTestCase._addExpectedFailurecCshy
|j}WnPtk
rZtjdt�y
td�Wn$tk
rT|j|tj��YnXYn
X||�dS)NzCTestResult has no addUnexpectedSuccess method, reporting as failure)	�addUnexpectedSuccessr[rUrVr�rr�r r!)rrr�rrr�_addUnexpectedSuccess<s

zTestCase._addUnexpectedSuccessNc
(Cs|}|dkr.|j�}t|dd�}|dk	r.|�|j|�t||j�}t|jdd�s^t|dd�r�z,t|jdd�pxt|dd�}|j|||�Wd|j|�XdSt|dd�}t|dd�}|p�|}t|�}	z�|	|_|	j	|��|j
�WdQRX|	j�r<||	_|	j	|dd��|�WdQRXd|	_|	j	|��|j
�WdQRX|j�x"|	jD]\}
}|j||
|��qLW|j||	j�|	j�r�|�r�|	j�r�|j||	j�n
|j|�n
|j|�|S|j|�|dk�r�t|d	d�}|dk	�r�|�|	jj�d|	_d|_XdS)
N�startTestRunr2Fr3�r:T)r#�stopTestRun)r�rrZ	startTestr�r�r�ZstopTestrr�r%r�rrr��
doCleanupsrr�rrr�r�r��clear)
rrZorig_resultr�r�Zskip_whyZexpecting_failure_methodZexpecting_failure_classr�outcomer�r,r�rrr�runKsh





zTestCase.runc
CsN|jp
t�}x:|jrF|jj�\}}}|j|��|||�WdQRXqW|jS)zNExecute all cleanup functions. Normally called for you after
        tearDown.N)r�rr�rXr%r)rr�r�r*r+rrrr��szTestCase.doCleanupscOs|j||�S)N)r�)rr*�kwdsrrr�__call__�szTestCase.__call__cCsJ|j�t||j��|j�x&|jrD|jjd�\}}}|||�q WdS)z6Run the test without collecting errors in a TestResultrN���)r�rrr�r�r�rX)rr�r*r+rrr�debug�szTestCase.debugcCst|��dS)zSkip this test.N)r	)rr,rrr�skipTest�szTestCase.skipTestcCs|j|��dS)z)Fail immediately, with the given message.N)rF)rrErrr�fail�sz
TestCase.failcCs&|r"|j|dt|��}|j|��dS)z#Check that the expression is false.z%s is not falseN)rDrrF)r�exprrErrr�assertFalse�szTestCase.assertFalsecCs&|s"|j|dt|��}|j|��dS)z"Check that the expression is true.z%s is not trueN)rDrrF)rr�rErrr�
assertTrue�szTestCase.assertTruecCsP|js|p|S|dkr|Syd||fStk
rJdt|�t|�fSXdS)a�Honour the longMessage attribute when generating failure messages.
        If longMessage is False this means:
        * Use only an explicit message if it is provided
        * Otherwise use the standard message for the assert

        If longMessage is True:
        * Use the standard message
        * If an explicit message is provided, plus ' : ' and the explicit message
        Nz%s : %s)�longMessage�UnicodeDecodeErrorr)rrErGrrrrD�s
zTestCase._formatMessagec
Os$t||�}z|jd||�Sd}XdS)a=Fail unless an exception of class expected_exception is raised
           by the callable when invoked with specified positional and
           keyword arguments. If a different type of exception is
           raised, it will not be caught, and the test case will be
           deemed to have suffered an error, exactly as for an
           unexpected exception.

           If called with the callable and arguments omitted, will return a
           context object used like this::

                with self.assertRaises(SomeException):
                    do_something()

           An optional keyword argument 'msg' can be provided when assertRaises
           is used as a context object.

           The context manager keeps a reference to the exception as
           the 'exception' attribute. This allows you to inspect the
           exception after the assertion::

               with self.assertRaises(SomeException) as cm:
                   do_something()
               the_exception = cm.exception
               self.assertEqual(the_exception.error_code, 3)
        �assertRaisesN)r^r])r�expected_exceptionr*r+�contextrrrr��s
zTestCase.assertRaisescOst||�}|jd||�S)a�Fail unless a warning of class warnClass is triggered
           by the callable when invoked with specified positional and
           keyword arguments.  If a different type of warning is
           triggered, it will not be handled: depending on the other
           warning filtering rules in effect, it might be silenced, printed
           out, or raised as an exception.

           If called with the callable and arguments omitted, will return a
           context object used like this::

                with self.assertWarns(SomeWarning):
                    do_something()

           An optional keyword argument 'msg' can be provided when assertWarns
           is used as a context object.

           The context manager keeps a reference to the first matching
           warning as the 'warning' attribute; similarly, the 'filename'
           and 'lineno' attributes give you information about the line
           of Python code from which the warning was triggered.
           This allows you to inspect the warning after the assertion::

               with self.assertWarns(SomeWarning) as cm:
                   do_something()
               the_warning = cm.warning
               self.assertEqual(the_warning.some_attribute, 147)
        �assertWarns)rlr])r�expected_warningr*r+r�rrrr��s
zTestCase.assertWarnscCst|||�S)a�Fail unless a log message of level *level* or higher is emitted
        on *logger_name* or its children.  If omitted, *level* defaults to
        INFO and *logger* defaults to the root logger.

        This method must be used as a context manager, and will yield
        a recording object with two attributes: `output` and `records`.
        At the end of the context manager, the `output` attribute will
        be a list of the matching formatted log messages and the
        `records` attribute will be a list of the corresponding LogRecord
        objects.

        Example::

            with self.assertLogs('foo', level='INFO') as cm:
                logging.getLogger('foo').info('first message')
                logging.getLogger('foo.bar').error('second message')
            self.assertEqual(cm.output, ['INFO:foo:first message',
                                         'ERROR:foo.bar:second message'])
        )r�)rr�r�rrr�
assertLogsszTestCase.assertLogscCsFt|�t|�kr@|jjt|��}|dk	r@t|t�r<t||�}|S|jS)aGet a detailed comparison function for the types of the two args.

        Returns: A callable accepting (first, second, msg=None) that will
        raise a failure exception if first != second with a useful human
        readable error message for those types.
        N)r/r�r�r.rrr�_baseAssertEqual)r�first�secondZasserterrrr�_getAssertEqualityFunc(s

zTestCase._getAssertEqualityFunccCs0||ks,dt||�}|j||�}|j|��dS)z:The default assertEqual implementation, not type specific.z%s != %sN)rrDrF)rr�r�rErGrrrr�BszTestCase._baseAssertEqualcCs|j||�}||||d�dS)z[Fail if the two objects are unequal as determined by the '=='
           operator.
        )rEN)r�)rr�r�rEZassertion_funcrrr�assertEqualIszTestCase.assertEqualcCs2||ks.|j|dt|�t|�f�}|j|��dS)zYFail if the two objects are equal as determined by the '!='
           operator.
        z%s == %sN)rDrrF)rr�r�rErrr�assertNotEqualPszTestCase.assertNotEqualcCs�||krdS|dk	r$|dk	r$td��|dk	r\t||�|kr@dSdt|�t|�t|�f}n<|dkrhd}tt||�|�dkr�dSdt|�t|�|f}|j||�}|j|��dS)a'Fail if the two objects are unequal as determined by their
           difference rounded to the given number of decimal places
           (default 7) and comparing to zero, or by comparing that the
           difference between the two objects is more than the given
           delta.

           Note that decimal places (from zero) are usually not the same
           as significant digits (measured from the most significant digit).

           If the two objects compare equal then they will automatically
           compare almost equal.
        Nz specify delta or places not bothz%s != %s within %s delta�rz%s != %s within %r places)rS�absr�roundrDrF)rr�r��placesrE�deltarGrrr�assertAlmostEqualYs&zTestCase.assertAlmostEqualcCs�|dk	r|dk	rtd��|dk	rZ||kr>t||�|kr>dSdt|�t|�t|�f}nF|dkrfd}||kr�tt||�|�dkr�dSdt|�t|�|f}|j||�}|j|��dS)a�Fail if the two objects are equal as determined by their
           difference rounded to the given number of decimal places
           (default 7) and comparing to zero, or by comparing that the
           difference between the two objects is less than the given delta.

           Note that decimal places (from zero) are usually not the same
           as significant digits (measured from the most significant digit).

           Objects that are equal automatically fail.
        Nz specify delta or places not bothz%s == %s within %s deltar�rz%s == %s within %r places)rSr�rr�rDrF)rr�r�r�rEr�rGrrr�assertNotAlmostEqual�s" zTestCase.assertNotAlmostEqualc'Cs�|dk	rP|j}t||�s.|jd|t|�f��t||�sT|jd|t|�f��nd}d}yt|�}Wn ttfk
r�d|}YnX|dkr�yt|�}Wn ttfk
r�d|}YnX|dk�r�||kr�dSd|j�ft||�}x�t	t
||��D]�}	y||	}
Wn.tttfk
�r8|d|	|f7}PYnXy||	}Wn.tttfk
�rt|d	|	|f7}PYnX|
|kr�|d
|	ft|
|�7}Pq�W||k�r�|dk�r�t|�t|�k�r�dS||k�r0|d|||f7}y|d|t||�f7}Wn,tttfk
�r,|d
||f7}YnXnh||k�r�|d|||f7}y|d|t||�f7}Wn,tttfk
�r�|d||f7}YnX|}ddj
tjtj|�j�tj|�j���}
|j||
�}|j||�}|j|�dS)aAAn equality assertion for ordered sequences (like lists and tuples).

        For the purposes of this function, a valid ordered sequence type is one
        which can be indexed, has a length, and has an equality operator.

        Args:
            seq1: The first sequence to compare.
            seq2: The second sequence to compare.
            seq_type: The expected datatype of the sequences, or None if no
                    datatype should be enforced.
            msg: Optional message to use on failure instead of a list of
                    differences.
        NzFirst sequence is not a %s: %szSecond sequence is not a %s: %sZsequencez(First %s has no length.    Non-sequence?z)Second %s has no length.    Non-sequence?z%ss differ: %s != %s
z(
Unable to index element %d of first %s
z)
Unable to index element %d of second %s
z#
First differing element %d:
%s
%s
z+
First %s contains %d additional elements.
zFirst extra element %d:
%s
z'Unable to index element %d of first %s
z,
Second %s contains %d additional elements.
z(Unable to index element %d of second %s
r�)r
r.rFrr�rS�NotImplementedError�
capitalizer�range�min�
IndexErrorr/�join�difflib�ndiff�pprint�pformat�
splitlines�_truncateMessagerDr�)rZseq1Zseq2rE�seq_typeZ
seq_type_nameZ	differingZlen1Zlen2�iZitem1Zitem2rG�diffMsgrrr�assertSequenceEqual�s�




zTestCase.assertSequenceEqualcCs2|j}|dkst|�|kr"||S|tt|�S)N)�maxDiffr��DIFF_OMITTED)rrw�diffZmax_diffrrrrszTestCase._truncateMessagecCs|j|||td�dS)aA list-specific equality assertion.

        Args:
            list1: The first list to compare.
            list2: The second list to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.

        )rN)r	r�)rZlist1Zlist2rErrrr�s
zTestCase.assertListEqualcCs|j|||td�dS)aA tuple-specific equality assertion.

        Args:
            tuple1: The first tuple to compare.
            tuple2: The second tuple to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.
        )rN)r	r?)rZtuple1Ztuple2rErrrr�s	zTestCase.assertTupleEqualc
 Cshy|j|�}Wn^tk
r>}z|jd|�WYdd}~Xn0tk
rl}z|jd|�WYdd}~XnXy|j|�}Wn^tk
r�}z|jd|�WYdd}~Xn0tk
r�}z|jd|�WYdd}~XnX|p�|s�dSg}|�r|jd�x|D]}|jt|���qW|�rH|jd�x|D]}|jt|���q0Wdj|�}	|j|j||	��dS)a�A set-specific equality assertion.

        Args:
            set1: The first set to compare.
            set2: The second set to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.

        assertSetEqual uses ducktyping to support different types of sets, and
        is optimized for sets specifically (parameters must support a
        difference method).
        z/invalid type when attempting set difference: %sNz2first argument does not support set difference: %sz3second argument does not support set difference: %sz*Items in the first set but not the second:z*Items in the second set but not the first:r�)�
differencerSr�r[r�reprr�rD)
rZset1Zset2rEZdifference1r$Zdifference2�lines�itemrGrrrr�"s2
  




zTestCase.assertSetEqualcCs2||kr.dt|�t|�f}|j|j||��dS)zDJust like self.assertTrue(a in b), but with a nicer default message.z%s not found in %sN)rr�rD)r�member�	containerrErGrrr�assertInMszTestCase.assertIncCs2||kr.dt|�t|�f}|j|j||��dS)zHJust like self.assertTrue(a not in b), but with a nicer default message.z%s unexpectedly found in %sN)rr�rD)rrrrErGrrr�assertNotInTszTestCase.assertNotIncCs2||k	r.dt|�t|�f}|j|j||��dS)zDJust like self.assertTrue(a is b), but with a nicer default message.z%s is not %sN)rr�rD)r�expr1�expr2rErGrrr�assertIs[szTestCase.assertIscCs,||kr(dt|�f}|j|j||��dS)zHJust like self.assertTrue(a is not b), but with a nicer default message.zunexpectedly identical: %sN)rr�rD)rrrrErGrrr�assertIsNotbszTestCase.assertIsNotcCs~|j|td�|j|td�||krzdt||�}ddjtjtj|�j�tj|�j���}|j	||�}|j
|j||��dS)Nz"First argument is not a dictionaryz#Second argument is not a dictionaryz%s != %sr�)�assertIsInstancer�rr�rrrrrrr�rD)rZd1Zd2rErGrrrrr�hs
zTestCase.assertDictEqualc	Cs�tjdt�g}g}xX|j�D]L\}}||kr:|j|�q|||kr|jdt|�t|�t||�f�qW|pt|szdSd}|r�ddjdd�|D��}|r�|r�|d	7}|d
dj|�7}|j|j||��dS)z2Checks whether dictionary is a superset of subset.z&assertDictContainsSubset is deprecatedz%s, expected: %s, actual: %sNr�zMissing: %s�,css|]}t|�VqdS)N)r)r<rzrrrr>�sz4TestCase.assertDictContainsSubset.<locals>.<genexpr>z; zMismatched values: %s)	rUrVrW�itemsrrr�r�rD)	rZsubsetZ
dictionaryrEZmissingZ
mismatched�key�valuerGrrr�assertDictContainsSubsetts,z!TestCase.assertDictContainsSubsetc
Cs�t|�t|�}}ytj|�}tj|�}Wntk
rHt||�}YnX||krVdSt||�}|r�d}dd�|D�}dj|�}	|j||	�}|j||�}|j	|�dS)a�An unordered sequence comparison asserting that the same elements,
        regardless of order.  If the same element occurs more than once,
        it verifies that the elements occur the same number of times.

            self.assertEqual(Counter(list(first)),
                             Counter(list(second)))

         Example:
            - [0, 1, 1] and [1, 0, 1] compare equal.
            - [0, 0, 1] and [0, 1] compare unequal.

        NzElement counts were not equal:
cSsg|]}d|�qS)z First has %d, Second has %d:  %rr)r<rrrr�
<listcomp>�sz-TestCase.assertCountEqual.<locals>.<listcomp>r�)
r�r��CounterrSrrr�rrDr�)
rr�r�rEZ	first_seqZ
second_seqZdifferencesrGrrrrr�assertCountEqual�s 



zTestCase.assertCountEqualcCs�|j|td�|j|td�||kr�t|�|jks@t|�|jkrN|j|||�|jdd�}|jdd�}t|�dkr�|jd�|kr�|dg}|dg}dt||�}dd	jt	j
||��}|j||�}|j|j
||��d
S)z-Assert that two multi-line strings are equal.zFirst argument is not a stringzSecond argument is not a stringT)�keependsrz
r�z%s != %sr�N)rrr��_diffThresholdr�rr�rr�rrrr�rD)rr�r�rEZ
firstlinesZsecondlinesrGrrrrr��s

zTestCase.assertMultiLineEqualcCs2||ks.dt|�t|�f}|j|j||��dS)zCJust like self.assertTrue(a < b), but with a nicer default message.z%s not less than %sN)rr�rD)r�a�brErGrrr�
assertLess�szTestCase.assertLesscCs2||ks.dt|�t|�f}|j|j||��dS)zDJust like self.assertTrue(a <= b), but with a nicer default message.z%s not less than or equal to %sN)rr�rD)rr$r%rErGrrr�assertLessEqual�szTestCase.assertLessEqualcCs2||ks.dt|�t|�f}|j|j||��dS)zCJust like self.assertTrue(a > b), but with a nicer default message.z%s not greater than %sN)rr�rD)rr$r%rErGrrr�
assertGreater�szTestCase.assertGreatercCs2||ks.dt|�t|�f}|j|j||��dS)zDJust like self.assertTrue(a >= b), but with a nicer default message.z"%s not greater than or equal to %sN)rr�rD)rr$r%rErGrrr�assertGreaterEqual�szTestCase.assertGreaterEqualcCs,|dk	r(dt|�f}|j|j||��dS)zCSame as self.assertTrue(obj is None), with a nicer default message.Nz%s is not None)rr�rD)rr(rErGrrr�assertIsNone�szTestCase.assertIsNonecCs"|dkrd}|j|j||��dS)z(Included for symmetry with assertIsNone.Nzunexpectedly None)r�rD)rr(rErGrrr�assertIsNotNone�szTestCase.assertIsNotNonecCs0t||�s,dt|�|f}|j|j||��dS)zTSame as self.assertTrue(isinstance(obj, cls)), with a nicer
        default message.z%s is not an instance of %rN)r.rr�rD)rr(r�rErGrrrr�s
zTestCase.assertIsInstancecCs0t||�r,dt|�|f}|j|j||��dS)z,Included for symmetry with assertIsInstance.z%s is an instance of %rN)r.rr�rD)rr(r�rErGrrr�assertNotIsInstance�s
zTestCase.assertNotIsInstancecOst|||�}|jd||�S)aAsserts that the message in a raised exception matches a regex.

        Args:
            expected_exception: Exception class expected to be raised.
            expected_regex: Regex (re pattern object or string) expected
                    to be found in error message.
            args: Function to be called and extra positional args.
            kwargs: Extra kwargs.
            msg: Optional message used in case of failure. Can only be used
                    when assertRaisesRegex is used as a context manager.
        �assertRaisesRegex)r^r])rr�rOr*r+r�rrrr-�s
zTestCase.assertRaisesRegexcOst|||�}|jd||�S)a�Asserts that the message in a triggered warning matches a regexp.
        Basic functioning is similar to assertWarns() with the addition
        that only warnings whose messages also match the regular expression
        are considered successful matches.

        Args:
            expected_warning: Warning class expected to be triggered.
            expected_regex: Regex (re pattern object or string) expected
                    to be found in error message.
            args: Function to be called and extra positional args.
            kwargs: Extra kwargs.
            msg: Optional message used in case of failure. Can only be used
                    when assertWarnsRegex is used as a context manager.
        �assertWarnsRegex)rlr])rr�rOr*r+r�rrrr.szTestCase.assertWarnsRegexcCsVt|ttf�r$|std��tj|�}|j|�sRd|j|f}|j||�}|j	|��dS)z=Fail the test unless the text matches the regular expression.z!expected_regex must not be empty.z&Regex didn't match: %r not found in %rN)
r.r�bytes�AssertionErrorrMrNrdrerDrF)r�textrOrErGrrr�assertRegexs

zTestCase.assertRegexcCs`t|ttf�rtj|�}|j|�}|r\d||j�|j��|j|f}|j	||�}|j
|��dS)z9Fail the test if the text matches the regular expression.z"Regex matched: %r matches %r in %rN)r.rr/rMrNrd�start�endrerDrF)rr1Zunexpected_regexrE�matchrGrrr�assertNotRegex&s

zTestCase.assertNotRegexcs�fdd�}|S)Ncs tjdj�j�td��||�S)NzPlease use {0} instead.r�)rUrVr`r
rW)r*r+)�
original_funcrr�deprecated_func6s
z,TestCase._deprecate.<locals>.deprecated_funcr)r7r8r)r7r�
_deprecate5szTestCase._deprecatei�i)r�)N)N)N)N)NN)N)N)N)NNN)NNN)NN)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)]r
rrr
r0rFr�r
r#Z_classSetupFailedrr�r�r�r��classmethodr�r�r�r�r�r�r�r�r�r�r�r&r'�_subtest_msg_sentinelr�r�r�r�r�r�r�r�r�r�r�r�rDr�r�r�r�r�r�r�r�r�r	rr�r�r�rrrrr�rr!r�r&r'r(r)r*r+rr,r-r.r2r6r9ZfailUnlessEqualZassertEqualsZfailIfEqualZassertNotEqualsZfailUnlessAlmostEqualZassertAlmostEqualsZfailIfAlmostEqualZassertNotAlmostEqualsZ
failUnlessZassert_ZfailUnlessRaisesZfailIfZassertRaisesRegexpZassertRegexpMatchesZassertNotRegexpMatchesrrrrr�fs�
 	


E
	


!



	
'
 
c


+






!










	r�csjeZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
�ZS)�FunctionTestCaseaIA test case that wraps a test function.

    This is useful for slipping pre-existing test functions into the
    unittest framework. Optionally, set-up and tidy-up functions can be
    supplied. As with TestCase, the tidy-up ('tearDown') function will
    always be called if the set-up ('setUp') function ran successfully.
    Ncs*tt|�j�||_||_||_||_dS)N)�superr<r�
_setUpFunc�
_tearDownFunc�	_testFunc�_description)rZtestFuncr�r�Zdescription)r�rrrTs
zFunctionTestCase.__init__cCs|jdk	r|j�dS)N)r>)rrrrr�[s
zFunctionTestCase.setUpcCs|jdk	r|j�dS)N)r?)rrrrr�_s
zFunctionTestCase.tearDowncCs|j�dS)N)r@)rrrrr�cszFunctionTestCase.runTestcCs|jjS)N)r@r
)rrrrr�fszFunctionTestCase.idcCs@t||j�stS|j|jko>|j|jko>|j|jko>|j|jkS)N)r.r�r�r>r?r@rA)rr�rrrr�iszFunctionTestCase.__eq__cCstt|�|j|j|j|jf�S)N)r�r/r>r?r@rA)rrrrr�rszFunctionTestCase.__hash__cCsdt|j�|jjfS)Nz%s (%s))rr�r@r
)rrrrr�vs
zFunctionTestCase.__str__cCsdt|j�|jfS)Nz<%s tec=%s>)rr�r@)rrrrr�zs
zFunctionTestCase.__repr__cCs2|jdk	r|jS|jj}|r.|jd�dj�p0dS)Nr�r)rAr@r
r�r�)rr�rrrr�~s
z!FunctionTestCase.shortDescription)NNN)r
rrr
rr�r�r�r�r�r�r�r�r��
__classcell__rr)r�rr<Ks	r<csDeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z�Z	S)
r�cs(t�j�||_||_||_|j|_dS)N)r=r�_messager"r�rF)rr"rwr�)r�rrr�s

z_SubTest.__init__cCstd��dS)Nzsubtests cannot be run directly)r�)rrrrr��sz_SubTest.runTestcCsbg}|jtk	r |jdj|j��|jrTdjdd�t|jj��D��}|jdj|��dj|�p`dS)Nz[{}]z, css|]\}}dj||�VqdS)z{}={!r}N)r`)r<�krvrrrr>�sz+_SubTest._subDescription.<locals>.<genexpr>z({})� z(<subtest>))rCr;rr`r�r��sortedr)r�partsZparams_descrrr�_subDescription�s
z_SubTest._subDescriptioncCsdj|jj�|j��S)Nz{} {})r`r"r�rH)rrrrr��sz_SubTest.idcCs
|jj�S)zlReturns a one-line description of the subtest, or None if no
        description has been provided.
        )r"r�)rrrrr��sz_SubTest.shortDescriptioncCsdj|j|j��S)Nz{} {})r`r"rH)rrrrr��sz_SubTest.__str__)
r
rrrr�rHr�r�r�rBrr)r�rr��sr�)0r
r r0rrIr�rrMrUr�r&rar�r�utilrrrrrZ
__unittest�objectr;r�	Exceptionr	rrrr)r6r8r9rr;rCrKrLr^rl�
namedtupler}r�r�r�r�r<r�rrrr�<module>sZ(
/%5
,l:PKń[v�?��#__pycache__/__main__.cpython-36.pycnu�[���3


 \��@sddZddlZejdjd�rBddlZejjej�Zedejd<[dZ	ddl
m
Z
mZe
dd�dS)	zMain entry point�Nz__main__.pyz -m unittestT�)�main�TestProgram)�module)�__doc__�sys�argv�endswithZos.path�os�path�basename�
executableZ
__unittestrr�rr�)/usr/lib64/python3.6/unittest/__main__.py�<module>sPKń[��kH��!__pycache__/runner.cpython-36.pycnu�[���3


 \G�@sndZddlZddlZddlZddlmZddlmZdZGdd�de	�Z
Gd	d
�d
ej�ZGdd�de	�Z
dS)
z
Running tests�N�)�result)�registerResultTc@s*eZdZdZdd�Zdd�Zd	dd�ZdS)
�_WritelnDecoratorz@Used to decorate file-like objects with a handy 'writeln' methodcCs
||_dS)N)�stream)�selfr�r�'/usr/lib64/python3.6/unittest/runner.py�__init__sz_WritelnDecorator.__init__cCs|dkrt|��t|j|�S)Nr�__getstate__)rr)�AttributeError�getattrr)r�attrrrr	�__getattr__sz_WritelnDecorator.__getattr__NcCs|r|j|�|jd�dS)N�
)�write)r�argrrr	�writelns
z_WritelnDecorator.writeln)N)�__name__�
__module__�__qualname__�__doc__r
rrrrrr	r
srcs�eZdZdZddZddZ�fdd�Zdd�Z�fd	d
�Z�fdd�Z	�fd
d�Z
�fdd�Z�fdd�Z�fdd�Z
�fdd�Zdd�Zdd�Z�ZS)�TextTestResultzhA test result class that can print formatted text results to a stream.

    Used by TextTestRunner.
    �=�F�-cs8tt|�j|||�||_|dk|_|dk|_||_dS)Nr)�superrr
r�showAll�dots�descriptions)rrr�	verbosity)�	__class__rr	r
%s


zTextTestResult.__init__cCs0|j�}|jr$|r$djt|�|f�St|�SdS)Nr)ZshortDescriptionr�join�str)r�testZdoc_first_linerrr	�getDescription,s
zTextTestResult.getDescriptioncsBtt|�j|�|jr>|jj|j|��|jjd�|jj�dS)Nz ... )rr�	startTestrrrr%�flush)rr$)r!rr	r&3s
zTextTestResult.startTestcsDtt|�j|�|jr$|jjd�n|jr@|jjd�|jj�dS)N�ok�.)	rr�
addSuccessrrrrrr')rr$)r!rr	r*:szTextTestResult.addSuccesscsFtt|�j||�|jr&|jjd�n|jrB|jjd�|jj�dS)N�ERROR�E)	rr�addErrorrrrrrr')rr$�err)r!rr	r-BszTextTestResult.addErrorcsFtt|�j||�|jr&|jjd�n|jrB|jjd�|jj�dS)N�FAIL�F)	rr�
addFailurerrrrrr')rr$r.)r!rr	r1JszTextTestResult.addFailurecsLtt|�j||�|jr,|jjdj|��n|jrH|jjd�|jj	�dS)Nz
skipped {0!r}�s)
rr�addSkiprrr�formatrrr')rr$�reason)r!rr	r3RszTextTestResult.addSkipcsFtt|�j||�|jr&|jjd�n|jrB|jjd�|jj�dS)Nzexpected failure�x)	rr�addExpectedFailurerrrrrr')rr$r.)r!rr	r7Zsz!TextTestResult.addExpectedFailurecsDtt|�j|�|jr$|jjd�n|jr@|jjd�|jj�dS)Nzunexpected success�u)	rr�addUnexpectedSuccessrrrrrr')rr$)r!rr	r9bsz#TextTestResult.addUnexpectedSuccesscCs6|js|jr|jj�|jd|j�|jd|j�dS)Nr+r/)rrrr�printErrorList�errors�failures)rrrr	�printErrorsjs
zTextTestResult.printErrorscCs\xV|D]N\}}|jj|j�|jjd||j|�f�|jj|j�|jjd|�qWdS)Nz%s: %sz%s)rr�
separator1r%�
separator2)rZflavourr;r$r.rrr	r:ps
zTextTestResult.printErrorList)rrrrr>r?r
r%r&r*r-r1r3r7r9r=r:�
__classcell__rr)r!r	rsrc@s4eZdZdZeZd
dd�dd�Zd	d
�Zdd�ZdS)�TextTestRunnerz�A test runner class that displays results in textual form.

    It prints out the names of tests as they are run, errors as they
    occur, and a summary of the results at the end of the test run.
    NTrF)�	tb_localsc	CsN|dkrtj}t|�|_||_||_||_||_||_||_	|dk	rJ||_
dS)z�Construct a TextTestRunner.

        Subclasses should accept **kwargs to ensure compatibility as the
        interface changes.
        N)�sys�stderrrrrr �failfast�bufferrB�warnings�resultclass)	rrrr rErFrHrGrBrrr	r
�s
zTextTestRunner.__init__cCs|j|j|j|j�S)N)rHrrr )rrrr	�_makeResult�szTextTestRunner._makeResultcCs4|j�}t|�|j|_|j|_|j|_tj���|jr^tj|j�|jdkr^tjdt	dd�t
j
�}t|dd�}|dk	r�|�z||�Wdt|dd�}|dk	r�|�Xt
j
�}WdQRX||}|j�t
|d	�r�|jj|j�|j}|jjd
||dk�rd�pd
|f�|jj�d}	}
}ytt|j|j|jf�}Wntk
�rVYnX|\}	}
}g}
|j��s�|jjd�t|j�t|j�}}|�r�|
jd|�|�r�|
jd|�n|jjd�|�r�|
jd|�|	�r�|
jd|	�|
�r|
jd|
�|
�r$|jjddj|
�f�n|jjd�|S)z&Run the given test case or test suite.�default�always�modulezPlease use assert\w+ instead.)�category�message�startTestRunN�stopTestRunr?zRan %d test%s in %.3fsrr2�rZFAILEDzfailures=%dz	errors=%dZOKz
skipped=%dzexpected failures=%dzunexpected successes=%dz (%s)z, r)rJrK)rIrrErFrBrG�catch_warnings�simplefilter�filterwarnings�DeprecationWarning�timer
r=�hasattrrrr?ZtestsRun�map�lenZexpectedFailures�unexpectedSuccesses�skippedrZ
wasSuccessfulrr<r;�appendr")rr$rZ	startTimerOrPZstopTimeZ	timeTaken�runZ
expectedFailsrZr[ZresultsZinfosZfailedZerroredrrr	r]�sr





zTextTestRunner.run)NTrFFNN)	rrrrrrHr
rIr]rrrr	rAxsrA)rrCrVrGrQrZsignalsrZ
__unittest�objectrZ
TestResultrrArrrr	�<module>s[PKń[���~~(__pycache__/signals.cpython-36.opt-2.pycnu�[���3


 \c	�@sbddlZddlZddlmZdZGdd�de�Zej�Zdd�Z	dd	�Z
dad
d�Zddd
�Z
dS)�N)�wrapsTc@seZdZdd�Zdd�ZdS)�_InterruptHandlercCsNd|_||_t|t�rD|tjkr(tj}n|tjkr<dd�}ntd��||_	dS)NFcSsdS)N�)Z
unused_signumZunused_framerr�(/usr/lib64/python3.6/unittest/signals.py�default_handlersz3_InterruptHandler.__init__.<locals>.default_handlerzYexpected SIGINT signal handler to be signal.SIG_IGN, signal.SIG_DFL, or a callable object)
�called�original_handler�
isinstance�int�signal�SIG_DFL�default_int_handler�SIG_IGN�	TypeErrorr)�selfrrrr�__init__
s



z_InterruptHandler.__init__cCsVtjtj�}||k	r |j||�|jr2|j||�d|_xtj�D]}|j�qBWdS)NT)r�	getsignal�SIGINTrr�_results�keys�stop)rZsignum�frameZinstalled_handler�resultrrr�__call__sz_InterruptHandler.__call__N)�__name__�
__module__�__qualname__rrrrrrr	srcCsdt|<dS)N�)r)rrrr�registerResult*srcCsttj|d��S)N)�boolr�pop)rrrr�removeResult-sr!cCs.tdkr*tjtj�}t|�atjtjt�dS)N)�_interrupt_handlerrrrr)rrrr�installHandler1sr#cs<�dk	r t���fdd��}|Stdk	r8tjtjtj�dS)Ncs2tjtj�}t�z
�||�Stjtj|�XdS)N)rrr�
removeHandler)�args�kwargs�initial)�methodrr�inner;s

zremoveHandler.<locals>.inner)rr"rrr)r(r)r)r(rr$9s
r$)N)r�weakref�	functoolsrZ
__unittest�objectr�WeakKeyDictionaryrrr!r"r#r$rrrr�<module>s PKń[b�red�d�%__pycache__/mock.cpython-36.opt-2.pycnu�[���3


 \�7�@sFd�Zd
ZddlZddlZddlZddlZddlmZddlm	Z	m
Z
dd�ee�D�Ze
fZdejkrzddlZe
ejjfZdZeZdd�Zdd�Zdd�Zd�dd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd�d'd(�Zd)d*�Zd+d,�Z Gd-d.�d.e!�Z"Gd/d0�d0e!�Z#e#�Z$e$j%Z%e$j&Z'e$j(Z)d1d2�Z*d3d4d5d6d7d8d9d:hZ+d;d<�Z,Gd=d>�d>e-�Z.d?d@�Z/GdAdB�dBe!�Z0GdCdD�dDe!�Z1GdEd	�d	e1�Z2dFdG�Z3GdHdI�dIe1�Z4GdJd�de4e2�Z5dKdL�Z6dMdN�Z7dOdP�Z8GdQdR�dRe!�Z9dSdT�Z:e%dddddfdUdV�Z;d�dWdX�Z<e%dddddfdYd�Z=GdZd[�d[e!�Z>d\d]�Z?d^d_�Z@e;e=_!e>e=_Ae<e=_Be@e=_Cd`e=_DdaZEdbZFdcjGddde�eFjH�D��ZIdcjGdfde�eFjH�D��ZJdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxhZKdydz�ZLd{d�dcjGeEeFeIeJg�jH�D�ZMeMeKBZNd|d}d~dd�d�d�d�hZOd�d��d�d��d�d��d��ZPeQeQeQeQd�dddd�d�dd�d��ZRd�d��ZSd�d��ZTd�d��ZUeSeTeUd��ZVd�d��ZWGd�d��d�e!�ZXGd�d
�d
eXe2�ZYGd�d�deXe5�ZZGd�d��d�e!�Z[Gd�d��d�e!�Z\e\�Z]d�d��Z^Gd�d��d�e_�Z`e`dd��Zad�d�d�Zbd�d��Zcd�d��ZdGd�d��d�e!�Zeefeb�efe]jg�fZhefe]jgji�fZjdakd�d��Zld�d�d�ZmGd�d�de5�ZndS)��Mock�	MagicMock�patch�sentinel�DEFAULT�ANY�call�create_autospec�
FILTER_DIR�NonCallableMock�NonCallableMagicMock�	mock_open�PropertyMockz1.0�N)�
ModuleType)�wraps�partialcCsh|]}|jd�s|�qS)�_)�
startswith)�.0�name�r�%/usr/lib64/python3.6/unittest/mock.py�	<setcomp>#sr�javaTcCstt|�t�S)N)�
issubclass�typer
)�objrrr�_is_instance_mock2srcCst|t�pt|t�ot|t�S)N)�
isinstance�BaseExceptionsrr)rrrr�
_is_exception8s
r cCs�t|t�r6|r6y
|j}Wntk
r.dSXd}n*t|t�s`y
|j}Wntk
r^dSX|rpt|d�}n|}y|tj|�fSt	k
r�dSXdS)NT)
rr�__init__�AttributeError�
FunctionTypes�__call__r�inspectZ	signature�
ValueError)�funcZas_instanceZeat_selfZsig_funcrrr�_get_signature_object?s$


r(FcsDt|||���dkrdS�\}��fdd�}t||�|t|�_dS)Ncs�j||�dS)N)�bind)�
_mock_self�args�kwargs)�sigrr�checksigdsz"_check_signature.<locals>.checksig)r(�_copy_func_detailsr�_mock_check_sig)r'�mock�	skipfirst�instancer.r)r-r�_check_signature_s
r4c#Cs�|j|_|j|_y|j|_Wntk
r0YnXy|j|_Wntk
rRYnXy|j|_Wntk
rtYnXy|j|_Wntk
r�YnXdS)N)�__name__�__doc__�__text_signature__r"�
__module__�__defaults__�__kwdefaults__)r'�funcopyrrrr/js$r/cCs&t|t�rdSt|dd�dk	r"dSdS)NTr$F)rr�getattr)rrrr�	_callable�s

r=cCst|�ttfkS)N)r�list�tuple)rrrr�_is_list�sr@cCsHt|t�st|dd�dk	Sx(|f|jD]}|jjd�dk	r(dSq(WdS)Nr$TF)rrr<�__mro__�__dict__�get)r�baserrr�_instance_callable�s
rEcs�t|�sdSt|t�}t|||�}|dkr.|S|\}��fdd�}t||�|j}|j�s^d}||d�}d|}	t|	|�||}
t|
|�|
S)Ncs�j||�dS)N)r))r+r,)r-rrr.�sz _set_signature.<locals>.checksigr;)Z
_checksig_r1zYdef %s(*args, **kwargs):
    _checksig_(*args, **kwargs)
    return mock(*args, **kwargs))	r=rrr(r/r5�isidentifier�exec�_setup_func)r1�originalr3r2�resultr'r.r�context�srcr;r)r-r�_set_signature�s$




rMc
s���_t��sdS�fdd�}�fdd�}�fdd�}�fdd�}�fd	d
�}�fdd�}�fd
d�}��fdd�}	d�_d�_d�_t��_t��_t��_�j	�_	�j
�_
�j�_|�_|�_
|�_|�_|	�_|�_|�_|�_��_dS)Ncs�j||�S)N)�assert_called_with)r+r,)r1rrrN�sz'_setup_func.<locals>.assert_called_withcs�j||�S)N)�
assert_called)r+r,)r1rrrO�sz"_setup_func.<locals>.assert_calledcs�j||�S)N)�assert_not_called)r+r,)r1rrrP�sz&_setup_func.<locals>.assert_not_calledcs�j||�S)N)�assert_called_once)r+r,)r1rrrQ�sz'_setup_func.<locals>.assert_called_oncecs�j||�S)N)�assert_called_once_with)r+r,)r1rrrR�sz,_setup_func.<locals>.assert_called_once_withcs�j||�S)N)�assert_has_calls)r+r,)r1rrrS�sz%_setup_func.<locals>.assert_has_callscs�j||�S)N)�assert_any_call)r+r,)r1rrrT�sz$_setup_func.<locals>.assert_any_callcs:t��_t��_�j��j}t|�r6|�k	r6|j�dS)N)�	_CallList�method_calls�
mock_calls�
reset_mock�return_valuer)�ret)r;r1rrrX�sz_setup_func.<locals>.reset_mockFr)r1r�called�
call_count�	call_argsrU�call_args_listrVrWrY�side_effect�_mock_childrenrNrRrSrTrXrOrPrQ�_mock_delegate)
r;r1rNrOrPrQrRrSrTrXr)r;r1rrH�s:rHcCsd|dd�|kS)Nz__%s__����r)rrrr�	_is_magic�srdc@seZdZdd�Zdd�ZdS)�_SentinelObjectcCs
||_dS)N)r)�selfrrrrr!�sz_SentinelObject.__init__cCs
d|jS)Nzsentinel.%s)r)rfrrr�__repr__�sz_SentinelObject.__repr__N)r5r8�__qualname__r!rgrrrrre�srec@seZdZdd�Zdd�ZdS)�	_SentinelcCs
i|_dS)N)�
_sentinels)rfrrrr!�sz_Sentinel.__init__cCs|dkrt�|jj|t|��S)N�	__bases__)r"rj�
setdefaultre)rfrrrr�__getattr__sz_Sentinel.__getattr__N)r5r8rhr!rmrrrrri�sricCs$t|�ttttfkr t|�|�S|S)N)r�dictr>r?�set)�valuerrr�_copysrqrY�_mock_return_valuer_�_mock_side_effect�_mock_parent�_mock_new_parent�
_mock_name�_mock_new_namecCs8tj|�d|}||fdd�}||fdd�}t||�S)NZ_mock_cSs"|j}|dkrt||�St||�S)N)rar<)rfr�	_the_namer-rrr�_gets
z"_delegating_property.<locals>._getcSs*|j}|dkr||j|<nt|||�dS)N)rarB�setattr)rfrprrxr-rrr�_set$sz"_delegating_property.<locals>._set)�_allowed_names�add�property)rrxryr{rrr�_delegating_propertys

rc@seZdZdd�Zdd�ZdS)rUcCsnt|t�stj||�St|�}t|�}||kr2dSx6td||d�D] }||||�}||krFdSqFWdS)NFr�T)rr>�__contains__�len�range)rfrpZ	len_valueZlen_self�iZsub_listrrrr�1s
z_CallList.__contains__cCstjt|��S)N)�pprintZpformatr>)rfrrrrg?sz_CallList.__repr__N)r5r8rhr�rgrrrrrU/srUcCsxt|�sdS|js,|js,|jdk	s,|jdk	r0dS|}x|dk	rR||krJdS|j}q6W|rd||_||_|rt||_||_dS)NFT)rrvrwrtru)�parentrpr�new_name�_parentrrr�_check_and_set_parentCs$



r�c@s$eZdZdd�Zdd�Zdd�ZdS)�	_MockItercCst|�|_dS)N)�iterr)rfrrrrr!]sz_MockIter.__init__cCs|S)Nr)rfrrr�__iter___sz_MockIter.__iter__cCs
t|j�S)N)�nextr)rfrrr�__next__asz_MockIter.__next__N)r5r8rhr!r�r�rrrrr�\sr�c@seZdZeZdZdd�ZdS)�BaseNcOsdS)Nr)rfr+r,rrrr!gsz
Base.__init__)r5r8rhrrrrsr!rrrrr�dsr�c@sDeZdZdd�ZdCdd�Zdd	�ZdDd
d�ZdEdd
�Zdd�Zdd�Z	dZ
eee	e
�Zedd��Z
ed�Zed�Zed�Zed�Zed�Zdd�Zdd�Zeee�ZdFddd�dd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Z d3d4�Z!d5d6�Z"d7d8�Z#d9d:�Z$d;d<�Z%dGd=d>�Z&d?d@�Z'dAdB�Z(dS)Hr
cOs$t|j|fd|ji�}tj|�}|S)Nr6)rr5r6�object�__new__)�clsr+�kw�newr3rrrr�os
zNonCallableMock.__new__N�FcKs�|dkr|}|j}
||
d<||
d<||
d<||
d<|dk	rB|}d}|
dkrR|dk	}
|j|||	|
�i|
d<||
d<d|
d<d	|
d
<d|
d<d|
d
<t�|
d<t�|
d<t�|
d<||
d<|r�|jf|�tt|�j||||||�dS)NrtrvrwruTr`�_mock_wrapsraFZ_mock_calledZ_mock_call_argsrZ_mock_call_countZ_mock_call_args_listZ_mock_mock_callsrV�_mock_unsafe)rB�_mock_add_specrU�configure_mock�_safe_superr
r!)rf�specrr�spec_setr��_spec_state�	_new_name�_new_parent�_spec_as_instance�	_eat_selfZunsafer,rBrrrr!xs8




zNonCallableMock.__init__cCs(d|_d|_d|_d|_t|||�dS)Nr�)rtrurvrwrz)rfr1�	attributerrr�attach_mock�s
zNonCallableMock.attach_mockcCs|j||�dS)N)r�)rfr�r�rrr�
mock_add_spec�szNonCallableMock.mock_add_specc	Cs|d}d}|dk	rRt|�rRt|t�r*|}nt|�}t|||�}|oH|d}t|�}|j}||d<||d<||d<||d<dS)Nr��_spec_class�	_spec_set�_spec_signature�
_mock_methods)r@rr�
_get_classr(�dirrB)	rfr�r�r�r�r�r��resrBrrrr��s
zNonCallableMock._mock_add_speccCs8|j}|jdk	r|jj}|tkr4|j|dd�}||_|S)Nz())r�r�)rrrarYr�_get_child_mock)rfrZrrrZ__get_return_value�s

z"NonCallableMock.__get_return_valuecCs,|jdk	r||j_n||_t||dd�dS)Nz())rarYrrr�)rfrprrrZ__set_return_value�s

z"NonCallableMock.__set_return_valuez1The value to be returned when the mock is called.cCs|jdkrt|�S|jS)N)r�r)rfrrr�	__class__�s
zNonCallableMock.__class__r[r\r]r^rWcCsT|j}|dkr|jS|j}|dk	rPt|�rPt|t�rPt|�rPt|�}||_|S)N)rarsr_�callablerr�r )rf�	delegatedZsfrrrZ__get_side_effect�sz!NonCallableMock.__get_side_effectcCs(t|�}|j}|dkr||_n||_dS)N)�	_try_iterrarsr_)rfrpr�rrrZ__set_side_effects
z!NonCallableMock.__set_side_effect)rYr_cCs�|dkrg}t|�|krdS|jt|��d|_d|_d|_t�|_t�|_t�|_|r^t	|_
|rhd|_x0|jj
�D]"}t|t�st|tkr�qt|j|�qtW|j
}t|�r�||k	r�|j|�dS)NFr)�id�appendr[r]r\rUrWr^rVrrrrsr`�valuesr�
_SpecState�_deletedrXr)rfZvisitedrYr_ZchildrZrrrrX
s,zNonCallableMock.reset_mockcKs`xZt|j�dd�d�D]B\}}|jd�}|j�}|}x|D]}t||�}q:Wt|||�qWdS)NcSs|djd�S)Nr�.)�count)�entryrrr�<lambda>8sz0NonCallableMock.configure_mock.<locals>.<lambda>)�keyr�)�sorted�items�split�popr<rz)rfr,�arg�valr+�finalrr�rrrr�+s	


zNonCallableMock.configure_mockcCs�|dkrt|��n:|jdk	r<||jks.|tkrLtd|��nt|�rLt|��|jsd|jd�rdt|��|jj|�}|tkr�t|��np|dkr�d}|j	dk	r�t
|j	|�}|j|||||d�}||j|<n.t|t
�r�t|j|j|j|j|j�}||j|<|S)	Nr�r�zMock object has no attribute %r�assert�assret)r�rrr�r�>r�r�)r�r�)r"r��_all_magicsrdr�rr`rCr�r�r<r�rr�rr�r�r3r�r)rfrrJrrrrrmAs6






zNonCallableMock.__getattr__c
Cs"|jg}|j}|}d}|dgkr$d}t�}xT|dk	r~|}|j|j|�d}|jdkrZd}|j}t|�|krnP|jt|��q,Wtt|��}|jp�d}t	|�dkr�|dd
kr�|d7}||d<dj
|�}d}|dkr�d	|}d}	|jdk	�rd
}	|j�r�d}	|	|jj
}	dt|�j
||	t|�fS)Nr��()r�r1r��().r�mock.z name=%rz spec=%rz spec_set=%rz<%s%s%s id='%s'>)r�r�)r1r�)rwruror�r�r}r>�reversedrvr��joinr�r�r5r)
rfZ
_name_listr�Zlast�dot�seenZ_firstrZname_stringZspec_stringrrrrggsL




zNonCallableMock.__repr__cCshtstj|�S|jpg}tt|��}t|j�}dd�|D�}dd�|D�}tt	|||t|j
���S)NcSsg|]}|jd�s|�qS)r)r)r�errr�
<listcomp>�sz+NonCallableMock.__dir__.<locals>.<listcomp>cSs$g|]}|jd�st|�r|�qS)r)rrd)rr�rrrr��s)r	r��__dir__r�r�rr>rBr�ror`)rfZextrasZ	from_typeZ	from_dictrrrr��s


zNonCallableMock.__dir__cs"|tkrtj�||�S�jrH�jdk	rH|�jkrH|�jkrHtd|��n�|tkrbd|}t|��n�|tkr�jdk	r�|�jkr�td|��t	|�s�t
t��|t||��|���fdd�}n(t
�|d|�t
t��||�|�j|<n.|dk�r�|�_dSt
�|||��r|�j|<tj�||�S)Nz!Mock object has no attribute '%s'z.Attempting to set unsupported magic method %r.cs��f|�|�S)Nr)r+r�)rIrfrrr��sz-NonCallableMock.__setattr__.<locals>.<lambda>r�)r|r��__setattr__r�r�rBr"�_unsupported_magicsr�rrzr�_get_methodr�r`r�)rfrrp�msgr)rIrfrr��s2




zNonCallableMock.__setattr__cCs�|tkr2|t|�jkr2tt|�|�||jkr2dS||jkrHtj||�|jj|t�}|t	krft
|��|tk	rv|j|=t	|j|<dS)N)r�rrB�delattrr��__delattr__r`rC�_missingr�r")rfrrrrrr��s

zNonCallableMock.__delattr__cCs|jpd}t|||�S)Nr1)rv�_format_call_signature)rfr+r,rrrr�_format_mock_call_signature�s
z+NonCallableMock._format_mock_call_signaturecCsDd}|j||�}|j}t|�dkr.|dd�}|j|�}|||fS)Nz!Expected call: %s
Actual call: %s�r�)r�r]r�)rfr+r,�message�expected_stringr]Z
actual_stringrrr�_format_mock_failure_message�s
z,NonCallableMock._format_mock_failure_messagecCst|j}|dk	rlt|�dkr(d}|\}}n
|\}}}y||j||�fStk
rh}z
|jd�Sd}~XqpXn|SdS)Nrbr�)r�r�r)�	TypeError�with_traceback)rf�_callr-rr+r,r�rrr�
_call_matcher�s

zNonCallableMock._call_matchercCs.|}|jdkr*d|jpd|jf}t|��dS)Nrz7Expected '%s' to not have been called. Called %s times.r1)r\rv�AssertionError)r*rfr�rrrrPs

z!NonCallableMock.assert_not_calledcCs(|}|jdkr$d|jpd}t|��dS)Nrz"Expected '%s' to have been called.r1)r\rvr�)r*rfr�rrrrOs

zNonCallableMock.assert_calledcCs.|}|jdks*d|jpd|jf}t|��dS)Nr�z8Expected '%s' to have been called once. Called %s times.r1)r\rvr�)r*rfr�rrrrQs

z"NonCallableMock.assert_called_oncecs||��jdkr(�j���}td|f�����fdd�}�j��f�}�j�j�}||krxt|t�rh|nd}t|��|�dS)NzExpected call: %s
Not calledcs�j���}|S)N)r�)r�)r+r,rfrr�_error_message'sz:NonCallableMock.assert_called_with.<locals>._error_message)r]r�r�r�r�	Exception)r*r+r,�expectedr��actual�causer)r+r,rfrrNs
z"NonCallableMock.assert_called_withcOs6|}|jdks*d|jpd|jf}t|��|j||�S)Nr�z1Expected '%s' to be called once. Called %s times.r1)r\rvr�rN)r*r+r,rfr�rrrrR1s
z'NonCallableMock.assert_called_once_withcs��fdd�|D�}t|t�r |nd}t�fdd��jD��}|sd||kr`tdt|��jf�|�dSt|�}g}x:|D]2}y|j|�Wqvtk
r�|j|�YqvXqvW|r�tdt	|�f�|�dS)Ncsg|]}�j|��qSr)r�)r�c)rfrrr�Fsz4NonCallableMock.assert_has_calls.<locals>.<listcomp>c3s|]}�j|�VqdS)N)r�)rr�)rfrr�	<genexpr>Hsz3NonCallableMock.assert_has_calls.<locals>.<genexpr>z(Calls not found.
Expected: %r
Actual: %rz%r not all found in call list)
rr�rUrWr�r>�remover&r�r?)rfZcallsZ	any_orderr�r�Z	all_callsZ	not_foundZkallr)rfrrS<s*

z NonCallableMock.assert_has_callscsZ�j||f�}�fdd��jD�}||krVt|t�r8|nd}�j||�}td|�|�dS)Ncsg|]}�j|��qSr)r�)rr�)rfrrr�fsz3NonCallableMock.assert_any_call.<locals>.<listcomp>z%s call not found)r�r^rr�r�r�)rfr+r,r�r�r�r�r)rfrrT_szNonCallableMock.assert_any_callcKsFt|�}t|t�s2t|t�r"t}q<t|t�r<t}n
|jd}|f|�S)Nr�)rr�
CallableMixinrrr
rrA)rfr��_type�klassrrrr�os



zNonCallableMock._get_child_mock)NNNNNNr�NFNF)F)FF)N)F))r5r8rhr�r!r�r�r�Z"_NonCallableMock__get_return_valueZ"_NonCallableMock__set_return_valueZ"_NonCallableMock__return_value_docr~rYr�rr[r\r]r^rWZ!_NonCallableMock__get_side_effectZ!_NonCallableMock__set_side_effectr_rXr�rmrgr�r�r�r�r�r�rPrOrQrNrRrSrTr�rrrrr
lsP

)
	


&2"
			
#cCsF|dkr|St|�r|St|�r$|Syt|�Stk
r@|SXdS)N)r r=r�r�)rrrrr��sr�c
@sBeZdZddedddddddf
dd�Zdd�Zdd�Zd	d
�ZdS)r�Nr�c	Ks6||jd<tt|�j|||||||	|
f|�||_dS)Nrr)rBr�r�r!r_)rfr�r_rYrrr�r�r�r�r�r,rrrr!�s



zCallableMixin.__init__cOsdS)Nr)rfr+r,rrrr0�szCallableMixin._mock_check_sigcOs|j||�|j||�S)N)r0�
_mock_call)r*r+r,rrrr$�szCallableMixin.__call__cOs�|}d|_|jd7_t||fdd�}||_|jj|�t�}|jdk	}|j}|j	}|dk}	|j
jtd||f��|j}
x�|
dk	�r*|r�|
jjt|||f��|
jdk	}|r�|
jd|}t|||f�}|
j
j|�|
j	�r|	r�d}nd}|
j	dk}	|
j	||}|
j}
t
|
�}
|
|k�rP|j|
�q|W|j}|dk	�r�t|��rL|�n,t|��snt|�}t|��rx|�n
|||�}|tk	�r�|S|jtk	�r�|jS|jdk	�r�|j||�S|jS)NTr�)�twoz()r�r�)r[r\�_Callr]r^r�rortrvrwrWrurVr�r}r_r r=r�rrrrYr�)r*r+r,rfr�r�Zdo_method_callsZmethod_call_nameZmock_call_nameZ	is_a_callr�Zthis_mock_callr�Z_new_parent_idZeffectrJrrrr��s`









zCallableMixin._mock_call)r5r8rhrr!r0r$r�rrrrr��sr�c@seZdZdS)rN)r5r8rhrrrrr�s1cCs2y
t||�Stk
r,t|�t||�SXdS)N)r<r"�
__import__)�thing�comp�import_pathrrr�_dot_lookup1s

r�cCsF|jd�}|jd�}t|�}x$|D]}|d|7}t|||�}q"W|S)Nr�rz.%s)r�r�r�r�)�targetZ
componentsr�r�r�rrr�	_importer9s


r�cCs
t|d�S)N�is_local)�hasattr)�patcherrrr�_is_startedDsr�c@sdeZdZdZgZdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�ZdS)�_patchNc

Csn|dk	r(|tk	rtd��|dk	r(td��||_||_||_||_||_||_d|_||_	||_
|	|_g|_dS)Nz,Cannot use 'new' and 'new_callable' togetherz1Cannot use 'autospec' and 'new_callable' togetherF)
rr&�getterr�r��new_callabler��createZ	has_localr��autospecr,�additional_patchers)
rfr�r�r�r�r�r�r�r�r,rrrr!Ns$z_patch.__init__c
CsHt|j|j|j|j|j|j|j|j|j	�	}|j
|_
dd�|jD�|_|S)NcSsg|]}|j��qSr)�copy)r�prrrr�qsz_patch.copy.<locals>.<listcomp>)r�r�r�r�r�r�r�r�r�r,�attribute_namer�)rfr�rrrrisz_patch.copycCst|t�r|j|�S|j|�S)N)rr�decorate_class�decorate_callable)rfr'rrrr$vs

z_patch.__call__cCsRxLt|�D]@}|jtj�sq
t||�}t|d�s2q
|j�}t||||��q
W|S)Nr$)r�rr�TEST_PREFIXr<r�rrz)rfr��attr�
attr_valuer�rrrr|s

z_patch.decorate_classcs<t�d�r�jj|��St����fdd���|g�_�S)N�	patchingscs�g}g}t�}z�ybxJ�jD]@}|j�}|j|�|jdk	rF|j|�q|jtkr|j|�qW|t|�7}�||�S||kr�t|�r�|j|�t	j
�}�YnXWdxt|�D]}|j|�q�WXdS)N)
r?r�	__enter__r�r�updater�rr��sys�exc_infor��__exit__)r+Zkeywargs�
extra_argsZentered_patchersr�patchingr�)r'�patchedrrr�s*




z)_patch.decorate_callable.<locals>.patched)r�rr�r)rfr'r)r'rrr�s
z_patch.decorate_callablecCs�|j�}|j}t}d}y|j|}Wn$ttfk
rHt||t�}YnXd}|tkrft|t	�rfd|_
|j
r�|tkr�td||f��||fS)NFTz!%s does not have the attribute %r)r�r�rrBr"�KeyErrorr<�	_builtinsrrr�)rfr�rrI�localrrr�get_original�sz_patch.get_originalcCs>|j|j|j}}}|j|j}}|j}|j�|_|dkr@d}|dkrLd}|dkrXd}|dk	rp|dk	rptd��|dk	s�|dk	r�|dkr�td��|j	�\}}|t
ko�|dk�rTd}	|dkr�|}|dkr�|}d}n&|dk	r�|dkr�|}d}n|dkr�|}|dk	�s
|dk	�r,|t
k�rtd��t|t��r,d}	t
}
i}|dk	�rD|}
nN|dk	�sX|dk	�r�|}|dk	�rj|}t|��r~d|k}
n
t|�}
|
�r�t}
|dk	�r�||d<|dk	�r�||d<t|
t��r�t|
t��r�|j�r�|j|d	<|j|�|
f|�}|	�r�t|��r�|}|dk	�r|}t|��r2t|��r2t}
|jd	�|
f|d
d�|��|_nl|dk	�r�|t
k	�rptd��|t
k�r�td
��t|�}|dk�r�|}t|f||jd�|��}n|�r�td��|}||_||_t|j|j|�|jdk	�r:i}|jt
k�r|||j<x.|jD]$}|j �}|jt
k�r|j|��qW|S|S)NFzCan't specify spec and autospecTz6Can't provide explicit spec_set *and* spec or autospecz!Can't use 'spec' with create=Truer$r�r�rz())r�r�zBautospec creates the mock for you. Can't specify autospec and new.z%Can't use 'autospec' with create=True)r��_namez.Can't pass kwargs to a mock we aren't creating)TN)!r�r�r�r�r,r�r�r�r�rrrrrr@r�rrr
r�r
rrEr�rY�boolr�
temp_originalr�rzrr�r	)rfr�r�r�r�r,r�rIrZinherit�Klass�_kwargsZ	this_specZnot_callableZnew_attrrrr�rrrr	�s�


















z_patch.__enter__cGs�t|�std��|jr4|jtk	r4t|j|j|j�nBt|j|j�|j	rvt
|j|j�sd|jdkrvt|j|j|j�|`|`|`x$t|j�D]}t|�r�|j
|�q�WdS)Nz stop called on unstarted patcherr6r8r9�__annotations__r:)r6r8r9rr:)r��RuntimeErrorr�rrrzr�r�r�r�r�r�r�r
)rfrr�rrrr
Hs z_patch.__exit__cCs|j�}|jj|�|S)N)r	�_active_patchesr�)rfrJrrr�start`sz_patch.startcCs.y|jj|�Wntk
r$YnX|j�S)N)rr�r&r
)rfrrr�stopgs
z_patch.stop)r5r8rhrrr!rr$rrrr	r
rrrrrrr�Is
(~r�csPy�jdd�\�}Wn&ttfk
r:td�f��YnX�fdd�}||fS)Nr�r�z.Need a valid target to patch. You supplied: %rcst��S)N)r�r)r�rrr�ysz_get_target.<locals>.<lambda>)�rsplitr�r&)r�r�r�r)r�r�_get_targetssr c

s$�fdd�}	t|	||||||||�	S)Ncs�S)Nrr)r�rrr��sz_patch_object.<locals>.<lambda>)r�)
r�r�r�r�r�r�r�r�r,r�r)r�r�
_patch_object}s
r!c
s�t��tkr�fdd�}n�fdd�}|s2td��t|j��}|d\}	}
t||	|
|||||i�	}|	|_xB|dd�D]2\}	}
t||	|
|||||i�	}|	|_|jj|�qvW|S)Ncst��S)N)r�r)r�rrr��sz!_patch_multiple.<locals>.<lambda>cs�S)Nrr)r�rrr��sz=Must supply at least one keyword argument with patch.multiplerr�)	r�strr&r>r�r�rr�r�)
r�r�r�r�r�r�r,r�r�r�r�r�Zthis_patcherr)r�r�_patch_multiple�s&

r#c

Ks$t|�\}}	t||	|||||||�	S)N)r r�)
r�r�r�r�r�r�r�r,r�r�rrrr�sE
c@sReZdZfdfdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	eZ
e	ZdS)�_patch_dictFcKs>t|t�rt|�}||_t|�|_|jj|�||_d|_dS)N)	rr"r��in_dictrnr�r
�clear�	_original)rfr%r�r&r,rrrr!0s

z_patch_dict.__init__cs.t�t�r�j��St����fdd��}|S)Nc
s"�j�z
�||�S�j�XdS)N)r$�
_unpatch_dict)r+r�)�frfrr�_inner>s
z$_patch_dict.__call__.<locals>._inner)rrrr)rfr)r*r)r)rfrr$;s

z_patch_dict.__call__cCs\xVt|�D]J}t||�}|jtj�r
t|d�r
t|j|j|j	�}||�}t
|||�q
W|S)Nr$)r�r<rrrr�r$r%r�r&rz)rfr�rrZ	decoratorZ	decoratedrrrrIs

z_patch_dict.decorate_classcCs|j�dS)N)r$)rfrrrr	Tsz_patch_dict.__enter__cCs�|j}|j}|j}y|j�}Wn2tk
rPi}x|D]}||||<q8WYnX||_|rdt|�y|j|�Wn.tk
r�x|D]}||||<q�WYnXdS)N)r�r%r&rr"r'�_clear_dictr
)rfr�r%r&rIr�rrrr$Ys"

z_patch_dict._patch_dictcCsV|j}|j}t|�y|j|�Wn.tk
rPx|D]}||||<q8WYnXdS)N)r%r'r+r
r")rfr%rIr�rrrr(ss
z_patch_dict._unpatch_dictcGs|j�dS)NF)r()rfr+rrrr
�sz_patch_dict.__exit__N)r5r8rhr!r$rr	r$r(r
rrrrrrr$s
r$cCsBy|j�Wn0tk
r<t|�}x|D]
}||=q*WYnXdS)N)r&r"r>)r%�keysr�rrrr+�s
r+cCs xttj�D]}|j�qWdS)N)r�r�rr)rrrr�_patch_stopall�sr-Ztestz�lt le gt ge eq ne getitem setitem delitem len contains iter hash str sizeof enter exit divmod rdivmod neg pos abs invert complex int float index trunc floor ceil bool next zHadd sub mul matmul div floordiv mod lshift rshift and xor or pow truediv� ccs|]}d|VqdS)zi%sNr)r�nrrrr��sr�ccs|]}d|VqdS)zr%sNr)rr/rrrr��s�__get__�__set__�
__delete__�__reversed__�__missing__�
__reduce__�
__reduce_ex__Z__getinitargs__�__getnewargs__�__getstate__�__setstate__�
__getformat__�
__setformat__rgr��__subclasses__�
__format__�__getnewargs_ex__cs�fdd�}||_|S)Ncs�|f|�|�S)Nr)rfr+r�)r'rr�method�sz_get_method.<locals>.method)r5)rr'r?r)r'rr��sr�cCsh|]}d|�qS)z__%s__r)rr?rrrr�srmr�r!r��__prepare__�__instancecheck__�__subclasscheck__�__del__cCs
tj|�S)N)r��__hash__)rfrrrr��sr�cCs
tj|�S)N)r��__str__)rfrrrr��scCs
tj|�S)N)r��
__sizeof__)rfrrrr��s)rDrErFr�y�?g�?)�__lt__�__gt__�__le__�__ge__�__int__r��__len__r
�__complex__�	__float__�__bool__�	__index__cs�fdd�}|S)Ncs$�jj}|tk	r|S�|kr dStS)NT)�__eq__rrr�NotImplemented)�other�ret_val)rfrrrQ�sz_get_eq.<locals>.__eq__r)rfrQr)rfr�_get_eq�srUcs�fdd�}|S)Ncs �jjtk	rtS�|krdStS)NF)�__ne__rrrrR)rS)rfrrrV�s
z_get_ne.<locals>.__ne__r)rfrVr)rfr�_get_ne�srWcs�fdd�}|S)Ncs �jj}|tkrtg�St|�S)N)r�rrrr�)rT)rfrrr��sz_get_iter.<locals>.__iter__r)rfr�r)rfr�	_get_iter�srX)rQrVr�cCs�tj|t�}|tk	r||_dStj|�}|dk	rdy||�}Wntk
rXt|�}YnX||_dStj|�}|dk	r�||�|_dS)N)�_return_valuesrCrrY�_calculate_return_valuer"�_side_effect_methodsr_)r1r?rZfixedZreturn_calulatorrYZ
side_effectorrrr�_set_return_values

r\c@seZdZdd�Zdd�ZdS)�
MagicMixincOs&|j�tt|�j||�|j�dS)N)�_mock_set_magicsr�r]r!)rfr+r�rrrr!(szMagicMixin.__init__cCs�t}t|dd�dk	rTtj|j�}t�}t|}x$|D]}|t|�jkr4t||�q4W|tt|�j�}t|�}x|D]}t||t	||��qtWdS)Nr�)
�_magicsr<�intersectionr�rorrBr�rz�
MagicProxy)rfZthese_magicsZ
remove_magicsr�r�rrrr^.s

zMagicMixin._mock_set_magicsN)r5r8rhr!r^rrrrr]'sr]c@seZdZddd�ZdS)rFcCs|j||�|j�dS)N)r�r^)rfr�r�rrrr�Gsz"NonCallableMagicMock.mock_add_specN)F)r5r8rhr�rrrrrEsc@seZdZddd�ZdS)rFcCs|j||�|j�dS)N)r�r^)rfr�r�rrrr�]szMagicMock.mock_add_specN)F)r5r8rhr�rrrrrRsc@s.eZdZdd�Zdd�Zdd�Zd
dd	�ZdS)racCs||_||_dS)N)rr�)rfrr�rrrr!iszMagicProxy.__init__cOs|j�}|||�S)N)�create_mock)rfr+r,�mrrrr$mszMagicProxy.__call__cCs8|j}|j}|j|||d�}t|||�t|||�|S)N)rr�r�)rr�r�rzr\)rfr�r�rcrrrrbqszMagicProxy.create_mockNcCs|j�S)N)rb)rfrr�rrrr0zszMagicProxy.__get__)N)r5r8rhr!r$rbr0rrrrrahs	rac@s$eZdZdd�Zdd�Zdd�ZdS)�_ANYcCsdS)NTr)rfrSrrrrQ�sz_ANY.__eq__cCsdS)NFr)rfrSrrrrV�sz_ANY.__ne__cCsdS)Nz<ANY>r)rfrrrrg�sz
_ANY.__repr__N)r5r8rhrQrVrgrrrrrdsrdcCsdd|}d}djdd�|D��}djdd�t|j��D��}|rD|}|r\|rT|d7}||7}||S)Nz%s(%%s)r�z, cSsg|]}t|��qSr)�repr)rr�rrrr��sz*_format_call_signature.<locals>.<listcomp>cSsg|]\}}d||f�qS)z%s=%rr)rr�rprrrr��s)r�r�r�)rr+r,r�Zformatted_argsZargs_stringZ
kwargs_stringrrrr��sr�c@sreZdZfddddfdd�Zfddddfdd�Zd	d
�ZejZdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)r�r�NFTcCs�f}i}t|�}|dkr$|\}}}nr|dkrd|\}	}
t|	t�rX|	}t|
t�rR|
}qb|
}q�|	|
}}n2|dkr�|\}t|t�r�|}nt|t�r�|}n|}|r�tj|||f�Stj||||f�S)Nr�rbr�)r�rr"r?r�)r�rprr�r��	from_kallr+r,�_len�first�secondrrrr��s.



z
_Call.__new__cCs||_||_||_dS)N)rvrt�_mock_from_kall)rfrprr�r�rfrrrr!�sz_Call.__init__cCsf|tkrdSyt|�}Wntk
r,dSXd}t|�dkrH|\}}n
|\}}}t|dd�rzt|dd�rz|j|jkrzdSd}|dkr�fi}}n�|dkr�|\}}}n�|dkr�|\}	t|	t�r�|	}i}n"t|	t�r�|	}fi}}nf}|	}nV|dk�r>|\}
}t|
t��r2|
}t|t��r&|i}}n
f|}}n
|
|}}ndS|�rV||k�rVdS||f||fkS)	NTFr�rbrtrr�r�)rr�r�r<rtrr?r")rfrSZ	len_otherZ	self_nameZ	self_argsZself_kwargsZ
other_nameZ
other_argsZother_kwargsrprhrirrrrQ�sP




z_Call.__eq__cOs<|jdkrtd||fdd�S|jd}t|j||f||d�S)Nr�z())r)rr�)rvr�)rfr+r,rrrrr$s

z_Call.__call__cCs2|jdkrt|dd�Sd|j|f}t||dd�S)NF)rrfz%s.%s)rr�rf)rvr�)rfrrrrrrms
z_Call.__getattr__cOs|jd�||�S)Nr�)rm)rfr+r,rrrr�$sz_Call.countcOs|jd�||�S)N�index)rm)rfr+r,rrrrk'sz_Call.indexcCs||js&|jpd}|jd�r"d|}|St|�dkr@d}|\}}n0|\}}}|sTd}n|jd�shd|}nd|}t|||�S)Nrz()zcall%srbzcall.%s)rjrvrr�r�)rfrr+r,rrrrg*s





z_Call.__repr__cCs8g}|}x"|dk	r*|jr"|j|�|j}q
Wtt|��S)N)rjr�rtrUr�)rf�valsr�rrr�	call_list?s


z_Call.call_list)r5r8rhr�r!rQr�rVr$rmr�rkrgrmrrrrr��s7r�)rfcKs,t|�rt|�}t|t�}d|i}|r0d|i}n|dkr<i}|rL|rLd|d<|j|�t}tj|�rji}n$t|�sxt}n|r�|r�t	|�r�t}|j
d|�}|}	|dkr�d}	|f|||	|d�|��}
t|t�r�t|
|�}
nt
||
||�|dk	o�|�r|
|j|<|�r,|�r,d|k�r,t||dd	|
d
�|
_x�t|�D]�}t|��rH�q6yt||�}Wntk
�rp�w6YnXd|i}|�r�d|i}t|t��s�t|||
||�}
|
|
j|<nZ|
}t|t��r�|
j}t|||�}||d<tf||||d�|��}
|
|
j|<t
||
|d
�t|
t��r6t|
||
��q6W|
S)Nr�r�Tr�rr�)r�r�r�rrYz())r3rr�r�)r�rr�r�)r2)r@rrr
rr%Zisdatadescriptorr=rrEr�r#rMr4r`rrYr�rdr<r"r�r1�
_must_skiprz)r�r�r3r�rr,�is_typerrr�r1r�rIr�r�r2rrrrPst










cCs|t|t�s$|t|di�krdS|j}xR|jD]H}|jj|t�}|tkrHq,t|tt	f�rZdStt|dd�t
�rp|SdSq,W|S)NrBFr0)rrr<r�rArBrCr�staticmethod�classmethod�MethodWrapperTypes)r�r�ror�rJrrrrn�s
rncCs$y|jStk
rt|�SXdS)N)r�r"r)rrrrr��sr�c@seZdZddd�ZdS)r�FNcCs(||_||_||_||_||_||_dS)N)r��idsr�r�r3r)rfr�r�r�rrsr3rrrr!�sz_SpecState.__init__)FNNNF)r5r8rhr!rrrrr��sr�c#spt|t�rdnd��fdd�|j��D�}|d�krD|dd�}n|ddd	�|d
<x|D]
}|Vq^WdS)N�
�
csg|]}|��qSrr)r�l)�seprrr�	sz&_iterate_read_data.<locals>.<listcomp>r����rxrxrxrx)r�bytesr�)�	read_dataZdata_as_list�liner)rwr�_iterate_read_data	s
r|r�cs���fdd�}���fdd�}���fdd��tdkr`ddl}ttt|j��jtt|j����a|dkrttdt	d	�}ttd
����j
_t��dg�d�j
_d�j_d�j_d�j_|�j_���d<�d�j_|�j_����fdd
�}||_�|_|S)Ncs �jjdk	r�jjSt�d�S)Nr)�	readlinesrYr>)r+r,)�_state�handlerr�_readlines_side_effect(	sz)mock_open.<locals>._readlines_side_effectcs(�jjdk	r�jjSt���j�d�S)Nr)�readrYrr�)r+r,)r~rrzrr�_read_side_effect-	sz$mock_open.<locals>._read_side_effectc3sJ�jjdk	rx�jjVqWx�dD]
}|Vq&Wxt���Vq6WdS)Nr)�readlinerYr)r{)r~rrzrr�_readline_side_effect2	s
z(mock_open.<locals>._readline_side_effectr�open)rr�)r�r�cs6t���d<�jj�dkr2���d<�d�j_tS)Nrr�)r|r�r_r)r+r,)r�r~rrzrr�
reset_dataS	s

zmock_open.<locals>.reset_data)�	file_spec�_ior>ror��
TextIOWrapper�union�BytesIOrr�r	rYr|�writer�r�r}r_)r1rzr�r�r�r�r)r�r~rrzrr	s."

c@s$eZdZdd�Zdd�Zdd�ZdS)r
cKs
tf|�S)N)r)rfr,rrrr�i	szPropertyMock._get_child_mockcCs|�S)Nr)rfrZobj_typerrrr0l	szPropertyMock.__get__cCs||�dS)Nr)rfrr�rrrr1n	szPropertyMock.__set__N)r5r8rhr�r0r1rrrrr
`	s	)
rrrrrrrrr	r
rrr
)F)F)NFNNN)FFNN)Nr�)o�__all__�__version__r%r�r�builtins�typesr�	functoolsrrr�r�
BaseExceptionr�platformrZlangZ	Throwabler	�superr�rr r(r4r/r=r@rErMrHrdr�rerirrZMISSINGr�ZDELETEDr�rqr|rr>rUr�r�r�r
r�r�rr�r�r�r�r r!r#rr$r+r-rnZmultipleZstopallrZ
magic_methodsZnumericsr�r�Zinplace�rightZ
_non_defaultsr�r_r�r�rZrRrYrUrWrXr[r\r]rrrardrr�r?r�rrrnr�r�rrQr#r0rrr�r|rr
rrrr�<module>s
 

4	i5,
1Jv	

	
,

w
DPKń[�b!����%__pycache__/case.cpython-36.opt-2.pycnu�[���3

�\dh���@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZmZmZmZmZdZe�ZdZGdd�de�ZGd	d
�d
e�ZGdd�de�ZGd
d�de�Zdd�Zdd�Zdd�Zdd�Zdd�Z dd�Z!Gdd�d�Z"dd�Z#Gdd �d e"�Z$Gd!d"�d"e$�Z%Gd#d$�d$e$�Z&ej'd%d&d'g�Z(Gd(d)�d)ej)�Z*Gd*d+�d+e"�Z+Gd,d-�d-e�Z,Gd.d/�d/e,�Z-Gd0d1�d1e,�Z.dS)2�N�)�result)�strclass�	safe_repr�_count_diff_all_purpose�_count_diff_hashable�_common_shorten_reprTz@
Diff is %s characters long. Set self.maxDiff to None to see it.c@seZdZdS)�SkipTestN)�__name__�
__module__�__qualname__�r
r
�%/usr/lib64/python3.6/unittest/case.pyr	sr	c@seZdZdS)�_ShouldStopN)r
rrr
r
r
rr"src@seZdZdS)�_UnexpectedSuccessN)r
rrr
r
r
rr'src@s&eZdZddd�Zejddd��ZdS)	�_OutcomeNcCs4d|_||_t|d�|_d|_g|_d|_g|_dS)NF�
addSubTestT)�expecting_failurer�hasattr�result_supports_subtests�success�skipped�expectedFailure�errors)�selfrr
r
r�__init__.sz_Outcome.__init__Fccs�|j}d|_z�y
dVWn�tk
r.�Yn�tk
rh}z d|_|jj|t|�f�WYdd}~Xnjtk
rzYnXtj�}|j	r�||_
nd|_|jj||f�d}YnX|jr�|jr�|jj|df�Wd|jo�||_XdS)NTF)
r�KeyboardInterruptr	r�append�strr�sys�exc_inforrrr)r�	test_case�isTestZold_success�er r
r
r�testPartExecutor7s*
$
z_Outcome.testPartExecutor)N)F)r
rrr�
contextlib�contextmanagerr$r
r
r
rr-s
	rcCs|S)Nr
)�objr
r
r�_idUsr(cs�fdd�}|S)Ncs4t|t�s$tj|��fdd��}|}d|_�|_|S)Ncst���dS)N)r	)�args�kwargs)�reasonr
r�skip_wrapper^sz-skip.<locals>.decorator.<locals>.skip_wrapperT)�
isinstance�type�	functools�wraps�__unittest_skip__�__unittest_skip_why__)�	test_itemr,)r+r
r�	decorator\s
zskip.<locals>.decoratorr
)r+r4r
)r+r�skipXs
r5cCs|rt|�StS)N)r5r()�	conditionr+r
r
r�skipIfhsr7cCs|st|�StS)N)r5r()r6r+r
r
r�
skipUnlesspsr8cCs
d|_|S)NT)�__unittest_expecting_failure__)r3r
r
rrxsrcs4t|t�r t�fdd�|D��St|t�o2t|��S)Nc3s|]}t|��VqdS)N)�_is_subtype)�.0r#)�basetyper
r�	<genexpr>~sz_is_subtype.<locals>.<genexpr>)r-�tuple�allr.�
issubclass)�expectedr<r
)r<rr:|s
r:c@seZdZdd�Zdd�ZdS)�_BaseTestCaseContextcCs
||_dS)N)r!)rr!r
r
rr�sz_BaseTestCaseContext.__init__cCs |jj|j|�}|jj|��dS)N)r!�_formatMessage�msg�failureException)r�standardMsgrDr
r
r�
_raiseFailure�sz"_BaseTestCaseContext._raiseFailureN)r
rrrrGr
r
r
rrB�srBcCsdtjkrt|�StSdS)NZWITHIN_PYTHON_RPM_BUILD)�os�environr5r()r+r
r
r�_skipInRpmBuild�s
rJc@seZdZddd�Zdd�ZdS)�_AssertRaisesBaseContextNcCs@tj||�||_||_|dk	r*tj|�}||_d|_d|_dS)N)	rBrrAr!�re�compile�expected_regex�obj_namerD)rrAr!rNr
r
rr�s
z!_AssertRaisesBaseContext.__init__cCs�z�t|j|j�s"td||jf��|rD|ddkrDtjdtd�f}|sx|jdd�|_	|rttjdt
t|��td�|S|^}}y|j|_
Wntk
r�t|�|_
YnX|�|||�WdQRXWdd}XdS)Nz%s() arg 1 must be %srzcallable is None�rDz3%r is an invalid keyword argument for this function)r:rA�
_base_type�	TypeError�_base_type_str�warnings�warn�DeprecationWarning�poprD�next�iterr
rO�AttributeErrorr)r�namer)r*Zcallable_objr
r
r�handle�s.z_AssertRaisesBaseContext.handle)N)r
rrrr\r
r
r
rrK�s

rKc@s$eZdZeZdZdd�Zdd�ZdS)�_AssertRaisesContextz-an exception type or tuple of exception typescCs|S)Nr
)rr
r
r�	__enter__�sz_AssertRaisesContext.__enter__c
Cs�|dkrby|jj}Wntk
r2t|j�}YnX|jrP|jdj||j��ql|jdj|��n
tj|�t	||j�s|dS|j
d�|_|jdkr�dS|j}|j
t|��s�|jdj|jt|���dS)Nz{} not raised by {}z
{} not raisedFTz"{}" does not match "{}")rAr
rZrrOrG�format�	traceback�clear_framesr@�with_tracebackZ	exceptionrN�search�pattern)r�exc_type�	exc_value�tb�exc_namerNr
r
r�__exit__�s(


z_AssertRaisesContext.__exit__N)r
rr�
BaseExceptionrQrSr^rir
r
r
rr]�sr]c@s$eZdZeZdZdd�Zdd�ZdS)�_AssertWarnsContextz(a warning type or tuple of warning typescCsRx$tjj�D]}t|dd�ri|_qWtjdd�|_|jj�|_tj	d|j
�|S)N�__warningregistry__T)�record�always)r�modules�values�getattrrlrT�catch_warnings�warnings_managerr^�simplefilterrA)r�vr
r
rr^�s
z_AssertWarnsContext.__enter__c
Cs|jj|||�|dk	rdSy|jj}Wntk
rFt|j�}YnXd}xd|jD]Z}|j}t||j�slqT|dkrx|}|j	dk	r�|j	j
t|��r�qT||_|j|_|j
|_
dSW|dk	r�|jdj|j	jt|���|jr�|jdj||j��n|jdj|��dS)Nz"{}" does not match "{}"z{} not triggered by {}z{} not triggered)rsrirAr
rZrrT�messager-rNrcZwarning�filename�linenorGr_rdrO)rrerfrgrhZfirst_matching�m�wr
r
rri�s8

z_AssertWarnsContext.__exit__N)r
rr�WarningrQrSr^rir
r
r
rrk�srk�_LoggingWatcher�records�outputc@s$eZdZdd�Zdd�Zdd�ZdS)�_CapturingHandlercCstjj|�tgg�|_dS)N)�logging�Handlerrr|�watcher)rr
r
rr,sz_CapturingHandler.__init__cCsdS)Nr
)rr
r
r�flush0sz_CapturingHandler.flushcCs*|jjj|�|j|�}|jjj|�dS)N)r�r}rr_r~)rrmrDr
r
r�emit3s
z_CapturingHandler.emitN)r
rrrr�r�r
r
r
rr'src@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_AssertLogsContextz"%(levelname)s:%(name)s:%(message)scCs:tj||�||_|r(tjj||�|_ntj|_d|_dS)N)	rBr�logger_namer�Z_nameToLevel�get�level�INFOrD)rr!r�r�r
r
rr?sz_AssertLogsContext.__init__cCs�t|jtj�r|j}|_ntj|j�}|_tj|j�}t�}|j	|�|j
|_
|jdd�|_|j
|_|j|_|g|_|j|j
�d|_|j
S)NF)r-r�r�ZLogger�loggerZ	getLoggerZ	Formatter�LOGGING_FORMATrZsetFormatterr��handlers�old_handlersr��	old_level�	propagate�
old_propagate�setLevel)rr�Z	formatterZhandlerr
r
rr^Hs
z_AssertLogsContext.__enter__cCs`|j|j_|j|j_|jj|j�|dk	r.dSt|jj	�dkr\|j
djtj
|j�|jj��dS)NFrz-no logs of level {} or higher triggered on {})r�r�r�r�r�r�r��lenr�r}rGr_r�ZgetLevelNamer�r[)rrerfrgr
r
rriYs

z_AssertLogsContext.__exit__N)r
rrr�rr^rir
r
r
rr�:s	r�c@s�eZdZeZdZd�Zd�ZdZd�dd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
edd��Zedd��Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zejefd(d)��Zd*d+�Zd,d-�Zd.d/�Z d�d1d2�Z!d3d4�Z"d5d6�Z#d7d8�Z$d9d:�Z%d�d;d<�Z&d�d=d>�Z'd�d?d@�Z(dAdB�Z)dCdD�Z*dEdF�Z+d�dGdH�Z,dIdJ�Z-d�dKdL�Z.d�dMdN�Z/d�dOdP�Z0d�dQdR�Z1d�dSdT�Z2d�dUdV�Z3dWdX�Z4d�dYdZ�Z5d�d[d\�Z6d�d]d^�Z7d�d_d`�Z8d�dadb�Z9d�dcdd�Z:d�dedf�Z;d�dgdh�Z<d�didj�Z=d�dkdl�Z>d�dmdn�Z?d�dodp�Z@d�dqdr�ZAd�dsdt�ZBd�dudv�ZCd�dwdx�ZDd�dydz�ZEd�d{d|�ZFd�d}d~�ZGdd��ZHd�d��ZId�d�d��ZJd�d�d��ZKd�d��ZLeLe/�ZMZNeLe0�ZOZPeLe1�ZQZReLe2�ZSZTeLe(�ZUZVeLe*�ZWeLe'�ZXeLeH�ZYeLeJ�ZZeLeK�Z[d0S)��TestCaseT�P���F�runTestcCs�||_d|_d|_yt||�}Wn.tk
rN|dkrJtd|j|f��Yn
X|j|_g|_d|_	i|_
|jtd�|jt
d�|jtd�|jtd�|jtd�|jtd�dS)	NzNo testr�zno such test method in %s: %s�assertDictEqual�assertListEqual�assertTupleEqual�assertSetEqual�assertMultiLineEqual)�_testMethodName�_outcome�_testMethodDocrqrZ�
ValueError�	__class__�__doc__�	_cleanups�_subtest�_type_equality_funcs�addTypeEqualityFunc�dict�listr>�set�	frozensetr)rZ
methodName�
testMethodr
r
rr�s&zTestCase.__init__cCs||j|<dS)N)r�)rZtypeobj�functionr
r
rr��s
zTestCase.addTypeEqualityFunccOs|jj|||f�dS)N)r�r)rr�r)r*r
r
r�
addCleanup�szTestCase.addCleanupcCsdS)Nr
)rr
r
r�setUp�szTestCase.setUpcCsdS)Nr
)rr
r
r�tearDown�szTestCase.tearDowncCsdS)Nr
)�clsr
r
r�
setUpClass�szTestCase.setUpClasscCsdS)Nr
)r�r
r
r�
tearDownClass�szTestCase.tearDownClasscCsdS)Nrr
)rr
r
r�countTestCases�szTestCase.countTestCasescCstj�S)N)rZ
TestResult)rr
r
r�defaultTestResult�szTestCase.defaultTestResultcCs |j}|r|jd�dj�pdS)N�
r)r��split�strip)r�docr
r
r�shortDescription�szTestCase.shortDescriptioncCsdt|j�|jfS)Nz%s.%s)rr�r�)rr
r
r�id�szTestCase.idcCs t|�t|�k	rtS|j|jkS)N)r.�NotImplementedr�)r�otherr
r
r�__eq__�szTestCase.__eq__cCstt|�|jf�S)N)�hashr.r�)rr
r
r�__hash__�szTestCase.__hash__cCsd|jt|j�fS)Nz%s (%s))r�rr�)rr
r
r�__str__�szTestCase.__str__cCsdt|j�|jfS)Nz<%s testMethod=%s>)rr�r�)rr
r
r�__repr__�szTestCase.__repr__cCs<t|dd�}|dk	r |||�ntjdtd�|j|�dS)N�addSkipz4TestResult has no addSkip method, skips not reportedr�)rqrTrU�RuntimeWarning�
addSuccess)rrr!r+r�r
r
r�_addSkipszTestCase._addSkipcks�|jdks|jjrdVdS|j}|dkr8tj|�}n|jj|�}t|||�|_zX|jj|jdd��dVWdQRX|jj	s�|jj
}|dk	r�|jr�t�n|jj
r�t�Wd||_XdS)NT)r")r�rr��collections�ChainMap�params�	new_child�_SubTestr$rrZfailfastrr)rrDr��parentZ
params_maprr
r
r�subTest	s$zTestCase.subTestcCsdx^|D]V\}}t|t�r*|j|j||�q|dk	rt|d|j�rP|j||�q|j||�qWdS)Nr)r-r�rr!r@rE�
addFailureZaddError)rrr�testr r
r
r�_feedErrorsToResult(s
zTestCase._feedErrorsToResultcCsDy
|j}Wn*tk
r4tjdt�|j|�YnX|||�dS)Nz@TestResult has no addExpectedFailure method, reporting as passes)�addExpectedFailurerZrTrUr�r�)rrr r�r
r
r�_addExpectedFailure2s
zTestCase._addExpectedFailurecCshy
|j}WnPtk
rZtjdt�y
td�Wn$tk
rT|j|tj��YnXYn
X||�dS)NzCTestResult has no addUnexpectedSuccess method, reporting as failure)	�addUnexpectedSuccessrZrTrUr�rr�rr )rrr�r
r
r�_addUnexpectedSuccess<s

zTestCase._addUnexpectedSuccessNc
(Cs|}|dkr.|j�}t|dd�}|dk	r.|�|j|�t||j�}t|jdd�s^t|dd�r�z,t|jdd�pxt|dd�}|j|||�Wd|j|�XdSt|dd�}t|dd�}|p�|}t|�}	z�|	|_|	j	|��|j
�WdQRX|	j�r<||	_|	j	|dd��|�WdQRXd|	_|	j	|��|j
�WdQRX|j�x"|	jD]\}
}|j||
|��qLW|j||	j�|	j�r�|�r�|	j�r�|j||	j�n
|j|�n
|j|�|S|j|�|dk�r�t|d	d�}|dk	�r�|�|	jj�d|	_d|_XdS)
N�startTestRunr1Fr2�r9T)r"�stopTestRun)r�rqZ	startTestr�r�r�ZstopTestrr�r$r�rrr��
doCleanupsrr�rrr�r�r��clear)
rrZorig_resultr�r�Zskip_whyZexpecting_failure_methodZexpecting_failure_classr�outcomer�r+r�r
r
r�runKsh





zTestCase.runc
CsN|jp
t�}x:|jrF|jj�\}}}|j|��|||�WdQRXqW|jS)N)r�rr�rWr$r)rr�r�r)r*r
r
rr��szTestCase.doCleanupscOs|j||�S)N)r�)rr)�kwdsr
r
r�__call__�szTestCase.__call__cCsJ|j�t||j��|j�x&|jrD|jjd�\}}}|||�q WdS)Nr���)r�rqr�r�r�rW)rr�r)r*r
r
r�debug�szTestCase.debugcCst|��dS)N)r	)rr+r
r
r�skipTest�szTestCase.skipTestcCs|j|��dS)N)rE)rrDr
r
r�fail�sz
TestCase.failcCs&|r"|j|dt|��}|j|��dS)Nz%s is not false)rCrrE)r�exprrDr
r
r�assertFalse�szTestCase.assertFalsecCs&|s"|j|dt|��}|j|��dS)Nz%s is not true)rCrrE)rr�rDr
r
r�
assertTrue�szTestCase.assertTruecCsP|js|p|S|dkr|Syd||fStk
rJdt|�t|�fSXdS)Nz%s : %s)�longMessage�UnicodeDecodeErrorr)rrDrFr
r
rrC�s
zTestCase._formatMessagec
Os$t||�}z|jd||�Sd}XdS)N�assertRaises)r]r\)r�expected_exceptionr)r*�contextr
r
rr��s
zTestCase.assertRaisescOst||�}|jd||�S)N�assertWarns)rkr\)r�expected_warningr)r*r�r
r
rr��s
zTestCase.assertWarnscCst|||�S)N)r�)rr�r�r
r
r�
assertLogsszTestCase.assertLogscCsFt|�t|�kr@|jjt|��}|dk	r@t|t�r<t||�}|S|jS)N)r.r�r�r-rrq�_baseAssertEqual)r�first�secondZasserterr
r
r�_getAssertEqualityFunc(s

zTestCase._getAssertEqualityFunccCs0||ks,dt||�}|j||�}|j|��dS)Nz%s != %s)rrCrE)rr�r�rDrFr
r
rr�BszTestCase._baseAssertEqualcCs|j||�}||||d�dS)N)rD)r�)rr�r�rDZassertion_funcr
r
r�assertEqualIszTestCase.assertEqualcCs2||ks.|j|dt|�t|�f�}|j|��dS)Nz%s == %s)rCrrE)rr�r�rDr
r
r�assertNotEqualPszTestCase.assertNotEqualcCs�||krdS|dk	r$|dk	r$td��|dk	r\t||�|kr@dSdt|�t|�t|�f}n<|dkrhd}tt||�|�dkr�dSdt|�t|�|f}|j||�}|j|��dS)Nz specify delta or places not bothz%s != %s within %s delta�rz%s != %s within %r places)rR�absr�roundrCrE)rr�r��placesrD�deltarFr
r
r�assertAlmostEqualYs&zTestCase.assertAlmostEqualcCs�|dk	r|dk	rtd��|dk	rZ||kr>t||�|kr>dSdt|�t|�t|�f}nF|dkrfd}||kr�tt||�|�dkr�dSdt|�t|�|f}|j||�}|j|��dS)Nz specify delta or places not bothz%s == %s within %s deltar�rz%s == %s within %r places)rRr�rr�rCrE)rr�r�r�rDr�rFr
r
r�assertNotAlmostEqual�s" zTestCase.assertNotAlmostEqualc'Cs�|dk	rP|j}t||�s.|jd|t|�f��t||�sT|jd|t|�f��nd}d}yt|�}Wn ttfk
r�d|}YnX|dkr�yt|�}Wn ttfk
r�d|}YnX|dk�r�||kr�dSd|j�ft||�}x�t	t
||��D]�}	y||	}
Wn.tttfk
�r8|d|	|f7}PYnXy||	}Wn.tttfk
�rt|d|	|f7}PYnX|
|kr�|d	|	ft|
|�7}Pq�W||k�r�|dk�r�t|�t|�k�r�dS||k�r0|d
|||f7}y|d|t||�f7}Wn,tttfk
�r,|d||f7}YnXnh||k�r�|d
|||f7}y|d|t||�f7}Wn,tttfk
�r�|d||f7}YnX|}ddj
tjtj|�j�tj|�j���}
|j||
�}|j||�}|j|�dS)NzFirst sequence is not a %s: %szSecond sequence is not a %s: %sZsequencez(First %s has no length.    Non-sequence?z)Second %s has no length.    Non-sequence?z%ss differ: %s != %s
z(
Unable to index element %d of first %s
z)
Unable to index element %d of second %s
z#
First differing element %d:
%s
%s
z+
First %s contains %d additional elements.
zFirst extra element %d:
%s
z'Unable to index element %d of first %s
z,
Second %s contains %d additional elements.
z(Unable to index element %d of second %s
r�)r
r-rErr�rR�NotImplementedError�
capitalizer�range�min�
IndexErrorr.�join�difflib�ndiff�pprint�pformat�
splitlines�_truncateMessagerCr�)rZseq1Zseq2rD�seq_typeZ
seq_type_nameZ	differingZlen1Zlen2�iZitem1Zitem2rF�diffMsgr
r
r�assertSequenceEqual�s�




zTestCase.assertSequenceEqualcCs2|j}|dkst|�|kr"||S|tt|�S)N)�maxDiffr��DIFF_OMITTED)rrv�diffZmax_diffr
r
rrszTestCase._truncateMessagecCs|j|||td�dS)N)r)r	r�)rZlist1Zlist2rDr
r
rr�s
zTestCase.assertListEqualcCs|j|||td�dS)N)r)r	r>)rZtuple1Ztuple2rDr
r
rr�s	zTestCase.assertTupleEqualc
 Cshy|j|�}Wn^tk
r>}z|jd|�WYdd}~Xn0tk
rl}z|jd|�WYdd}~XnXy|j|�}Wn^tk
r�}z|jd|�WYdd}~Xn0tk
r�}z|jd|�WYdd}~XnX|p�|s�dSg}|�r|jd�x|D]}|jt|���qW|�rH|jd�x|D]}|jt|���q0Wdj|�}	|j|j||	��dS)Nz/invalid type when attempting set difference: %sz2first argument does not support set difference: %sz3second argument does not support set difference: %sz*Items in the first set but not the second:z*Items in the second set but not the first:r�)�
differencerRr�rZr�reprr�rC)
rZset1Zset2rDZdifference1r#Zdifference2�lines�itemrFr
r
rr�"s2
  




zTestCase.assertSetEqualcCs2||kr.dt|�t|�f}|j|j||��dS)Nz%s not found in %s)rr�rC)r�member�	containerrDrFr
r
r�assertInMszTestCase.assertIncCs2||kr.dt|�t|�f}|j|j||��dS)Nz%s unexpectedly found in %s)rr�rC)rrrrDrFr
r
r�assertNotInTszTestCase.assertNotIncCs2||k	r.dt|�t|�f}|j|j||��dS)Nz%s is not %s)rr�rC)r�expr1�expr2rDrFr
r
r�assertIs[szTestCase.assertIscCs,||kr(dt|�f}|j|j||��dS)Nzunexpectedly identical: %s)rr�rC)rrrrDrFr
r
r�assertIsNotbszTestCase.assertIsNotcCs~|j|td�|j|td�||krzdt||�}ddjtjtj|�j�tj|�j���}|j	||�}|j
|j||��dS)Nz"First argument is not a dictionaryz#Second argument is not a dictionaryz%s != %sr�)�assertIsInstancer�rr�rrrrrrr�rC)rZd1Zd2rDrFrr
r
rr�hs
zTestCase.assertDictEqualc	Cs�tjdt�g}g}xX|j�D]L\}}||kr:|j|�q|||kr|jdt|�t|�t||�f�qW|pt|szdSd}|r�ddjdd�|D��}|r�|r�|d7}|d	dj|�7}|j|j||��dS)
Nz&assertDictContainsSubset is deprecatedz%s, expected: %s, actual: %sr�zMissing: %s�,css|]}t|�VqdS)N)r)r;ryr
r
rr=�sz4TestCase.assertDictContainsSubset.<locals>.<genexpr>z; zMismatched values: %s)	rTrUrV�itemsrrr�r�rC)	rZsubsetZ
dictionaryrDZmissingZ
mismatched�key�valuerFr
r
r�assertDictContainsSubsetts,z!TestCase.assertDictContainsSubsetc
Cs�t|�t|�}}ytj|�}tj|�}Wntk
rHt||�}YnX||krVdSt||�}|r�d}dd�|D�}dj|�}	|j||	�}|j||�}|j	|�dS)NzElement counts were not equal:
cSsg|]}d|�qS)z First has %d, Second has %d:  %rr
)r;rr
r
r�
<listcomp>�sz-TestCase.assertCountEqual.<locals>.<listcomp>r�)
r�r��CounterrRrrr�rrCr�)
rr�r�rDZ	first_seqZ
second_seqZdifferencesrFrrr
r
r�assertCountEqual�s 



zTestCase.assertCountEqualcCs�|j|td�|j|td�||kr�t|�|jks@t|�|jkrN|j|||�|jdd�}|jdd�}t|�dkr�|jd�|kr�|dg}|dg}dt||�}dd	jt	j
||��}|j||�}|j|j
||��dS)
NzFirst argument is not a stringzSecond argument is not a stringT)�keependsrz
r�z%s != %sr�)rrr��_diffThresholdr�rr�rr�rrrr�rC)rr�r�rDZ
firstlinesZsecondlinesrFrr
r
rr��s

zTestCase.assertMultiLineEqualcCs2||ks.dt|�t|�f}|j|j||��dS)Nz%s not less than %s)rr�rC)r�a�brDrFr
r
r�
assertLess�szTestCase.assertLesscCs2||ks.dt|�t|�f}|j|j||��dS)Nz%s not less than or equal to %s)rr�rC)rr$r%rDrFr
r
r�assertLessEqual�szTestCase.assertLessEqualcCs2||ks.dt|�t|�f}|j|j||��dS)Nz%s not greater than %s)rr�rC)rr$r%rDrFr
r
r�
assertGreater�szTestCase.assertGreatercCs2||ks.dt|�t|�f}|j|j||��dS)Nz"%s not greater than or equal to %s)rr�rC)rr$r%rDrFr
r
r�assertGreaterEqual�szTestCase.assertGreaterEqualcCs,|dk	r(dt|�f}|j|j||��dS)Nz%s is not None)rr�rC)rr'rDrFr
r
r�assertIsNone�szTestCase.assertIsNonecCs"|dkrd}|j|j||��dS)Nzunexpectedly None)r�rC)rr'rDrFr
r
r�assertIsNotNone�szTestCase.assertIsNotNonecCs0t||�s,dt|�|f}|j|j||��dS)Nz%s is not an instance of %r)r-rr�rC)rr'r�rDrFr
r
rr�s
zTestCase.assertIsInstancecCs0t||�r,dt|�|f}|j|j||��dS)Nz%s is an instance of %r)r-rr�rC)rr'r�rDrFr
r
r�assertNotIsInstance�s
zTestCase.assertNotIsInstancecOst|||�}|jd||�S)N�assertRaisesRegex)r]r\)rr�rNr)r*r�r
r
rr-�s
zTestCase.assertRaisesRegexcOst|||�}|jd||�S)N�assertWarnsRegex)rkr\)rr�rNr)r*r�r
r
rr.szTestCase.assertWarnsRegexcCsJt|ttf�rtj|�}|j|�sFd|j|f}|j||�}|j|��dS)Nz&Regex didn't match: %r not found in %r)	r-r�bytesrLrMrcrdrCrE)r�textrNrDrFr
r
r�assertRegexs

zTestCase.assertRegexcCs`t|ttf�rtj|�}|j|�}|r\d||j�|j��|j|f}|j	||�}|j
|��dS)Nz"Regex matched: %r matches %r in %r)r-rr/rLrMrc�start�endrdrCrE)rr0Zunexpected_regexrD�matchrFr
r
r�assertNotRegex&s

zTestCase.assertNotRegexcs�fdd�}|S)Ncs tjdj�j�td��||�S)NzPlease use {0} instead.r�)rTrUr_r
rV)r)r*)�
original_funcr
r�deprecated_func6s
z,TestCase._deprecate.<locals>.deprecated_funcr
)r6r7r
)r6r�
_deprecate5szTestCase._deprecatei�i)r�)N)N)N)N)NN)N)N)N)NNN)NNN)NN)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)\r
rr�AssertionErrorrEr�r
r#Z_classSetupFailedrr�r�r�r��classmethodr�r�r�r�r�r�r�r�r�r�r�r%r&�_subtest_msg_sentinelr�r�r�r�r�r�r�r�r�r�r�r�rCr�r�r�r�r�r�r�r�r�r	rr�r�r�rrrrr�rr!r�r&r'r(r)r*r+rr,r-r.r1r5r8ZfailUnlessEqualZassertEqualsZfailIfEqualZassertNotEqualsZfailUnlessAlmostEqualZassertAlmostEqualsZfailIfAlmostEqualZassertNotAlmostEqualsZ
failUnlessZassert_ZfailUnlessRaisesZfailIfZassertRaisesRegexpZassertRegexpMatchesZassertNotRegexpMatchesr
r
r
rr�fs�!
 	


E
	


!



	
'
 
c


+






!










	r�csfeZdZd�fdd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Z�Z
S)�FunctionTestCaseNcs*tt|�j�||_||_||_||_dS)N)�superr<r�
_setUpFunc�
_tearDownFunc�	_testFunc�_description)rZtestFuncr�r�Zdescription)r�r
rrTs
zFunctionTestCase.__init__cCs|jdk	r|j�dS)N)r>)rr
r
rr�[s
zFunctionTestCase.setUpcCs|jdk	r|j�dS)N)r?)rr
r
rr�_s
zFunctionTestCase.tearDowncCs|j�dS)N)r@)rr
r
rr�cszFunctionTestCase.runTestcCs|jjS)N)r@r
)rr
r
rr�fszFunctionTestCase.idcCs@t||j�stS|j|jko>|j|jko>|j|jko>|j|jkS)N)r-r�r�r>r?r@rA)rr�r
r
rr�iszFunctionTestCase.__eq__cCstt|�|j|j|j|jf�S)N)r�r.r>r?r@rA)rr
r
rr�rszFunctionTestCase.__hash__cCsdt|j�|jjfS)Nz%s (%s))rr�r@r
)rr
r
rr�vs
zFunctionTestCase.__str__cCsdt|j�|jfS)Nz<%s tec=%s>)rr�r@)rr
r
rr�zs
zFunctionTestCase.__repr__cCs2|jdk	r|jS|jj}|r.|jd�dj�p0dS)Nr�r)rAr@r�r�r�)rr�r
r
rr�~s
z!FunctionTestCase.shortDescription)NNN)r
rrrr�r�r�r�r�r�r�r�r��
__classcell__r
r
)r�rr<Ks		r<csDeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z�Z	S)
r�cs(t�j�||_||_||_|j|_dS)N)r=r�_messager!r�rE)rr!rvr�)r�r
rr�s

z_SubTest.__init__cCstd��dS)Nzsubtests cannot be run directly)r�)rr
r
rr��sz_SubTest.runTestcCsbg}|jtk	r |jdj|j��|jrTdjdd�t|jj��D��}|jdj|��dj|�p`dS)Nz[{}]z, css|]\}}dj||�VqdS)z{}={!r}N)r_)r;�krur
r
rr=�sz+_SubTest._subDescription.<locals>.<genexpr>z({})� z(<subtest>))rCr;rr_r�r��sortedr)r�partsZparams_descr
r
r�_subDescription�s
z_SubTest._subDescriptioncCsdj|jj�|j��S)Nz{} {})r_r!r�rH)rr
r
rr��sz_SubTest.idcCs
|jj�S)N)r!r�)rr
r
rr��sz_SubTest.shortDescriptioncCsdj|j|j��S)Nz{} {})r_r!rH)rr
r
rr��sz_SubTest.__str__)
r
rrrr�rHr�r�r�rBr
r
)r�rr��sr�)/rr/rrHr�rrLrTr�r%r`r�r�utilrrrrrZ
__unittest�objectr;r�	Exceptionr	rrrr(r5r7r8rr:rBrJrKr]rk�
namedtupler|r�rr�r�r<r�r
r
r
r�<module>sX(
/%5
,l:PKń[�?���)__pycache__/__init__.cpython-36.opt-2.pycnu�[���3

�\dhk�@s�dddddddddd	d
ddd
ddddgZejdddg�dZddlmZddlmZmZmZm	Z	m
Z
mZmZm
Z
ddlmZmZddlmZmZmZmZmZddlmZmZddlmZmZddlmZmZmZm Z eZ!dd�Z"d S)!�
TestResult�TestCase�	TestSuite�TextTestRunner�
TestLoader�FunctionTestCase�main�defaultTestLoader�SkipTest�skip�skipIf�
skipUnless�expectedFailure�TextTestResult�installHandler�registerResult�removeResult�
removeHandler�getTestCaseNames�	makeSuite�
findTestCasesT�)r)rrr	r
rrr
�_skipInRpmBuild)�
BaseTestSuiter)rrrrr)�TestProgramr)rr)rrrrcCs"ddl}|jjt�}|j||d�S)N�)Z	start_dir�pattern)Zos.path�path�dirname�__file__Zdiscover)�loaderZtestsr�osZthis_dir�r!�)/usr/lib64/python3.6/unittest/__init__.py�
load_testsKsr#N)#�__all__�extendZ
__unittest�resultrZcaserrr	r
rrr
rZsuiterrrrrrrrrrZrunnerrrZsignalsrrrrZ_TextTestResultr#r!r!r!r"�<module>/s

(PKń[�l����#__pycache__/__init__.cpython-36.pycnu�[���3

�\dhk�@s�dZddddddddd	d
ddd
dddddgZejdddg�dZddlmZddlmZmZm	Z	m
Z
mZmZm
Z
mZddlmZmZddlmZmZmZmZmZddlmZmZddlmZmZddlmZmZm Z m!Z!eZ"dd �Z#d!S)"a�
Python unit testing framework, based on Erich Gamma's JUnit and Kent Beck's
Smalltalk testing framework (used with permission).

This module contains the core framework classes that form the basis of
specific test cases and suites (TestCase, TestSuite etc.), and also a
text-based utility class for running the tests and reporting the results
 (TextTestRunner).

Simple usage:

    import unittest

    class IntegerArithmeticTestCase(unittest.TestCase):
        def testAdd(self):  # test method names begin with 'test'
            self.assertEqual((1 + 2), 3)
            self.assertEqual(0 + 1, 1)
        def testMultiply(self):
            self.assertEqual((0 * 10), 0)
            self.assertEqual((5 * 8), 40)

    if __name__ == '__main__':
        unittest.main()

Further information is available in the bundled documentation, and from

  http://docs.python.org/library/unittest.html

Copyright (c) 1999-2003 Steve Purcell
Copyright (c) 2003-2010 Python Software Foundation
This module is free software, and you may redistribute it and/or modify
it under the same terms as Python itself, so long as this copyright message
and disclaimer are retained in their original form.

IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.

THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE.  THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
�
TestResult�TestCase�	TestSuite�TextTestRunner�
TestLoader�FunctionTestCase�main�defaultTestLoader�SkipTest�skip�skipIf�
skipUnless�expectedFailure�TextTestResult�installHandler�registerResult�removeResult�
removeHandler�getTestCaseNames�	makeSuite�
findTestCasesT�)r)rrr	r
rrr
�_skipInRpmBuild)�
BaseTestSuiter)rrrrr)�TestProgramr)rr)rrrrcCs"ddl}|jjt�}|j||d�S)N�)Z	start_dir�pattern)Zos.path�path�dirname�__file__Zdiscover)�loaderZtestsr�osZthis_dir�r!�)/usr/lib64/python3.6/unittest/__init__.py�
load_testsKsr#N)$�__doc__�__all__�extendZ
__unittest�resultrZcaserrr	r
rrr
rZsuiterrrrrrrrrrZrunnerrrZsignalsrrrrZ_TextTestResultr#r!r!r!r"�<module>-s 

(PKń[�v��ff%__pycache__/main.cpython-36.opt-1.pycnu�[���3


 \8)�@sldZddlZddlZddlZddlmZmZddlmZdZ	dZ
dZd	d
�Zdd�Z
Gd
d�de�ZeZdS)zUnittest main program�N�)�loader�runner)�installHandlerTaExamples:
  %(prog)s test_module               - run tests from test_module
  %(prog)s module.TestClass          - run tests from module.TestClass
  %(prog)s module.Class.test_method  - run specified test method
  %(prog)s path/to/test_file.py      - run tests from test_file.py
aFExamples:
  %(prog)s                           - run default set of tests
  %(prog)s MyTestSuite               - run suite 'MyTestSuite'
  %(prog)s MyTestCase.testSomething  - run MyTestCase.testSomething
  %(prog)s MyTestCase                - run all 'test*' test methods
                                       in MyTestCase
cCsxtjj|�rt|j�jd�rttjj|�rXtjj|tj��}tjj|�sP|jtj	�rT|S|}|dd�j
dd�j
dd�S|S)Nz.py��\�.�/���)�os�path�isfile�lower�endswith�isabs�relpath�getcwd�
startswith�pardir�replace)�nameZrel_path�r�%/usr/lib64/python3.6/unittest/main.py�
_convert_namesrcCsdd�|D�S)NcSsg|]}t|��qSr)r)�.0rrrr�
<listcomp>.sz"_convert_names.<locals>.<listcomp>r)�namesrrr�_convert_names-src@s�eZdZdZdZdZdZZZZ	Z
dZddddej
ddddddfdd�dd	�Zdd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zddd�Zdd�ZdS) �TestProgramzA command-line program that runs a set of tests; this is primarily
       for making test modules conveniently executable.
    Nr�__main__TF)�	tb_localscCs�t|t�r@t|�|_x0|jd�dd�D]}
t|j|
�|_q(Wn||_|dkrTtj}||_||_	|	|_
||_|
|_||_
|dkr�tjr�d|_n||_||_||_||_tjj|d�|_|j|�|j�dS)Nrr�defaultr)�
isinstance�str�
__import__�module�split�getattr�sys�argv�exit�failfast�
catchbreak�	verbosity�bufferr �warnoptions�warnings�defaultTest�
testRunner�
testLoaderrr�basename�progName�	parseArgs�runTests)�selfr%r1r)r2r3r*r-r+r,r.r0r �partrrr�__init__;s,


zTestProgram.__init__cCs4|rt|�|jdkr|j�|j�tjd�dS)N�)�print�_discovery_parser�_initArgParsers�_print_helpr(r*)r8�msgrrr�	usageExitas
zTestProgram.usageExitcOsZ|jdkr6t|jj��ttd|ji�|jj�n t|jj��ttd|ji�dS)N�prog)	r%r<�_main_parserZformat_help�
MAIN_EXAMPLESr5r=�
print_help�MODULE_EXAMPLES)r8�args�kwargsrrrr?is
zTestProgram._print_helpcCs�|j�|jdkrpt|�dkrD|dj�dkrD|j|dd��dS|jj|dd�|�|js�|jg�dSn|jj|dd�|�|jr�t|j�|_	t
dkr�d|_n6|jdkr�d|_	n$t|jt
�r�|jf|_	nt|j�|_	|j�dS)Nr�discoverr;r)r>r%�lenr�
_do_discoveryrC�
parse_args�testsr�	testNames�__name__r1r"r#�list�createTests)r8r)rrrr6rs(


zTestProgram.parseArgscCs4|jdkr|jj|j�|_n|jj|j|j�|_dS)N)rNr3ZloadTestsFromModuler%�testZloadTestsFromNames)r8rrrrQ�s

zTestProgram.createTestscCs$|j�}|j|�|_|j|�|_dS)N)�_getParentArgParser�_getMainArgParserrC�_getDiscoveryArgParserr=)r8Z
parent_parserrrrr>�szTestProgram._initArgParserscCs�tjdd�}|jddddddd	�|jd
ddddd
d	�|jddddd�|jdkrn|jdddddd�d|_|jdkr�|jdddddd�d|_|jdkr�|jdddddd�d|_|S)NF)Zadd_helpz-vz	--verboser-Zstore_constr;zVerbose output)�dest�actionZconst�helpz-qz--quietrzQuiet outputz--localsr �
store_truez"Show local variables in tracebacks)rVrWrXz-fz
--failfastr+zStop on first fail or errorz-cz--catchr,z'Catch Ctrl-C and display results so farz-bz--bufferr.z%Buffer stdout and stderr during tests)�argparse�ArgumentParser�add_argumentr+r,r.)r8�parserrrrrS�s4







zTestProgram._getParentArgParsercCs2tj|gd�}|j|_|j|_|jdddd�|S)N)�parentsrM�*z?a list of any number of test modules, classes and test methods.)�nargsrX)rZr[r5rBr?rEr\)r8�parentr]rrrrT�szTestProgram._getMainArgParsercCs~tj|gd�}d|j|_d|_|jddddd�|jd	d
ddd�|jd
dddd�x"dD]}|j|dtjtjd�q\W|S)N)r^z%s discoverzcFor test discovery all test modules must be importable from the top level directory of the project.z-sz--start-directory�startz*Directory to start discovery ('.' default))rVrXz-pz	--pattern�patternz+Pattern to match tests ('test*.py' default)z-tz--top-level-directory�topz<Top level directory of project (defaults to start directory)�?)r`r!rX)rbrcrd)rZr[r5rBZepilogr\ZSUPPRESS)r8rar]�argrrrrU�s



z"TestProgram._getDiscoveryArgParsercCshd|_d|_d|_|dk	r:|jdkr,|j�|jj||�|dkrH|jn|�}|j|j|j|j�|_dS)Nrztest*.py)	rbrcrdr=r>rLr3rIrR)r8r)�LoaderrrrrrK�s
zTestProgram._do_discoverycCs�|jrt�|jdkrtj|_t|jt�r�yVy"|j|j|j|j	|j
|jd�}Wn.tk
r||j|j|j|j	|j
d�}YnXWq�tk
r�|j�}Yq�Xn|j}|j
|j�|_|jr�tj|jj��dS)N)r-r+r.r0r )r-r+r.r0)r,rr2rZTextTestRunnerr"�typer-r+r.r0r �	TypeErrorZrunrR�resultr*r(Z
wasSuccessful)r8r2rrrr7�s.
zTestProgram.runTests)N)N)rO�
__module__�__qualname__�__doc__r%r-r+r,r.r5r0r=rZdefaultTestLoaderr:rAr?r6rQr>rSrTrUrKr7rrrrr1s&#
	
r)rmr(rZr�rrZsignalsrZ
__unittestrDrFrr�objectr�mainrrrr�<module>s	TPKń[tp��%__pycache__/util.cpython-36.opt-2.pycnu�[���3


 \9�@s�ddlmZmZddlmZdZdZdZdZdZ	dZ
eeee
ee	Zdd�Zd	d
�Z
ddd
�Zdd�Zdd�Zdd�Zdd�Zedd�Zdd�Zdd�Zdd�ZdS) �)�
namedtuple�OrderedDict)�commonprefixT�P��cCsBt|�||}|tkr>d|d|�||t|�|d�f}|S)Nz%s[%d chars]%s)�len�_PLACEHOLDER_LEN)�s�	prefixlenZ	suffixlen�skip�r
�%/usr/lib64/python3.6/unittest/util.py�_shortens&rcs�ttt|��}ttt|��}|tkr(|St|��t���t|�tt}|t	krxt
�t|��t��fdd�|D��St
�tt	��t��fdd�|D��S)Nc3s|]}�|�d�VqdS)Nr
)�.0r
)�prefixrr
r�	<genexpr>'sz'_common_shorten_repr.<locals>.<genexpr>c3s&|]}�t|�d�tt�VqdS)N)r�
_MIN_DIFF_LEN�_MIN_END_LEN)rr
)rrr
rr*s)�tuple�map�	safe_repr�maxr�_MAX_LENGTHr�_MIN_BEGIN_LENr	�_MIN_COMMON_LENr)�args�maxlenZ
common_lenr
)rrr�_common_shorten_reprsrFcCsRyt|�}Wntk
r*tj|�}YnX|s>t|�tkrB|S|dt�dS)Nz [truncated]...)�repr�	Exception�object�__repr__rr)�objZshort�resultr
r
rr-srcCsd|j|jfS)Nz%s.%s)�
__module__�__qualname__)�clsr
r
r�strclass6sr(cCs*d}}g}g}�xy�||}||}||kr\|j|�|d7}x�|||krX|d7}qBWn�||kr�|j|�|d7}xf|||kr�|d7}qxWnL|d7}zx|||kr�|d7}q�WWd|d7}x|||kr�|d7}q�WXWqtk
�r|j||d��|j||d��PYqXqW||fS)Nr�)�append�
IndexError�extend)�expected�actual�i�j�missingZ
unexpected�e�ar
r
r�sorted_list_difference9s:

r4cCsLg}x>|rB|j�}y|j|�Wqtk
r>|j|�YqXqW||fS)N)�pop�remove�
ValueErrorr*)r-r.r1�itemr
r
r�unorderable_list_differencebsr9cCs||k||kS)Nr
)�x�yr
r
r�
three_way_cmpssr<ZMismatchzactual expected valuecCsDt|�t|�}}t|�t|�}}t�}g}x�t|�D]�\}}	|	|krJq8d}
}x.t||�D] }|||	kr^|
d7}
|||<q^Wx,t|�D] \}}
|
|	kr�|d7}|||<q�W|
|kr8t|
||	�}|j|�q8Wxlt|�D]`\}}	|	|kr�q�d}x2t||�D]$}|||	k�r�|d7}|||<�q�Wtd||	�}|j|�q�W|S)Nrr))�listrr!�	enumerate�range�	_Mismatchr*)r.r-r
�t�m�nZNULLr$r/�elem�cnt_s�cnt_tr0Z
other_elem�diffr
r
r�_count_diff_all_purposeys<rHcCs,t�}x |D]}|j|d�d||<qW|S)Nrr))r�get)�iterable�crDr
r
r�_ordered_count�s
rLc	Cs�t|�t|�}}g}x>|j�D]2\}}|j|d�}||kr t|||�}|j|�q Wx2|j�D]&\}}||kr`td||�}|j|�q`W|S)Nr)rL�itemsrIr@r*)	r.r-r
rAr$rDrErFrGr
r
r�_count_diff_hashable�srNN)F)�collectionsrrZos.pathrZ
__unittestrr	rrrrrrrr(r4r9r<r@rHrLrNr
r
r
r�<module>s(
	)
#PKń[Kk��\�\�__pycache__/mock.cpython-36.pycnu�[���3


 \�7�@sFd�Zd
ZddlZddlZddlZddlZddlmZddlm	Z	m
Z
dd�ee�D�Ze
fZdejkrzddlZe
ejjfZdZeZdd�Zdd�Zdd�Zd�dd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd�d'd(�Zd)d*�Zd+d,�Z Gd-d.�d.e!�Z"Gd/d0�d0e!�Z#e#�Z$e$j%Z%e$j&Z'e$j(Z)d1d2�Z*d3d4d5d6d7d8d9d:hZ+d;d<�Z,Gd=d>�d>e-�Z.d?d@�Z/GdAdB�dBe!�Z0GdCdD�dDe!�Z1GdEd	�d	e1�Z2dFdG�Z3GdHdI�dIe1�Z4GdJd�de4e2�Z5dKdL�Z6dMdN�Z7dOdP�Z8GdQdR�dRe!�Z9dSdT�Z:e%dddddfdUdV�Z;d�dWdX�Z<e%dddddfdYd�Z=GdZd[�d[e!�Z>d\d]�Z?d^d_�Z@e;e=_!e>e=_Ae<e=_Be@e=_Cd`e=_DdaZEdbZFdcjGddde�eFjH�D��ZIdcjGdfde�eFjH�D��ZJdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxhZKdydz�ZLd{d�dcjGeEeFeIeJg�jH�D�ZMeMeKBZNd|d}d~dd�d�d�d�hZOd�d��d�d��d�d��d��ZPeQeQeQeQd�dddd�d�dd�d��ZRd�d��ZSd�d��ZTd�d��ZUeSeTeUd��ZVd�d��ZWGd�d��d�e!�ZXGd�d
�d
eXe2�ZYGd�d�deXe5�ZZGd�d��d�e!�Z[Gd�d��d�e!�Z\e\�Z]d�d��Z^Gd�d��d�e_�Z`e`dd��Zad�d�d�Zbd�d��Zcd�d��ZdGd�d��d�e!�Zeefeb�efe]jg�fZhefe]jgji�fZjdakd�d��Zld�d�d�ZmGd�d�de5�ZndS)��Mock�	MagicMock�patch�sentinel�DEFAULT�ANY�call�create_autospec�
FILTER_DIR�NonCallableMock�NonCallableMagicMock�	mock_open�PropertyMockz1.0�N)�
ModuleType)�wraps�partialcCsh|]}|jd�s|�qS)�_)�
startswith)�.0�name�r�%/usr/lib64/python3.6/unittest/mock.py�	<setcomp>#sr�javaTcCstt|�t�S)N)�
issubclass�typer
)�objrrr�_is_instance_mock2srcCst|t�pt|t�ot|t�S)N)�
isinstance�BaseExceptionsrr)rrrr�
_is_exception8s
r cCs�t|t�r6|r6y
|j}Wntk
r.dSXd}n*t|t�s`y
|j}Wntk
r^dSX|rpt|d�}n|}y|tj|�fSt	k
r�dSXdS)z�
    Given an arbitrary, possibly callable object, try to create a suitable
    signature object.
    Return a (reduced func, signature) tuple, or None.
    NT)
rr�__init__�AttributeError�
FunctionTypes�__call__r�inspectZ	signature�
ValueError)�funcZas_instanceZeat_selfZsig_funcrrr�_get_signature_object?s$


r(FcsDt|||���dkrdS�\}��fdd�}t||�|t|�_dS)Ncs�j||�dS)N)�bind)�
_mock_self�args�kwargs)�sigrr�checksigdsz"_check_signature.<locals>.checksig)r(�_copy_func_detailsr�_mock_check_sig)r'�mock�	skipfirst�instancer.r)r-r�_check_signature_s
r4c#Cs�|j|_|j|_y|j|_Wntk
r0YnXy|j|_Wntk
rRYnXy|j|_Wntk
rtYnXy|j|_Wntk
r�YnXdS)N)�__name__�__doc__�__text_signature__r"�
__module__�__defaults__�__kwdefaults__)r'�funcopyrrrr/js$r/cCs&t|t�rdSt|dd�dk	r"dSdS)NTr$F)rr�getattr)rrrr�	_callable�s

r=cCst|�ttfkS)N)r�list�tuple)rrrr�_is_list�sr@cCsHt|t�st|dd�dk	Sx(|f|jD]}|jjd�dk	r(dSq(WdS)ztGiven an object, return True if the object is callable.
    For classes, return True if instances would be callable.r$NTF)rrr<�__mro__�__dict__�get)r�baserrr�_instance_callable�s
rEcs�t|�sdSt|t�}t|||�}|dkr.|S|\}��fdd�}t||�|j}|j�s^d}||d�}d|}	t|	|�||}
t|
|�|
S)Ncs�j||�dS)N)r))r+r,)r-rrr.�sz _set_signature.<locals>.checksigr;)Z
_checksig_r1zYdef %s(*args, **kwargs):
    _checksig_(*args, **kwargs)
    return mock(*args, **kwargs))	r=rrr(r/r5�isidentifier�exec�_setup_func)r1�originalr3r2�resultr'r.r�context�srcr;r)r-r�_set_signature�s$




rMc
s���_t��sdS�fdd�}�fdd�}�fdd�}�fdd�}�fd	d
�}�fdd�}�fd
d�}��fdd�}	d�_d�_d�_t��_t��_t��_�j	�_	�j
�_
�j�_|�_|�_
|�_|�_|	�_|�_|�_|�_��_dS)Ncs�j||�S)N)�assert_called_with)r+r,)r1rrrN�sz'_setup_func.<locals>.assert_called_withcs�j||�S)N)�
assert_called)r+r,)r1rrrO�sz"_setup_func.<locals>.assert_calledcs�j||�S)N)�assert_not_called)r+r,)r1rrrP�sz&_setup_func.<locals>.assert_not_calledcs�j||�S)N)�assert_called_once)r+r,)r1rrrQ�sz'_setup_func.<locals>.assert_called_oncecs�j||�S)N)�assert_called_once_with)r+r,)r1rrrR�sz,_setup_func.<locals>.assert_called_once_withcs�j||�S)N)�assert_has_calls)r+r,)r1rrrS�sz%_setup_func.<locals>.assert_has_callscs�j||�S)N)�assert_any_call)r+r,)r1rrrT�sz$_setup_func.<locals>.assert_any_callcs:t��_t��_�j��j}t|�r6|�k	r6|j�dS)N)�	_CallList�method_calls�
mock_calls�
reset_mock�return_valuer)�ret)r;r1rrrX�sz_setup_func.<locals>.reset_mockFr)r1r�called�
call_count�	call_argsrU�call_args_listrVrWrY�side_effect�_mock_childrenrNrRrSrTrXrOrPrQ�_mock_delegate)
r;r1rNrOrPrQrRrSrTrXr)r;r1rrH�s:rHcCsd|dd�|kS)Nz__%s__����r)rrrr�	_is_magic�srdc@s eZdZdZdd�Zdd�ZdS)�_SentinelObjectz!A unique, named, sentinel object.cCs
||_dS)N)r)�selfrrrrr!�sz_SentinelObject.__init__cCs
d|jS)Nzsentinel.%s)r)rfrrr�__repr__�sz_SentinelObject.__repr__N)r5r8�__qualname__r6r!rgrrrrre�srec@s eZdZdZdd�Zdd�ZdS)�	_SentinelzAAccess attributes to return a named object, usable as a sentinel.cCs
i|_dS)N)�
_sentinels)rfrrrr!�sz_Sentinel.__init__cCs|dkrt�|jj|t|��S)N�	__bases__)r"rj�
setdefaultre)rfrrrr�__getattr__sz_Sentinel.__getattr__N)r5r8rhr6r!rmrrrrri�sricCs$t|�ttttfkr t|�|�S|S)N)r�dictr>r?�set)�valuerrr�_copysrqrY�_mock_return_valuer_�_mock_side_effect�_mock_parent�_mock_new_parent�
_mock_name�_mock_new_namecCs8tj|�d|}||fdd�}||fdd�}t||�S)NZ_mock_cSs"|j}|dkrt||�St||�S)N)rar<)rfr�	_the_namer-rrr�_gets
z"_delegating_property.<locals>._getcSs*|j}|dkr||j|<nt|||�dS)N)rarB�setattr)rfrprrxr-rrr�_set$sz"_delegating_property.<locals>._set)�_allowed_names�add�property)rrxryr{rrr�_delegating_propertys

rc@seZdZdd�Zdd�ZdS)rUcCsnt|t�stj||�St|�}t|�}||kr2dSx6td||d�D] }||||�}||krFdSqFWdS)NFr�T)rr>�__contains__�len�range)rfrpZ	len_valueZlen_self�iZsub_listrrrr�1s
z_CallList.__contains__cCstjt|��S)N)�pprintZpformatr>)rfrrrrg?sz_CallList.__repr__N)r5r8rhr�rgrrrrrU/srUcCsxt|�sdS|js,|js,|jdk	s,|jdk	r0dS|}x|dk	rR||krJdS|j}q6W|rd||_||_|rt||_||_dS)NFT)rrvrwrtru)�parentrpr�new_name�_parentrrr�_check_and_set_parentCs$



r�c@s$eZdZdd�Zdd�Zdd�ZdS)�	_MockItercCst|�|_dS)N)�iterr)rfrrrrr!]sz_MockIter.__init__cCs|S)Nr)rfrrr�__iter___sz_MockIter.__iter__cCs
t|j�S)N)�nextr)rfrrr�__next__asz_MockIter.__next__N)r5r8rhr!r�r�rrrrr�\sr�c@seZdZeZdZdd�ZdS)�BaseNcOsdS)Nr)rfr+r,rrrr!gsz
Base.__init__)r5r8rhrrrrsr!rrrrr�dsr�c@sHeZdZdZdd�ZdDdd�Zd	d
�ZdEdd�ZdFd
d�Zdd�Z	dd�Z
dZee	e
e�Z
edd��Zed�Zed�Zed�Zed�Zed�Zdd�Zdd�Zeee�ZdGddd�d d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Z d2d3�Z!d4d5�Z"d6d7�Z#d8d9�Z$d:d;�Z%d<d=�Z&dHd>d?�Z'd@dA�Z(dBdC�Z)dS)Ir
z A non-callable version of `Mock`cOs$t|j|fd|ji�}tj|�}|S)Nr6)rr5r6�object�__new__)�clsr+�kw�newr3rrrr�os
zNonCallableMock.__new__N�FcKs�|dkr|}|j}
||
d<||
d<||
d<||
d<|dk	rB|}d}|
dkrR|dk	}
|j|||	|
�i|
d<||
d<d|
d<d	|
d
<d|
d<d|
d
<t�|
d<t�|
d<t�|
d<||
d<|r�|jf|�tt|�j||||||�dS)NrtrvrwruTr`�_mock_wrapsraFZ_mock_calledZ_mock_call_argsrZ_mock_call_countZ_mock_call_args_listZ_mock_mock_callsrV�_mock_unsafe)rB�_mock_add_specrU�configure_mock�_safe_superr
r!)rf�specrr�spec_setr��_spec_state�	_new_name�_new_parent�_spec_as_instance�	_eat_selfZunsafer,rBrrrr!xs8




zNonCallableMock.__init__cCs(d|_d|_d|_d|_t|||�dS)z�
        Attach a mock as an attribute of this one, replacing its name and
        parent. Calls to the attached mock will be recorded in the
        `method_calls` and `mock_calls` attributes of this one.Nr�)rtrurvrwrz)rfr1�	attributerrr�attach_mock�s
zNonCallableMock.attach_mockcCs|j||�dS)z�Add a spec to a mock. `spec` can either be an object or a
        list of strings. Only attributes on the `spec` can be fetched as
        attributes from the mock.

        If `spec_set` is True then only attributes on the spec can be set.N)r�)rfr�r�rrr�
mock_add_spec�szNonCallableMock.mock_add_specc	Cs|d}d}|dk	rRt|�rRt|t�r*|}nt|�}t|||�}|oH|d}t|�}|j}||d<||d<||d<||d<dS)Nr��_spec_class�	_spec_set�_spec_signature�
_mock_methods)r@rr�
_get_classr(�dirrB)	rfr�r�r�r�r�r��resrBrrrr��s
zNonCallableMock._mock_add_speccCs8|j}|jdk	r|jj}|tkr4|j|dd�}||_|S)Nz())r�r�)rrrarYr�_get_child_mock)rfrZrrrZ__get_return_value�s

z"NonCallableMock.__get_return_valuecCs,|jdk	r||j_n||_t||dd�dS)Nz())rarYrrr�)rfrprrrZ__set_return_value�s

z"NonCallableMock.__set_return_valuez1The value to be returned when the mock is called.cCs|jdkrt|�S|jS)N)r�r)rfrrr�	__class__�s
zNonCallableMock.__class__r[r\r]r^rWcCsT|j}|dkr|jS|j}|dk	rPt|�rPt|t�rPt|�rPt|�}||_|S)N)rarsr_�callablerr�r )rf�	delegatedZsfrrrZ__get_side_effect�sz!NonCallableMock.__get_side_effectcCs(t|�}|j}|dkr||_n||_dS)N)�	_try_iterrarsr_)rfrpr�rrrZ__set_side_effects
z!NonCallableMock.__set_side_effect)rYr_cCs�|dkrg}t|�|krdS|jt|��d|_d|_d|_t�|_t�|_t�|_|r^t	|_
|rhd|_x0|jj
�D]"}t|t�st|tkr�qt|j|�qtW|j
}t|�r�||k	r�|j|�dS)z-Restore the mock object to its initial state.NFr)�id�appendr[r]r\rUrWr^rVrrrrsr`�valuesr�
_SpecState�_deletedrXr)rfZvisitedrYr_ZchildrZrrrrX
s,zNonCallableMock.reset_mockcKs`xZt|j�dd�d�D]B\}}|jd�}|j�}|}x|D]}t||�}q:Wt|||�qWdS)aZSet attributes on the mock through keyword arguments.

        Attributes plus return values and side effects can be set on child
        mocks using standard dot notation and unpacking a dictionary in the
        method call:

        >>> attrs = {'method.return_value': 3, 'other.side_effect': KeyError}
        >>> mock.configure_mock(**attrs)cSs|djd�S)Nr�.)�count)�entryrrr�<lambda>8sz0NonCallableMock.configure_mock.<locals>.<lambda>)�keyr�N)�sorted�items�split�popr<rz)rfr,�arg�valr+�finalrr�rrrr�+s	


zNonCallableMock.configure_mockcCs�|dkrt|��n:|jdk	r<||jks.|tkrLtd|��nt|�rLt|��|jsd|jd�rdt|��|jj|�}|tkr�t|��np|dkr�d}|j	dk	r�t
|j	|�}|j|||||d�}||j|<n.t|t
�r�t|j|j|j|j|j�}||j|<|S)	Nr�r�zMock object has no attribute %r�assert�assret)r�rrr�r�>r�r�)r�r�)r"r��_all_magicsrdr�rr`rCr�r�r<r�rr�rr�r�r3r�r)rfrrJrrrrrmAs6






zNonCallableMock.__getattr__c
Cs"|jg}|j}|}d}|dgkr$d}t�}xT|dk	r~|}|j|j|�d}|jdkrZd}|j}t|�|krnP|jt|��q,Wtt|��}|jp�d}t	|�dkr�|dd
kr�|d7}||d<dj
|�}d}|dkr�d	|}d}	|jdk	�rd
}	|j�r�d}	|	|jj
}	dt|�j
||	t|�fS)Nr��()r�r1r��().r�mock.z name=%rz spec=%rz spec_set=%rz<%s%s%s id='%s'>)r�r�)r1r�)rwruror�r�r}r>�reversedrvr��joinr�r�r5r)
rfZ
_name_listr�Zlast�dot�seenZ_firstrZname_stringZspec_stringrrrrggsL




zNonCallableMock.__repr__cCshtstj|�S|jpg}tt|��}t|j�}dd�|D�}dd�|D�}tt	|||t|j
���S)z8Filter the output of `dir(mock)` to only useful members.cSsg|]}|jd�s|�qS)r)r)r�errr�
<listcomp>�sz+NonCallableMock.__dir__.<locals>.<listcomp>cSs$g|]}|jd�st|�r|�qS)r)rrd)rr�rrrr��s)r	r��__dir__r�r�rr>rBr�ror`)rfZextrasZ	from_typeZ	from_dictrrrr��s


zNonCallableMock.__dir__cs"|tkrtj�||�S�jrH�jdk	rH|�jkrH|�jkrHtd|��n�|tkrbd|}t|��n�|tkr�jdk	r�|�jkr�td|��t	|�s�t
t��|t||��|���fdd�}n(t
�|d|�t
t��||�|�j|<n.|dk�r�|�_dSt
�|||��r|�j|<tj�||�S)Nz!Mock object has no attribute '%s'z.Attempting to set unsupported magic method %r.cs��f|�|�S)Nr)r+r�)rIrfrrr��sz-NonCallableMock.__setattr__.<locals>.<lambda>r�)r|r��__setattr__r�r�rBr"�_unsupported_magicsr�rrzr�_get_methodr�r`r�)rfrrp�msgr)rIrfrr��s2




zNonCallableMock.__setattr__cCs�|tkr2|t|�jkr2tt|�|�||jkr2dS||jkrHtj||�|jj|t�}|t	krft
|��|tk	rv|j|=t	|j|<dS)N)r�rrB�delattrr��__delattr__r`rC�_missingr�r")rfrrrrrr��s

zNonCallableMock.__delattr__cCs|jpd}t|||�S)Nr1)rv�_format_call_signature)rfr+r,rrrr�_format_mock_call_signature�s
z+NonCallableMock._format_mock_call_signaturecCsDd}|j||�}|j}t|�dkr.|dd�}|j|�}|||fS)Nz!Expected call: %s
Actual call: %s�r�)r�r]r�)rfr+r,�message�expected_stringr]Z
actual_stringrrr�_format_mock_failure_message�s
z,NonCallableMock._format_mock_failure_messagecCst|j}|dk	rlt|�dkr(d}|\}}n
|\}}}y||j||�fStk
rh}z
|jd�Sd}~XqpXn|SdS)a
        Given a call (or simply an (args, kwargs) tuple), return a
        comparison key suitable for matching with other calls.
        This is a best effort method which relies on the spec's signature,
        if available, or falls back on the arguments themselves.
        Nrbr�)r�r�r)�	TypeError�with_traceback)rf�_callr-rr+r,r�rrr�
_call_matcher�s

zNonCallableMock._call_matchercCs.|}|jdkr*d|jpd|jf}t|��dS)z/assert that the mock was never called.
        rz7Expected '%s' to not have been called. Called %s times.r1N)r\rv�AssertionError)r*rfr�rrrrPs

z!NonCallableMock.assert_not_calledcCs(|}|jdkr$d|jpd}t|��dS)z6assert that the mock was called at least once
        rz"Expected '%s' to have been called.r1N)r\rvr�)r*rfr�rrrrOs

zNonCallableMock.assert_calledcCs.|}|jdks*d|jpd|jf}t|��dS)z3assert that the mock was called only once.
        r�z8Expected '%s' to have been called once. Called %s times.r1N)r\rvr�)r*rfr�rrrrQs

z"NonCallableMock.assert_called_oncecs||��jdkr(�j���}td|f�����fdd�}�j��f�}�j�j�}||krxt|t�rh|nd}t|��|�dS)z�assert that the mock was called with the specified arguments.

        Raises an AssertionError if the args and keyword args passed in are
        different to the last call to the mock.NzExpected call: %s
Not calledcs�j���}|S)N)r�)r�)r+r,rfrr�_error_message'sz:NonCallableMock.assert_called_with.<locals>._error_message)r]r�r�r�r�	Exception)r*r+r,�expectedr��actual�causer)r+r,rfrrNs
z"NonCallableMock.assert_called_withcOs6|}|jdks*d|jpd|jf}t|��|j||�S)ziassert that the mock was called exactly once and that that call was
        with the specified arguments.r�z1Expected '%s' to be called once. Called %s times.r1)r\rvr�rN)r*r+r,rfr�rrrrR1s
z'NonCallableMock.assert_called_once_withcs��fdd�|D�}t|t�r |nd}t�fdd��jD��}|sd||kr`tdt|��jf�|�dSt|�}g}x:|D]2}y|j|�Wqvtk
r�|j|�YqvXqvW|r�tdt	|�f�|�dS)a�assert the mock has been called with the specified calls.
        The `mock_calls` list is checked for the calls.

        If `any_order` is False (the default) then the calls must be
        sequential. There can be extra calls before or after the
        specified calls.

        If `any_order` is True then the calls can be in any order, but
        they must all appear in `mock_calls`.csg|]}�j|��qSr)r�)r�c)rfrrr�Fsz4NonCallableMock.assert_has_calls.<locals>.<listcomp>Nc3s|]}�j|�VqdS)N)r�)rr�)rfrr�	<genexpr>Hsz3NonCallableMock.assert_has_calls.<locals>.<genexpr>z(Calls not found.
Expected: %r
Actual: %rz%r not all found in call list)
rr�rUrWr�r>�remover&r�r?)rfZcallsZ	any_orderr�r�Z	all_callsZ	not_foundZkallr)rfrrS<s*

z NonCallableMock.assert_has_callscsZ�j||f�}�fdd��jD�}||krVt|t�r8|nd}�j||�}td|�|�dS)z�assert the mock has been called with the specified arguments.

        The assert passes if the mock has *ever* been called, unlike
        `assert_called_with` and `assert_called_once_with` that only pass if
        the call is the most recent one.csg|]}�j|��qSr)r�)rr�)rfrrr�fsz3NonCallableMock.assert_any_call.<locals>.<listcomp>Nz%s call not found)r�r^rr�r�r�)rfr+r,r�r�r�r�r)rfrrT_szNonCallableMock.assert_any_callcKsFt|�}t|t�s2t|t�r"t}q<t|t�r<t}n
|jd}|f|�S)aPCreate the child mocks for attributes and return value.
        By default child mocks will be the same type as the parent.
        Subclasses of Mock may want to override this to customize the way
        child mocks are made.

        For non-callable mocks the callable variant will be used (rather than
        any custom subclass).r�)rr�
CallableMixinrrr
rrA)rfr��_type�klassrrrr�os



zNonCallableMock._get_child_mock)NNNNNNr�NFNF)F)FF)N)F)*r5r8rhr6r�r!r�r�r�Z"_NonCallableMock__get_return_valueZ"_NonCallableMock__set_return_valueZ"_NonCallableMock__return_value_docr~rYr�rr[r\r]r^rWZ!_NonCallableMock__get_side_effectZ!_NonCallableMock__set_side_effectr_rXr�rmrgr�r�r�r�r�r�rPrOrQrNrRrSrTr�rrrrr
lsR

)
	


&2"
			
#cCsF|dkr|St|�r|St|�r$|Syt|�Stk
r@|SXdS)N)r r=r�r�)rrrrr��sr�c
@sBeZdZddedddddddf
dd�Zdd�Zdd�Zd	d
�ZdS)r�Nr�c	Ks6||jd<tt|�j|||||||	|
f|�||_dS)Nrr)rBr�r�r!r_)rfr�r_rYrrr�r�r�r�r�r,rrrr!�s



zCallableMixin.__init__cOsdS)Nr)rfr+r,rrrr0�szCallableMixin._mock_check_sigcOs|j||�|j||�S)N)r0�
_mock_call)r*r+r,rrrr$�szCallableMixin.__call__cOs�|}d|_|jd7_t||fdd�}||_|jj|�t�}|jdk	}|j}|j	}|dk}	|j
jtd||f��|j}
x�|
dk	�r*|r�|
jjt|||f��|
jdk	}|r�|
jd|}t|||f�}|
j
j|�|
j	�r|	r�d}nd}|
j	dk}	|
j	||}|
j}
t
|
�}
|
|k�rP|j|
�q|W|j}|dk	�r�t|��rL|�n,t|��snt|�}t|��rx|�n
|||�}|tk	�r�|S|jtk	�r�|jS|jdk	�r�|j||�S|jS)NTr�)�twoz()r�r�)r[r\�_Callr]r^r�rortrvrwrWrurVr�r}r_r r=r�rrrrYr�)r*r+r,rfr�r�Zdo_method_callsZmethod_call_nameZmock_call_nameZ	is_a_callr�Zthis_mock_callr�Z_new_parent_idZeffectrJrrrr��s`









zCallableMixin._mock_call)r5r8rhrr!r0r$r�rrrrr��sr�c@seZdZdZdS)ra�	
    Create a new `Mock` object. `Mock` takes several optional arguments
    that specify the behaviour of the Mock object:

    * `spec`: This can be either a list of strings or an existing object (a
      class or instance) that acts as the specification for the mock object. If
      you pass in an object then a list of strings is formed by calling dir on
      the object (excluding unsupported magic attributes and methods). Accessing
      any attribute not in this list will raise an `AttributeError`.

      If `spec` is an object (rather than a list of strings) then
      `mock.__class__` returns the class of the spec object. This allows mocks
      to pass `isinstance` tests.

    * `spec_set`: A stricter variant of `spec`. If used, attempting to *set*
      or get an attribute on the mock that isn't on the object passed as
      `spec_set` will raise an `AttributeError`.

    * `side_effect`: A function to be called whenever the Mock is called. See
      the `side_effect` attribute. Useful for raising exceptions or
      dynamically changing return values. The function is called with the same
      arguments as the mock, and unless it returns `DEFAULT`, the return
      value of this function is used as the return value.

      If `side_effect` is an iterable then each call to the mock will return
      the next value from the iterable. If any of the members of the iterable
      are exceptions they will be raised instead of returned.

    * `return_value`: The value returned when the mock is called. By default
      this is a new Mock (created on first access). See the
      `return_value` attribute.

    * `wraps`: Item for the mock object to wrap. If `wraps` is not None then
      calling the Mock will pass the call through to the wrapped object
      (returning the real result). Attribute access on the mock will return a
      Mock object that wraps the corresponding attribute of the wrapped object
      (so attempting to access an attribute that doesn't exist will raise an
      `AttributeError`).

      If the mock has an explicit `return_value` set then calls are not passed
      to the wrapped object and the `return_value` is returned instead.

    * `name`: If the mock has a name then it will be used in the repr of the
      mock. This can be useful for debugging. The name is propagated to child
      mocks.

    Mocks can also be called with arbitrary keyword arguments. These will be
    used to set attributes on the mock after it is created.
    N)r5r8rhr6rrrrr�s1cCs2y
t||�Stk
r,t|�t||�SXdS)N)r<r"�
__import__)�thing�comp�import_pathrrr�_dot_lookup1s

r�cCsF|jd�}|jd�}t|�}x$|D]}|d|7}t|||�}q"W|S)Nr�rz.%s)r�r�r�r�)�targetZ
componentsr�r�r�rrr�	_importer9s


r�cCs
t|d�S)N�is_local)�hasattr)�patcherrrr�_is_startedDsr�c@sdeZdZdZgZdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�ZdS)�_patchNc

Csn|dk	r(|tk	rtd��|dk	r(td��||_||_||_||_||_||_d|_||_	||_
|	|_g|_dS)Nz,Cannot use 'new' and 'new_callable' togetherz1Cannot use 'autospec' and 'new_callable' togetherF)
rr&�getterr�r��new_callabler��createZ	has_localr��autospecr,�additional_patchers)
rfr�r�r�r�r�r�r�r�r,rrrr!Ns$z_patch.__init__c
CsHt|j|j|j|j|j|j|j|j|j	�	}|j
|_
dd�|jD�|_|S)NcSsg|]}|j��qSr)�copy)r�prrrr�qsz_patch.copy.<locals>.<listcomp>)r�r�r�r�r�r�r�r�r�r,�attribute_namer�)rfr�rrrrisz_patch.copycCst|t�r|j|�S|j|�S)N)rr�decorate_class�decorate_callable)rfr'rrrr$vs

z_patch.__call__cCsRxLt|�D]@}|jtj�sq
t||�}t|d�s2q
|j�}t||||��q
W|S)Nr$)r�rr�TEST_PREFIXr<r�rrz)rfr��attr�
attr_valuer�rrrr|s

z_patch.decorate_classcs<t�d�r�jj|��St����fdd���|g�_�S)N�	patchingscs�g}g}t�}z�ybxJ�jD]@}|j�}|j|�|jdk	rF|j|�q|jtkr|j|�qW|t|�7}�||�S||kr�t|�r�|j|�t	j
�}�YnXWdxt|�D]}|j|�q�WXdS)N)
r?r�	__enter__r�r�updater�rr��sys�exc_infor��__exit__)r+Zkeywargs�
extra_argsZentered_patchersr�patchingr�)r'�patchedrrr�s*




z)_patch.decorate_callable.<locals>.patched)r�rr�r)rfr'r)r'rrr�s
z_patch.decorate_callablecCs�|j�}|j}t}d}y|j|}Wn$ttfk
rHt||t�}YnXd}|tkrft|t	�rfd|_
|j
r�|tkr�td||f��||fS)NFTz!%s does not have the attribute %r)r�r�rrBr"�KeyErrorr<�	_builtinsrrr�)rfr�rrI�localrrr�get_original�sz_patch.get_originalcCs>|j|j|j}}}|j|j}}|j}|j�|_|dkr@d}|dkrLd}|dkrXd}|dk	rp|dk	rptd��|dk	s�|dk	r�|dkr�td��|j	�\}}|t
ko�|dk�rTd}	|dkr�|}|dkr�|}d}n&|dk	r�|dkr�|}d}n|dkr�|}|dk	�s
|dk	�r,|t
k�rtd��t|t��r,d}	t
}
i}|dk	�rD|}
nN|dk	�sX|dk	�r�|}|dk	�rj|}t|��r~d|k}
n
t|�}
|
�r�t}
|dk	�r�||d<|dk	�r�||d	<t|
t��r�t|
t��r�|j�r�|j|d
<|j|�|
f|�}|	�r�t|��r�|}|dk	�r|}t|��r2t|��r2t}
|jd
�|
f|dd�|��|_nl|dk	�r�|t
k	�rptd
��|t
k�r�td��t|�}|dk�r�|}t|f||jd�|��}n|�r�td��|}||_||_t|j|j|�|jdk	�r:i}|jt
k�r|||j<x.|jD]$}|j �}|jt
k�r|j|��qW|S|S)zPerform the patch.FNzCan't specify spec and autospecTz6Can't provide explicit spec_set *and* spec or autospecz!Can't use 'spec' with create=Truer$r�r�rz())r�r�zBautospec creates the mock for you. Can't specify autospec and new.z%Can't use 'autospec' with create=True)r��_namez.Can't pass kwargs to a mock we aren't creating)TN)!r�r�r�r�r,r�r�r�r�rrrrrr@r�rrr
r�r
rrEr�rY�boolr�
temp_originalr�rzrr�r	)rfr�r�r�r�r,r�rIrZinherit�Klass�_kwargsZ	this_specZnot_callableZnew_attrrrr�rrrr	�s�


















z_patch.__enter__cGs�t|�std��|jr4|jtk	r4t|j|j|j�nBt|j|j�|j	rvt
|j|j�sd|jdkrvt|j|j|j�|`|`|`x$t|j�D]}t|�r�|j
|�q�WdS)	zUndo the patch.z stop called on unstarted patcherr6r8r9�__annotations__r:N)r6r8r9rr:)r��RuntimeErrorr�rrrzr�r�r�r�r�r�r�r
)rfrr�rrrr
Hs z_patch.__exit__cCs|j�}|jj|�|S)z-Activate a patch, returning any created mock.)r	�_active_patchesr�)rfrJrrr�start`sz_patch.startcCs.y|jj|�Wntk
r$YnX|j�S)zStop an active patch.)rr�r&r
)rfrrr�stopgs
z_patch.stop)r5r8rhrrr!rr$rrrr	r
rrrrrrr�Is
(~r�csPy�jdd�\�}Wn&ttfk
r:td�f��YnX�fdd�}||fS)Nr�r�z.Need a valid target to patch. You supplied: %rcst��S)N)r�r)r�rrr�ysz_get_target.<locals>.<lambda>)�rsplitr�r&)r�r�r�r)r�r�_get_targetssr c

s$�fdd�}	t|	||||||||�	S)a
    patch the named member (`attribute`) on an object (`target`) with a mock
    object.

    `patch.object` can be used as a decorator, class decorator or a context
    manager. Arguments `new`, `spec`, `create`, `spec_set`,
    `autospec` and `new_callable` have the same meaning as for `patch`. Like
    `patch`, `patch.object` takes arbitrary keyword arguments for configuring
    the mock object it creates.

    When used as a class decorator `patch.object` honours `patch.TEST_PREFIX`
    for choosing which methods to wrap.
    cs�S)Nrr)r�rrr��sz_patch_object.<locals>.<lambda>)r�)
r�r�r�r�r�r�r�r�r,r�r)r�r�
_patch_object}s
r!c
s�t��tkr�fdd�}n�fdd�}|s2td��t|j��}|d\}	}
t||	|
|||||i�	}|	|_xB|dd�D]2\}	}
t||	|
|||||i�	}|	|_|jj|�qvW|S)a�Perform multiple patches in a single call. It takes the object to be
    patched (either as an object or a string to fetch the object by importing)
    and keyword arguments for the patches::

        with patch.multiple(settings, FIRST_PATCH='one', SECOND_PATCH='two'):
            ...

    Use `DEFAULT` as the value if you want `patch.multiple` to create
    mocks for you. In this case the created mocks are passed into a decorated
    function by keyword, and a dictionary is returned when `patch.multiple` is
    used as a context manager.

    `patch.multiple` can be used as a decorator, class decorator or a context
    manager. The arguments `spec`, `spec_set`, `create`,
    `autospec` and `new_callable` have the same meaning as for `patch`. These
    arguments will be applied to *all* patches done by `patch.multiple`.

    When used as a class decorator `patch.multiple` honours `patch.TEST_PREFIX`
    for choosing which methods to wrap.
    cst��S)N)r�r)r�rrr��sz!_patch_multiple.<locals>.<lambda>cs�S)Nrr)r�rrr��sz=Must supply at least one keyword argument with patch.multiplerr�N)	r�strr&r>r�r�rr�r�)
r�r�r�r�r�r�r,r�r�r�r�r�Zthis_patcherr)r�r�_patch_multiple�s&

r#c

Ks$t|�\}}	t||	|||||||�	S)a�

    `patch` acts as a function decorator, class decorator or a context
    manager. Inside the body of the function or with statement, the `target`
    is patched with a `new` object. When the function/with statement exits
    the patch is undone.

    If `new` is omitted, then the target is replaced with a
    `MagicMock`. If `patch` is used as a decorator and `new` is
    omitted, the created mock is passed in as an extra argument to the
    decorated function. If `patch` is used as a context manager the created
    mock is returned by the context manager.

    `target` should be a string in the form `'package.module.ClassName'`. The
    `target` is imported and the specified object replaced with the `new`
    object, so the `target` must be importable from the environment you are
    calling `patch` from. The target is imported when the decorated function
    is executed, not at decoration time.

    The `spec` and `spec_set` keyword arguments are passed to the `MagicMock`
    if patch is creating one for you.

    In addition you can pass `spec=True` or `spec_set=True`, which causes
    patch to pass in the object being mocked as the spec/spec_set object.

    `new_callable` allows you to specify a different class, or callable object,
    that will be called to create the `new` object. By default `MagicMock` is
    used.

    A more powerful form of `spec` is `autospec`. If you set `autospec=True`
    then the mock will be created with a spec from the object being replaced.
    All attributes of the mock will also have the spec of the corresponding
    attribute of the object being replaced. Methods and functions being
    mocked will have their arguments checked and will raise a `TypeError` if
    they are called with the wrong signature. For mocks replacing a class,
    their return value (the 'instance') will have the same spec as the class.

    Instead of `autospec=True` you can pass `autospec=some_object` to use an
    arbitrary object as the spec instead of the one being replaced.

    By default `patch` will fail to replace attributes that don't exist. If
    you pass in `create=True`, and the attribute doesn't exist, patch will
    create the attribute for you when the patched function is called, and
    delete it again afterwards. This is useful for writing tests against
    attributes that your production code creates at runtime. It is off by
    default because it can be dangerous. With it switched on you can write
    passing tests against APIs that don't actually exist!

    Patch can be used as a `TestCase` class decorator. It works by
    decorating each test method in the class. This reduces the boilerplate
    code when your test methods share a common patchings set. `patch` finds
    tests by looking for method names that start with `patch.TEST_PREFIX`.
    By default this is `test`, which matches the way `unittest` finds tests.
    You can specify an alternative prefix by setting `patch.TEST_PREFIX`.

    Patch can be used as a context manager, with the with statement. Here the
    patching applies to the indented block after the with statement. If you
    use "as" then the patched object will be bound to the name after the
    "as"; very useful if `patch` is creating a mock object for you.

    `patch` takes arbitrary keyword arguments. These will be passed to
    the `Mock` (or `new_callable`) on construction.

    `patch.dict(...)`, `patch.multiple(...)` and `patch.object(...)` are
    available for alternate use-cases.
    )r r�)
r�r�r�r�r�r�r�r,r�r�rrrr�sE
c@sVeZdZdZfdfdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
eZe
ZdS)�_patch_dicta#
    Patch a dictionary, or dictionary like object, and restore the dictionary
    to its original state after the test.

    `in_dict` can be a dictionary or a mapping like container. If it is a
    mapping then it must at least support getting, setting and deleting items
    plus iterating over keys.

    `in_dict` can also be a string specifying the name of the dictionary, which
    will then be fetched by importing it.

    `values` can be a dictionary of values to set in the dictionary. `values`
    can also be an iterable of `(key, value)` pairs.

    If `clear` is True then the dictionary will be cleared before the new
    values are set.

    `patch.dict` can also be called with arbitrary keyword arguments to set
    values in the dictionary::

        with patch.dict('sys.modules', mymodule=Mock(), other_module=Mock()):
            ...

    `patch.dict` can be used as a context manager, decorator or class
    decorator. When used as a class decorator `patch.dict` honours
    `patch.TEST_PREFIX` for choosing which methods to wrap.
    FcKs>t|t�rt|�}||_t|�|_|jj|�||_d|_dS)N)	rr"r��in_dictrnr�r
�clear�	_original)rfr%r�r&r,rrrr!0s

z_patch_dict.__init__cs.t�t�r�j��St����fdd��}|S)Nc
s"�j�z
�||�S�j�XdS)N)r$�
_unpatch_dict)r+r�)�frfrr�_inner>s
z$_patch_dict.__call__.<locals>._inner)rrrr)rfr)r*r)r)rfrr$;s

z_patch_dict.__call__cCs\xVt|�D]J}t||�}|jtj�r
t|d�r
t|j|j|j	�}||�}t
|||�q
W|S)Nr$)r�r<rrrr�r$r%r�r&rz)rfr�rrZ	decoratorZ	decoratedrrrrIs

z_patch_dict.decorate_classcCs|j�dS)zPatch the dict.N)r$)rfrrrr	Tsz_patch_dict.__enter__cCs�|j}|j}|j}y|j�}Wn2tk
rPi}x|D]}||||<q8WYnX||_|rdt|�y|j|�Wn.tk
r�x|D]}||||<q�WYnXdS)N)r�r%r&rr"r'�_clear_dictr
)rfr�r%r&rIr�rrrr$Ys"

z_patch_dict._patch_dictcCsV|j}|j}t|�y|j|�Wn.tk
rPx|D]}||||<q8WYnXdS)N)r%r'r+r
r")rfr%rIr�rrrr(ss
z_patch_dict._unpatch_dictcGs|j�dS)zUnpatch the dict.F)r()rfr+rrrr
�sz_patch_dict.__exit__N)
r5r8rhr6r!r$rr	r$r(r
rrrrrrr$s
r$cCsBy|j�Wn0tk
r<t|�}x|D]
}||=q*WYnXdS)N)r&r"r>)r%�keysr�rrrr+�s
r+cCs xttj�D]}|j�qWdS)z7Stop all active patches. LIFO to unroll nested patches.N)r�r�rr)rrrr�_patch_stopall�sr-Ztestz�lt le gt ge eq ne getitem setitem delitem len contains iter hash str sizeof enter exit divmod rdivmod neg pos abs invert complex int float index trunc floor ceil bool next zHadd sub mul matmul div floordiv mod lshift rshift and xor or pow truediv� ccs|]}d|VqdS)zi%sNr)r�nrrrr��sr�ccs|]}d|VqdS)zr%sNr)rr/rrrr��s�__get__�__set__�
__delete__�__reversed__�__missing__�
__reduce__�
__reduce_ex__Z__getinitargs__�__getnewargs__�__getstate__�__setstate__�
__getformat__�
__setformat__rgr��__subclasses__�
__format__�__getnewargs_ex__cs�fdd�}||_|S)z:Turns a callable object (like a mock) into a real functioncs�|f|�|�S)Nr)rfr+r�)r'rr�method�sz_get_method.<locals>.method)r5)rr'r?r)r'rr��sr�cCsh|]}d|�qS)z__%s__r)rr?rrrr�srmr�r!r��__prepare__�__instancecheck__�__subclasscheck__�__del__cCs
tj|�S)N)r��__hash__)rfrrrr��sr�cCs
tj|�S)N)r��__str__)rfrrrr��scCs
tj|�S)N)r��
__sizeof__)rfrrrr��s)rDrErFr�y�?g�?)�__lt__�__gt__�__le__�__ge__�__int__r��__len__r
�__complex__�	__float__�__bool__�	__index__cs�fdd�}|S)Ncs$�jj}|tk	r|S�|kr dStS)NT)�__eq__rrr�NotImplemented)�other�ret_val)rfrrrQ�sz_get_eq.<locals>.__eq__r)rfrQr)rfr�_get_eq�srUcs�fdd�}|S)Ncs �jjtk	rtS�|krdStS)NF)�__ne__rrrrR)rS)rfrrrV�s
z_get_ne.<locals>.__ne__r)rfrVr)rfr�_get_ne�srWcs�fdd�}|S)Ncs �jj}|tkrtg�St|�S)N)r�rrrr�)rT)rfrrr��sz_get_iter.<locals>.__iter__r)rfr�r)rfr�	_get_iter�srX)rQrVr�cCs�tj|t�}|tk	r||_dStj|�}|dk	rdy||�}Wntk
rXt|�}YnX||_dStj|�}|dk	r�||�|_dS)N)�_return_valuesrCrrY�_calculate_return_valuer"�_side_effect_methodsr_)r1r?rZfixedZreturn_calulatorrYZ
side_effectorrrr�_set_return_values

r\c@seZdZdd�Zdd�ZdS)�
MagicMixincOs&|j�tt|�j||�|j�dS)N)�_mock_set_magicsr�r]r!)rfr+r�rrrr!(szMagicMixin.__init__cCs�t}t|dd�dk	rTtj|j�}t�}t|}x$|D]}|t|�jkr4t||�q4W|tt|�j�}t|�}x|D]}t||t	||��qtWdS)Nr�)
�_magicsr<�intersectionr�rorrBr�rz�
MagicProxy)rfZthese_magicsZ
remove_magicsr�r�rrrr^.s

zMagicMixin._mock_set_magicsN)r5r8rhr!r^rrrrr]'sr]c@seZdZdZddd�ZdS)rz-A version of `MagicMock` that isn't callable.FcCs|j||�|j�dS)z�Add a spec to a mock. `spec` can either be an object or a
        list of strings. Only attributes on the `spec` can be fetched as
        attributes from the mock.

        If `spec_set` is True then only attributes on the spec can be set.N)r�r^)rfr�r�rrrr�Gsz"NonCallableMagicMock.mock_add_specN)F)r5r8rhr6r�rrrrrEsc@seZdZdZddd�ZdS)ra�
    MagicMock is a subclass of Mock with default implementations
    of most of the magic methods. You can use MagicMock without having to
    configure the magic methods yourself.

    If you use the `spec` or `spec_set` arguments then *only* magic
    methods that exist in the spec will be created.

    Attributes and the return value of a `MagicMock` will also be `MagicMocks`.
    FcCs|j||�|j�dS)z�Add a spec to a mock. `spec` can either be an object or a
        list of strings. Only attributes on the `spec` can be fetched as
        attributes from the mock.

        If `spec_set` is True then only attributes on the spec can be set.N)r�r^)rfr�r�rrrr�]szMagicMock.mock_add_specN)F)r5r8rhr6r�rrrrrRs
c@s.eZdZdd�Zdd�Zdd�Zd
dd	�ZdS)racCs||_||_dS)N)rr�)rfrr�rrrr!iszMagicProxy.__init__cOs|j�}|||�S)N)�create_mock)rfr+r,�mrrrr$mszMagicProxy.__call__cCs8|j}|j}|j|||d�}t|||�t|||�|S)N)rr�r�)rr�r�rzr\)rfr�r�rcrrrrbqszMagicProxy.create_mockNcCs|j�S)N)rb)rfrr�rrrr0zszMagicProxy.__get__)N)r5r8rhr!r$rbr0rrrrrahs	rac@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_ANYz2A helper object that compares equal to everything.cCsdS)NTr)rfrSrrrrQ�sz_ANY.__eq__cCsdS)NFr)rfrSrrrrV�sz_ANY.__ne__cCsdS)Nz<ANY>r)rfrrrrg�sz
_ANY.__repr__N)r5r8rhr6rQrVrgrrrrrdsrdcCsdd|}d}djdd�|D��}djdd�t|j��D��}|rD|}|r\|rT|d7}||7}||S)Nz%s(%%s)r�z, cSsg|]}t|��qSr)�repr)rr�rrrr��sz*_format_call_signature.<locals>.<listcomp>cSsg|]\}}d||f�qS)z%s=%rr)rr�rprrrr��s)r�r�r�)rr+r,r�Zformatted_argsZargs_stringZ
kwargs_stringrrrr��sr�c@sveZdZdZfddddfdd�Zfddddfdd	�Zd
d�ZejZdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)r�a�
    A tuple for holding the results of a call to a mock, either in the form
    `(args, kwargs)` or `(name, args, kwargs)`.

    If args or kwargs are empty then a call tuple will compare equal to
    a tuple without those values. This makes comparisons less verbose::

        _Call(('name', (), {})) == ('name',)
        _Call(('name', (1,), {})) == ('name', (1,))
        _Call(((), {'a': 'b'})) == ({'a': 'b'},)

    The `_Call` object provides a useful shortcut for comparing with call::

        _Call(((1, 2), {'a': 3})) == call(1, 2, a=3)
        _Call(('foo', (1, 2), {'a': 3})) == call.foo(1, 2, a=3)

    If the _Call has no name then it will match any name.
    r�NFTcCs�f}i}t|�}|dkr$|\}}}nr|dkrd|\}	}
t|	t�rX|	}t|
t�rR|
}qb|
}q�|	|
}}n2|dkr�|\}t|t�r�|}nt|t�r�|}n|}|r�tj|||f�Stj||||f�S)Nr�rbr�)r�rr"r?r�)r�rprr�r��	from_kallr+r,�_len�first�secondrrrr��s.



z
_Call.__new__cCs||_||_||_dS)N)rvrt�_mock_from_kall)rfrprr�r�rfrrrr!�sz_Call.__init__cCsf|tkrdSyt|�}Wntk
r,dSXd}t|�dkrH|\}}n
|\}}}t|dd�rzt|dd�rz|j|jkrzdSd}|dkr�fi}}n�|dkr�|\}}}n�|dkr�|\}	t|	t�r�|	}i}n"t|	t�r�|	}fi}}nf}|	}nV|dk�r>|\}
}t|
t��r2|
}t|t��r&|i}}n
f|}}n
|
|}}ndS|�rV||k�rVdS||f||fkS)	NTFr�rbrtrr�r�)rr�r�r<rtrr?r")rfrSZ	len_otherZ	self_nameZ	self_argsZself_kwargsZ
other_nameZ
other_argsZother_kwargsrprhrirrrrQ�sP




z_Call.__eq__cOs<|jdkrtd||fdd�S|jd}t|j||f||d�S)Nr�z())r)rr�)rvr�)rfr+r,rrrrr$s

z_Call.__call__cCs2|jdkrt|dd�Sd|j|f}t||dd�S)NF)rrfz%s.%s)rr�rf)rvr�)rfrrrrrrms
z_Call.__getattr__cOs|jd�||�S)Nr�)rm)rfr+r,rrrr�$sz_Call.countcOs|jd�||�S)N�index)rm)rfr+r,rrrrk'sz_Call.indexcCs||js&|jpd}|jd�r"d|}|St|�dkr@d}|\}}n0|\}}}|sTd}n|jd�shd|}nd|}t|||�S)Nrz()zcall%srbzcall.%s)rjrvrr�r�)rfrr+r,rrrrg*s





z_Call.__repr__cCs8g}|}x"|dk	r*|jr"|j|�|j}q
Wtt|��S)z�For a call object that represents multiple calls, `call_list`
        returns a list of all the intermediate calls as well as the
        final call.N)rjr�rtrUr�)rf�valsr�rrr�	call_list?s


z_Call.call_list)r5r8rhr6r�r!rQr�rVr$rmr�rkrgrmrrrrr��s7r�)rfcKs,t|�rt|�}t|t�}d|i}|r0d|i}n|dkr<i}|rL|rLd|d<|j|�t}tj|�rji}n$t|�sxt}n|r�|r�t	|�r�t}|j
d|�}|}	|dkr�d}	|f|||	|d�|��}
t|t�r�t|
|�}
nt
||
||�|dk	o�|�r|
|j|<|�r,|�r,d	|k�r,t||dd
|
d�|
_x�t|�D]�}t|��rH�q6yt||�}Wntk
�rp�w6YnXd|i}|�r�d|i}t|t��s�t|||
||�}
|
|
j|<nZ|
}t|t��r�|
j}t|||�}||d<tf||||d
�|��}
|
|
j|<t
||
|d�t|
t��r6t|
||
��q6W|
S)aICreate a mock object using another object as a spec. Attributes on the
    mock will use the corresponding attribute on the `spec` object as their
    spec.

    Functions or methods being mocked will have their arguments checked
    to check that they are called with the correct signature.

    If `spec_set` is True then attempting to set attributes that don't exist
    on the spec object will raise an `AttributeError`.

    If a class is used as a spec then the return value of the mock (the
    instance of the class) will have the same spec. You can use a class as the
    spec for an instance object by passing `instance=True`. The returned mock
    will only be callable if instances of the mock are callable.

    `create_autospec` also takes arbitrary keyword arguments that are passed to
    the constructor of the created mock.r�r�NTr�rr�)r�r�r�rrYz())r3rr�r�)r�rr�r�)r2)r@rrr
rr%Zisdatadescriptorr=rrEr�r#rMr4r`rrYr�rdr<r"r�r1�
_must_skiprz)r�r�r3r�rr,�is_typerrr�r1r�rIr�r�r2rrrrPst










cCs|t|t�s$|t|di�krdS|j}xR|jD]H}|jj|t�}|tkrHq,t|tt	f�rZdStt|dd�t
�rp|SdSq,W|S)z[
    Return whether we should skip the first argument on spec's `entry`
    attribute.
    rBFr0N)rrr<r�rArBrCr�staticmethod�classmethod�MethodWrapperTypes)r�r�ror�rJrrrrn�s
rncCs$y|jStk
rt|�SXdS)N)r�r"r)rrrrr��sr�c@seZdZddd�ZdS)r�FNcCs(||_||_||_||_||_||_dS)N)r��idsr�r�r3r)rfr�r�r�rrsr3rrrr!�sz_SpecState.__init__)FNNNF)r5r8rhr!rrrrr��sr�c#spt|t�rdnd��fdd�|j��D�}|d�krD|dd�}n|ddd	�|d
<x|D]
}|Vq^WdS)N�
�
csg|]}|��qSrr)r�l)�seprrr�	sz&_iterate_read_data.<locals>.<listcomp>r����rxrxrxrx)r�bytesr�)�	read_dataZdata_as_list�liner)rwr�_iterate_read_data	s
r|r�cs���fdd�}���fdd�}���fdd��tdkr`ddl}ttt|j��jtt|j����a|dkrttd	t	d
�}ttd����j
_t��dg�d�j
_d�j_d�j_d�j_|�j_���d<�d�j_|�j_����fd
d�}||_�|_|S)a�
    A helper function to create a mock to replace the use of `open`. It works
    for `open` called directly or used as a context manager.

    The `mock` argument is the mock object to configure. If `None` (the
    default) then a `MagicMock` will be created for you, with the API limited
    to methods or attributes available on standard file handles.

    `read_data` is a string for the `read` methoddline`, and `readlines` of the
    file handle to return.  This is an empty string by default.
    cs �jjdk	r�jjSt�d�S)Nr)�	readlinesrYr>)r+r,)�_state�handlerr�_readlines_side_effect(	sz)mock_open.<locals>._readlines_side_effectcs(�jjdk	r�jjSt���j�d�S)Nr)�readrYrr�)r+r,)r~rrzrr�_read_side_effect-	sz$mock_open.<locals>._read_side_effectc3sJ�jjdk	rx�jjVqWx�dD]
}|Vq&Wxt���Vq6WdS)Nr)�readlinerYr)r{)r~rrzrr�_readline_side_effect2	s
z(mock_open.<locals>._readline_side_effectNr�open)rr�)r�r�cs6t���d<�jj�dkr2���d<�d�j_tS)Nrr�)r|r�r_r)r+r,)r�r~rrzrr�
reset_dataS	s

zmock_open.<locals>.reset_data)�	file_spec�_ior>ror��
TextIOWrapper�union�BytesIOrr�r	rYr|�writer�r�r}r_)r1rzr�r�r�r�r)r�r~rrzrr	s."

c@s(eZdZdZdd�Zdd�Zdd�ZdS)	r
aW
    A mock intended to be used as a property, or other descriptor, on a class.
    `PropertyMock` provides `__get__` and `__set__` methods so you can specify
    a return value when it is fetched.

    Fetching a `PropertyMock` instance from an object calls the mock, with
    no args. Setting it calls the mock with the value being set.
    cKs
tf|�S)N)r)rfr,rrrr�i	szPropertyMock._get_child_mockcCs|�S)Nr)rfrZobj_typerrrr0l	szPropertyMock.__get__cCs||�dS)Nr)rfrr�rrrr1n	szPropertyMock.__set__N)r5r8rhr6r�r0r1rrrrr
`	s)
rrrrrrrrr	r
rrr
)F)F)NFNNN)FFNN)Nr�)o�__all__�__version__r%r�r�builtins�typesr�	functoolsrrr�r�
BaseExceptionr�platformrZlangZ	Throwabler	�superr�rr r(r4r/r=r@rErMrHrdr�rerirrZMISSINGr�ZDELETEDr�rqr|rr>rUr�r�r�r
r�r�rr�r�r�r�r r!r#rr$r+r-rnZmultipleZstopallrZ
magic_methodsZnumericsr�r�Zinplace�rightZ
_non_defaultsr�r_r�r�rZrRrYrUrWrXr[r\r]rrrardrr�r?r�rrrnr�r�rrQr#r0rrr�r|rr
rrrr�<module>s
 

4	i5,
1Jv	

	
,

w
DPKń[��ݥ~~)__pycache__/__main__.cpython-36.opt-2.pycnu�[���3


 \��@s`ddlZejdjd�r>ddlZejjej�Zedejd<[dZddl	m	Z	m
Z
e	dd�dS)�Nz__main__.pyz -m unittestT�)�main�TestProgram)�module)�sys�argv�endswithZos.path�os�path�basename�
executableZ
__unittestrr�r
r
�)/usr/lib64/python3.6/unittest/__main__.py�<module>sPKń[Kk��\�\�%__pycache__/mock.cpython-36.opt-1.pycnu�[���3


 \�7�@sFd�Zd
ZddlZddlZddlZddlZddlmZddlm	Z	m
Z
dd�ee�D�Ze
fZdejkrzddlZe
ejjfZdZeZdd�Zdd�Zdd�Zd�dd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd�d'd(�Zd)d*�Zd+d,�Z Gd-d.�d.e!�Z"Gd/d0�d0e!�Z#e#�Z$e$j%Z%e$j&Z'e$j(Z)d1d2�Z*d3d4d5d6d7d8d9d:hZ+d;d<�Z,Gd=d>�d>e-�Z.d?d@�Z/GdAdB�dBe!�Z0GdCdD�dDe!�Z1GdEd	�d	e1�Z2dFdG�Z3GdHdI�dIe1�Z4GdJd�de4e2�Z5dKdL�Z6dMdN�Z7dOdP�Z8GdQdR�dRe!�Z9dSdT�Z:e%dddddfdUdV�Z;d�dWdX�Z<e%dddddfdYd�Z=GdZd[�d[e!�Z>d\d]�Z?d^d_�Z@e;e=_!e>e=_Ae<e=_Be@e=_Cd`e=_DdaZEdbZFdcjGddde�eFjH�D��ZIdcjGdfde�eFjH�D��ZJdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxhZKdydz�ZLd{d�dcjGeEeFeIeJg�jH�D�ZMeMeKBZNd|d}d~dd�d�d�d�hZOd�d��d�d��d�d��d��ZPeQeQeQeQd�dddd�d�dd�d��ZRd�d��ZSd�d��ZTd�d��ZUeSeTeUd��ZVd�d��ZWGd�d��d�e!�ZXGd�d
�d
eXe2�ZYGd�d�deXe5�ZZGd�d��d�e!�Z[Gd�d��d�e!�Z\e\�Z]d�d��Z^Gd�d��d�e_�Z`e`dd��Zad�d�d�Zbd�d��Zcd�d��ZdGd�d��d�e!�Zeefeb�efe]jg�fZhefe]jgji�fZjdakd�d��Zld�d�d�ZmGd�d�de5�ZndS)��Mock�	MagicMock�patch�sentinel�DEFAULT�ANY�call�create_autospec�
FILTER_DIR�NonCallableMock�NonCallableMagicMock�	mock_open�PropertyMockz1.0�N)�
ModuleType)�wraps�partialcCsh|]}|jd�s|�qS)�_)�
startswith)�.0�name�r�%/usr/lib64/python3.6/unittest/mock.py�	<setcomp>#sr�javaTcCstt|�t�S)N)�
issubclass�typer
)�objrrr�_is_instance_mock2srcCst|t�pt|t�ot|t�S)N)�
isinstance�BaseExceptionsrr)rrrr�
_is_exception8s
r cCs�t|t�r6|r6y
|j}Wntk
r.dSXd}n*t|t�s`y
|j}Wntk
r^dSX|rpt|d�}n|}y|tj|�fSt	k
r�dSXdS)z�
    Given an arbitrary, possibly callable object, try to create a suitable
    signature object.
    Return a (reduced func, signature) tuple, or None.
    NT)
rr�__init__�AttributeError�
FunctionTypes�__call__r�inspectZ	signature�
ValueError)�funcZas_instanceZeat_selfZsig_funcrrr�_get_signature_object?s$


r(FcsDt|||���dkrdS�\}��fdd�}t||�|t|�_dS)Ncs�j||�dS)N)�bind)�
_mock_self�args�kwargs)�sigrr�checksigdsz"_check_signature.<locals>.checksig)r(�_copy_func_detailsr�_mock_check_sig)r'�mock�	skipfirst�instancer.r)r-r�_check_signature_s
r4c#Cs�|j|_|j|_y|j|_Wntk
r0YnXy|j|_Wntk
rRYnXy|j|_Wntk
rtYnXy|j|_Wntk
r�YnXdS)N)�__name__�__doc__�__text_signature__r"�
__module__�__defaults__�__kwdefaults__)r'�funcopyrrrr/js$r/cCs&t|t�rdSt|dd�dk	r"dSdS)NTr$F)rr�getattr)rrrr�	_callable�s

r=cCst|�ttfkS)N)r�list�tuple)rrrr�_is_list�sr@cCsHt|t�st|dd�dk	Sx(|f|jD]}|jjd�dk	r(dSq(WdS)ztGiven an object, return True if the object is callable.
    For classes, return True if instances would be callable.r$NTF)rrr<�__mro__�__dict__�get)r�baserrr�_instance_callable�s
rEcs�t|�sdSt|t�}t|||�}|dkr.|S|\}��fdd�}t||�|j}|j�s^d}||d�}d|}	t|	|�||}
t|
|�|
S)Ncs�j||�dS)N)r))r+r,)r-rrr.�sz _set_signature.<locals>.checksigr;)Z
_checksig_r1zYdef %s(*args, **kwargs):
    _checksig_(*args, **kwargs)
    return mock(*args, **kwargs))	r=rrr(r/r5�isidentifier�exec�_setup_func)r1�originalr3r2�resultr'r.r�context�srcr;r)r-r�_set_signature�s$




rMc
s���_t��sdS�fdd�}�fdd�}�fdd�}�fdd�}�fd	d
�}�fdd�}�fd
d�}��fdd�}	d�_d�_d�_t��_t��_t��_�j	�_	�j
�_
�j�_|�_|�_
|�_|�_|	�_|�_|�_|�_��_dS)Ncs�j||�S)N)�assert_called_with)r+r,)r1rrrN�sz'_setup_func.<locals>.assert_called_withcs�j||�S)N)�
assert_called)r+r,)r1rrrO�sz"_setup_func.<locals>.assert_calledcs�j||�S)N)�assert_not_called)r+r,)r1rrrP�sz&_setup_func.<locals>.assert_not_calledcs�j||�S)N)�assert_called_once)r+r,)r1rrrQ�sz'_setup_func.<locals>.assert_called_oncecs�j||�S)N)�assert_called_once_with)r+r,)r1rrrR�sz,_setup_func.<locals>.assert_called_once_withcs�j||�S)N)�assert_has_calls)r+r,)r1rrrS�sz%_setup_func.<locals>.assert_has_callscs�j||�S)N)�assert_any_call)r+r,)r1rrrT�sz$_setup_func.<locals>.assert_any_callcs:t��_t��_�j��j}t|�r6|�k	r6|j�dS)N)�	_CallList�method_calls�
mock_calls�
reset_mock�return_valuer)�ret)r;r1rrrX�sz_setup_func.<locals>.reset_mockFr)r1r�called�
call_count�	call_argsrU�call_args_listrVrWrY�side_effect�_mock_childrenrNrRrSrTrXrOrPrQ�_mock_delegate)
r;r1rNrOrPrQrRrSrTrXr)r;r1rrH�s:rHcCsd|dd�|kS)Nz__%s__����r)rrrr�	_is_magic�srdc@s eZdZdZdd�Zdd�ZdS)�_SentinelObjectz!A unique, named, sentinel object.cCs
||_dS)N)r)�selfrrrrr!�sz_SentinelObject.__init__cCs
d|jS)Nzsentinel.%s)r)rfrrr�__repr__�sz_SentinelObject.__repr__N)r5r8�__qualname__r6r!rgrrrrre�srec@s eZdZdZdd�Zdd�ZdS)�	_SentinelzAAccess attributes to return a named object, usable as a sentinel.cCs
i|_dS)N)�
_sentinels)rfrrrr!�sz_Sentinel.__init__cCs|dkrt�|jj|t|��S)N�	__bases__)r"rj�
setdefaultre)rfrrrr�__getattr__sz_Sentinel.__getattr__N)r5r8rhr6r!rmrrrrri�sricCs$t|�ttttfkr t|�|�S|S)N)r�dictr>r?�set)�valuerrr�_copysrqrY�_mock_return_valuer_�_mock_side_effect�_mock_parent�_mock_new_parent�
_mock_name�_mock_new_namecCs8tj|�d|}||fdd�}||fdd�}t||�S)NZ_mock_cSs"|j}|dkrt||�St||�S)N)rar<)rfr�	_the_namer-rrr�_gets
z"_delegating_property.<locals>._getcSs*|j}|dkr||j|<nt|||�dS)N)rarB�setattr)rfrprrxr-rrr�_set$sz"_delegating_property.<locals>._set)�_allowed_names�add�property)rrxryr{rrr�_delegating_propertys

rc@seZdZdd�Zdd�ZdS)rUcCsnt|t�stj||�St|�}t|�}||kr2dSx6td||d�D] }||||�}||krFdSqFWdS)NFr�T)rr>�__contains__�len�range)rfrpZ	len_valueZlen_self�iZsub_listrrrr�1s
z_CallList.__contains__cCstjt|��S)N)�pprintZpformatr>)rfrrrrg?sz_CallList.__repr__N)r5r8rhr�rgrrrrrU/srUcCsxt|�sdS|js,|js,|jdk	s,|jdk	r0dS|}x|dk	rR||krJdS|j}q6W|rd||_||_|rt||_||_dS)NFT)rrvrwrtru)�parentrpr�new_name�_parentrrr�_check_and_set_parentCs$



r�c@s$eZdZdd�Zdd�Zdd�ZdS)�	_MockItercCst|�|_dS)N)�iterr)rfrrrrr!]sz_MockIter.__init__cCs|S)Nr)rfrrr�__iter___sz_MockIter.__iter__cCs
t|j�S)N)�nextr)rfrrr�__next__asz_MockIter.__next__N)r5r8rhr!r�r�rrrrr�\sr�c@seZdZeZdZdd�ZdS)�BaseNcOsdS)Nr)rfr+r,rrrr!gsz
Base.__init__)r5r8rhrrrrsr!rrrrr�dsr�c@sHeZdZdZdd�ZdDdd�Zd	d
�ZdEdd�ZdFd
d�Zdd�Z	dd�Z
dZee	e
e�Z
edd��Zed�Zed�Zed�Zed�Zed�Zdd�Zdd�Zeee�ZdGddd�d d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Z d2d3�Z!d4d5�Z"d6d7�Z#d8d9�Z$d:d;�Z%d<d=�Z&dHd>d?�Z'd@dA�Z(dBdC�Z)dS)Ir
z A non-callable version of `Mock`cOs$t|j|fd|ji�}tj|�}|S)Nr6)rr5r6�object�__new__)�clsr+�kw�newr3rrrr�os
zNonCallableMock.__new__N�FcKs�|dkr|}|j}
||
d<||
d<||
d<||
d<|dk	rB|}d}|
dkrR|dk	}
|j|||	|
�i|
d<||
d<d|
d<d	|
d
<d|
d<d|
d
<t�|
d<t�|
d<t�|
d<||
d<|r�|jf|�tt|�j||||||�dS)NrtrvrwruTr`�_mock_wrapsraFZ_mock_calledZ_mock_call_argsrZ_mock_call_countZ_mock_call_args_listZ_mock_mock_callsrV�_mock_unsafe)rB�_mock_add_specrU�configure_mock�_safe_superr
r!)rf�specrr�spec_setr��_spec_state�	_new_name�_new_parent�_spec_as_instance�	_eat_selfZunsafer,rBrrrr!xs8




zNonCallableMock.__init__cCs(d|_d|_d|_d|_t|||�dS)z�
        Attach a mock as an attribute of this one, replacing its name and
        parent. Calls to the attached mock will be recorded in the
        `method_calls` and `mock_calls` attributes of this one.Nr�)rtrurvrwrz)rfr1�	attributerrr�attach_mock�s
zNonCallableMock.attach_mockcCs|j||�dS)z�Add a spec to a mock. `spec` can either be an object or a
        list of strings. Only attributes on the `spec` can be fetched as
        attributes from the mock.

        If `spec_set` is True then only attributes on the spec can be set.N)r�)rfr�r�rrr�
mock_add_spec�szNonCallableMock.mock_add_specc	Cs|d}d}|dk	rRt|�rRt|t�r*|}nt|�}t|||�}|oH|d}t|�}|j}||d<||d<||d<||d<dS)Nr��_spec_class�	_spec_set�_spec_signature�
_mock_methods)r@rr�
_get_classr(�dirrB)	rfr�r�r�r�r�r��resrBrrrr��s
zNonCallableMock._mock_add_speccCs8|j}|jdk	r|jj}|tkr4|j|dd�}||_|S)Nz())r�r�)rrrarYr�_get_child_mock)rfrZrrrZ__get_return_value�s

z"NonCallableMock.__get_return_valuecCs,|jdk	r||j_n||_t||dd�dS)Nz())rarYrrr�)rfrprrrZ__set_return_value�s

z"NonCallableMock.__set_return_valuez1The value to be returned when the mock is called.cCs|jdkrt|�S|jS)N)r�r)rfrrr�	__class__�s
zNonCallableMock.__class__r[r\r]r^rWcCsT|j}|dkr|jS|j}|dk	rPt|�rPt|t�rPt|�rPt|�}||_|S)N)rarsr_�callablerr�r )rf�	delegatedZsfrrrZ__get_side_effect�sz!NonCallableMock.__get_side_effectcCs(t|�}|j}|dkr||_n||_dS)N)�	_try_iterrarsr_)rfrpr�rrrZ__set_side_effects
z!NonCallableMock.__set_side_effect)rYr_cCs�|dkrg}t|�|krdS|jt|��d|_d|_d|_t�|_t�|_t�|_|r^t	|_
|rhd|_x0|jj
�D]"}t|t�st|tkr�qt|j|�qtW|j
}t|�r�||k	r�|j|�dS)z-Restore the mock object to its initial state.NFr)�id�appendr[r]r\rUrWr^rVrrrrsr`�valuesr�
_SpecState�_deletedrXr)rfZvisitedrYr_ZchildrZrrrrX
s,zNonCallableMock.reset_mockcKs`xZt|j�dd�d�D]B\}}|jd�}|j�}|}x|D]}t||�}q:Wt|||�qWdS)aZSet attributes on the mock through keyword arguments.

        Attributes plus return values and side effects can be set on child
        mocks using standard dot notation and unpacking a dictionary in the
        method call:

        >>> attrs = {'method.return_value': 3, 'other.side_effect': KeyError}
        >>> mock.configure_mock(**attrs)cSs|djd�S)Nr�.)�count)�entryrrr�<lambda>8sz0NonCallableMock.configure_mock.<locals>.<lambda>)�keyr�N)�sorted�items�split�popr<rz)rfr,�arg�valr+�finalrr�rrrr�+s	


zNonCallableMock.configure_mockcCs�|dkrt|��n:|jdk	r<||jks.|tkrLtd|��nt|�rLt|��|jsd|jd�rdt|��|jj|�}|tkr�t|��np|dkr�d}|j	dk	r�t
|j	|�}|j|||||d�}||j|<n.t|t
�r�t|j|j|j|j|j�}||j|<|S)	Nr�r�zMock object has no attribute %r�assert�assret)r�rrr�r�>r�r�)r�r�)r"r��_all_magicsrdr�rr`rCr�r�r<r�rr�rr�r�r3r�r)rfrrJrrrrrmAs6






zNonCallableMock.__getattr__c
Cs"|jg}|j}|}d}|dgkr$d}t�}xT|dk	r~|}|j|j|�d}|jdkrZd}|j}t|�|krnP|jt|��q,Wtt|��}|jp�d}t	|�dkr�|dd
kr�|d7}||d<dj
|�}d}|dkr�d	|}d}	|jdk	�rd
}	|j�r�d}	|	|jj
}	dt|�j
||	t|�fS)Nr��()r�r1r��().r�mock.z name=%rz spec=%rz spec_set=%rz<%s%s%s id='%s'>)r�r�)r1r�)rwruror�r�r}r>�reversedrvr��joinr�r�r5r)
rfZ
_name_listr�Zlast�dot�seenZ_firstrZname_stringZspec_stringrrrrggsL




zNonCallableMock.__repr__cCshtstj|�S|jpg}tt|��}t|j�}dd�|D�}dd�|D�}tt	|||t|j
���S)z8Filter the output of `dir(mock)` to only useful members.cSsg|]}|jd�s|�qS)r)r)r�errr�
<listcomp>�sz+NonCallableMock.__dir__.<locals>.<listcomp>cSs$g|]}|jd�st|�r|�qS)r)rrd)rr�rrrr��s)r	r��__dir__r�r�rr>rBr�ror`)rfZextrasZ	from_typeZ	from_dictrrrr��s


zNonCallableMock.__dir__cs"|tkrtj�||�S�jrH�jdk	rH|�jkrH|�jkrHtd|��n�|tkrbd|}t|��n�|tkr�jdk	r�|�jkr�td|��t	|�s�t
t��|t||��|���fdd�}n(t
�|d|�t
t��||�|�j|<n.|dk�r�|�_dSt
�|||��r|�j|<tj�||�S)Nz!Mock object has no attribute '%s'z.Attempting to set unsupported magic method %r.cs��f|�|�S)Nr)r+r�)rIrfrrr��sz-NonCallableMock.__setattr__.<locals>.<lambda>r�)r|r��__setattr__r�r�rBr"�_unsupported_magicsr�rrzr�_get_methodr�r`r�)rfrrp�msgr)rIrfrr��s2




zNonCallableMock.__setattr__cCs�|tkr2|t|�jkr2tt|�|�||jkr2dS||jkrHtj||�|jj|t�}|t	krft
|��|tk	rv|j|=t	|j|<dS)N)r�rrB�delattrr��__delattr__r`rC�_missingr�r")rfrrrrrr��s

zNonCallableMock.__delattr__cCs|jpd}t|||�S)Nr1)rv�_format_call_signature)rfr+r,rrrr�_format_mock_call_signature�s
z+NonCallableMock._format_mock_call_signaturecCsDd}|j||�}|j}t|�dkr.|dd�}|j|�}|||fS)Nz!Expected call: %s
Actual call: %s�r�)r�r]r�)rfr+r,�message�expected_stringr]Z
actual_stringrrr�_format_mock_failure_message�s
z,NonCallableMock._format_mock_failure_messagecCst|j}|dk	rlt|�dkr(d}|\}}n
|\}}}y||j||�fStk
rh}z
|jd�Sd}~XqpXn|SdS)a
        Given a call (or simply an (args, kwargs) tuple), return a
        comparison key suitable for matching with other calls.
        This is a best effort method which relies on the spec's signature,
        if available, or falls back on the arguments themselves.
        Nrbr�)r�r�r)�	TypeError�with_traceback)rf�_callr-rr+r,r�rrr�
_call_matcher�s

zNonCallableMock._call_matchercCs.|}|jdkr*d|jpd|jf}t|��dS)z/assert that the mock was never called.
        rz7Expected '%s' to not have been called. Called %s times.r1N)r\rv�AssertionError)r*rfr�rrrrPs

z!NonCallableMock.assert_not_calledcCs(|}|jdkr$d|jpd}t|��dS)z6assert that the mock was called at least once
        rz"Expected '%s' to have been called.r1N)r\rvr�)r*rfr�rrrrOs

zNonCallableMock.assert_calledcCs.|}|jdks*d|jpd|jf}t|��dS)z3assert that the mock was called only once.
        r�z8Expected '%s' to have been called once. Called %s times.r1N)r\rvr�)r*rfr�rrrrQs

z"NonCallableMock.assert_called_oncecs||��jdkr(�j���}td|f�����fdd�}�j��f�}�j�j�}||krxt|t�rh|nd}t|��|�dS)z�assert that the mock was called with the specified arguments.

        Raises an AssertionError if the args and keyword args passed in are
        different to the last call to the mock.NzExpected call: %s
Not calledcs�j���}|S)N)r�)r�)r+r,rfrr�_error_message'sz:NonCallableMock.assert_called_with.<locals>._error_message)r]r�r�r�r�	Exception)r*r+r,�expectedr��actual�causer)r+r,rfrrNs
z"NonCallableMock.assert_called_withcOs6|}|jdks*d|jpd|jf}t|��|j||�S)ziassert that the mock was called exactly once and that that call was
        with the specified arguments.r�z1Expected '%s' to be called once. Called %s times.r1)r\rvr�rN)r*r+r,rfr�rrrrR1s
z'NonCallableMock.assert_called_once_withcs��fdd�|D�}t|t�r |nd}t�fdd��jD��}|sd||kr`tdt|��jf�|�dSt|�}g}x:|D]2}y|j|�Wqvtk
r�|j|�YqvXqvW|r�tdt	|�f�|�dS)a�assert the mock has been called with the specified calls.
        The `mock_calls` list is checked for the calls.

        If `any_order` is False (the default) then the calls must be
        sequential. There can be extra calls before or after the
        specified calls.

        If `any_order` is True then the calls can be in any order, but
        they must all appear in `mock_calls`.csg|]}�j|��qSr)r�)r�c)rfrrr�Fsz4NonCallableMock.assert_has_calls.<locals>.<listcomp>Nc3s|]}�j|�VqdS)N)r�)rr�)rfrr�	<genexpr>Hsz3NonCallableMock.assert_has_calls.<locals>.<genexpr>z(Calls not found.
Expected: %r
Actual: %rz%r not all found in call list)
rr�rUrWr�r>�remover&r�r?)rfZcallsZ	any_orderr�r�Z	all_callsZ	not_foundZkallr)rfrrS<s*

z NonCallableMock.assert_has_callscsZ�j||f�}�fdd��jD�}||krVt|t�r8|nd}�j||�}td|�|�dS)z�assert the mock has been called with the specified arguments.

        The assert passes if the mock has *ever* been called, unlike
        `assert_called_with` and `assert_called_once_with` that only pass if
        the call is the most recent one.csg|]}�j|��qSr)r�)rr�)rfrrr�fsz3NonCallableMock.assert_any_call.<locals>.<listcomp>Nz%s call not found)r�r^rr�r�r�)rfr+r,r�r�r�r�r)rfrrT_szNonCallableMock.assert_any_callcKsFt|�}t|t�s2t|t�r"t}q<t|t�r<t}n
|jd}|f|�S)aPCreate the child mocks for attributes and return value.
        By default child mocks will be the same type as the parent.
        Subclasses of Mock may want to override this to customize the way
        child mocks are made.

        For non-callable mocks the callable variant will be used (rather than
        any custom subclass).r�)rr�
CallableMixinrrr
rrA)rfr��_type�klassrrrr�os



zNonCallableMock._get_child_mock)NNNNNNr�NFNF)F)FF)N)F)*r5r8rhr6r�r!r�r�r�Z"_NonCallableMock__get_return_valueZ"_NonCallableMock__set_return_valueZ"_NonCallableMock__return_value_docr~rYr�rr[r\r]r^rWZ!_NonCallableMock__get_side_effectZ!_NonCallableMock__set_side_effectr_rXr�rmrgr�r�r�r�r�r�rPrOrQrNrRrSrTr�rrrrr
lsR

)
	


&2"
			
#cCsF|dkr|St|�r|St|�r$|Syt|�Stk
r@|SXdS)N)r r=r�r�)rrrrr��sr�c
@sBeZdZddedddddddf
dd�Zdd�Zdd�Zd	d
�ZdS)r�Nr�c	Ks6||jd<tt|�j|||||||	|
f|�||_dS)Nrr)rBr�r�r!r_)rfr�r_rYrrr�r�r�r�r�r,rrrr!�s



zCallableMixin.__init__cOsdS)Nr)rfr+r,rrrr0�szCallableMixin._mock_check_sigcOs|j||�|j||�S)N)r0�
_mock_call)r*r+r,rrrr$�szCallableMixin.__call__cOs�|}d|_|jd7_t||fdd�}||_|jj|�t�}|jdk	}|j}|j	}|dk}	|j
jtd||f��|j}
x�|
dk	�r*|r�|
jjt|||f��|
jdk	}|r�|
jd|}t|||f�}|
j
j|�|
j	�r|	r�d}nd}|
j	dk}	|
j	||}|
j}
t
|
�}
|
|k�rP|j|
�q|W|j}|dk	�r�t|��rL|�n,t|��snt|�}t|��rx|�n
|||�}|tk	�r�|S|jtk	�r�|jS|jdk	�r�|j||�S|jS)NTr�)�twoz()r�r�)r[r\�_Callr]r^r�rortrvrwrWrurVr�r}r_r r=r�rrrrYr�)r*r+r,rfr�r�Zdo_method_callsZmethod_call_nameZmock_call_nameZ	is_a_callr�Zthis_mock_callr�Z_new_parent_idZeffectrJrrrr��s`









zCallableMixin._mock_call)r5r8rhrr!r0r$r�rrrrr��sr�c@seZdZdZdS)ra�	
    Create a new `Mock` object. `Mock` takes several optional arguments
    that specify the behaviour of the Mock object:

    * `spec`: This can be either a list of strings or an existing object (a
      class or instance) that acts as the specification for the mock object. If
      you pass in an object then a list of strings is formed by calling dir on
      the object (excluding unsupported magic attributes and methods). Accessing
      any attribute not in this list will raise an `AttributeError`.

      If `spec` is an object (rather than a list of strings) then
      `mock.__class__` returns the class of the spec object. This allows mocks
      to pass `isinstance` tests.

    * `spec_set`: A stricter variant of `spec`. If used, attempting to *set*
      or get an attribute on the mock that isn't on the object passed as
      `spec_set` will raise an `AttributeError`.

    * `side_effect`: A function to be called whenever the Mock is called. See
      the `side_effect` attribute. Useful for raising exceptions or
      dynamically changing return values. The function is called with the same
      arguments as the mock, and unless it returns `DEFAULT`, the return
      value of this function is used as the return value.

      If `side_effect` is an iterable then each call to the mock will return
      the next value from the iterable. If any of the members of the iterable
      are exceptions they will be raised instead of returned.

    * `return_value`: The value returned when the mock is called. By default
      this is a new Mock (created on first access). See the
      `return_value` attribute.

    * `wraps`: Item for the mock object to wrap. If `wraps` is not None then
      calling the Mock will pass the call through to the wrapped object
      (returning the real result). Attribute access on the mock will return a
      Mock object that wraps the corresponding attribute of the wrapped object
      (so attempting to access an attribute that doesn't exist will raise an
      `AttributeError`).

      If the mock has an explicit `return_value` set then calls are not passed
      to the wrapped object and the `return_value` is returned instead.

    * `name`: If the mock has a name then it will be used in the repr of the
      mock. This can be useful for debugging. The name is propagated to child
      mocks.

    Mocks can also be called with arbitrary keyword arguments. These will be
    used to set attributes on the mock after it is created.
    N)r5r8rhr6rrrrr�s1cCs2y
t||�Stk
r,t|�t||�SXdS)N)r<r"�
__import__)�thing�comp�import_pathrrr�_dot_lookup1s

r�cCsF|jd�}|jd�}t|�}x$|D]}|d|7}t|||�}q"W|S)Nr�rz.%s)r�r�r�r�)�targetZ
componentsr�r�r�rrr�	_importer9s


r�cCs
t|d�S)N�is_local)�hasattr)�patcherrrr�_is_startedDsr�c@sdeZdZdZgZdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�ZdS)�_patchNc

Csn|dk	r(|tk	rtd��|dk	r(td��||_||_||_||_||_||_d|_||_	||_
|	|_g|_dS)Nz,Cannot use 'new' and 'new_callable' togetherz1Cannot use 'autospec' and 'new_callable' togetherF)
rr&�getterr�r��new_callabler��createZ	has_localr��autospecr,�additional_patchers)
rfr�r�r�r�r�r�r�r�r,rrrr!Ns$z_patch.__init__c
CsHt|j|j|j|j|j|j|j|j|j	�	}|j
|_
dd�|jD�|_|S)NcSsg|]}|j��qSr)�copy)r�prrrr�qsz_patch.copy.<locals>.<listcomp>)r�r�r�r�r�r�r�r�r�r,�attribute_namer�)rfr�rrrrisz_patch.copycCst|t�r|j|�S|j|�S)N)rr�decorate_class�decorate_callable)rfr'rrrr$vs

z_patch.__call__cCsRxLt|�D]@}|jtj�sq
t||�}t|d�s2q
|j�}t||||��q
W|S)Nr$)r�rr�TEST_PREFIXr<r�rrz)rfr��attr�
attr_valuer�rrrr|s

z_patch.decorate_classcs<t�d�r�jj|��St����fdd���|g�_�S)N�	patchingscs�g}g}t�}z�ybxJ�jD]@}|j�}|j|�|jdk	rF|j|�q|jtkr|j|�qW|t|�7}�||�S||kr�t|�r�|j|�t	j
�}�YnXWdxt|�D]}|j|�q�WXdS)N)
r?r�	__enter__r�r�updater�rr��sys�exc_infor��__exit__)r+Zkeywargs�
extra_argsZentered_patchersr�patchingr�)r'�patchedrrr�s*




z)_patch.decorate_callable.<locals>.patched)r�rr�r)rfr'r)r'rrr�s
z_patch.decorate_callablecCs�|j�}|j}t}d}y|j|}Wn$ttfk
rHt||t�}YnXd}|tkrft|t	�rfd|_
|j
r�|tkr�td||f��||fS)NFTz!%s does not have the attribute %r)r�r�rrBr"�KeyErrorr<�	_builtinsrrr�)rfr�rrI�localrrr�get_original�sz_patch.get_originalcCs>|j|j|j}}}|j|j}}|j}|j�|_|dkr@d}|dkrLd}|dkrXd}|dk	rp|dk	rptd��|dk	s�|dk	r�|dkr�td��|j	�\}}|t
ko�|dk�rTd}	|dkr�|}|dkr�|}d}n&|dk	r�|dkr�|}d}n|dkr�|}|dk	�s
|dk	�r,|t
k�rtd��t|t��r,d}	t
}
i}|dk	�rD|}
nN|dk	�sX|dk	�r�|}|dk	�rj|}t|��r~d|k}
n
t|�}
|
�r�t}
|dk	�r�||d<|dk	�r�||d	<t|
t��r�t|
t��r�|j�r�|j|d
<|j|�|
f|�}|	�r�t|��r�|}|dk	�r|}t|��r2t|��r2t}
|jd
�|
f|dd�|��|_nl|dk	�r�|t
k	�rptd
��|t
k�r�td��t|�}|dk�r�|}t|f||jd�|��}n|�r�td��|}||_||_t|j|j|�|jdk	�r:i}|jt
k�r|||j<x.|jD]$}|j �}|jt
k�r|j|��qW|S|S)zPerform the patch.FNzCan't specify spec and autospecTz6Can't provide explicit spec_set *and* spec or autospecz!Can't use 'spec' with create=Truer$r�r�rz())r�r�zBautospec creates the mock for you. Can't specify autospec and new.z%Can't use 'autospec' with create=True)r��_namez.Can't pass kwargs to a mock we aren't creating)TN)!r�r�r�r�r,r�r�r�r�rrrrrr@r�rrr
r�r
rrEr�rY�boolr�
temp_originalr�rzrr�r	)rfr�r�r�r�r,r�rIrZinherit�Klass�_kwargsZ	this_specZnot_callableZnew_attrrrr�rrrr	�s�


















z_patch.__enter__cGs�t|�std��|jr4|jtk	r4t|j|j|j�nBt|j|j�|j	rvt
|j|j�sd|jdkrvt|j|j|j�|`|`|`x$t|j�D]}t|�r�|j
|�q�WdS)	zUndo the patch.z stop called on unstarted patcherr6r8r9�__annotations__r:N)r6r8r9rr:)r��RuntimeErrorr�rrrzr�r�r�r�r�r�r�r
)rfrr�rrrr
Hs z_patch.__exit__cCs|j�}|jj|�|S)z-Activate a patch, returning any created mock.)r	�_active_patchesr�)rfrJrrr�start`sz_patch.startcCs.y|jj|�Wntk
r$YnX|j�S)zStop an active patch.)rr�r&r
)rfrrr�stopgs
z_patch.stop)r5r8rhrrr!rr$rrrr	r
rrrrrrr�Is
(~r�csPy�jdd�\�}Wn&ttfk
r:td�f��YnX�fdd�}||fS)Nr�r�z.Need a valid target to patch. You supplied: %rcst��S)N)r�r)r�rrr�ysz_get_target.<locals>.<lambda>)�rsplitr�r&)r�r�r�r)r�r�_get_targetssr c

s$�fdd�}	t|	||||||||�	S)a
    patch the named member (`attribute`) on an object (`target`) with a mock
    object.

    `patch.object` can be used as a decorator, class decorator or a context
    manager. Arguments `new`, `spec`, `create`, `spec_set`,
    `autospec` and `new_callable` have the same meaning as for `patch`. Like
    `patch`, `patch.object` takes arbitrary keyword arguments for configuring
    the mock object it creates.

    When used as a class decorator `patch.object` honours `patch.TEST_PREFIX`
    for choosing which methods to wrap.
    cs�S)Nrr)r�rrr��sz_patch_object.<locals>.<lambda>)r�)
r�r�r�r�r�r�r�r�r,r�r)r�r�
_patch_object}s
r!c
s�t��tkr�fdd�}n�fdd�}|s2td��t|j��}|d\}	}
t||	|
|||||i�	}|	|_xB|dd�D]2\}	}
t||	|
|||||i�	}|	|_|jj|�qvW|S)a�Perform multiple patches in a single call. It takes the object to be
    patched (either as an object or a string to fetch the object by importing)
    and keyword arguments for the patches::

        with patch.multiple(settings, FIRST_PATCH='one', SECOND_PATCH='two'):
            ...

    Use `DEFAULT` as the value if you want `patch.multiple` to create
    mocks for you. In this case the created mocks are passed into a decorated
    function by keyword, and a dictionary is returned when `patch.multiple` is
    used as a context manager.

    `patch.multiple` can be used as a decorator, class decorator or a context
    manager. The arguments `spec`, `spec_set`, `create`,
    `autospec` and `new_callable` have the same meaning as for `patch`. These
    arguments will be applied to *all* patches done by `patch.multiple`.

    When used as a class decorator `patch.multiple` honours `patch.TEST_PREFIX`
    for choosing which methods to wrap.
    cst��S)N)r�r)r�rrr��sz!_patch_multiple.<locals>.<lambda>cs�S)Nrr)r�rrr��sz=Must supply at least one keyword argument with patch.multiplerr�N)	r�strr&r>r�r�rr�r�)
r�r�r�r�r�r�r,r�r�r�r�r�Zthis_patcherr)r�r�_patch_multiple�s&

r#c

Ks$t|�\}}	t||	|||||||�	S)a�

    `patch` acts as a function decorator, class decorator or a context
    manager. Inside the body of the function or with statement, the `target`
    is patched with a `new` object. When the function/with statement exits
    the patch is undone.

    If `new` is omitted, then the target is replaced with a
    `MagicMock`. If `patch` is used as a decorator and `new` is
    omitted, the created mock is passed in as an extra argument to the
    decorated function. If `patch` is used as a context manager the created
    mock is returned by the context manager.

    `target` should be a string in the form `'package.module.ClassName'`. The
    `target` is imported and the specified object replaced with the `new`
    object, so the `target` must be importable from the environment you are
    calling `patch` from. The target is imported when the decorated function
    is executed, not at decoration time.

    The `spec` and `spec_set` keyword arguments are passed to the `MagicMock`
    if patch is creating one for you.

    In addition you can pass `spec=True` or `spec_set=True`, which causes
    patch to pass in the object being mocked as the spec/spec_set object.

    `new_callable` allows you to specify a different class, or callable object,
    that will be called to create the `new` object. By default `MagicMock` is
    used.

    A more powerful form of `spec` is `autospec`. If you set `autospec=True`
    then the mock will be created with a spec from the object being replaced.
    All attributes of the mock will also have the spec of the corresponding
    attribute of the object being replaced. Methods and functions being
    mocked will have their arguments checked and will raise a `TypeError` if
    they are called with the wrong signature. For mocks replacing a class,
    their return value (the 'instance') will have the same spec as the class.

    Instead of `autospec=True` you can pass `autospec=some_object` to use an
    arbitrary object as the spec instead of the one being replaced.

    By default `patch` will fail to replace attributes that don't exist. If
    you pass in `create=True`, and the attribute doesn't exist, patch will
    create the attribute for you when the patched function is called, and
    delete it again afterwards. This is useful for writing tests against
    attributes that your production code creates at runtime. It is off by
    default because it can be dangerous. With it switched on you can write
    passing tests against APIs that don't actually exist!

    Patch can be used as a `TestCase` class decorator. It works by
    decorating each test method in the class. This reduces the boilerplate
    code when your test methods share a common patchings set. `patch` finds
    tests by looking for method names that start with `patch.TEST_PREFIX`.
    By default this is `test`, which matches the way `unittest` finds tests.
    You can specify an alternative prefix by setting `patch.TEST_PREFIX`.

    Patch can be used as a context manager, with the with statement. Here the
    patching applies to the indented block after the with statement. If you
    use "as" then the patched object will be bound to the name after the
    "as"; very useful if `patch` is creating a mock object for you.

    `patch` takes arbitrary keyword arguments. These will be passed to
    the `Mock` (or `new_callable`) on construction.

    `patch.dict(...)`, `patch.multiple(...)` and `patch.object(...)` are
    available for alternate use-cases.
    )r r�)
r�r�r�r�r�r�r�r,r�r�rrrr�sE
c@sVeZdZdZfdfdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
eZe
ZdS)�_patch_dicta#
    Patch a dictionary, or dictionary like object, and restore the dictionary
    to its original state after the test.

    `in_dict` can be a dictionary or a mapping like container. If it is a
    mapping then it must at least support getting, setting and deleting items
    plus iterating over keys.

    `in_dict` can also be a string specifying the name of the dictionary, which
    will then be fetched by importing it.

    `values` can be a dictionary of values to set in the dictionary. `values`
    can also be an iterable of `(key, value)` pairs.

    If `clear` is True then the dictionary will be cleared before the new
    values are set.

    `patch.dict` can also be called with arbitrary keyword arguments to set
    values in the dictionary::

        with patch.dict('sys.modules', mymodule=Mock(), other_module=Mock()):
            ...

    `patch.dict` can be used as a context manager, decorator or class
    decorator. When used as a class decorator `patch.dict` honours
    `patch.TEST_PREFIX` for choosing which methods to wrap.
    FcKs>t|t�rt|�}||_t|�|_|jj|�||_d|_dS)N)	rr"r��in_dictrnr�r
�clear�	_original)rfr%r�r&r,rrrr!0s

z_patch_dict.__init__cs.t�t�r�j��St����fdd��}|S)Nc
s"�j�z
�||�S�j�XdS)N)r$�
_unpatch_dict)r+r�)�frfrr�_inner>s
z$_patch_dict.__call__.<locals>._inner)rrrr)rfr)r*r)r)rfrr$;s

z_patch_dict.__call__cCs\xVt|�D]J}t||�}|jtj�r
t|d�r
t|j|j|j	�}||�}t
|||�q
W|S)Nr$)r�r<rrrr�r$r%r�r&rz)rfr�rrZ	decoratorZ	decoratedrrrrIs

z_patch_dict.decorate_classcCs|j�dS)zPatch the dict.N)r$)rfrrrr	Tsz_patch_dict.__enter__cCs�|j}|j}|j}y|j�}Wn2tk
rPi}x|D]}||||<q8WYnX||_|rdt|�y|j|�Wn.tk
r�x|D]}||||<q�WYnXdS)N)r�r%r&rr"r'�_clear_dictr
)rfr�r%r&rIr�rrrr$Ys"

z_patch_dict._patch_dictcCsV|j}|j}t|�y|j|�Wn.tk
rPx|D]}||||<q8WYnXdS)N)r%r'r+r
r")rfr%rIr�rrrr(ss
z_patch_dict._unpatch_dictcGs|j�dS)zUnpatch the dict.F)r()rfr+rrrr
�sz_patch_dict.__exit__N)
r5r8rhr6r!r$rr	r$r(r
rrrrrrr$s
r$cCsBy|j�Wn0tk
r<t|�}x|D]
}||=q*WYnXdS)N)r&r"r>)r%�keysr�rrrr+�s
r+cCs xttj�D]}|j�qWdS)z7Stop all active patches. LIFO to unroll nested patches.N)r�r�rr)rrrr�_patch_stopall�sr-Ztestz�lt le gt ge eq ne getitem setitem delitem len contains iter hash str sizeof enter exit divmod rdivmod neg pos abs invert complex int float index trunc floor ceil bool next zHadd sub mul matmul div floordiv mod lshift rshift and xor or pow truediv� ccs|]}d|VqdS)zi%sNr)r�nrrrr��sr�ccs|]}d|VqdS)zr%sNr)rr/rrrr��s�__get__�__set__�
__delete__�__reversed__�__missing__�
__reduce__�
__reduce_ex__Z__getinitargs__�__getnewargs__�__getstate__�__setstate__�
__getformat__�
__setformat__rgr��__subclasses__�
__format__�__getnewargs_ex__cs�fdd�}||_|S)z:Turns a callable object (like a mock) into a real functioncs�|f|�|�S)Nr)rfr+r�)r'rr�method�sz_get_method.<locals>.method)r5)rr'r?r)r'rr��sr�cCsh|]}d|�qS)z__%s__r)rr?rrrr�srmr�r!r��__prepare__�__instancecheck__�__subclasscheck__�__del__cCs
tj|�S)N)r��__hash__)rfrrrr��sr�cCs
tj|�S)N)r��__str__)rfrrrr��scCs
tj|�S)N)r��
__sizeof__)rfrrrr��s)rDrErFr�y�?g�?)�__lt__�__gt__�__le__�__ge__�__int__r��__len__r
�__complex__�	__float__�__bool__�	__index__cs�fdd�}|S)Ncs$�jj}|tk	r|S�|kr dStS)NT)�__eq__rrr�NotImplemented)�other�ret_val)rfrrrQ�sz_get_eq.<locals>.__eq__r)rfrQr)rfr�_get_eq�srUcs�fdd�}|S)Ncs �jjtk	rtS�|krdStS)NF)�__ne__rrrrR)rS)rfrrrV�s
z_get_ne.<locals>.__ne__r)rfrVr)rfr�_get_ne�srWcs�fdd�}|S)Ncs �jj}|tkrtg�St|�S)N)r�rrrr�)rT)rfrrr��sz_get_iter.<locals>.__iter__r)rfr�r)rfr�	_get_iter�srX)rQrVr�cCs�tj|t�}|tk	r||_dStj|�}|dk	rdy||�}Wntk
rXt|�}YnX||_dStj|�}|dk	r�||�|_dS)N)�_return_valuesrCrrY�_calculate_return_valuer"�_side_effect_methodsr_)r1r?rZfixedZreturn_calulatorrYZ
side_effectorrrr�_set_return_values

r\c@seZdZdd�Zdd�ZdS)�
MagicMixincOs&|j�tt|�j||�|j�dS)N)�_mock_set_magicsr�r]r!)rfr+r�rrrr!(szMagicMixin.__init__cCs�t}t|dd�dk	rTtj|j�}t�}t|}x$|D]}|t|�jkr4t||�q4W|tt|�j�}t|�}x|D]}t||t	||��qtWdS)Nr�)
�_magicsr<�intersectionr�rorrBr�rz�
MagicProxy)rfZthese_magicsZ
remove_magicsr�r�rrrr^.s

zMagicMixin._mock_set_magicsN)r5r8rhr!r^rrrrr]'sr]c@seZdZdZddd�ZdS)rz-A version of `MagicMock` that isn't callable.FcCs|j||�|j�dS)z�Add a spec to a mock. `spec` can either be an object or a
        list of strings. Only attributes on the `spec` can be fetched as
        attributes from the mock.

        If `spec_set` is True then only attributes on the spec can be set.N)r�r^)rfr�r�rrrr�Gsz"NonCallableMagicMock.mock_add_specN)F)r5r8rhr6r�rrrrrEsc@seZdZdZddd�ZdS)ra�
    MagicMock is a subclass of Mock with default implementations
    of most of the magic methods. You can use MagicMock without having to
    configure the magic methods yourself.

    If you use the `spec` or `spec_set` arguments then *only* magic
    methods that exist in the spec will be created.

    Attributes and the return value of a `MagicMock` will also be `MagicMocks`.
    FcCs|j||�|j�dS)z�Add a spec to a mock. `spec` can either be an object or a
        list of strings. Only attributes on the `spec` can be fetched as
        attributes from the mock.

        If `spec_set` is True then only attributes on the spec can be set.N)r�r^)rfr�r�rrrr�]szMagicMock.mock_add_specN)F)r5r8rhr6r�rrrrrRs
c@s.eZdZdd�Zdd�Zdd�Zd
dd	�ZdS)racCs||_||_dS)N)rr�)rfrr�rrrr!iszMagicProxy.__init__cOs|j�}|||�S)N)�create_mock)rfr+r,�mrrrr$mszMagicProxy.__call__cCs8|j}|j}|j|||d�}t|||�t|||�|S)N)rr�r�)rr�r�rzr\)rfr�r�rcrrrrbqszMagicProxy.create_mockNcCs|j�S)N)rb)rfrr�rrrr0zszMagicProxy.__get__)N)r5r8rhr!r$rbr0rrrrrahs	rac@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_ANYz2A helper object that compares equal to everything.cCsdS)NTr)rfrSrrrrQ�sz_ANY.__eq__cCsdS)NFr)rfrSrrrrV�sz_ANY.__ne__cCsdS)Nz<ANY>r)rfrrrrg�sz
_ANY.__repr__N)r5r8rhr6rQrVrgrrrrrdsrdcCsdd|}d}djdd�|D��}djdd�t|j��D��}|rD|}|r\|rT|d7}||7}||S)Nz%s(%%s)r�z, cSsg|]}t|��qSr)�repr)rr�rrrr��sz*_format_call_signature.<locals>.<listcomp>cSsg|]\}}d||f�qS)z%s=%rr)rr�rprrrr��s)r�r�r�)rr+r,r�Zformatted_argsZargs_stringZ
kwargs_stringrrrr��sr�c@sveZdZdZfddddfdd�Zfddddfdd	�Zd
d�ZejZdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)r�a�
    A tuple for holding the results of a call to a mock, either in the form
    `(args, kwargs)` or `(name, args, kwargs)`.

    If args or kwargs are empty then a call tuple will compare equal to
    a tuple without those values. This makes comparisons less verbose::

        _Call(('name', (), {})) == ('name',)
        _Call(('name', (1,), {})) == ('name', (1,))
        _Call(((), {'a': 'b'})) == ({'a': 'b'},)

    The `_Call` object provides a useful shortcut for comparing with call::

        _Call(((1, 2), {'a': 3})) == call(1, 2, a=3)
        _Call(('foo', (1, 2), {'a': 3})) == call.foo(1, 2, a=3)

    If the _Call has no name then it will match any name.
    r�NFTcCs�f}i}t|�}|dkr$|\}}}nr|dkrd|\}	}
t|	t�rX|	}t|
t�rR|
}qb|
}q�|	|
}}n2|dkr�|\}t|t�r�|}nt|t�r�|}n|}|r�tj|||f�Stj||||f�S)Nr�rbr�)r�rr"r?r�)r�rprr�r��	from_kallr+r,�_len�first�secondrrrr��s.



z
_Call.__new__cCs||_||_||_dS)N)rvrt�_mock_from_kall)rfrprr�r�rfrrrr!�sz_Call.__init__cCsf|tkrdSyt|�}Wntk
r,dSXd}t|�dkrH|\}}n
|\}}}t|dd�rzt|dd�rz|j|jkrzdSd}|dkr�fi}}n�|dkr�|\}}}n�|dkr�|\}	t|	t�r�|	}i}n"t|	t�r�|	}fi}}nf}|	}nV|dk�r>|\}
}t|
t��r2|
}t|t��r&|i}}n
f|}}n
|
|}}ndS|�rV||k�rVdS||f||fkS)	NTFr�rbrtrr�r�)rr�r�r<rtrr?r")rfrSZ	len_otherZ	self_nameZ	self_argsZself_kwargsZ
other_nameZ
other_argsZother_kwargsrprhrirrrrQ�sP




z_Call.__eq__cOs<|jdkrtd||fdd�S|jd}t|j||f||d�S)Nr�z())r)rr�)rvr�)rfr+r,rrrrr$s

z_Call.__call__cCs2|jdkrt|dd�Sd|j|f}t||dd�S)NF)rrfz%s.%s)rr�rf)rvr�)rfrrrrrrms
z_Call.__getattr__cOs|jd�||�S)Nr�)rm)rfr+r,rrrr�$sz_Call.countcOs|jd�||�S)N�index)rm)rfr+r,rrrrk'sz_Call.indexcCs||js&|jpd}|jd�r"d|}|St|�dkr@d}|\}}n0|\}}}|sTd}n|jd�shd|}nd|}t|||�S)Nrz()zcall%srbzcall.%s)rjrvrr�r�)rfrr+r,rrrrg*s





z_Call.__repr__cCs8g}|}x"|dk	r*|jr"|j|�|j}q
Wtt|��S)z�For a call object that represents multiple calls, `call_list`
        returns a list of all the intermediate calls as well as the
        final call.N)rjr�rtrUr�)rf�valsr�rrr�	call_list?s


z_Call.call_list)r5r8rhr6r�r!rQr�rVr$rmr�rkrgrmrrrrr��s7r�)rfcKs,t|�rt|�}t|t�}d|i}|r0d|i}n|dkr<i}|rL|rLd|d<|j|�t}tj|�rji}n$t|�sxt}n|r�|r�t	|�r�t}|j
d|�}|}	|dkr�d}	|f|||	|d�|��}
t|t�r�t|
|�}
nt
||
||�|dk	o�|�r|
|j|<|�r,|�r,d	|k�r,t||dd
|
d�|
_x�t|�D]�}t|��rH�q6yt||�}Wntk
�rp�w6YnXd|i}|�r�d|i}t|t��s�t|||
||�}
|
|
j|<nZ|
}t|t��r�|
j}t|||�}||d<tf||||d
�|��}
|
|
j|<t
||
|d�t|
t��r6t|
||
��q6W|
S)aICreate a mock object using another object as a spec. Attributes on the
    mock will use the corresponding attribute on the `spec` object as their
    spec.

    Functions or methods being mocked will have their arguments checked
    to check that they are called with the correct signature.

    If `spec_set` is True then attempting to set attributes that don't exist
    on the spec object will raise an `AttributeError`.

    If a class is used as a spec then the return value of the mock (the
    instance of the class) will have the same spec. You can use a class as the
    spec for an instance object by passing `instance=True`. The returned mock
    will only be callable if instances of the mock are callable.

    `create_autospec` also takes arbitrary keyword arguments that are passed to
    the constructor of the created mock.r�r�NTr�rr�)r�r�r�rrYz())r3rr�r�)r�rr�r�)r2)r@rrr
rr%Zisdatadescriptorr=rrEr�r#rMr4r`rrYr�rdr<r"r�r1�
_must_skiprz)r�r�r3r�rr,�is_typerrr�r1r�rIr�r�r2rrrrPst










cCs|t|t�s$|t|di�krdS|j}xR|jD]H}|jj|t�}|tkrHq,t|tt	f�rZdStt|dd�t
�rp|SdSq,W|S)z[
    Return whether we should skip the first argument on spec's `entry`
    attribute.
    rBFr0N)rrr<r�rArBrCr�staticmethod�classmethod�MethodWrapperTypes)r�r�ror�rJrrrrn�s
rncCs$y|jStk
rt|�SXdS)N)r�r"r)rrrrr��sr�c@seZdZddd�ZdS)r�FNcCs(||_||_||_||_||_||_dS)N)r��idsr�r�r3r)rfr�r�r�rrsr3rrrr!�sz_SpecState.__init__)FNNNF)r5r8rhr!rrrrr��sr�c#spt|t�rdnd��fdd�|j��D�}|d�krD|dd�}n|ddd	�|d
<x|D]
}|Vq^WdS)N�
�
csg|]}|��qSrr)r�l)�seprrr�	sz&_iterate_read_data.<locals>.<listcomp>r����rxrxrxrx)r�bytesr�)�	read_dataZdata_as_list�liner)rwr�_iterate_read_data	s
r|r�cs���fdd�}���fdd�}���fdd��tdkr`ddl}ttt|j��jtt|j����a|dkrttd	t	d
�}ttd����j
_t��dg�d�j
_d�j_d�j_d�j_|�j_���d<�d�j_|�j_����fd
d�}||_�|_|S)a�
    A helper function to create a mock to replace the use of `open`. It works
    for `open` called directly or used as a context manager.

    The `mock` argument is the mock object to configure. If `None` (the
    default) then a `MagicMock` will be created for you, with the API limited
    to methods or attributes available on standard file handles.

    `read_data` is a string for the `read` methoddline`, and `readlines` of the
    file handle to return.  This is an empty string by default.
    cs �jjdk	r�jjSt�d�S)Nr)�	readlinesrYr>)r+r,)�_state�handlerr�_readlines_side_effect(	sz)mock_open.<locals>._readlines_side_effectcs(�jjdk	r�jjSt���j�d�S)Nr)�readrYrr�)r+r,)r~rrzrr�_read_side_effect-	sz$mock_open.<locals>._read_side_effectc3sJ�jjdk	rx�jjVqWx�dD]
}|Vq&Wxt���Vq6WdS)Nr)�readlinerYr)r{)r~rrzrr�_readline_side_effect2	s
z(mock_open.<locals>._readline_side_effectNr�open)rr�)r�r�cs6t���d<�jj�dkr2���d<�d�j_tS)Nrr�)r|r�r_r)r+r,)r�r~rrzrr�
reset_dataS	s

zmock_open.<locals>.reset_data)�	file_spec�_ior>ror��
TextIOWrapper�union�BytesIOrr�r	rYr|�writer�r�r}r_)r1rzr�r�r�r�r)r�r~rrzrr	s."

c@s(eZdZdZdd�Zdd�Zdd�ZdS)	r
aW
    A mock intended to be used as a property, or other descriptor, on a class.
    `PropertyMock` provides `__get__` and `__set__` methods so you can specify
    a return value when it is fetched.

    Fetching a `PropertyMock` instance from an object calls the mock, with
    no args. Setting it calls the mock with the value being set.
    cKs
tf|�S)N)r)rfr,rrrr�i	szPropertyMock._get_child_mockcCs|�S)Nr)rfrZobj_typerrrr0l	szPropertyMock.__get__cCs||�dS)Nr)rfrr�rrrr1n	szPropertyMock.__set__N)r5r8rhr6r�r0r1rrrrr
`	s)
rrrrrrrrr	r
rrr
)F)F)NFNNN)FFNN)Nr�)o�__all__�__version__r%r�r�builtins�typesr�	functoolsrrr�r�
BaseExceptionr�platformrZlangZ	Throwabler	�superr�rr r(r4r/r=r@rErMrHrdr�rerirrZMISSINGr�ZDELETEDr�rqr|rr>rUr�r�r�r
r�r�rr�r�r�r�r r!r#rr$r+r-rnZmultipleZstopallrZ
magic_methodsZnumericsr�r�Zinplace�rightZ
_non_defaultsr�r_r�r�rZrRrYrUrWrXr[r\r]rrrardrr�r?r�rrrnr�r�rrQr#r0rrr�r|rr
rrrr�<module>s
 

4	i5,
1Jv	

	
,

w
DPKń[Z�Z��#�#&__pycache__/suite.cpython-36.opt-1.pycnu�[���3


 \�(�@s|dZddlZddlmZddlmZdZdd�ZGd	d
�d
e�ZGdd�de�Z	Gdd
�d
e�Z
dd�ZGdd�de�ZdS)�	TestSuite�N�)�case)�utilTcCst||dd��}|�dS)NcSsdS)N�rrr�&/usr/lib64/python3.6/unittest/suite.py�<lambda>sz!_call_if_exists.<locals>.<lambda>)�getattr)�parent�attr�funcrrr�_call_if_existssr
c@speZdZdZdZffdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�
BaseTestSuitezNA simple test suite that doesn't provide class or module shared fixtures.
    TcCsg|_d|_|j|�dS)Nr)�_tests�_removed_tests�addTests)�self�testsrrr�__init__szBaseTestSuite.__init__cCsdtj|j�t|�fS)Nz
<%s tests=%s>)r�strclass�	__class__�list)rrrr�__repr__szBaseTestSuite.__repr__cCs t||j�stSt|�t|�kS)N)�
isinstancer�NotImplementedr)r�otherrrr�__eq__szBaseTestSuite.__eq__cCs
t|j�S)N)�iterr)rrrr�__iter__"szBaseTestSuite.__iter__cCs(|j}x|D]}|r||j�7}qW|S)N)r�countTestCases)rZcases�testrrrr%s

zBaseTestSuite.countTestCasescCsLt|�stdjt|����t|t�r<t|tjt	f�r<td��|j
j|�dS)Nz{} is not callablezNTestCases and TestSuites must be instantiated before passing them to addTest())�callable�	TypeError�format�reprr�type�
issubclassrZTestCaserr�append)rr rrr�addTest,szBaseTestSuite.addTestcCs.t|t�rtd��x|D]}|j|�qWdS)Nz0tests must be an iterable of tests, not a string)r�strr"r()rrr rrrr6s

zBaseTestSuite.addTestscCs:x4t|�D](\}}|jrP||�|jr
|j|�q
W|S)N)�	enumerate�
shouldStop�_cleanup�_removeTestAtIndex)r�result�indexr rrr�run<szBaseTestSuite.runcCsNy|j|}Wntk
r"Yn(Xt|d�r@|j|j�7_d|j|<dS)z2Stop holding a reference to the TestCase at index.rN)rr"�hasattrrr)rr/r rrrr-Es
z BaseTestSuite._removeTestAtIndexcOs|j||�S)N)r0)r�args�kwdsrrr�__call__SszBaseTestSuite.__call__cCsx|D]}|j�qWdS)z7Run the tests without collecting errors in a TestResultN)�debug)rr rrrr5Vs
zBaseTestSuite.debugN)�__name__�
__module__�__qualname__�__doc__r,rrrrrr(rr0r-r4r5rrrrrs
	rc@sReZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)ra�A test suite is a composite test consisting of a number of TestCases.

    For use, create an instance of TestSuite, then add test case instances.
    When all tests have been added, the suite can be passed to a test
    runner, such as TextTestRunner. It will run the individual test cases
    in the order in which they were added, aggregating the results. When
    subclassing, do not forget to call the base class constructor.
    FcCs�d}t|dd�dkrd|_}x�t|�D]�\}}|jr8Pt|�r�|j||�|j||�|j||�|j|_	t|jdd�s(t|dd�r�q(|s�||�n|j
�|jr(|j|�q(W|r�|jd|�|j
|�d|_|S)NF�_testRunEnteredT�_classSetupFailed�_moduleSetUpFailed)r	r:r*r+�_isnotsuite�_tearDownPreviousClass�_handleModuleFixture�_handleClassSetUpr�_previousTestClassr5r,r-�_handleModuleTearDown)rr.r5ZtopLevelr/r rrrr0fs0


z
TestSuite.runcCst�}|j|d�dS)z7Run the tests without collecting errors in a TestResultTN)�_DebugResultr0)rr5rrrr5�szTestSuite.debugc	 Cs�t|dd�}|j}||krdS|jr(dSt|dd�r8dSy
d|_Wntk
rVYnXt|dd�}|dk	r�t|d�zdy
|�WnTtk
r�}z8t|t�r��d|_t	j
|�}d|}|j|||�WYdd}~XnXWdt|d�XdS)	NrA�__unittest_skip__F�
setUpClass�_setupStdoutTzsetUpClass (%s)�_restoreStdout)r	rr<r;r"r
�	ExceptionrrCrr�_addClassOrModuleLevelException)	rr r.�
previousClass�currentClassrE�e�	className�	errorNamerrrr@�s2




$zTestSuite._handleClassSetUpcCs"d}t|dd�}|dk	r|j}|S)NrA)r	r7)rr.�previousModulerJrrr�_get_previous_module�s
zTestSuite._get_previous_modulec	 Cs�|j|�}|jj}||krdS|j|�d|_ytj|}Wntk
rPdSXt|dd�}|dk	r�t	|d�zZy
|�WnJt
k
r�}z.t|t�r��d|_d|}|j
|||�WYdd}~XnXWdt	|d�XdS)NF�setUpModulerFTzsetUpModule (%s)rG)rPrr7rBr<�sys�modules�KeyErrorr	r
rHrrCrI)	rr r.rOZ
currentModule�modulerQrLrNrrrr?�s,




$zTestSuite._handleModuleFixturecCsLt|�}t|dd�}|dk	r8t|tj�r8||t|��n|j|tj��dS)N�addSkip)	�_ErrorHolderr	rrZSkipTestr)ZaddErrorrR�exc_info)rr.Z	exceptionrN�errorrVrrrrI�s
z)TestSuite._addClassOrModuleLevelExceptionc Cs�|j|�}|dkrdS|jr dSytj|}Wntk
rBdSXt|dd�}|dk	r�t|d�zTy
|�WnDtk
r�}z(t|t	�r��d|}|j
|||�WYdd}~XnXWdt|d�XdS)N�tearDownModulerFztearDownModule (%s)rG)rPr<rRrSrTr	r
rHrrCrI)rr.rOrUrZrLrNrrrrB�s(



$zTestSuite._handleModuleTearDownc	Cs�t|dd�}|j}||krdSt|dd�r.dSt|dd�r>dSt|dd�rNdSt|dd�}|dk	r�t|d�z^y
|�WnNtk
r�}z2t|t�r��tj|�}d|}|j|||�WYdd}~XnXWdt|d	�XdS)
NrAr;Fr<rD�
tearDownClassrFztearDownClass (%s)rG)	r	rr
rHrrCrrrI)	rr r.rJrKr[rLrMrNrrrr>�s,



$z TestSuite._tearDownPreviousClassN)F)r6r7r8r9r0r5r@rPr?rIrBr>rrrrr\s
! c@sTeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�ZdS)rWz�
    Placeholder for a TestCase inside a result. As far as a TestResult
    is concerned, this looks exactly like a unit test. Used to insert
    arbitrary errors into a test suite run.
    NcCs
||_dS)N)�description)rr\rrrrsz_ErrorHolder.__init__cCs|jS)N)r\)rrrr�idsz_ErrorHolder.idcCsdS)Nr)rrrr�shortDescription sz_ErrorHolder.shortDescriptioncCsd|jfS)Nz<ErrorHolder description=%r>)r\)rrrrr#sz_ErrorHolder.__repr__cCs|j�S)N)r])rrrr�__str__&sz_ErrorHolder.__str__cCsdS)Nr)rr.rrrr0)sz_ErrorHolder.runcCs
|j|�S)N)r0)rr.rrrr4.sz_ErrorHolder.__call__cCsdS)Nrr)rrrrr1sz_ErrorHolder.countTestCases)
r6r7r8r9ZfailureExceptionrr]r^rr_r0r4rrrrrrWsrWcCs&yt|�Wntk
r dSXdS)z?A crude way to tell apart testcases and suites with duck-typingTF)rr")r rrrr=4s
r=c@seZdZdZdZdZdZdS)rCzCUsed by the TestSuite to hold previous class when running in debug.NF)r6r7r8r9rAr<r+rrrrrC=srC)
r9rR�rrZ
__unittestr
�objectrrrWr=rCrrrr�<module>sL3&	PKń[Z�Z��#�# __pycache__/suite.cpython-36.pycnu�[���3


 \�(�@s|dZddlZddlmZddlmZdZdd�ZGd	d
�d
e�ZGdd�de�Z	Gdd
�d
e�Z
dd�ZGdd�de�ZdS)�	TestSuite�N�)�case)�utilTcCst||dd��}|�dS)NcSsdS)N�rrr�&/usr/lib64/python3.6/unittest/suite.py�<lambda>sz!_call_if_exists.<locals>.<lambda>)�getattr)�parent�attr�funcrrr�_call_if_existssr
c@speZdZdZdZffdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�
BaseTestSuitezNA simple test suite that doesn't provide class or module shared fixtures.
    TcCsg|_d|_|j|�dS)Nr)�_tests�_removed_tests�addTests)�self�testsrrr�__init__szBaseTestSuite.__init__cCsdtj|j�t|�fS)Nz
<%s tests=%s>)r�strclass�	__class__�list)rrrr�__repr__szBaseTestSuite.__repr__cCs t||j�stSt|�t|�kS)N)�
isinstancer�NotImplementedr)r�otherrrr�__eq__szBaseTestSuite.__eq__cCs
t|j�S)N)�iterr)rrrr�__iter__"szBaseTestSuite.__iter__cCs(|j}x|D]}|r||j�7}qW|S)N)r�countTestCases)rZcases�testrrrr%s

zBaseTestSuite.countTestCasescCsLt|�stdjt|����t|t�r<t|tjt	f�r<td��|j
j|�dS)Nz{} is not callablezNTestCases and TestSuites must be instantiated before passing them to addTest())�callable�	TypeError�format�reprr�type�
issubclassrZTestCaserr�append)rr rrr�addTest,szBaseTestSuite.addTestcCs.t|t�rtd��x|D]}|j|�qWdS)Nz0tests must be an iterable of tests, not a string)r�strr"r()rrr rrrr6s

zBaseTestSuite.addTestscCs:x4t|�D](\}}|jrP||�|jr
|j|�q
W|S)N)�	enumerate�
shouldStop�_cleanup�_removeTestAtIndex)r�result�indexr rrr�run<szBaseTestSuite.runcCsNy|j|}Wntk
r"Yn(Xt|d�r@|j|j�7_d|j|<dS)z2Stop holding a reference to the TestCase at index.rN)rr"�hasattrrr)rr/r rrrr-Es
z BaseTestSuite._removeTestAtIndexcOs|j||�S)N)r0)r�args�kwdsrrr�__call__SszBaseTestSuite.__call__cCsx|D]}|j�qWdS)z7Run the tests without collecting errors in a TestResultN)�debug)rr rrrr5Vs
zBaseTestSuite.debugN)�__name__�
__module__�__qualname__�__doc__r,rrrrrr(rr0r-r4r5rrrrrs
	rc@sReZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)ra�A test suite is a composite test consisting of a number of TestCases.

    For use, create an instance of TestSuite, then add test case instances.
    When all tests have been added, the suite can be passed to a test
    runner, such as TextTestRunner. It will run the individual test cases
    in the order in which they were added, aggregating the results. When
    subclassing, do not forget to call the base class constructor.
    FcCs�d}t|dd�dkrd|_}x�t|�D]�\}}|jr8Pt|�r�|j||�|j||�|j||�|j|_	t|jdd�s(t|dd�r�q(|s�||�n|j
�|jr(|j|�q(W|r�|jd|�|j
|�d|_|S)NF�_testRunEnteredT�_classSetupFailed�_moduleSetUpFailed)r	r:r*r+�_isnotsuite�_tearDownPreviousClass�_handleModuleFixture�_handleClassSetUpr�_previousTestClassr5r,r-�_handleModuleTearDown)rr.r5ZtopLevelr/r rrrr0fs0


z
TestSuite.runcCst�}|j|d�dS)z7Run the tests without collecting errors in a TestResultTN)�_DebugResultr0)rr5rrrr5�szTestSuite.debugc	 Cs�t|dd�}|j}||krdS|jr(dSt|dd�r8dSy
d|_Wntk
rVYnXt|dd�}|dk	r�t|d�zdy
|�WnTtk
r�}z8t|t�r��d|_t	j
|�}d|}|j|||�WYdd}~XnXWdt|d�XdS)	NrA�__unittest_skip__F�
setUpClass�_setupStdoutTzsetUpClass (%s)�_restoreStdout)r	rr<r;r"r
�	ExceptionrrCrr�_addClassOrModuleLevelException)	rr r.�
previousClass�currentClassrE�e�	className�	errorNamerrrr@�s2




$zTestSuite._handleClassSetUpcCs"d}t|dd�}|dk	r|j}|S)NrA)r	r7)rr.�previousModulerJrrr�_get_previous_module�s
zTestSuite._get_previous_modulec	 Cs�|j|�}|jj}||krdS|j|�d|_ytj|}Wntk
rPdSXt|dd�}|dk	r�t	|d�zZy
|�WnJt
k
r�}z.t|t�r��d|_d|}|j
|||�WYdd}~XnXWdt	|d�XdS)NF�setUpModulerFTzsetUpModule (%s)rG)rPrr7rBr<�sys�modules�KeyErrorr	r
rHrrCrI)	rr r.rOZ
currentModule�modulerQrLrNrrrr?�s,




$zTestSuite._handleModuleFixturecCsLt|�}t|dd�}|dk	r8t|tj�r8||t|��n|j|tj��dS)N�addSkip)	�_ErrorHolderr	rrZSkipTestr)ZaddErrorrR�exc_info)rr.Z	exceptionrN�errorrVrrrrI�s
z)TestSuite._addClassOrModuleLevelExceptionc Cs�|j|�}|dkrdS|jr dSytj|}Wntk
rBdSXt|dd�}|dk	r�t|d�zTy
|�WnDtk
r�}z(t|t	�r��d|}|j
|||�WYdd}~XnXWdt|d�XdS)N�tearDownModulerFztearDownModule (%s)rG)rPr<rRrSrTr	r
rHrrCrI)rr.rOrUrZrLrNrrrrB�s(



$zTestSuite._handleModuleTearDownc	Cs�t|dd�}|j}||krdSt|dd�r.dSt|dd�r>dSt|dd�rNdSt|dd�}|dk	r�t|d�z^y
|�WnNtk
r�}z2t|t�r��tj|�}d|}|j|||�WYdd}~XnXWdt|d	�XdS)
NrAr;Fr<rD�
tearDownClassrFztearDownClass (%s)rG)	r	rr
rHrrCrrrI)	rr r.rJrKr[rLrMrNrrrr>�s,



$z TestSuite._tearDownPreviousClassN)F)r6r7r8r9r0r5r@rPr?rIrBr>rrrrr\s
! c@sTeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�ZdS)rWz�
    Placeholder for a TestCase inside a result. As far as a TestResult
    is concerned, this looks exactly like a unit test. Used to insert
    arbitrary errors into a test suite run.
    NcCs
||_dS)N)�description)rr\rrrrsz_ErrorHolder.__init__cCs|jS)N)r\)rrrr�idsz_ErrorHolder.idcCsdS)Nr)rrrr�shortDescription sz_ErrorHolder.shortDescriptioncCsd|jfS)Nz<ErrorHolder description=%r>)r\)rrrrr#sz_ErrorHolder.__repr__cCs|j�S)N)r])rrrr�__str__&sz_ErrorHolder.__str__cCsdS)Nr)rr.rrrr0)sz_ErrorHolder.runcCs
|j|�S)N)r0)rr.rrrr4.sz_ErrorHolder.__call__cCsdS)Nrr)rrrrr1sz_ErrorHolder.countTestCases)
r6r7r8r9ZfailureExceptionrr]r^rr_r0r4rrrrrrWsrWcCs&yt|�Wntk
r dSXdS)z?A crude way to tell apart testcases and suites with duck-typingTF)rr")r rrrr=4s
r=c@seZdZdZdZdZdZdS)rCzCUsed by the TestSuite to hold previous class when running in debug.NF)r6r7r8r9rAr<r+rrrrrC=srC)
r9rR�rrZ
__unittestr
�objectrrrWr=rCrrrr�<module>sL3&	PKń[���~~"__pycache__/signals.cpython-36.pycnu�[���3


 \c	�@sbddlZddlZddlmZdZGdd�de�Zej�Zdd�Z	dd	�Z
dad
d�Zddd
�Z
dS)�N)�wrapsTc@seZdZdd�Zdd�ZdS)�_InterruptHandlercCsNd|_||_t|t�rD|tjkr(tj}n|tjkr<dd�}ntd��||_	dS)NFcSsdS)N�)Z
unused_signumZunused_framerr�(/usr/lib64/python3.6/unittest/signals.py�default_handlersz3_InterruptHandler.__init__.<locals>.default_handlerzYexpected SIGINT signal handler to be signal.SIG_IGN, signal.SIG_DFL, or a callable object)
�called�original_handler�
isinstance�int�signal�SIG_DFL�default_int_handler�SIG_IGN�	TypeErrorr)�selfrrrr�__init__
s



z_InterruptHandler.__init__cCsVtjtj�}||k	r |j||�|jr2|j||�d|_xtj�D]}|j�qBWdS)NT)r�	getsignal�SIGINTrr�_results�keys�stop)rZsignum�frameZinstalled_handler�resultrrr�__call__sz_InterruptHandler.__call__N)�__name__�
__module__�__qualname__rrrrrrr	srcCsdt|<dS)N�)r)rrrr�registerResult*srcCsttj|d��S)N)�boolr�pop)rrrr�removeResult-sr!cCs.tdkr*tjtj�}t|�atjtjt�dS)N)�_interrupt_handlerrrrr)rrrr�installHandler1sr#cs<�dk	r t���fdd��}|Stdk	r8tjtjtj�dS)Ncs2tjtj�}t�z
�||�Stjtj|�XdS)N)rrr�
removeHandler)�args�kwargs�initial)�methodrr�inner;s

zremoveHandler.<locals>.inner)rr"rrr)r(r)r)r(rr$9s
r$)N)r�weakref�	functoolsrZ
__unittest�objectr�WeakKeyDictionaryrrr!r"r#r$rrrr�<module>s PKń[nԀ<<!__pycache__/result.cpython-36.pycnu�[���3


 \�@s\dZddlZddlZddlZddlmZddlmZdZdd�Z	d	Z
d
ZGdd�de�Z
dS)
zTest result object�N�)�util)�wrapsTcst���fdd��}|S)Ncs$t|dd�r|j��|f|�|�S)N�failfastF)�getattr�stop)�self�args�kw)�method��'/usr/lib64/python3.6/unittest/result.py�inner
szfailfast.<locals>.inner)r)rrr)rr
rsrz
Stdout:
%sz
Stderr:
%sc@s�eZdZdZdZdZdZd.dd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zedd��Zedd��Zdd�Zdd�Zdd�Zdd�Zed d!��Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�ZdS)/�
TestResulta�Holder for test result information.

    Test results are automatically managed by the TestCase and TestSuite
    classes, and do not need to be explicitly manipulated by writers of tests.

    Each instance holds the total number of tests run, and collections of
    failures and errors that occurred among those test runs. The collections
    contain tuples of (testcase, exceptioninfo), where exceptioninfo is the
    formatted traceback of the error that occurred.
    NFcCsbd|_g|_g|_d|_g|_g|_g|_d|_d|_d|_	d|_
d|_tj
|_tj|_d|_dS)NFr)r�failures�errors�testsRun�skipped�expectedFailures�unexpectedSuccesses�
shouldStop�buffer�	tb_locals�_stdout_buffer�_stderr_buffer�sys�stdout�_original_stdout�stderr�_original_stderr�
_mirrorOutput)r�streamZdescriptions�	verbosityrrr
�__init__&szTestResult.__init__cCsdS)z#Called by TestRunner after test runNr)rrrr
�printErrors7szTestResult.printErrorscCs |jd7_d|_|j�dS)z-Called when the given test is about to be runrFN)rr �_setupStdout)r�testrrr
�	startTest:szTestResult.startTestcCs8|jr4|jdkr$tj�|_tj�|_|jt_|jt_dS)N)rr�io�StringIOrrrr)rrrr
r%@s


zTestResult._setupStdoutcCsdS)zpCalled once before any tests are executed.

        See startTest for a method called before each test.
        Nr)rrrr
�startTestRunHszTestResult.startTestRuncCs|j�d|_dS)z'Called when the given test has been runFN)�_restoreStdoutr )rr&rrr
�stopTestNszTestResult.stopTestcCs�|jr�|jrltjj�}tjj�}|rF|jd�s6|d7}|jjt	|�|rl|jd�s\|d7}|j
jt|�|jt_|j
t_|jj
d�|jj�|jj
d�|jj�dS)N�
r)rr rr�getvaluer�endswithr�write�STDOUT_LINEr�STDERR_LINEr�seek�truncater)r�output�errorrrr
r+Ss$




zTestResult._restoreStdoutcCsdS)zmCalled once after all tests are executed.

        See stopTest for a method called after each test.
        Nr)rrrr
�stopTestRunhszTestResult.stopTestRuncCs"|jj||j||�f�d|_dS)zmCalled when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info().
        TN)r�append�_exc_info_to_stringr )rr&�errrrr
�addErrornszTestResult.addErrorcCs"|jj||j||�f�d|_dS)zdCalled when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info().TN)rr8r9r )rr&r:rrr
�
addFailurevszTestResult.addFailurecCsZ|dk	rVt|dd�r|j�t|d|j�r4|j}n|j}|j||j||�f�d|_dS)z�Called at the end of a subtest.
        'err' is None if the subtest ended successfully, otherwise it's a
        tuple of values as returned by sys.exc_info().
        NrFrT)	rr�
issubclass�failureExceptionrrr8r9r )rr&Zsubtestr:rrrr
�
addSubTest}szTestResult.addSubTestcCsdS)z-Called when a test has completed successfullyNr)rr&rrr
�
addSuccess�szTestResult.addSuccesscCs|jj||f�dS)zCalled when a test is skipped.N)rr8)rr&�reasonrrr
�addSkip�szTestResult.addSkipcCs|jj||j||�f�dS)z/Called when an expected failure/error occurred.N)rr8r9)rr&r:rrr
�addExpectedFailure�szTestResult.addExpectedFailurecCs|jj|�dS)z5Called when a test was expected to fail, but succeed.N)rr8)rr&rrr
�addUnexpectedSuccess�szTestResult.addUnexpectedSuccesscCs>t|j�t|j�kodkno<t|d�p<t|j�dkS)z/Tells whether or not this result was a success.rr)�lenrr�hasattrr)rrrr
�
wasSuccessful�s$zTestResult.wasSuccessfulcCs
d|_dS)z+Indicates that the tests should be aborted.TN)r)rrrr
r�szTestResult.stopcCs�|\}}}x|r"|j|�r"|j}qW||jkr:|j|�}nd}tj|||||jd�}t|j��}|j	r�t
jj�}	t
j
j�}
|	r�|	jd�s�|	d7}	|jt|	�|
r�|
jd�s�|
d7}
|jt|
�dj|�S)z>Converts a sys.exc_info()-style tuple of values into a string.N)�limit�capture_localsr-�)�_is_relevant_tb_level�tb_nextr>�_count_relevant_tb_levels�	traceback�TracebackExceptionr�list�formatrrrr.rr/r8r1r2�join)rr:r&�exctype�value�tb�lengthZtb_eZmsgLinesr5r6rrr
r9�s*






zTestResult._exc_info_to_stringcCsd|jjkS)N�
__unittest)�tb_frame�	f_globals)rrUrrr
rK�sz TestResult._is_relevant_tb_levelcCs,d}x"|r&|j|�r&|d7}|j}qW|S)Nrr)rKrL)rrUrVrrr
rM�s

z$TestResult._count_relevant_tb_levelscCs&dtj|j�|jt|j�t|j�fS)Nz!<%s run=%i errors=%i failures=%i>)rZstrclass�	__class__rrErr)rrrr
�__repr__�szTestResult.__repr__)NNN)�__name__�
__module__�__qualname__�__doc__Z_previousTestClassZ_testRunEnteredZ_moduleSetUpFailedr#r$r'r%r*r,r+r7rr;r<r?r@rBrCrDrGrr9rKrMr[rrrr
rs2

	r)r_r(rrNrJr�	functoolsrrWrr1r2�objectrrrrr
�<module>sPKń[�p�4��'__pycache__/result.cpython-36.opt-2.pycnu�[���3


 \�@sXddlZddlZddlZddlmZddlmZdZdd�ZdZ	d	Z
Gd
d�de�ZdS)�N�)�util)�wrapsTcst���fdd��}|S)Ncs$t|dd�r|j��|f|�|�S)N�failfastF)�getattr�stop)�self�args�kw)�method��'/usr/lib64/python3.6/unittest/result.py�inner
szfailfast.<locals>.inner)r)rrr)rr
rsrz
Stdout:
%sz
Stderr:
%sc@s�eZdZdZdZdZd-dd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
edd��Zedd��Zdd�Zdd�Zdd�Zdd�Zedd ��Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�ZdS).�
TestResultNFcCsbd|_g|_g|_d|_g|_g|_g|_d|_d|_d|_	d|_
d|_tj
|_tj|_d|_dS)NFr)r�failures�errors�testsRun�skipped�expectedFailures�unexpectedSuccesses�
shouldStop�buffer�	tb_locals�_stdout_buffer�_stderr_buffer�sys�stdout�_original_stdout�stderr�_original_stderr�
_mirrorOutput)r�streamZdescriptions�	verbosityrrr
�__init__&szTestResult.__init__cCsdS)Nr)rrrr
�printErrors7szTestResult.printErrorscCs |jd7_d|_|j�dS)NrF)rr �_setupStdout)r�testrrr
�	startTest:szTestResult.startTestcCs8|jr4|jdkr$tj�|_tj�|_|jt_|jt_dS)N)rr�io�StringIOrrrr)rrrr
r%@s


zTestResult._setupStdoutcCsdS)Nr)rrrr
�startTestRunHszTestResult.startTestRuncCs|j�d|_dS)NF)�_restoreStdoutr )rr&rrr
�stopTestNszTestResult.stopTestcCs�|jr�|jrltjj�}tjj�}|rF|jd�s6|d7}|jjt	|�|rl|jd�s\|d7}|j
jt|�|jt_|j
t_|jj
d�|jj�|jj
d�|jj�dS)N�
r)rr rr�getvaluer�endswithr�write�STDOUT_LINEr�STDERR_LINEr�seek�truncater)r�output�errorrrr
r+Ss$




zTestResult._restoreStdoutcCsdS)Nr)rrrr
�stopTestRunhszTestResult.stopTestRuncCs"|jj||j||�f�d|_dS)NT)r�append�_exc_info_to_stringr )rr&�errrrr
�addErrornszTestResult.addErrorcCs"|jj||j||�f�d|_dS)NT)rr8r9r )rr&r:rrr
�
addFailurevszTestResult.addFailurecCsZ|dk	rVt|dd�r|j�t|d|j�r4|j}n|j}|j||j||�f�d|_dS)NrFrT)	rr�
issubclass�failureExceptionrrr8r9r )rr&Zsubtestr:rrrr
�
addSubTest}szTestResult.addSubTestcCsdS)Nr)rr&rrr
�
addSuccess�szTestResult.addSuccesscCs|jj||f�dS)N)rr8)rr&�reasonrrr
�addSkip�szTestResult.addSkipcCs|jj||j||�f�dS)N)rr8r9)rr&r:rrr
�addExpectedFailure�szTestResult.addExpectedFailurecCs|jj|�dS)N)rr8)rr&rrr
�addUnexpectedSuccess�szTestResult.addUnexpectedSuccesscCs>t|j�t|j�kodkno<t|d�p<t|j�dkS)Nrr)�lenrr�hasattrr)rrrr
�
wasSuccessful�s$zTestResult.wasSuccessfulcCs
d|_dS)NT)r)rrrr
r�szTestResult.stopcCs�|\}}}x|r"|j|�r"|j}qW||jkr:|j|�}nd}tj|||||jd�}t|j��}|j	r�t
jj�}	t
j
j�}
|	r�|	jd�s�|	d7}	|jt|	�|
r�|
jd�s�|
d7}
|jt|
�dj|�S)N)�limit�capture_localsr-�)�_is_relevant_tb_level�tb_nextr>�_count_relevant_tb_levels�	traceback�TracebackExceptionr�list�formatrrrr.rr/r8r1r2�join)rr:r&�exctype�value�tb�lengthZtb_eZmsgLinesr5r6rrr
r9�s*






zTestResult._exc_info_to_stringcCsd|jjkS)N�
__unittest)�tb_frame�	f_globals)rrUrrr
rK�sz TestResult._is_relevant_tb_levelcCs,d}x"|r&|j|�r&|d7}|j}qW|S)Nrr)rKrL)rrUrVrrr
rM�s

z$TestResult._count_relevant_tb_levelscCs&dtj|j�|jt|j�t|j�fS)Nz!<%s run=%i errors=%i failures=%i>)rZstrclass�	__class__rrErr)rrrr
�__repr__�szTestResult.__repr__)NNN)�__name__�
__module__�__qualname__Z_previousTestClassZ_testRunEnteredZ_moduleSetUpFailedr#r$r'r%r*r,r+r7rr;r<r?r@rBrCrDrGrr9rKrMr[rrrr
rs0
	r)
r(rrNrJr�	functoolsrrWrr1r2�objectrrrrr
�<module>sPKń[��#�ĻĻ%__pycache__/case.cpython-36.opt-1.pycnu�[���3

�\dh���@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZmZmZmZmZdZe�ZdZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�ZGdd�de�Zdd�Zdd�Zdd�Zdd�Z dd�Z!dd�Z"Gdd�d�Z#dd�Z$Gd d!�d!e#�Z%Gd"d#�d#e%�Z&Gd$d%�d%e%�Z'e	j(d&d'd(g�Z)Gd)d*�d*ej*�Z+Gd+d,�d,e#�Z,Gd-d.�d.e�Z-Gd/d0�d0e-�Z.Gd1d2�d2e-�Z/dS)3zTest case implementation�N�)�result)�strclass�	safe_repr�_count_diff_all_purpose�_count_diff_hashable�_common_shorten_reprTz@
Diff is %s characters long. Set self.maxDiff to None to see it.c@seZdZdZdS)�SkipTestz�
    Raise this exception in a test to skip it.

    Usually you can use TestCase.skipTest() or one of the skipping decorators
    instead of raising this directly.
    N)�__name__�
__module__�__qualname__�__doc__�rr�%/usr/lib64/python3.6/unittest/case.pyr	sr	c@seZdZdZdS)�_ShouldStopz
    The test should stop.
    N)r
rrr
rrrrr"src@seZdZdZdS)�_UnexpectedSuccessz7
    The test was supposed to fail, but it didn't!
    N)r
rrr
rrrrr'src@s&eZdZddd�Zejddd��ZdS)	�_OutcomeNcCs4d|_||_t|d�|_d|_g|_d|_g|_dS)NF�
addSubTestT)�expecting_failurer�hasattr�result_supports_subtests�success�skipped�expectedFailure�errors)�selfrrrr�__init__.sz_Outcome.__init__Fccs�|j}d|_z�y
dVWn�tk
r.�Yn�tk
rh}z d|_|jj|t|�f�WYdd}~Xnjtk
rzYnXtj�}|j	r�||_
nd|_|jj||f�d}YnX|jr�|jr�|jj|df�Wd|jo�||_XdS)NTF)
r�KeyboardInterruptr	r�append�strr�sys�exc_inforrrr)r�	test_case�isTestZold_success�er!rrr�testPartExecutor7s*
$
z_Outcome.testPartExecutor)N)F)r
rrr�
contextlib�contextmanagerr%rrrrr-s
	rcCs|S)Nr)�objrrr�_idUsr)cs�fdd�}|S)z&
    Unconditionally skip a test.
    cs4t|t�s$tj|��fdd��}|}d|_�|_|S)Ncst���dS)N)r	)�args�kwargs)�reasonrr�skip_wrapper^sz-skip.<locals>.decorator.<locals>.skip_wrapperT)�
isinstance�type�	functools�wraps�__unittest_skip__�__unittest_skip_why__)�	test_itemr-)r,rr�	decorator\s
zskip.<locals>.decoratorr)r,r5r)r,r�skipXs
r6cCs|rt|�StS)z/
    Skip a test if the condition is true.
    )r6r))�	conditionr,rrr�skipIfhsr8cCs|st|�StS)z3
    Skip a test unless the condition is true.
    )r6r))r7r,rrr�
skipUnlesspsr9cCs
d|_|S)NT)�__unittest_expecting_failure__)r4rrrrxsrcs4t|t�r t�fdd�|D��St|t�o2t|��S)Nc3s|]}t|��VqdS)N)�_is_subtype)�.0r$)�basetyperr�	<genexpr>~sz_is_subtype.<locals>.<genexpr>)r.�tuple�allr/�
issubclass)�expectedr=r)r=rr;|s
r;c@seZdZdd�Zdd�ZdS)�_BaseTestCaseContextcCs
||_dS)N)r")rr"rrrr�sz_BaseTestCaseContext.__init__cCs |jj|j|�}|jj|��dS)N)r"�_formatMessage�msg�failureException)r�standardMsgrErrr�
_raiseFailure�sz"_BaseTestCaseContext._raiseFailureN)r
rrrrHrrrrrC�srCcCsdtjkrt|�StSdS)a
    Non-standard/downstream-only decorator for marking a specific unit test
    to be skipped when run within the %check of an rpmbuild.

    Specifically, this takes effect when WITHIN_PYTHON_RPM_BUILD is set within
    the environment, and has no effect otherwise.
    ZWITHIN_PYTHON_RPM_BUILDN)�os�environr6r))r,rrr�_skipInRpmBuild�s
rKc@seZdZddd�Zdd�ZdS)�_AssertRaisesBaseContextNcCs@tj||�||_||_|dk	r*tj|�}||_d|_d|_dS)N)	rCrrBr"�re�compile�expected_regex�obj_namerE)rrBr"rOrrrr�s
z!_AssertRaisesBaseContext.__init__cCs�z�t|j|j�s"td||jf��|rD|ddkrDtjdtd�f}|sx|jdd�|_	|rttjdt
t|��td�|S|^}}y|j|_
Wntk
r�t|�|_
YnX|�|||�WdQRXWdd}XdS)z�
        If args is empty, assertRaises/Warns is being used as a
        context manager, so check for a 'msg' kwarg and return self.
        If args is not empty, call a callable passing positional and keyword
        arguments.
        z%s() arg 1 must be %srNzcallable is None�rEz3%r is an invalid keyword argument for this function)r;rB�
_base_type�	TypeError�_base_type_str�warnings�warn�DeprecationWarning�poprE�next�iterr
rP�AttributeErrorr)r�namer*r+Zcallable_objrrr�handle�s.z_AssertRaisesBaseContext.handle)N)r
rrrr]rrrrrL�s

rLc@s(eZdZdZeZdZdd�Zdd�ZdS)�_AssertRaisesContextzCA context manager used to implement TestCase.assertRaises* methods.z-an exception type or tuple of exception typescCs|S)Nr)rrrr�	__enter__�sz_AssertRaisesContext.__enter__c
Cs�|dkrby|jj}Wntk
r2t|j�}YnX|jrP|jdj||j��ql|jdj|��n
tj|�t	||j�s|dS|j
d�|_|jdkr�dS|j}|j
t|��s�|jdj|jt|���dS)Nz{} not raised by {}z
{} not raisedFTz"{}" does not match "{}")rBr
r[rrPrH�format�	traceback�clear_framesrA�with_tracebackZ	exceptionrO�search�pattern)r�exc_type�	exc_value�tb�exc_namerOrrr�__exit__�s(


z_AssertRaisesContext.__exit__N)	r
rrr
�
BaseExceptionrRrTr_rjrrrrr^�s
r^c@s(eZdZdZeZdZdd�Zdd�ZdS)�_AssertWarnsContextzBA context manager used to implement TestCase.assertWarns* methods.z(a warning type or tuple of warning typescCsRx$tjj�D]}t|dd�ri|_qWtjdd�|_|jj�|_tj	d|j
�|S)N�__warningregistry__T)�record�always)r �modules�values�getattrrmrU�catch_warnings�warnings_managerr_�simplefilterrB)r�vrrrr_�s
z_AssertWarnsContext.__enter__c
Cs|jj|||�|dk	rdSy|jj}Wntk
rFt|j�}YnXd}xd|jD]Z}|j}t||j�slqT|dkrx|}|j	dk	r�|j	j
t|��r�qT||_|j|_|j
|_
dSW|dk	r�|jdj|j	jt|���|jr�|jdj||j��n|jdj|��dS)Nz"{}" does not match "{}"z{} not triggered by {}z{} not triggered)rtrjrBr
r[rrU�messager.rOrdZwarning�filename�linenorHr`rerP)rrfrgrhriZfirst_matching�m�wrrrrj�s8

z_AssertWarnsContext.__exit__N)	r
rrr
�WarningrRrTr_rjrrrrrl�s
rl�_LoggingWatcher�records�outputc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_CapturingHandlerzM
    A logging handler capturing all (raw and formatted) logging output.
    cCstjj|�tgg�|_dS)N)�logging�Handlerrr}�watcher)rrrrr,sz_CapturingHandler.__init__cCsdS)Nr)rrrr�flush0sz_CapturingHandler.flushcCs*|jjj|�|j|�}|jjj|�dS)N)r�r~rr`r)rrnrErrr�emit3s
z_CapturingHandler.emitN)r
rrr
rr�r�rrrrr�'sr�c@s,eZdZdZdZdd�Zdd�Zdd�Zd	S)
�_AssertLogsContextz:A context manager used to implement TestCase.assertLogs().z"%(levelname)s:%(name)s:%(message)scCs:tj||�||_|r(tjj||�|_ntj|_d|_dS)N)	rCr�logger_namer�Z_nameToLevel�get�level�INFOrE)rr"r�r�rrrr?sz_AssertLogsContext.__init__cCs�t|jtj�r|j}|_ntj|j�}|_tj|j�}t�}|j	|�|j
|_
|jdd�|_|j
|_|j|_|g|_|j|j
�d|_|j
S)NF)r.r�r�ZLogger�loggerZ	getLoggerZ	Formatter�LOGGING_FORMATr�ZsetFormatterr��handlers�old_handlersr��	old_level�	propagate�
old_propagate�setLevel)rr�Z	formatterZhandlerrrrr_Hs
z_AssertLogsContext.__enter__cCs`|j|j_|j|j_|jj|j�|dk	r.dSt|jj	�dkr\|j
djtj
|j�|jj��dS)NFrz-no logs of level {} or higher triggered on {})r�r�r�r�r�r�r��lenr�r~rHr`r�ZgetLevelNamer�r\)rrfrgrhrrrrjYs

z_AssertLogsContext.__exit__N)r
rrr
r�rr_rjrrrrr�:s
	r�c@s�eZdZdZeZdZd�Zd�ZdZ	d�d	d
�Z
dd�Zd
d�Zdd�Z
dd�Zedd��Zedd��Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zejefd)d*��Zd+d,�Zd-d.�Z d/d0�Z!d�d2d3�Z"d4d5�Z#d6d7�Z$d8d9�Z%d:d;�Z&d�d<d=�Z'd�d>d?�Z(d�d@dA�Z)dBdC�Z*dDdE�Z+dFdG�Z,d�dHdI�Z-dJdK�Z.d�dLdM�Z/d�dNdO�Z0d�dPdQ�Z1d�dRdS�Z2d�dTdU�Z3d�dVdW�Z4dXdY�Z5d�dZd[�Z6d�d\d]�Z7d�d^d_�Z8d�d`da�Z9d�dbdc�Z:d�ddde�Z;d�dfdg�Z<d�dhdi�Z=d�djdk�Z>d�dldm�Z?d�dndo�Z@d�dpdq�ZAd�drds�ZBd�dtdu�ZCd�dvdw�ZDd�dxdy�ZEd�dzd{�ZFd�d|d}�ZGd�d~d�ZHd�d��ZId�d��ZJd�d�d��ZKd�d�d��ZLd�d��ZMeMe0�ZNZOeMe1�ZPZQeMe2�ZRZSeMe3�ZTZUeMe)�ZVZWeMe+�ZXeMe(�ZYeMeI�ZZeMeK�Z[eMeL�Z\d1S)��TestCaseaWA class whose instances are single test cases.

    By default, the test code itself should be placed in a method named
    'runTest'.

    If the fixture may be used for many test cases, create as
    many test methods as are needed. When instantiating such a TestCase
    subclass, specify in the constructor arguments the name of the test method
    that the instance is to execute.

    Test authors should subclass TestCase for their own tests. Construction
    and deconstruction of the test's environment ('fixture') can be
    implemented by overriding the 'setUp' and 'tearDown' methods respectively.

    If it is necessary to override the __init__ method, the base class
    __init__ method must always be called. It is important that subclasses
    should not change the signature of their __init__ method, since instances
    of the classes are instantiated automatically by parts of the framework
    in order to be run.

    When subclassing TestCase, you can set these attributes:
    * failureException: determines which exception will be raised when
        the instance's assertion methods fail; test methods raising this
        exception will be deemed to have 'failed' rather than 'errored'.
    * longMessage: determines whether long messages (including repr of
        objects used in assert methods) will be printed on failure in *addition*
        to any explicit message passed.
    * maxDiff: sets the maximum length of a diff in failure messages
        by assert methods using difflib. It is looked up as an instance
        attribute so can be configured by individual tests if required.
    T�P���F�runTestcCs�||_d|_d|_yt||�}Wn.tk
rN|dkrJtd|j|f��Yn
X|j|_g|_d|_	i|_
|jtd�|jt
d�|jtd�|jtd�|jtd�|jtd	�dS)
z�Create an instance of the class that will use the named test
           method when executed. Raises a ValueError if the instance does
           not have a method with the specified name.
        NzNo testr�zno such test method in %s: %s�assertDictEqual�assertListEqual�assertTupleEqual�assertSetEqual�assertMultiLineEqual)�_testMethodName�_outcome�_testMethodDocrrr[�
ValueError�	__class__r
�	_cleanups�_subtest�_type_equality_funcs�addTypeEqualityFunc�dict�listr?�set�	frozensetr)rZ
methodName�
testMethodrrrr�s&zTestCase.__init__cCs||j|<dS)a[Add a type specific assertEqual style function to compare a type.

        This method is for use by TestCase subclasses that need to register
        their own type equality functions to provide nicer error messages.

        Args:
            typeobj: The data type to call this function on when both values
                    are of the same type in assertEqual().
            function: The callable taking two arguments and an optional
                    msg= argument that raises self.failureException with a
                    useful error message when the two arguments are not equal.
        N)r�)rZtypeobj�functionrrrr��s
zTestCase.addTypeEqualityFunccOs|jj|||f�dS)aAdd a function, with arguments, to be called when the test is
        completed. Functions added are called on a LIFO basis and are
        called after tearDown on test failure or success.

        Cleanup items are called even if setUp fails (unlike tearDown).N)r�r)rr�r*r+rrr�
addCleanup�szTestCase.addCleanupcCsdS)zAHook method for setting up the test fixture before exercising it.Nr)rrrr�setUp�szTestCase.setUpcCsdS)zAHook method for deconstructing the test fixture after testing it.Nr)rrrr�tearDown�szTestCase.tearDowncCsdS)zKHook method for setting up class fixture before running tests in the class.Nr)�clsrrr�
setUpClass�szTestCase.setUpClasscCsdS)zVHook method for deconstructing the class fixture after running all tests in the class.Nr)r�rrr�
tearDownClass�szTestCase.tearDownClasscCsdS)Nrr)rrrr�countTestCases�szTestCase.countTestCasescCstj�S)N)rZ
TestResult)rrrr�defaultTestResult�szTestCase.defaultTestResultcCs |j}|r|jd�dj�pdS)z�Returns a one-line description of the test, or None if no
        description has been provided.

        The default implementation of this method returns the first line of
        the specified test method's docstring.
        �
rN)r��split�strip)r�docrrr�shortDescription�szTestCase.shortDescriptioncCsdt|j�|jfS)Nz%s.%s)rr�r�)rrrr�id�szTestCase.idcCs t|�t|�k	rtS|j|jkS)N)r/�NotImplementedr�)r�otherrrr�__eq__�szTestCase.__eq__cCstt|�|jf�S)N)�hashr/r�)rrrr�__hash__�szTestCase.__hash__cCsd|jt|j�fS)Nz%s (%s))r�rr�)rrrr�__str__�szTestCase.__str__cCsdt|j�|jfS)Nz<%s testMethod=%s>)rr�r�)rrrr�__repr__�szTestCase.__repr__cCs<t|dd�}|dk	r |||�ntjdtd�|j|�dS)N�addSkipz4TestResult has no addSkip method, skips not reportedr�)rrrUrV�RuntimeWarning�
addSuccess)rrr"r,r�rrr�_addSkipszTestCase._addSkipcks�|jdks|jjrdVdS|j}|dkr8tj|�}n|jj|�}t|||�|_zX|jj|jdd��dVWdQRX|jj	s�|jj
}|dk	r�|jr�t�n|jj
r�t�Wd||_XdS)aPReturn a context manager that will return the enclosed block
        of code in a subtest identified by the optional message and
        keyword parameters.  A failure in the subtest marks the test
        case as failed but resumes execution at the end of the enclosed
        block, allowing further test code to be executed.
        NT)r#)r�rr��collections�ChainMap�params�	new_child�_SubTestr%rrZfailfastrr)rrEr��parentZ
params_maprrrr�subTest	s$zTestCase.subTestcCsdx^|D]V\}}t|t�r*|j|j||�q|dk	rt|d|j�rP|j||�q|j||�qWdS)Nr)r.r�rr"rArF�
addFailureZaddError)rrr�testr!rrr�_feedErrorsToResult(s
zTestCase._feedErrorsToResultcCsDy
|j}Wn*tk
r4tjdt�|j|�YnX|||�dS)Nz@TestResult has no addExpectedFailure method, reporting as passes)�addExpectedFailurer[rUrVr�r�)rrr!r�rrr�_addExpectedFailure2s
zTestCase._addExpectedFailurecCshy
|j}WnPtk
rZtjdt�y
td�Wn$tk
rT|j|tj��YnXYn
X||�dS)NzCTestResult has no addUnexpectedSuccess method, reporting as failure)	�addUnexpectedSuccessr[rUrVr�rr�r r!)rrr�rrr�_addUnexpectedSuccess<s

zTestCase._addUnexpectedSuccessNc
(Cs|}|dkr.|j�}t|dd�}|dk	r.|�|j|�t||j�}t|jdd�s^t|dd�r�z,t|jdd�pxt|dd�}|j|||�Wd|j|�XdSt|dd�}t|dd�}|p�|}t|�}	z�|	|_|	j	|��|j
�WdQRX|	j�r<||	_|	j	|dd��|�WdQRXd|	_|	j	|��|j
�WdQRX|j�x"|	jD]\}
}|j||
|��qLW|j||	j�|	j�r�|�r�|	j�r�|j||	j�n
|j|�n
|j|�|S|j|�|dk�r�t|d	d�}|dk	�r�|�|	jj�d|	_d|_XdS)
N�startTestRunr2Fr3�r:T)r#�stopTestRun)r�rrZ	startTestr�r�r�ZstopTestrr�r%r�rrr��
doCleanupsrr�rrr�r�r��clear)
rrZorig_resultr�r�Zskip_whyZexpecting_failure_methodZexpecting_failure_classr�outcomer�r,r�rrr�runKsh





zTestCase.runc
CsN|jp
t�}x:|jrF|jj�\}}}|j|��|||�WdQRXqW|jS)zNExecute all cleanup functions. Normally called for you after
        tearDown.N)r�rr�rXr%r)rr�r�r*r+rrrr��szTestCase.doCleanupscOs|j||�S)N)r�)rr*�kwdsrrr�__call__�szTestCase.__call__cCsJ|j�t||j��|j�x&|jrD|jjd�\}}}|||�q WdS)z6Run the test without collecting errors in a TestResultrN���)r�rrr�r�r�rX)rr�r*r+rrr�debug�szTestCase.debugcCst|��dS)zSkip this test.N)r	)rr,rrr�skipTest�szTestCase.skipTestcCs|j|��dS)z)Fail immediately, with the given message.N)rF)rrErrr�fail�sz
TestCase.failcCs&|r"|j|dt|��}|j|��dS)z#Check that the expression is false.z%s is not falseN)rDrrF)r�exprrErrr�assertFalse�szTestCase.assertFalsecCs&|s"|j|dt|��}|j|��dS)z"Check that the expression is true.z%s is not trueN)rDrrF)rr�rErrr�
assertTrue�szTestCase.assertTruecCsP|js|p|S|dkr|Syd||fStk
rJdt|�t|�fSXdS)a�Honour the longMessage attribute when generating failure messages.
        If longMessage is False this means:
        * Use only an explicit message if it is provided
        * Otherwise use the standard message for the assert

        If longMessage is True:
        * Use the standard message
        * If an explicit message is provided, plus ' : ' and the explicit message
        Nz%s : %s)�longMessage�UnicodeDecodeErrorr)rrErGrrrrD�s
zTestCase._formatMessagec
Os$t||�}z|jd||�Sd}XdS)a=Fail unless an exception of class expected_exception is raised
           by the callable when invoked with specified positional and
           keyword arguments. If a different type of exception is
           raised, it will not be caught, and the test case will be
           deemed to have suffered an error, exactly as for an
           unexpected exception.

           If called with the callable and arguments omitted, will return a
           context object used like this::

                with self.assertRaises(SomeException):
                    do_something()

           An optional keyword argument 'msg' can be provided when assertRaises
           is used as a context object.

           The context manager keeps a reference to the exception as
           the 'exception' attribute. This allows you to inspect the
           exception after the assertion::

               with self.assertRaises(SomeException) as cm:
                   do_something()
               the_exception = cm.exception
               self.assertEqual(the_exception.error_code, 3)
        �assertRaisesN)r^r])r�expected_exceptionr*r+�contextrrrr��s
zTestCase.assertRaisescOst||�}|jd||�S)a�Fail unless a warning of class warnClass is triggered
           by the callable when invoked with specified positional and
           keyword arguments.  If a different type of warning is
           triggered, it will not be handled: depending on the other
           warning filtering rules in effect, it might be silenced, printed
           out, or raised as an exception.

           If called with the callable and arguments omitted, will return a
           context object used like this::

                with self.assertWarns(SomeWarning):
                    do_something()

           An optional keyword argument 'msg' can be provided when assertWarns
           is used as a context object.

           The context manager keeps a reference to the first matching
           warning as the 'warning' attribute; similarly, the 'filename'
           and 'lineno' attributes give you information about the line
           of Python code from which the warning was triggered.
           This allows you to inspect the warning after the assertion::

               with self.assertWarns(SomeWarning) as cm:
                   do_something()
               the_warning = cm.warning
               self.assertEqual(the_warning.some_attribute, 147)
        �assertWarns)rlr])r�expected_warningr*r+r�rrrr��s
zTestCase.assertWarnscCst|||�S)a�Fail unless a log message of level *level* or higher is emitted
        on *logger_name* or its children.  If omitted, *level* defaults to
        INFO and *logger* defaults to the root logger.

        This method must be used as a context manager, and will yield
        a recording object with two attributes: `output` and `records`.
        At the end of the context manager, the `output` attribute will
        be a list of the matching formatted log messages and the
        `records` attribute will be a list of the corresponding LogRecord
        objects.

        Example::

            with self.assertLogs('foo', level='INFO') as cm:
                logging.getLogger('foo').info('first message')
                logging.getLogger('foo.bar').error('second message')
            self.assertEqual(cm.output, ['INFO:foo:first message',
                                         'ERROR:foo.bar:second message'])
        )r�)rr�r�rrr�
assertLogsszTestCase.assertLogscCsFt|�t|�kr@|jjt|��}|dk	r@t|t�r<t||�}|S|jS)aGet a detailed comparison function for the types of the two args.

        Returns: A callable accepting (first, second, msg=None) that will
        raise a failure exception if first != second with a useful human
        readable error message for those types.
        N)r/r�r�r.rrr�_baseAssertEqual)r�first�secondZasserterrrr�_getAssertEqualityFunc(s

zTestCase._getAssertEqualityFunccCs0||ks,dt||�}|j||�}|j|��dS)z:The default assertEqual implementation, not type specific.z%s != %sN)rrDrF)rr�r�rErGrrrr�BszTestCase._baseAssertEqualcCs|j||�}||||d�dS)z[Fail if the two objects are unequal as determined by the '=='
           operator.
        )rEN)r�)rr�r�rEZassertion_funcrrr�assertEqualIszTestCase.assertEqualcCs2||ks.|j|dt|�t|�f�}|j|��dS)zYFail if the two objects are equal as determined by the '!='
           operator.
        z%s == %sN)rDrrF)rr�r�rErrr�assertNotEqualPszTestCase.assertNotEqualcCs�||krdS|dk	r$|dk	r$td��|dk	r\t||�|kr@dSdt|�t|�t|�f}n<|dkrhd}tt||�|�dkr�dSdt|�t|�|f}|j||�}|j|��dS)a'Fail if the two objects are unequal as determined by their
           difference rounded to the given number of decimal places
           (default 7) and comparing to zero, or by comparing that the
           difference between the two objects is more than the given
           delta.

           Note that decimal places (from zero) are usually not the same
           as significant digits (measured from the most significant digit).

           If the two objects compare equal then they will automatically
           compare almost equal.
        Nz specify delta or places not bothz%s != %s within %s delta�rz%s != %s within %r places)rS�absr�roundrDrF)rr�r��placesrE�deltarGrrr�assertAlmostEqualYs&zTestCase.assertAlmostEqualcCs�|dk	r|dk	rtd��|dk	rZ||kr>t||�|kr>dSdt|�t|�t|�f}nF|dkrfd}||kr�tt||�|�dkr�dSdt|�t|�|f}|j||�}|j|��dS)a�Fail if the two objects are equal as determined by their
           difference rounded to the given number of decimal places
           (default 7) and comparing to zero, or by comparing that the
           difference between the two objects is less than the given delta.

           Note that decimal places (from zero) are usually not the same
           as significant digits (measured from the most significant digit).

           Objects that are equal automatically fail.
        Nz specify delta or places not bothz%s == %s within %s deltar�rz%s == %s within %r places)rSr�rr�rDrF)rr�r�r�rEr�rGrrr�assertNotAlmostEqual�s" zTestCase.assertNotAlmostEqualc'Cs�|dk	rP|j}t||�s.|jd|t|�f��t||�sT|jd|t|�f��nd}d}yt|�}Wn ttfk
r�d|}YnX|dkr�yt|�}Wn ttfk
r�d|}YnX|dk�r�||kr�dSd|j�ft||�}x�t	t
||��D]�}	y||	}
Wn.tttfk
�r8|d|	|f7}PYnXy||	}Wn.tttfk
�rt|d	|	|f7}PYnX|
|kr�|d
|	ft|
|�7}Pq�W||k�r�|dk�r�t|�t|�k�r�dS||k�r0|d|||f7}y|d|t||�f7}Wn,tttfk
�r,|d
||f7}YnXnh||k�r�|d|||f7}y|d|t||�f7}Wn,tttfk
�r�|d||f7}YnX|}ddj
tjtj|�j�tj|�j���}
|j||
�}|j||�}|j|�dS)aAAn equality assertion for ordered sequences (like lists and tuples).

        For the purposes of this function, a valid ordered sequence type is one
        which can be indexed, has a length, and has an equality operator.

        Args:
            seq1: The first sequence to compare.
            seq2: The second sequence to compare.
            seq_type: The expected datatype of the sequences, or None if no
                    datatype should be enforced.
            msg: Optional message to use on failure instead of a list of
                    differences.
        NzFirst sequence is not a %s: %szSecond sequence is not a %s: %sZsequencez(First %s has no length.    Non-sequence?z)Second %s has no length.    Non-sequence?z%ss differ: %s != %s
z(
Unable to index element %d of first %s
z)
Unable to index element %d of second %s
z#
First differing element %d:
%s
%s
z+
First %s contains %d additional elements.
zFirst extra element %d:
%s
z'Unable to index element %d of first %s
z,
Second %s contains %d additional elements.
z(Unable to index element %d of second %s
r�)r
r.rFrr�rS�NotImplementedError�
capitalizer�range�min�
IndexErrorr/�join�difflib�ndiff�pprint�pformat�
splitlines�_truncateMessagerDr�)rZseq1Zseq2rE�seq_typeZ
seq_type_nameZ	differingZlen1Zlen2�iZitem1Zitem2rG�diffMsgrrr�assertSequenceEqual�s�




zTestCase.assertSequenceEqualcCs2|j}|dkst|�|kr"||S|tt|�S)N)�maxDiffr��DIFF_OMITTED)rrw�diffZmax_diffrrrrszTestCase._truncateMessagecCs|j|||td�dS)aA list-specific equality assertion.

        Args:
            list1: The first list to compare.
            list2: The second list to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.

        )rN)r	r�)rZlist1Zlist2rErrrr�s
zTestCase.assertListEqualcCs|j|||td�dS)aA tuple-specific equality assertion.

        Args:
            tuple1: The first tuple to compare.
            tuple2: The second tuple to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.
        )rN)r	r?)rZtuple1Ztuple2rErrrr�s	zTestCase.assertTupleEqualc
 Cshy|j|�}Wn^tk
r>}z|jd|�WYdd}~Xn0tk
rl}z|jd|�WYdd}~XnXy|j|�}Wn^tk
r�}z|jd|�WYdd}~Xn0tk
r�}z|jd|�WYdd}~XnX|p�|s�dSg}|�r|jd�x|D]}|jt|���qW|�rH|jd�x|D]}|jt|���q0Wdj|�}	|j|j||	��dS)a�A set-specific equality assertion.

        Args:
            set1: The first set to compare.
            set2: The second set to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.

        assertSetEqual uses ducktyping to support different types of sets, and
        is optimized for sets specifically (parameters must support a
        difference method).
        z/invalid type when attempting set difference: %sNz2first argument does not support set difference: %sz3second argument does not support set difference: %sz*Items in the first set but not the second:z*Items in the second set but not the first:r�)�
differencerSr�r[r�reprr�rD)
rZset1Zset2rEZdifference1r$Zdifference2�lines�itemrGrrrr�"s2
  




zTestCase.assertSetEqualcCs2||kr.dt|�t|�f}|j|j||��dS)zDJust like self.assertTrue(a in b), but with a nicer default message.z%s not found in %sN)rr�rD)r�member�	containerrErGrrr�assertInMszTestCase.assertIncCs2||kr.dt|�t|�f}|j|j||��dS)zHJust like self.assertTrue(a not in b), but with a nicer default message.z%s unexpectedly found in %sN)rr�rD)rrrrErGrrr�assertNotInTszTestCase.assertNotIncCs2||k	r.dt|�t|�f}|j|j||��dS)zDJust like self.assertTrue(a is b), but with a nicer default message.z%s is not %sN)rr�rD)r�expr1�expr2rErGrrr�assertIs[szTestCase.assertIscCs,||kr(dt|�f}|j|j||��dS)zHJust like self.assertTrue(a is not b), but with a nicer default message.zunexpectedly identical: %sN)rr�rD)rrrrErGrrr�assertIsNotbszTestCase.assertIsNotcCs~|j|td�|j|td�||krzdt||�}ddjtjtj|�j�tj|�j���}|j	||�}|j
|j||��dS)Nz"First argument is not a dictionaryz#Second argument is not a dictionaryz%s != %sr�)�assertIsInstancer�rr�rrrrrrr�rD)rZd1Zd2rErGrrrrr�hs
zTestCase.assertDictEqualc	Cs�tjdt�g}g}xX|j�D]L\}}||kr:|j|�q|||kr|jdt|�t|�t||�f�qW|pt|szdSd}|r�ddjdd�|D��}|r�|r�|d	7}|d
dj|�7}|j|j||��dS)z2Checks whether dictionary is a superset of subset.z&assertDictContainsSubset is deprecatedz%s, expected: %s, actual: %sNr�zMissing: %s�,css|]}t|�VqdS)N)r)r<rzrrrr>�sz4TestCase.assertDictContainsSubset.<locals>.<genexpr>z; zMismatched values: %s)	rUrVrW�itemsrrr�r�rD)	rZsubsetZ
dictionaryrEZmissingZ
mismatched�key�valuerGrrr�assertDictContainsSubsetts,z!TestCase.assertDictContainsSubsetc
Cs�t|�t|�}}ytj|�}tj|�}Wntk
rHt||�}YnX||krVdSt||�}|r�d}dd�|D�}dj|�}	|j||	�}|j||�}|j	|�dS)a�An unordered sequence comparison asserting that the same elements,
        regardless of order.  If the same element occurs more than once,
        it verifies that the elements occur the same number of times.

            self.assertEqual(Counter(list(first)),
                             Counter(list(second)))

         Example:
            - [0, 1, 1] and [1, 0, 1] compare equal.
            - [0, 0, 1] and [0, 1] compare unequal.

        NzElement counts were not equal:
cSsg|]}d|�qS)z First has %d, Second has %d:  %rr)r<rrrr�
<listcomp>�sz-TestCase.assertCountEqual.<locals>.<listcomp>r�)
r�r��CounterrSrrr�rrDr�)
rr�r�rEZ	first_seqZ
second_seqZdifferencesrGrrrrr�assertCountEqual�s 



zTestCase.assertCountEqualcCs�|j|td�|j|td�||kr�t|�|jks@t|�|jkrN|j|||�|jdd�}|jdd�}t|�dkr�|jd�|kr�|dg}|dg}dt||�}dd	jt	j
||��}|j||�}|j|j
||��d
S)z-Assert that two multi-line strings are equal.zFirst argument is not a stringzSecond argument is not a stringT)�keependsrz
r�z%s != %sr�N)rrr��_diffThresholdr�rr�rr�rrrr�rD)rr�r�rEZ
firstlinesZsecondlinesrGrrrrr��s

zTestCase.assertMultiLineEqualcCs2||ks.dt|�t|�f}|j|j||��dS)zCJust like self.assertTrue(a < b), but with a nicer default message.z%s not less than %sN)rr�rD)r�a�brErGrrr�
assertLess�szTestCase.assertLesscCs2||ks.dt|�t|�f}|j|j||��dS)zDJust like self.assertTrue(a <= b), but with a nicer default message.z%s not less than or equal to %sN)rr�rD)rr$r%rErGrrr�assertLessEqual�szTestCase.assertLessEqualcCs2||ks.dt|�t|�f}|j|j||��dS)zCJust like self.assertTrue(a > b), but with a nicer default message.z%s not greater than %sN)rr�rD)rr$r%rErGrrr�
assertGreater�szTestCase.assertGreatercCs2||ks.dt|�t|�f}|j|j||��dS)zDJust like self.assertTrue(a >= b), but with a nicer default message.z"%s not greater than or equal to %sN)rr�rD)rr$r%rErGrrr�assertGreaterEqual�szTestCase.assertGreaterEqualcCs,|dk	r(dt|�f}|j|j||��dS)zCSame as self.assertTrue(obj is None), with a nicer default message.Nz%s is not None)rr�rD)rr(rErGrrr�assertIsNone�szTestCase.assertIsNonecCs"|dkrd}|j|j||��dS)z(Included for symmetry with assertIsNone.Nzunexpectedly None)r�rD)rr(rErGrrr�assertIsNotNone�szTestCase.assertIsNotNonecCs0t||�s,dt|�|f}|j|j||��dS)zTSame as self.assertTrue(isinstance(obj, cls)), with a nicer
        default message.z%s is not an instance of %rN)r.rr�rD)rr(r�rErGrrrr�s
zTestCase.assertIsInstancecCs0t||�r,dt|�|f}|j|j||��dS)z,Included for symmetry with assertIsInstance.z%s is an instance of %rN)r.rr�rD)rr(r�rErGrrr�assertNotIsInstance�s
zTestCase.assertNotIsInstancecOst|||�}|jd||�S)aAsserts that the message in a raised exception matches a regex.

        Args:
            expected_exception: Exception class expected to be raised.
            expected_regex: Regex (re pattern object or string) expected
                    to be found in error message.
            args: Function to be called and extra positional args.
            kwargs: Extra kwargs.
            msg: Optional message used in case of failure. Can only be used
                    when assertRaisesRegex is used as a context manager.
        �assertRaisesRegex)r^r])rr�rOr*r+r�rrrr-�s
zTestCase.assertRaisesRegexcOst|||�}|jd||�S)a�Asserts that the message in a triggered warning matches a regexp.
        Basic functioning is similar to assertWarns() with the addition
        that only warnings whose messages also match the regular expression
        are considered successful matches.

        Args:
            expected_warning: Warning class expected to be triggered.
            expected_regex: Regex (re pattern object or string) expected
                    to be found in error message.
            args: Function to be called and extra positional args.
            kwargs: Extra kwargs.
            msg: Optional message used in case of failure. Can only be used
                    when assertWarnsRegex is used as a context manager.
        �assertWarnsRegex)rlr])rr�rOr*r+r�rrrr.szTestCase.assertWarnsRegexcCsJt|ttf�rtj|�}|j|�sFd|j|f}|j||�}|j|��dS)z=Fail the test unless the text matches the regular expression.z&Regex didn't match: %r not found in %rN)	r.r�bytesrMrNrdrerDrF)r�textrOrErGrrr�assertRegexs

zTestCase.assertRegexcCs`t|ttf�rtj|�}|j|�}|r\d||j�|j��|j|f}|j	||�}|j
|��dS)z9Fail the test if the text matches the regular expression.z"Regex matched: %r matches %r in %rN)r.rr/rMrNrd�start�endrerDrF)rr0Zunexpected_regexrE�matchrGrrr�assertNotRegex&s

zTestCase.assertNotRegexcs�fdd�}|S)Ncs tjdj�j�td��||�S)NzPlease use {0} instead.r�)rUrVr`r
rW)r*r+)�
original_funcrr�deprecated_func6s
z,TestCase._deprecate.<locals>.deprecated_funcr)r6r7r)r6r�
_deprecate5szTestCase._deprecatei�i)r�)N)N)N)N)NN)N)N)N)NNN)NNN)NN)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)]r
rrr
�AssertionErrorrFr�r
r#Z_classSetupFailedrr�r�r�r��classmethodr�r�r�r�r�r�r�r�r�r�r�r&r'�_subtest_msg_sentinelr�r�r�r�r�r�r�r�r�r�r�r�rDr�r�r�r�r�r�r�r�r�r	rr�r�r�rrrrr�rr!r�r&r'r(r)r*r+rr,r-r.r1r5r8ZfailUnlessEqualZassertEqualsZfailIfEqualZassertNotEqualsZfailUnlessAlmostEqualZassertAlmostEqualsZfailIfAlmostEqualZassertNotAlmostEqualsZ
failUnlessZassert_ZfailUnlessRaisesZfailIfZassertRaisesRegexpZassertRegexpMatchesZassertNotRegexpMatchesrrrrr�fs�
 	


E
	


!



	
'
 
c


+






!










	r�csjeZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
�ZS)�FunctionTestCaseaIA test case that wraps a test function.

    This is useful for slipping pre-existing test functions into the
    unittest framework. Optionally, set-up and tidy-up functions can be
    supplied. As with TestCase, the tidy-up ('tearDown') function will
    always be called if the set-up ('setUp') function ran successfully.
    Ncs*tt|�j�||_||_||_||_dS)N)�superr<r�
_setUpFunc�
_tearDownFunc�	_testFunc�_description)rZtestFuncr�r�Zdescription)r�rrrTs
zFunctionTestCase.__init__cCs|jdk	r|j�dS)N)r>)rrrrr�[s
zFunctionTestCase.setUpcCs|jdk	r|j�dS)N)r?)rrrrr�_s
zFunctionTestCase.tearDowncCs|j�dS)N)r@)rrrrr�cszFunctionTestCase.runTestcCs|jjS)N)r@r
)rrrrr�fszFunctionTestCase.idcCs@t||j�stS|j|jko>|j|jko>|j|jko>|j|jkS)N)r.r�r�r>r?r@rA)rr�rrrr�iszFunctionTestCase.__eq__cCstt|�|j|j|j|jf�S)N)r�r/r>r?r@rA)rrrrr�rszFunctionTestCase.__hash__cCsdt|j�|jjfS)Nz%s (%s))rr�r@r
)rrrrr�vs
zFunctionTestCase.__str__cCsdt|j�|jfS)Nz<%s tec=%s>)rr�r@)rrrrr�zs
zFunctionTestCase.__repr__cCs2|jdk	r|jS|jj}|r.|jd�dj�p0dS)Nr�r)rAr@r
r�r�)rr�rrrr�~s
z!FunctionTestCase.shortDescription)NNN)r
rrr
rr�r�r�r�r�r�r�r�r��
__classcell__rr)r�rr<Ks	r<csDeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z�Z	S)
r�cs(t�j�||_||_||_|j|_dS)N)r=r�_messager"r�rF)rr"rwr�)r�rrr�s

z_SubTest.__init__cCstd��dS)Nzsubtests cannot be run directly)r�)rrrrr��sz_SubTest.runTestcCsbg}|jtk	r |jdj|j��|jrTdjdd�t|jj��D��}|jdj|��dj|�p`dS)Nz[{}]z, css|]\}}dj||�VqdS)z{}={!r}N)r`)r<�krvrrrr>�sz+_SubTest._subDescription.<locals>.<genexpr>z({})� z(<subtest>))rCr;rr`r�r��sortedr)r�partsZparams_descrrr�_subDescription�s
z_SubTest._subDescriptioncCsdj|jj�|j��S)Nz{} {})r`r"r�rH)rrrrr��sz_SubTest.idcCs
|jj�S)zlReturns a one-line description of the subtest, or None if no
        description has been provided.
        )r"r�)rrrrr��sz_SubTest.shortDescriptioncCsdj|j|j��S)Nz{} {})r`r"rH)rrrrr��sz_SubTest.__str__)
r
rrrr�rHr�r�r�rBrr)r�rr��sr�)0r
r r0rrIr�rrMrUr�r&rar�r�utilrrrrrZ
__unittest�objectr;r�	Exceptionr	rrrr)r6r8r9rr;rCrKrLr^rl�
namedtupler}r�r�r�r�r<r�rrrr�<module>sZ(
/%5
,l:PKń[&�%���__pycache__/util.cpython-36.pycnu�[���3


 \9�@s�dZddlmZmZddlmZdZdZdZdZ	dZ
dZee	eeee
Zedks\t
�dd	�Zd
d�Zd d
d�Zdd�Zdd�Zdd�Zdd�Zedd�Zdd�Zdd�Zdd�ZdS)!zVarious utility functions.�)�
namedtuple�OrderedDict)�commonprefixT�P��cCsBt|�||}|tkr>d|d|�||t|�|d�f}|S)Nz%s[%d chars]%s)�len�_PLACEHOLDER_LEN)�s�	prefixlenZ	suffixlen�skip�r
�%/usr/lib64/python3.6/unittest/util.py�_shortens&rcs�ttt|��}ttt|��}|tkr(|St|��t���t|�tt}|t	kr�ttt	|�tkspt
�t�t|��t��fdd�|D��St�tt	��t��fdd�|D��S)Nc3s|]}�|�d�VqdS)Nr
)�.0r
)�prefixrr
r�	<genexpr>'sz'_common_shorten_repr.<locals>.<genexpr>c3s&|]}�t|�d�tt�VqdS)N)r�
_MIN_DIFF_LEN�_MIN_END_LEN)rr
)rrr
rr*s)�tuple�map�	safe_repr�maxr�_MAX_LENGTHr�_MIN_BEGIN_LENr	�_MIN_COMMON_LEN�AssertionErrorr)�args�maxlenZ
common_lenr
)rrr�_common_shorten_reprs 
rFcCsRyt|�}Wntk
r*tj|�}YnX|s>t|�tkrB|S|dt�dS)Nz [truncated]...)�repr�	Exception�object�__repr__rr)�objZshort�resultr
r
rr-srcCsd|j|jfS)Nz%s.%s)�
__module__�__qualname__)�clsr
r
r�strclass6sr)cCs*d}}g}g}�xy�||}||}||kr\|j|�|d7}x�|||krX|d7}qBWn�||kr�|j|�|d7}xf|||kr�|d7}qxWnL|d7}zx|||kr�|d7}q�WWd|d7}x|||kr�|d7}q�WXWqtk
�r|j||d��|j||d��PYqXqW||fS)arFinds elements in only one or the other of two, sorted input lists.

    Returns a two-element tuple of lists.    The first list contains those
    elements in the "expected" list but not in the "actual" list, and the
    second contains those elements in the "actual" list but not in the
    "expected" list.    Duplicate elements in either input list are ignored.
    r�N)�append�
IndexError�extend)�expected�actual�i�j�missingZ
unexpected�e�ar
r
r�sorted_list_difference9s:

r5cCsLg}x>|rB|j�}y|j|�Wqtk
r>|j|�YqXqW||fS)z�Same behavior as sorted_list_difference but
    for lists of unorderable items (like dicts).

    As it does a linear search per item (remove) it
    has O(n*n) performance.)�pop�remove�
ValueErrorr+)r.r/r2�itemr
r
r�unorderable_list_differencebsr:cCs||k||kS)z.Return -1 if x < y, 0 if x == y and 1 if x > yr
)�x�yr
r
r�
three_way_cmpssr=ZMismatchzactual expected valuecCsDt|�t|�}}t|�t|�}}t�}g}x�t|�D]�\}}	|	|krJq8d}
}x.t||�D] }|||	kr^|
d7}
|||<q^Wx,t|�D] \}}
|
|	kr�|d7}|||<q�W|
|kr8t|
||	�}|j|�q8Wxlt|�D]`\}}	|	|kr�q�d}x2t||�D]$}|||	k�r�|d7}|||<�q�Wtd||	�}|j|�q�W|S)zHReturns list of (cnt_act, cnt_exp, elem) triples where the counts differrr*)�listrr"�	enumerate�range�	_Mismatchr+)r/r.r
�t�m�nZNULLr%r0�elem�cnt_s�cnt_tr1Z
other_elem�diffr
r
r�_count_diff_all_purposeys<rIcCs,t�}x |D]}|j|d�d||<qW|S)z@Return dict of element counts, in the order they were first seenrr*)r�get)�iterable�crEr
r
r�_ordered_count�s
rMc	Cs�t|�t|�}}g}x>|j�D]2\}}|j|d�}||kr t|||�}|j|�q Wx2|j�D]&\}}||kr`td||�}|j|�q`W|S)zHReturns list of (cnt_act, cnt_exp, elem) triples where the counts differr)rM�itemsrJrAr+)	r/r.r
rBr%rErFrGrHr
r
r�_count_diff_hashable�srON)F)�__doc__�collectionsrrZos.pathrZ
__unittestrr	rrrrrrrrr)r5r:r=rArIrMrOr
r
r
r�<module>s,
	)
#PKń[�چ���&__pycache__/suite.cpython-36.opt-2.pycnu�[���3


 \�(�@sxddlZddlmZddlmZdZdd�ZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�Z	dd�Z
Gdd�de�ZdS)�N�)�case)�utilTcCst||dd��}|�dS)NcSsdS)N�rrr�&/usr/lib64/python3.6/unittest/suite.py�<lambda>sz!_call_if_exists.<locals>.<lambda>)�getattr)�parent�attr�funcrrr�_call_if_existssrc@sleZdZdZffdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�
BaseTestSuiteTcCsg|_d|_|j|�dS)Nr)�_tests�_removed_tests�addTests)�self�testsrrr�__init__szBaseTestSuite.__init__cCsdtj|j�t|�fS)Nz
<%s tests=%s>)r�strclass�	__class__�list)rrrr�__repr__szBaseTestSuite.__repr__cCs t||j�stSt|�t|�kS)N)�
isinstancer�NotImplementedr)r�otherrrr�__eq__szBaseTestSuite.__eq__cCs
t|j�S)N)�iterr)rrrr�__iter__"szBaseTestSuite.__iter__cCs(|j}x|D]}|r||j�7}qW|S)N)r�countTestCases)rZcases�testrrrr%s

zBaseTestSuite.countTestCasescCsLt|�stdjt|����t|t�r<t|tjt	f�r<td��|j
j|�dS)Nz{} is not callablezNTestCases and TestSuites must be instantiated before passing them to addTest())�callable�	TypeError�format�reprr�type�
issubclassrZTestCase�	TestSuiter�append)rrrrr�addTest,szBaseTestSuite.addTestcCs.t|t�rtd��x|D]}|j|�qWdS)Nz0tests must be an iterable of tests, not a string)r�strr!r()rrrrrrr6s

zBaseTestSuite.addTestscCs:x4t|�D](\}}|jrP||�|jr
|j|�q
W|S)N)�	enumerate�
shouldStop�_cleanup�_removeTestAtIndex)r�result�indexrrrr�run<szBaseTestSuite.runcCsNy|j|}Wntk
r"Yn(Xt|d�r@|j|j�7_d|j|<dS)Nr)rr!�hasattrrr)rr/rrrrr-Es
z BaseTestSuite._removeTestAtIndexcOs|j||�S)N)r0)r�args�kwdsrrr�__call__SszBaseTestSuite.__call__cCsx|D]}|j�qWdS)N)�debug)rrrrrr5Vs
zBaseTestSuite.debugN)�__name__�
__module__�__qualname__r,rrrrrr(rr0r-r4r5rrrrr
s
	r
c@sNeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dS)r&FcCs�d}t|dd�dkrd|_}x�t|�D]�\}}|jr8Pt|�r�|j||�|j||�|j||�|j|_	t|jdd�s(t|dd�r�q(|s�||�n|j
�|jr(|j|�q(W|r�|jd|�|j
|�d|_|S)NF�_testRunEnteredT�_classSetupFailed�_moduleSetUpFailed)rr9r*r+�_isnotsuite�_tearDownPreviousClass�_handleModuleFixture�_handleClassSetUpr�_previousTestClassr5r,r-�_handleModuleTearDown)rr.r5ZtopLevelr/rrrrr0fs0


z
TestSuite.runcCst�}|j|d�dS)NT)�_DebugResultr0)rr5rrrr5�szTestSuite.debugc	 Cs�t|dd�}|j}||krdS|jr(dSt|dd�r8dSy
d|_Wntk
rVYnXt|dd�}|dk	r�t|d�zdy
|�WnTtk
r�}z8t|t�r��d|_t	j
|�}d|}|j|||�WYdd}~XnXWdt|d�XdS)	Nr@�__unittest_skip__F�
setUpClass�_setupStdoutTzsetUpClass (%s)�_restoreStdout)rrr;r:r!r�	ExceptionrrBrr�_addClassOrModuleLevelException)	rrr.�
previousClass�currentClassrD�e�	className�	errorNamerrrr?�s2




$zTestSuite._handleClassSetUpcCs"d}t|dd�}|dk	r|j}|S)Nr@)rr7)rr.�previousModulerIrrr�_get_previous_module�s
zTestSuite._get_previous_modulec	 Cs�|j|�}|jj}||krdS|j|�d|_ytj|}Wntk
rPdSXt|dd�}|dk	r�t	|d�zZy
|�WnJt
k
r�}z.t|t�r��d|_d|}|j
|||�WYdd}~XnXWdt	|d�XdS)NF�setUpModulerETzsetUpModule (%s)rF)rOrr7rAr;�sys�modules�KeyErrorrrrGrrBrH)	rrr.rNZ
currentModule�modulerPrKrMrrrr>�s,




$zTestSuite._handleModuleFixturecCsLt|�}t|dd�}|dk	r8t|tj�r8||t|��n|j|tj��dS)N�addSkip)	�_ErrorHolderrrrZSkipTestr)ZaddErrorrQ�exc_info)rr.Z	exceptionrM�errorrUrrrrH�s
z)TestSuite._addClassOrModuleLevelExceptionc Cs�|j|�}|dkrdS|jr dSytj|}Wntk
rBdSXt|dd�}|dk	r�t|d�zTy
|�WnDtk
r�}z(t|t	�r��d|}|j
|||�WYdd}~XnXWdt|d�XdS)N�tearDownModulerEztearDownModule (%s)rF)rOr;rQrRrSrrrGrrBrH)rr.rNrTrYrKrMrrrrA�s(



$zTestSuite._handleModuleTearDownc	Cs�t|dd�}|j}||krdSt|dd�r.dSt|dd�r>dSt|dd�rNdSt|dd�}|dk	r�t|d�z^y
|�WnNtk
r�}z2t|t�r��tj|�}d|}|j|||�WYdd}~XnXWdt|d	�XdS)
Nr@r:Fr;rC�
tearDownClassrEztearDownClass (%s)rF)	rrrrGrrBrrrH)	rrr.rIrJrZrKrLrMrrrr=�s,



$z TestSuite._tearDownPreviousClassN)F)r6r7r8r0r5r?rOr>rHrAr=rrrrr&\s

! r&c@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)rVNcCs
||_dS)N)�description)rr[rrrrsz_ErrorHolder.__init__cCs|jS)N)r[)rrrr�idsz_ErrorHolder.idcCsdS)Nr)rrrr�shortDescription sz_ErrorHolder.shortDescriptioncCsd|jfS)Nz<ErrorHolder description=%r>)r[)rrrrr#sz_ErrorHolder.__repr__cCs|j�S)N)r\)rrrr�__str__&sz_ErrorHolder.__str__cCsdS)Nr)rr.rrrr0)sz_ErrorHolder.runcCs
|j|�S)N)r0)rr.rrrr4.sz_ErrorHolder.__call__cCsdS)Nrr)rrrrr1sz_ErrorHolder.countTestCases)r6r7r8ZfailureExceptionrr\r]rr^r0r4rrrrrrVs
rVcCs&yt|�Wntk
r dSXdS)NTF)rr!)rrrrr<4s
r<c@seZdZdZdZdZdS)rBNF)r6r7r8r@r;r+rrrrrB=srB)rQ�rrZ
__unittestr�objectr
r&rVr<rBrrrr�<module>sL3&	PKń[b��C+C+'__pycache__/loader.cpython-36.opt-2.pycnu�[���3


 \�V�@s�ddlZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZdZej
dej�ZGdd�de	j�Zd	d
�Zdd�Zd
d�Zdd�Zdd�ZGdd�de�Ze�Zddd�Zejfdd�Zdeje
jfdd�Zdeje
jfdd�ZdS)�N)�fnmatch�)�case�suite�utilTz[_a-z]\w*\.py$cs,eZdZdZ�fdd�Z�fdd�Z�ZS)�_FailedTestNcs||_tt|�j|�dS)N)�
_exception�superr�__init__)�selfZmethod_name�	exception)�	__class__��'/usr/lib64/python3.6/unittest/loader.pyr
sz_FailedTest.__init__cs*|�jkrtt��j|�S�fdd�}|S)Ncs
�j�dS)N)rr)rrr�testFailure!sz,_FailedTest.__getattr__.<locals>.testFailure)�_testMethodNamer	r�__getattr__)r�namer)r
)rrrs
z_FailedTest.__getattr__)�__name__�
__module__�__qualname__rr
r�
__classcell__rr)r
rrsrcCs"d|tj�f}t|t|�||�S)Nz#Failed to import test module: %s
%s)�	traceback�
format_exc�_make_failed_test�ImportError)r�
suiteClass�messagerrr�_make_failed_import_test&srcCsdtj�f}t||||�S)NzFailed to call load_tests:
%s)rrr)rrrrrrr�_make_failed_load_tests+srcCst||�}||f�|fS)N)r)�
methodnamerrr�testrrrr0s
rcCs<tjt|��dd��}||i}tdtjf|�}|||�f�S)NcSsdS)Nr)rrrr�testSkipped5sz'_make_skipped_test.<locals>.testSkippedZ
ModuleSkipped)r�skip�str�type�TestCase)r rrr"ZattrsZ	TestClassrrr�_make_skipped_test4sr'cCs*|j�jd�r|dd�Stjj|�dS)Nz	$py.class�	ri����)�lower�endswith�os�path�splitext)r,rrr�_jython_aware_splitext<sr.cs�eZdZdZeej�Zej	Z
dZ�fdd�Zdd�Z
dd�dd	�Zd d
d�Zd!dd
�Zdd�Zd"dd�Zdd�Zdd�Zdd�Zdd�Zd#dd�Zd$dd�Z�ZS)%�
TestLoaderr!Ncs tt|�j�g|_t�|_dS)N)r	r/r
�errors�set�_loading_packages)r)r
rrr
LszTestLoader.__init__cCsHt|tj�rtd��|j|�}|r4t|d�r4dg}|jt||��}|S)NzYTest cases should not be derived from TestSuite. Maybe you meant to derive from TestCase?ZrunTest)�
issubclassr�	TestSuite�	TypeError�getTestCaseNames�hasattrr�map)r�
testCaseClassZ
testCaseNamesZloaded_suiterrr�loadTestsFromTestCaseSs
z TestLoader.loadTestsFromTestCase)�patternc
Os2t|�dksd|kr,tjdt�|jdd�t|�dkrRt|�d}tdj|���t|�dkrxt|�d}tdj|���g}x@t|�D]4}t	||�}t
|t�r�t|t
j�r�|j|j|��q�Wt	|dd�}	|j|�}|	dk	�r.y|	|||�Stk
�r,}
z$t|j|
|j�\}}|jj|�|Sd}
~
XnX|S)NrZuse_load_testsz(use_load_tests is deprecated and ignoredrzCloadTestsFromModule() takes 1 positional argument but {} were givenz=loadTestsFromModule() got an unexpected keyword argument '{}'�
load_tests)�len�warnings�warn�DeprecationWarning�popr5�format�sorted�dir�getattr�
isinstancer%r3rr&�appendr:r�	Exceptionrrr0)
r�moduler;�argsZkwsZ	complaint�testsr�objr<�e�
error_case�
error_messagerrr�loadTestsFromModuleas4


zTestLoader.loadTestsFromModulecCs>|jd�}d\}}|dkr�|dd�}xb|r�ydj|�}t|�}PWq(tk
r�|j�}t||j�\}}|s�|jj|�|SYq(Xq(W|dd�}|}	x�|D]�}
y|	t	|	|
�}}	Wq�t
k
�r2}z\t	|	dd�dk	r�|dk	r�|jj|�|St|
||jdtj
�f�\}}|jj|�|SWYdd}~Xq�Xq�Wt|	tj��rP|j|	�St|	t��rtt|	tj��rt|j|	�St|	tj��r�t|t��r�t|tj��r�|d}||�}
tt	|
|�tj��s�|j|
g�Snt|	tj��r�|	St|	��r.|	�}t|tj��r|St|tj��r|j|g�Std|	|f��ntd|	��dS)	N�.r�__path__zFailed to access attribute:
%sz"calling %s returned %s, not a testz$don't know how to make test from: %s)NN���)�split�join�
__import__rrArrr0rGrE�AttributeErrorrrrrF�types�
ModuleTyperPr%r3rr&r:�FunctionTyperr4�callabler5)rrrI�partsrNrOZ
parts_copy�module_nameZnext_attributerL�part�parentrMZinstr!rrr�loadTestsFromName�sl	





zTestLoader.loadTestsFromNamecs��fdd�|D�}�j|�S)Ncsg|]}�j|���qSr)r`)�.0r)rIrrr�
<listcomp>�sz1TestLoader.loadTestsFromNames.<locals>.<listcomp>)r)r�namesrIZsuitesr)rIrr�loadTestsFromNames�szTestLoader.loadTestsFromNamescCs@||jfdd�}tt|t|���}|jr<|jtj|j�d�|S)NcSs|j|�ott||��S)N)�
startswithr[rE)Zattrnamer9�prefixrrr�isTestMethod�s
z1TestLoader.getTestCaseNames.<locals>.isTestMethod)�key)�testMethodPrefix�list�filterrD�sortTestMethodsUsing�sort�	functools�
cmp_to_key)rr9rgZtestFnNamesrrrr6�szTestLoader.getTestCaseNames�test*.pycCsRd}|dkr|jdk	r|j}n|dkr.d}|}tjj|�}|tjkrRtjjd|�||_d}d}g}tjjtjj|��r�tjj|�}||kr�tjjtjj|d��}�nxyt	|�Wnt
k
r�d}Y�nRXtj|}|jd�d}	ytjjtjj
|j��}Wn�tk
�r�y
|j}
Wntk
�r8d}
YnX|
�r�|
jdk�r�|
jdk	�r�d}x�|jD]T}|�r�|j|��r��qd|j|jjdtjj��d|_|j|j||dd���qdWn*|jtjk�r�td�d�ntdj|��d�YnX|�r |�s|j|	�|_tjj|�ntjj|�|�r2t
d	|��|�sHt|j||��}|j |�S)
NFTrz__init__.pyrQ)�	namespacez2Can not use builtin modules as dotted module namesz$don't know how to discover from {!r}z%Start directory is not importable: %r)!�_top_level_dirr+r,�abspath�sys�insert�isdir�isfilerUrVr�modulesrT�dirname�__file__rW�__spec__�loader�submodule_search_locationsrRrer�replace�sep�extend�_find_tests�builtin_module_namesr5rB� _get_directory_containing_module�removerjr)r�	start_dirr;Z
top_level_dirZset_implicit_topZis_not_importable�is_namespacerKZ
the_moduleZtop_part�specr,rrr�discover�sv





zTestLoader.discovercCsRtj|}tjj|j�}tjj|�j�jd�rBtjj	tjj	|��Stjj	|�SdS)Nz__init__.py)
rtrxr+r,rsrz�basenamer)rery)rr]rI�	full_pathrrrr�Xs

z+TestLoader._get_directory_containing_modulecCsB||jkrdSttjj|��}tjj||j�}|jtjjd�}|S)NrQ)rrr.r+r,�normpath�relpathr~r)rr,Z_relpathrrrr�_get_name_from_pathds
zTestLoader._get_name_from_pathcCst|�tj|S)N)rVrtrx)rrrrr�_get_module_from_namepsz TestLoader._get_module_from_namecCs
t||�S)N)r)rr,r�r;rrr�_match_pathtszTestLoader._match_pathFc
cs�|j|�}|dkrD||jkrD|j|||�\}}|dk	r<|V|sDdSttj|��}x||D]t}tjj||�}	|j|	||�\}}|dk	r�|V|rX|j|	�}|jj|�z|j	|	||�EdHWd|jj
|�XqXWdS)NrQ)r�r2�_find_test_pathrCr+�listdirr,rU�addr��discard)
rr�r;rqrrKZshould_recurse�pathsr,r�rrrr�xs*


zTestLoader._find_testscCsPtjj|�}tjj|��rFtj|�s(dS|j|||�s:d	S|j|�}y|j|�}WnXt	j
k
r�}zt|||j�dfSd}~Xn�t
||j�\}}	|jj|	�|dfStjjt|d|��}
ttjj|
��}ttjj|��}|j�|j�k�r0tjj|�}
ttjj|��}tjj|�}d}t|||
|f��|j||d�dfS�ntjj|��rH|�rztjjtjj|d���rzd
Sd}d}|j|�}y|j|�}WnZt	j
k
�r�}zt|||j�dfSd}~Xnzt
||j�\}}	|jj|	�|dfSt|dd�}|jj|�z(|j||d�}|dk	�r0|dfS|dfS|jj|�XndSdS)NFrzzW%r module incorrectly imported from %r. Expected %r. Is this module globally installed?)r;z__init__.pyr<T)NF)NF)NF)NF)r+r,r�rw�VALID_MODULE_NAME�matchr�r�r�rZSkipTestr'rrr0rGrsrEr.�realpathr)ryrrPrvrUr2r�r�)rr�r;rqr�rrIrMrNrOZmod_filer�Zfullpath_noextZ
module_dirZmod_nameZexpected_dir�msgr<rK�packagerrrr��sl



zTestLoader._find_test_path)N)N)rpN)F)F)rrrri�staticmethodr�
three_way_cmprlrr4rrrr
r:rPr`rdr6r�r�r�r�r�r�r�rrr)r
rr/Bs"
(
N

n
"r/cCs t�}||_||_|r||_|S)N)r/rlrir)rf�	sortUsingrr|rrr�_makeLoader�sr�cCst||�j|�S)N)r�r6)r9rfr�rrrr6�sr6r!cCst|||�j|�S)N)r�r:)r9rfr�rrrr�	makeSuite�sr�cCst|||�j|�S)N)r�rP)rIrfr�rrrr�
findTestCases�sr�)N) r+�rertrrXrnr>r�rrrZ
__unittest�compile�
IGNORECASEr�r&rrrrr'r.�objectr/ZdefaultTestLoaderr�r�r6r4r�r�rrrr�<module>s6'
PK��[��WW	runner.pynu�[���PK��[d��__�util.pynu�[���PK��[5V����&3case.pynu�[���PK��[؁�N�X�X	loader.pynu�[���PK��[ڗ��c	c	
usignals.pynu�[���PK��[2��|22�~suite.pynu�[���PK��[l�k�+�__pycache__/async_case.cpython-38.opt-2.pycnu�[���PK��[:��'F�__pycache__/runner.cpython-38.opt-2.pycnu�[���PK��[��e�WW)��__pycache__/__init__.cpython-38.opt-2.pycnu�[���PK��[���pp)P�__pycache__/__main__.cpython-38.opt-2.pycnu�[���PK��[a!n�}}'�__pycache__/result.cpython-38.opt-1.pycnu�[���PK��[��QQ�__pycache__/util.cpython-38.pycnu�[���PK��[P�<��(�__pycache__/signals.cpython-38.opt-2.pycnu�[���PK��[���8�8!�__pycache__/loader.cpython-38.pycnu�[���PK��[P�<��"�R__pycache__/signals.cpython-38.pycnu�[���PK��[|�Eo%�[__pycache__/util.cpython-38.opt-1.pycnu�[���PK��[���58.8.%m__pycache__/mock.cpython-38.opt-1.pycnu�[���PK��[�6��jj!��__pycache__/runner.cpython-38.pycnu�[���PK��[��.z�&�&&S�__pycache__/suite.cpython-38.opt-1.pycnu�[���PK��[�6��jj'z�__pycache__/runner.cpython-38.opt-1.pycnu�[���PK��[��F�88);�__pycache__/__init__.cpython-38.opt-1.pycnu�[���PK��[���vpp�__pycache__/main.cpython-38.pycnu�[���PK��[��F�88#�$__pycache__/__init__.cpython-38.pycnu�[���PK��[ߜ|}�}�%1__pycache__/mock.cpython-38.opt-2.pycnu�[���PK��[��W�؉؉%�__pycache__/case.cpython-38.opt-2.pycnu�[���PK��[a!n�}}!�__pycache__/result.cpython-38.pycnu�[���PK��[�{��%�__pycache__/main.cpython-38.opt-2.pycnu�[���PK��[�����%��__pycache__/case.cpython-38.opt-1.pycnu�[���PK��[l�k�+K�__pycache__/async_case.cpython-38.opt-1.pycnu�[���PK��[-:p_8_8'��__pycache__/loader.cpython-38.opt-1.pycnu�[���PK��[�f�YY%a�__pycache__/async_case.cpython-38.pycnu�[���PK��[�V)��-�-'�__pycache__/loader.cpython-38.opt-2.pycnu�[���PK��[jr�&6�6�H&__pycache__/case.cpython-38.pycnu�[���PK��[4')6OO'��__pycache__/result.cpython-38.opt-2.pycnu�[���PK��[��.z�&�& s__pycache__/suite.cpython-38.pycnu�[���PK��[2B�Z�"�"&�)__pycache__/suite.cpython-38.opt-2.pycnu�[���PK��[�1��)�L__pycache__/__main__.cpython-38.opt-1.pycnu�[���PK��[�l%�88%�N__pycache__/util.cpython-38.opt-2.pycnu�[���PK��[�1��#:]__pycache__/__main__.cpython-38.pycnu�[���PK��[P�<��(___pycache__/signals.cpython-38.opt-1.pycnu�[���PK��[���vpp%$h__pycache__/main.cpython-38.opt-1.pycnu�[���PK��[���58.8.�__pycache__/mock.cpython-38.pycnu�[���PK��[)����p�	mock.pynu�[���PK��[�b!%���4__main__.pynu�[���PK��[����+�+�6main.pynu�[���PK��[�����b__init__.pynu�[���PK��[V�q��
�oasync_case.pynu�[���PK��[[[$�	ʆresult.pynu�[���PK��[r�n���util.pyonu�[���PK��[��W�p,p,
�loader.pycnu�[���PK��[�����
��result.pycnu�[���PK��[(�G<<�main.pycnu�[���PK��[FE���@!__main__.pycnu�[���PK��[�nT�+�+
d#loader.pyonu�[���PK��[&�xK��
�Orunner.pyonu�[���PK��['�y9*)*)	�msuite.pyonu�[���PK��[(�G<<�main.pyonu�[���PK��[+���%�%b�test/test_skipping.pyonu�[���PK��[D����)�test/dummy.pycnu�[���PK��[+���%�%��test/test_skipping.pycnu�[���PK��[o5��z4z4�
test/test_assertions.pycnu�[���PK��[ٙ7�L@L@r7
test/test_setups.pynu�[���PK��[Ij̟'�'x
test/test_break.pycnu�[���PK��[��4}pp�
test/test_skipping.pynu�[���PK��[�22
��
test/dummy.pynu�[���PK��[��Yo���
test/test_functiontestcase.pynu�[���PK��[aDϗS�S��
test/test_result.pyonu�[���PK��[M;E,2/2/� test/test_suite.pynu�[���PK��[4���-7-7NPtest/test_runner.pyonu�[���PK��[CV�EE��test/test_discovery.pyonu�[���PK��[pV'�.�.	�test/test_assertions.pynu�[���PK��[�
�����	�test/test_case.pynu�[���PK��[r�=��
�
�test/support.pynu�[���PK��[�grx�%�%��test/test_break.pynu�[���PK��[z#�����test/__init__.pyonu�[���PK��[lױœ���e�test/test_loader.pyonu�[���PK��[lױœ���E�test/test_loader.pycnu�[���PK��[�L�����%ltest/test_case.pycnu�[���PK��[�L�����$test/test_case.pyonu�[���PK��[%v
�tt�test/support.pyonu�[���PK��[4���-7-7��test/test_runner.pycnu�[���PK��[�}'��*+test/test_functiontestcase.pyonu�[���PK��[����(�(?Ctest/test_program.pyonu�[���PK��[
�pa����3ltest/test_loader.pynu�[���PK��[aDϗS�S@/test/test_result.pycnu�[���PK��[�ú��(�(�test/test_program.pycnu�[���PK��[CV�EEI�test/test_discovery.pycnu�[���PK��[�Fcw�!�!��test/test_runner.pynu�[���PK��[����pJpJwtest/test_result.pynu�[���PK��[�}'��*^test/test_functiontestcase.pycnu�[���PK��[D����?vtest/dummy.pyonu�[���PK��[���7�7�vtest/test_discovery.pynu�[���PK��[L�B2.�test/__init__.pynu�[���PK��[%v
�ttp�test/support.pycnu�[���PK��[Ij̟'�'$�test/test_break.pyonu�[���PK��[z#����test/__init__.pycnu�[���PK��[S.#Ď<�<��test/test_suite.pycnu�[���PK��[\�p�q�q�1test/test_setups.pycnu�[���PK��[o5��z4z4ۣtest/test_assertions.pyonu�[���PK��[x�'Ә���test/test_program.pynu�[���PK��[\�p�q�qy�test/test_setups.pyonu�[���PK��[S.#Ď<�<�htest/test_suite.pyonu�[���PK��[FE�����__main__.pyonu�[���PK��[�A�����__init__.pyonu�[���PK��[�X���
�
��signals.pycnu�[���PK��[u<�΢΢ؾcase.pyonu�[���PK��['�y9*)*)	�asuite.pycnu�[���PK��[�����
A�result.pyonu�[���PK��[�X���
�
p�signals.pyonu�[���PK��[u<�΢΢��case.pycnu�[���PK��[�A����X__init__.pycnu�[���PK��[&�xK��
�drunner.pycnu�[���PK��[r�n����util.pycnu�[���PKń[v�?��)��__pycache__/__main__.cpython-36.opt-1.pycnu�[���PKń[�l����)��__pycache__/__init__.cpython-36.opt-1.pycnu�[���PKń[��kH��'��__pycache__/runner.cpython-36.opt-1.pycnu�[���PKń[�eg��%ɽ__pycache__/main.cpython-36.opt-2.pycnu�[���PKń[F�k9�5�5'��__pycache__/loader.cpython-36.opt-1.pycnu�[���PKń[�ZS�PP%�__pycache__/util.cpython-36.opt-1.pycnu�[���PKń[�E�8,6,6!�!__pycache__/loader.cpython-36.pycnu�[���PKń[T`��aa'X__pycache__/runner.cpython-36.opt-2.pycnu�[���PKń[nԀ<<'�p__pycache__/result.cpython-36.opt-1.pycnu�[���PKń[���~~(S�__pycache__/signals.cpython-36.opt-1.pycnu�[���PKń[�v��ff)�__pycache__/main.cpython-36.pycnu�[���PKń[8��o����ޱ__pycache__/case.cpython-36.pycnu�[���PKń[v�?��#'n__pycache__/__main__.cpython-36.pycnu�[���PKń[��kH��!p__pycache__/runner.cpython-36.pycnu�[���PKń[���~~(4�__pycache__/signals.cpython-36.opt-2.pycnu�[���PKń[b�red�d�%
�__pycache__/mock.cpython-36.opt-2.pycnu�[���PKń[�b!����%�H__pycache__/case.cpython-36.opt-2.pycnu�[���PKń[�?���)��__pycache__/__init__.cpython-36.opt-2.pycnu�[���PKń[�l����#��__pycache__/__init__.cpython-36.pycnu�[���PKń[�v��ff%�__pycache__/main.cpython-36.opt-1.pycnu�[���PKń[tp��%�__pycache__/util.cpython-36.opt-2.pycnu�[���PKń[Kk��\�\�__pycache__/mock.cpython-36.pycnu�[���PKń[��ݥ~~)�__pycache__/__main__.cpython-36.opt-2.pycnu�[���PKń[Kk��\�\�%��__pycache__/mock.cpython-36.opt-1.pycnu�[���PKń[Z�Z��#�#&R�__pycache__/suite.cpython-36.opt-1.pycnu�[���PKń[Z�Z��#�# }__pycache__/suite.cpython-36.pycnu�[���PKń[���~~"�3__pycache__/signals.cpython-36.pycnu�[���PKń[nԀ<<!r<__pycache__/result.cpython-36.pycnu�[���PKń[�p�4��'�X__pycache__/result.cpython-36.opt-2.pycnu�[���PKń[��#�ĻĻ%To__pycache__/case.cpython-36.opt-1.pycnu�[���PKń[&�%���m+ __pycache__/util.cpython-36.pycnu�[���PKń[�چ���&O> __pycache__/suite.cpython-36.opt-2.pycnu�[���PKń[b��C+C+'L^ __pycache__/loader.cpython-36.opt-2.pycnu�[���PK��3�