HEX
Server: Apache
System: Linux vmi318001.contaboserver.net 6.8.0-117-generic #117-Ubuntu SMP PREEMPT_DYNAMIC Tue May 5 19:26:24 UTC 2026 x86_64
User: boxelikax (1004)
PHP: 8.2.33
Disabled: NONE
Upload Files
File: /home/boxelikax/public_html/demoltec.com/unittest.tar
util.py000064400000012137152401764000006076 0ustar00"""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
case.py000064400000162207152401764000006040 0ustar00"""Test case implementation"""

import sys
import functools
import difflib
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.expectedFailure = None

    @contextlib.contextmanager
    def testPartExecutor(self, test_case, subTest=False):
        old_success = self.success
        self.success = True
        try:
            yield
        except KeyboardInterrupt:
            raise
        except SkipTest as e:
            self.success = False
            _addSkip(self.result, 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
                if subTest:
                    self.result.addSubTest(test_case.test_case, test_case, exc_info)
                else:
                    _addError(self.result, test_case, exc_info)
            # explicitly break a reference cycle:
            # exc_info -> frame -> exc_info
            exc_info = None
        else:
            if subTest and self.success:
                self.result.addSubTest(test_case.test_case, test_case, None)
        finally:
            self.success = self.success and old_success


def _addSkip(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)

def _addError(result, test, exc_info):
    if result is not None and exc_info is not None:
        if issubclass(exc_info[0], test.failureException):
            result.addFailure(test, exc_info)
        else:
            result.addError(test, exc_info)

def _id(obj):
    return obj


def _enter_context(cm, addcleanup):
    # We look up the special methods on the type to match the with
    # statement.
    cls = type(cm)
    try:
        enter = cls.__enter__
        exit = cls.__exit__
    except AttributeError:
        raise TypeError(f"'{cls.__module__}.{cls.__qualname__}' object does "
                        f"not support the context manager protocol") from None
    result = enter(cm)
    addcleanup(exit, cm, None, None, None)
    return result


_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 enterModuleContext(cm):
    """Same as enterContext, but module-wide."""
    return _enter_context(cm, addModuleCleanup)


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_getitem__ = classmethod(types.GenericAlias)


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))


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

    def __init_subclass__(cls, *args, **kwargs):
        # Attribute used by TestSuite for classSetUp
        cls._classSetupFailed = False
        cls._class_cleanups = []
        super().__init_subclass__(*args, **kwargs)

    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(self, function, /, *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)."""
        self._cleanups.append((function, args, kwargs))

    def enterContext(self, cm):
        """Enters the supplied context manager.

        If successful, also adds its __exit__ method as a cleanup
        function and returns the result of the __enter__ method.
        """
        return _enter_context(cm, self.addCleanup)

    @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))

    @classmethod
    def enterClassContext(cls, cm):
        """Same as enterContext, but class-wide."""
        return _enter_context(cm, cls.addClassCleanup)

    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.%s)" % (self._testMethodName, strclass(self.__class__), self._testMethodName)

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

    @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, subTest=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 _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):
        if method() is not None:
            warnings.warn(f'It is deprecated to return a value that is not None from a '
                          f'test case ({method})', DeprecationWarning, stacklevel=3)

    def _callTearDown(self):
        self.tearDown()

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

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

        result.startTest(self)
        try:
            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.
                skip_why = (getattr(self.__class__, '__unittest_skip_why__', '')
                            or getattr(testMethod, '__unittest_skip_why__', ''))
                _addSkip(result, self, skip_why)
                return result

            expecting_failure = (
                getattr(self, "__unittest_expecting_failure__", False) or
                getattr(testMethod, "__unittest_expecting_failure__", False)
            )
            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):
                        self._callTestMethod(testMethod)
                    outcome.expecting_failure = False
                    with outcome.testPartExecutor(self):
                        self._callTearDown()
                self.doCleanups()

                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:
                # explicitly break reference cycle:
                # outcome.expectedFailure -> frame -> outcome -> outcome.expectedFailure
                outcome.expectedFailure = None
                outcome = None

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

        finally:
            result.stopTest(self)
            if stopTestRun is not None:
                stopTestRun()

    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:
                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"""
        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.
            skip_why = (getattr(self.__class__, '__unittest_skip_why__', '')
                        or getattr(testMethod, '__unittest_skip_why__', ''))
            raise SkipTest(skip_why)

        self._callSetUp()
        self._callTestMethod(testMethod)
        self._callTearDown()
        while self._cleanups:
            function, args, kwargs = self._cleanups.pop()
            self._callCleanup(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'])
        """
        # Lazy import to avoid importing logging if it is not needed.
        from ._log import _AssertLogsContext
        return _AssertLogsContext(self, logger, level, no_logs=False)

    def assertNoLogs(self, logger=None, level=None):
        """ Fail unless no log messages of level *level* or higher are emitted
        on *logger_name* or its children.

        This method must be used as a context manager.
        """
        from ._log import _AssertLogsContext
        return _AssertLogsContext(self, logger, level, no_logs=True)

    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())
signals.py000064400000004543152401764000006563 0ustar00import 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)
_log.py000064400000005272152401764000006043 0ustar00import logging
import collections

from .case import _BaseTestCaseContext


_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 for assertLogs() and assertNoLogs() """

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

    def __init__(self, test_case, logger_name, level, no_logs):
        _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
        self.no_logs = no_logs

    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.setLevel(self.level)
        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
        if self.no_logs:
            return
        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 self.no_logs:
            # assertNoLogs
            if len(self.watcher.records) > 0:
                self._raiseFailure(
                    "Unexpected logs found: {!r}".format(
                        self.watcher.output
                    )
                )

        else:
            # assertLogs
            if len(self.watcher.records) == 0:
                self._raiseFailure(
                    "no logs of level {} or higher triggered on {}"
                    .format(logging.getLevelName(self.level), self.logger.name))
loader.py000064400000054010152401764000006363 0ustar00"""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?")
        if testCaseClass in (case.TestCase, case.FunctionTestCase):
            # We don't load any tests from base types that should not be loaded.
            testCaseNames = []
        else:
            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)
                and obj not in (case.TestCase, case.FunctionTestCase)
            ):
                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)
            and obj not in (case.TestCase, case.FunctionTestCase)
        ):
            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
        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:
                    if 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(
                            f"don't know how to discover from {the_module!r}"
                            ) from None

                if set_implicit_top:
                    self._top_level_dir = self._get_directory_containing_module(top_part)
                    sys.path.remove(top_level_dir)

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

        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):
        """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)
            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)
            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)
                finally:
                    self._loading_packages.discard(name)

    def _find_test_path(self, full_path, pattern):
        """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 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()


# These functions are considered obsolete for long time.
# They will be removed in Python 3.13.

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):
    import warnings
    warnings.warn(
        "unittest.getTestCaseNames() is deprecated and will be removed in Python 3.13. "
        "Please use unittest.TestLoader.getTestCaseNames() instead.",
        DeprecationWarning, stacklevel=2
    )
    return _makeLoader(prefix, sortUsing, testNamePatterns=testNamePatterns).getTestCaseNames(testCaseClass)

def makeSuite(testCaseClass, prefix='test', sortUsing=util.three_way_cmp,
              suiteClass=suite.TestSuite):
    import warnings
    warnings.warn(
        "unittest.makeSuite() is deprecated and will be removed in Python 3.13. "
        "Please use unittest.TestLoader.loadTestsFromTestCase() instead.",
        DeprecationWarning, stacklevel=2
    )
    return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromTestCase(
        testCaseClass)

def findTestCases(module, prefix='test', sortUsing=util.three_way_cmp,
                  suiteClass=suite.TestSuite):
    import warnings
    warnings.warn(
        "unittest.findTestCases() is deprecated and will be removed in Python 3.13. "
        "Please use unittest.TestLoader.loadTestsFromModule() instead.",
        DeprecationWarning, stacklevel=2
    )
    return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromModule(\
        module)
suite.py000064400000032310152401764000006245 0ustar00"""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

        failed = False
        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)
        doClassCleanups = getattr(currentClass, 'doClassCleanups', None)
        if setUpClass is not None:
            _call_if_exists(result, '_setupStdout')
            try:
                try:
                    setUpClass()
                except Exception as e:
                    if isinstance(result, _DebugResult):
                        raise
                    failed = True
                    try:
                        currentClass._classSetupFailed = True
                    except TypeError:
                        pass
                    className = util.strclass(currentClass)
                    self._createClassOrModuleLevelException(result, e,
                                                            'setUpClass',
                                                            className)
                if failed and doClassCleanups is not None:
                    doClassCleanups()
                    for exc_info in currentClass.tearDown_exceptions:
                        self._createClassOrModuleLevelException(
                                result, exc_info[1], 'setUpClass', className,
                                info=exc_info)
            finally:
                _call_if_exists(result, '_restoreStdout')

    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:
                try:
                    setUpModule()
                except Exception as e:
                    if isinstance(result, _DebugResult):
                        raise
                    result._moduleSetUpFailed = True
                    self._createClassOrModuleLevelException(result, e,
                                                            'setUpModule',
                                                            currentModule)
                if result._moduleSetUpFailed:
                    try:
                        case.doModuleCleanups()
                    except Exception as e:
                        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

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

    def _tearDownPreviousClass(self, test, result):
        previousClass = getattr(result, '_previousTestClass', None)
        currentClass = test.__class__
        if currentClass == previousClass or previousClass is None:
            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)
        doClassCleanups = getattr(previousClass, 'doClassCleanups', None)
        if tearDownClass is None and doClassCleanups is None:
            return

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


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
__main__.py000064400000000730152401764000006635 0ustar00"""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)
result.py000064400000020506152401764000006436 0ustar00"""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 instances 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
        tb = self._clean_tracebacks(exctype, value, tb, test)
        tb_e = traceback.TracebackException(
            exctype, value, tb,
            capture_locals=self.tb_locals, compact=True)
        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 _clean_tracebacks(self, exctype, value, tb, test):
        ret = None
        first = True
        excs = [(exctype, value, tb)]
        seen = {id(value)}  # Detect loops in chained exceptions.
        while excs:
            (exctype, value, tb) = excs.pop()
            # Skip test runner traceback levels
            while tb and self._is_relevant_tb_level(tb):
                tb = tb.tb_next

            # Skip assert*() traceback levels
            if exctype is test.failureException:
                self._remove_unittest_tb_frames(tb)

            if first:
                ret = tb
                first = False
            else:
                value.__traceback__ = tb

            if value is not None:
                for c in (value.__cause__, value.__context__):
                    if c is not None and id(c) not in seen:
                        excs.append((type(c), c, c.__traceback__))
                        seen.add(id(c))
        return ret

    def _is_relevant_tb_level(self, tb):
        return '__unittest' in tb.tb_frame.f_globals

    def _remove_unittest_tb_frames(self, tb):
        '''Truncates usercode tb at the first unittest frame.

        If the first frame of the traceback is in user code,
        the prefix up to the first unittest frame is returned.
        If the first frame is already in the unittest module,
        the traceback is not modified.
        '''
        prev = None
        while tb and not self._is_relevant_tb_level(tb):
            prev = tb
            tb = tb.tb_next
        if prev is not None:
            prev.tb_next = None

    def __repr__(self):
        return ("<%s run=%i errors=%i failures=%i>" %
               (util.strclass(self.__class__), self.testsRun, len(self.errors),
                len(self.failures)))
__init__.py000064400000007536152401764000006667 0ustar00"""
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', 'doModuleCleanups', 'enterModuleContext']

# Expose obsolete functions for backwards compatibility
# bpo-5846: Deprecated in Python 3.11, scheduled for removal in Python 3.13.
__all__.extend(['getTestCaseNames', 'makeSuite', 'findTestCases'])

__unittest = True

from .result import TestResult
from .case import (addModuleCleanup, TestCase, FunctionTestCase, SkipTest, skip,
                   skipIf, skipUnless, expectedFailure, doModuleCleanups,
                   enterModuleContext)
from .suite import BaseTestSuite, TestSuite
from .loader import TestLoader, defaultTestLoader
from .main import TestProgram, main
from .runner import TextTestRunner, TextTestResult
from .signals import installHandler, registerResult, removeResult, removeHandler
# IsolatedAsyncioTestCase will be imported lazily.
from .loader import makeSuite, getTestCaseNames, findTestCases

# 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)


# Lazy import of IsolatedAsyncioTestCase from .async_case
# It imports asyncio, which is relatively heavy, but most tests
# do not need it.

def __dir__():
    return globals().keys() | {'IsolatedAsyncioTestCase'}

def __getattr__(name):
    if name == 'IsolatedAsyncioTestCase':
        global IsolatedAsyncioTestCase
        from .async_case import IsolatedAsyncioTestCase
        return IsolatedAsyncioTestCase
    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
async_case.py000064400000012531152401764000007227 0ustar00import asyncio
import contextvars
import inspect
import warnings

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._asyncioRunner = None
        self._asyncioTestContext = contextvars.copy_context()

    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()" itself
        # 2. Class can implement "async def __call__()" method
        # 3. Regular "def func()" that returns awaitable object
        self.addCleanup(*(func, *args), **kwargs)

    async def enterAsyncContext(self, cm):
        """Enters the supplied asynchronous context manager.

        If successful, also adds its __aexit__ method as a cleanup
        function and returns the result of the __aenter__ method.
        """
        # We look up the special methods on the type to match the with
        # statement.
        cls = type(cm)
        try:
            enter = cls.__aenter__
            exit = cls.__aexit__
        except AttributeError:
            raise TypeError(f"'{cls.__module__}.{cls.__qualname__}' object does "
                            f"not support the asynchronous context manager protocol"
                           ) from None
        result = await enter(cm)
        self.addAsyncCleanup(exit, cm, None, None, None)
        return result

    def _callSetUp(self):
        # Force loop to be initialized and set as the current loop
        # so that setUp functions can use get_event_loop() and get the
        # correct loop instance.
        self._asyncioRunner.get_loop()
        self._asyncioTestContext.run(self.setUp)
        self._callAsync(self.asyncSetUp)

    def _callTestMethod(self, method):
        if self._callMaybeAsync(method) is not None:
            warnings.warn(f'It is deprecated to return a value that is not None from a '
                          f'test case ({method})', DeprecationWarning, stacklevel=4)

    def _callTearDown(self):
        self._callAsync(self.asyncTearDown)
        self._asyncioTestContext.run(self.tearDown)

    def _callCleanup(self, function, *args, **kwargs):
        self._callMaybeAsync(function, *args, **kwargs)

    def _callAsync(self, func, /, *args, **kwargs):
        assert self._asyncioRunner is not None, 'asyncio runner is not initialized'
        assert inspect.iscoroutinefunction(func), f'{func!r} is not an async function'
        return self._asyncioRunner.run(
            func(*args, **kwargs),
            context=self._asyncioTestContext
        )

    def _callMaybeAsync(self, func, /, *args, **kwargs):
        assert self._asyncioRunner is not None, 'asyncio runner is not initialized'
        if inspect.iscoroutinefunction(func):
            return self._asyncioRunner.run(
                func(*args, **kwargs),
                context=self._asyncioTestContext,
            )
        else:
            return self._asyncioTestContext.run(func, *args, **kwargs)

    def _setupAsyncioRunner(self):
        assert self._asyncioRunner is None, 'asyncio runner is already initialized'
        runner = asyncio.Runner(debug=True)
        self._asyncioRunner = runner

    def _tearDownAsyncioRunner(self):
        runner = self._asyncioRunner
        runner.close()

    def run(self, result=None):
        self._setupAsyncioRunner()
        try:
            return super().run(result)
        finally:
            self._tearDownAsyncioRunner()

    def debug(self):
        self._setupAsyncioRunner()
        super().debug()
        self._tearDownAsyncioRunner()

    def __del__(self):
        if self._asyncioRunner is not None:
            self._tearDownAsyncioRunner()
runner.py000064400000022312152401764000006426 0ustar00"""Running tests"""

import sys
import time
import warnings

from . import result
from .case import _SubTest
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
        self._newline = True

    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()
            self._newline = False

    def _write_status(self, test, status):
        is_subtest = isinstance(test, _SubTest)
        if is_subtest or self._newline:
            if not self._newline:
                self.stream.writeln()
            if is_subtest:
                self.stream.write("  ")
            self.stream.write(self.getDescription(test))
            self.stream.write(" ... ")
        self.stream.writeln(status)
        self.stream.flush()
        self._newline = True

    def addSubTest(self, test, subtest, err):
        if err is not None:
            if self.showAll:
                if issubclass(err[0], subtest.failureException):
                    self._write_status(subtest, "FAIL")
                else:
                    self._write_status(subtest, "ERROR")
            elif self.dots:
                if issubclass(err[0], subtest.failureException):
                    self.stream.write('F')
                else:
                    self.stream.write('E')
                self.stream.flush()
        super(TextTestResult, self).addSubTest(test, subtest, err)

    def addSuccess(self, test):
        super(TextTestResult, self).addSuccess(test)
        if self.showAll:
            self._write_status(test, "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._write_status(test, "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._write_status(test, "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._write_status(test, "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")
            self.stream.flush()
        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")
            self.stream.flush()
        elif self.dots:
            self.stream.write("u")
            self.stream.flush()

    def printErrors(self):
        if self.dots or self.showAll:
            self.stream.writeln()
            self.stream.flush()
        self.printErrorList('ERROR', self.errors)
        self.printErrorList('FAIL', self.failures)
        unexpectedSuccesses = getattr(self, 'unexpectedSuccesses', ())
        if unexpectedSuccesses:
            self.stream.writeln(self.separator1)
            for test in unexpectedSuccesses:
                self.stream.writeln(f"UNEXPECTED SUCCESS: {self.getDescription(test)}")
            self.stream.flush()

    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)
            self.stream.flush()


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")
        self.stream.flush()
        return result
main.py000064400000026227152401764000006052 0ustar00"""Unittest main program"""

import sys
import argparse
import os
import warnings

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 os.path.normpath(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):
        warnings.warn("TestProgram.usageExit() is deprecated and will be"
                      " removed in Python 3.13", DeprecationWarning)
        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
__pycache__/signals.cpython-311.pyc000064400000007471152401764000013126 0ustar00�

;/�R�|��~�ddlZddlZddlmZdZGd�de��Zej��Zd�Z	d�Z
dad�Zd
d	�Z
dS)�N)�wrapsTc��eZdZd�Zd�ZdS)�_InterruptHandlerc���d|_||_t|t��r@|tjkr
tj}n#|tjkrd�}ntd���||_	dS)NFc��dS�N�)�
unused_signum�unused_frames  �;/opt/alt/python-internal/lib/python3.11/unittest/signals.py�default_handlerz3_InterruptHandler.__init__.<locals>.default_handlers���D�zYexpected 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
)�selfr
s  r�__init__z_InterruptHandler.__init__
s������ /����o�s�+�+�	3��&�.�0�0�"(�"<��� �F�N�2�2����� �!2�3�3�3� /����rc��tjtj��}||ur|�||��|jr|�||��d|_t
���D]}|����dS)NT)r�	getsignal�SIGINTr
r�_results�keys�stop)r�signum�frame�installed_handler�results     r�__call__z_InterruptHandler.__call__s���"�,�V�]�;�;���D�(�(�
� � ���/�/�/��;�	0�� � ���/�/�/�����m�m�o�o�	�	�F��K�K�M�M�M�M�	�	rN)�__name__�
__module__�__qualname__rr$r	rrrr	s2������/�/�/�$����rrc��dt|<dS)N�)r�r#s r�registerResultr+*s���H�V���rc�R�tt�|d����Sr)�boolr�popr*s r�removeResultr/-s������V�T�*�*�+�+�+rc��t�Stjtj��}t	|��atjtjt��dSdSr)�_interrupt_handlerrrrr)r
s r�installHandlerr21sK���!� �*�6�=�9�9��.��?�?���
�f�m�%7�8�8�8�8�8�"�!rc�����t����fd���}|St�+tjtjtj��dSdS)Nc����tjtj��}t��	�|i|��tjtj|��S#tjtj|��wxYwr)rrr�
removeHandler)�args�kwargs�initial�methods   �r�innerzremoveHandler.<locals>.inner;sf����&�v�}�5�5�G��O�O�O�
6��v�t�.�v�.�.��
�f�m�W�5�5�5�5���
�f�m�W�5�5�5�5���s�A�!A7)rr1rrr)r9r:s` rr5r59sg���
��	�v���	6�	6�	6�	6�
��	6����%��
�f�m�%7�%H�I�I�I�I�I�&�%rr)r�weakref�	functoolsr�
__unittest�objectr�WeakKeyDictionaryrr+r/r1r2r5r	rr�<module>r@s���
�
�
�
�����������
�
����������@%�7�$�&�&�����,�,�,���9�9�9�J�J�J�J�J�Jr__pycache__/result.cpython-311.opt-2.pyc000064400000025700152401764000013737 0ustar00�

Vs�L�R�\��f�	ddlZddlZddlZddlmZddlmZdZd�ZdZ	dZ
Gd	�d
e��ZdS)�N�)�util��wrapsTc�<��t����fd���}|S)Nc�f��t|dd��r|����|g|�Ri|��S)N�failfastF)�getattr�stop)�self�args�kw�methods   ��:/opt/alt/python-internal/lib/python3.11/unittest/result.py�innerzfailfast.<locals>.inner
sD����4��U�+�+�	��I�I�K�K�K��v�d�(�T�(�(�(�R�(�(�(�r)rrs` rr	r	s3���
�6�]�]�)�)�)�)��]�)��Lrz
Stdout:
%sz
Stderr:
%sc���eZdZ	dZdZdZdd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
ed���Zed���Zd
�Zd�Zd�Zd�Zed���Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS)�
TestResultNFc��d|_g|_g|_d|_g|_g|_g|_d|_d|_d|_	d|_
d|_tj
|_tj|_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�stream�descriptions�	verbositys    r�__init__zTestResult.__init__&s|����
���
������
���� "���#%�� ����������"���"��� #�
��� #�
���"����rc��dS�N��rs r�printErrorszTestResult.printErrors7s��-�-rc�^�	|xjdz
c_d|_|���dS)NrF)rr&�_setupStdout�r�tests  r�	startTestzTestResult.startTest:s5��7��
�
���
�
�"����������rc���|jr[|j�0tj��|_tj��|_|jt
_|jt
_dSdSr,)rr �io�StringIOrr!r"r$r.s rr1zTestResult._setupStdout@sS���;�	-��"�*�&(�k�m�m��#�&(�k�m�m��#��,�C�J��,�C�J�J�J�	-�	-rc��dSr,r-r.s r�startTestRunzTestResult.startTestRunH���	�	rc�>�	|���d|_dS)NF)�_restoreStdoutr&r2s  r�stopTestzTestResult.stopTestNs%��5�������"����rc��|j�rI|jr�tj���}tj���}|r<|�d��s|dz
}|j�t|z��|r<|�d��s|dz
}|j
�t|z��|jt_|j
t_|j�
d��|j���|j�
d��|j���dSdS)N�
r)rr&r!r"�getvaluer$�endswithr#�write�STDOUT_LINEr%�STDERR_LINEr�seek�truncater )r�output�errors   rr<zTestResult._restoreStdoutSs>���;�	+��!�

E���,�,�.�.���
�+�+�-�-���F�!�?�?�4�0�0�'��$����)�/�/��f�0D�E�E�E��E� �>�>�$�/�/�&���
���)�/�/��e�0C�D�D�D��.�C�J��.�C�J���$�$�Q�'�'�'���(�(�*�*�*���$�$�Q�'�'�'���(�(�*�*�*�*�*�%	+�	+rc��dSr,r-r.s r�stopTestRunzTestResult.stopTestRunhr:rc�v�	|j�||�||��f��d|_dS�NT)r�append�_exc_info_to_stringr&�rr3�errs   r�addErrorzTestResult.addErrornsB��	�	
����D�$�":�":�3��"E�"E�F�G�G�G�!����rc�v�	|j�||�||��f��d|_dSrL)rrMrNr&rOs   r�
addFailurezTestResult.addFailurevs@��	'��
���d�D�$<�$<�S�$�$G�$G�H�I�I�I�!����rc��	|��t|dd��r|���t|d|j��r|j}n|j}|�||�||��f��d|_dSdS)Nr	FrT)	r
r�
issubclass�failureExceptionrrrMrNr&)rr3�subtestrPrs     r�
addSubTestzTestResult.addSubTest}s���	��?��t�Z��/�/�
��	�	�����#�a�&�$�"7�8�8�
%���������M�M�7�D�$<�$<�S�$�$G�$G�H�I�I�I�!%�D�����?rc��	dSr,r-r2s  r�
addSuccesszTestResult.addSuccess�s
��7��rc�@�	|j�||f��dSr,)rrM)rr3�reasons   r�addSkipzTestResult.addSkip�s%��,�����T�6�N�+�+�+�+�+rc�h�	|j�||�||��f��dSr,)rrMrNrOs   r�addExpectedFailurezTestResult.addExpectedFailure�sB��=���$�$�
�4�+�+�C��6�6�7�	9�	9�	9�	9�	9rc�<�	|j�|��dSr,)rrMr2s  r�addUnexpectedSuccesszTestResult.addUnexpectedSuccess�s"��C�� �'�'��-�-�-�-�-rc��	t|j��t|j��cxkodknco(t|d��pt|j��dkS)Nrr)�lenrr�hasattrrr.s r�
wasSuccessfulzTestResult.wasSuccessful�sm��=��T�]�#�#�s�4�;�'7�'7�<�<�<�<�1�<�<�<�<�5��T�#8�9�9�9�4��T�-�.�.�!�3�	6rc��	d|_dSrL)rr.s rrzTestResult.stop�s��9�����rc�R�	|\}}}|�||||��}tj||||jd���}t	|�����}|jr�tj�	��}tj
�	��}	|r7|�d��s|dz
}|�t|z��|	r7|	�d��s|	dz
}	|�t|	z��d�|��S)NT)�capture_locals�compactr?�)�_clean_tracebacks�	traceback�TracebackExceptionr�list�formatrr!r"r@r$rArMrCrD�join)
rrPr3�exctype�value�tb�tb_e�msgLinesrGrHs
          rrNzTestResult._exc_info_to_string�s ��L� �����
�
#�
#�G�U�B��
=�
=���+��U�B��>�4�9�9�9������
�
�&�&���;�
	5��Z�(�(�*�*�F��J�'�'�)�)�E��
6����t�,�,�#��d�N�F�����f� 4�5�5�5��
5��~�~�d�+�+�"��T�M�E�����e� 3�4�4�4��w�w�x� � � rc��d}d}|||fg}t|��h}|r�|���\}}}|r3|�|��r|j}|r|�|���||jur|�|��|r|}d}n||_|�p|j|jfD]a}	|	�]t|	��|vrL|�	t|	��|	|	jf��|�t|	�����b|��|S)NTF)�id�pop�_is_relevant_tb_level�tb_nextrV�_remove_unittest_tb_frames�
__traceback__�	__cause__�__context__rM�type�add)
rrqrrrsr3�ret�first�excs�seen�cs
          rrkzTestResult._clean_tracebacks�sC�������%��$�%���5�	�	�{���	(�#'�8�8�:�:� �W�e�R��
 ��3�3�B�7�7�
 ��Z���
 ��3�3�B�7�7�
 ��$�/�/�/��/�/��3�3�3��
)������&(��#�� ��/�5�+<�=�(�(�A��}��A���d�):�):����T�!�W�W�a���$A�B�B�B�����A�������)�	(�*�
rc��d|jjvS)N�
__unittest)�tb_frame�	f_globals)rrss  rryz TestResult._is_relevant_tb_level�s���r�{�4�4�4rc��	d}|r5|�|��s |}|j}|r|�|��� |�	d|_dSdSr,)ryrz)rrs�prevs   rr{z%TestResult._remove_unittest_tb_frames�sq��	����	��3�3�B�7�7�	��D���B��	��3�3�B�7�7�	����D�L�L�L��rc��dtj|j��|jt	|j��t	|j��fzS)Nz!<%s run=%i errors=%i failures=%i>)r�strclass�	__class__rrcrrr.s r�__repr__zTestResult.__repr__�s@��3��
�d�n�-�-�t�}�c�$�+�>N�>N��D�M�"�"�$�$�	%r)NNN)�__name__�
__module__�__qualname__�_previousTestClass�_testRunEntered�_moduleSetUpFailedr*r/r4r1r9r=r<rJr	rQrSrXrZr]r_rarerrNrkryr{r�r-rrrrs�������	����O���#�#�#�#�".�.�.����-�-�-����#�#�#�
+�+�+�*����"�"��X�"��"�"��X�"�&�&�&�"
�
�
�,�,�,�9�9�9�
�.�.��X�.�6�6�6����!�!�!�,���85�5�5�
 �
 �
 �%�%�%�%�%rr)
r6r!rlrjr�	functoolsrr�r	rCrD�objectrr-rr�<module>r�s����	�	�	�	�
�
�
�
�����������������
�
��������\%�\%�\%�\%�\%��\%�\%�\%�\%�\%r__pycache__/async_case.cpython-311.pyc000064400000015533152401764000013574 0ustar00�

��Hx�N�ddlZddlZddlZddlZddlmZGd�de��ZdS)�N�)�TestCasec���eZdZd�fd�	Zd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�fd�	Z�fd�Zd�Z�xZS)�IsolatedAsyncioTestCase�runTestc���t���|��d|_tj��|_dS�N)�super�__init__�_asyncioRunner�contextvars�copy_context�_asyncioTestContext)�self�
methodName�	__class__s  ��>/opt/alt/python-internal/lib/python3.11/unittest/async_case.pyrz IsolatedAsyncioTestCase.__init__#s:���
������$�$�$�"���#.�#;�#=�#=�� � � �c��
K�dSr	��rs r�
asyncSetUpz"IsolatedAsyncioTestCase.asyncSetUp(������rc��
K�dSr	rrs r�
asyncTearDownz%IsolatedAsyncioTestCase.asyncTearDown+rrc�(�|j|g|�Ri|��dSr	)�
addCleanup�r�func�args�kwargss    r�addAsyncCleanupz'IsolatedAsyncioTestCase.addAsyncCleanup.s)��	���$�����1�&�1�1�1�1�1rc��K�t|��}	|j}|j}n/#t$r"t	d|j�d|j�d���d�wxYw||���d{V��}|�||ddd��|S)z�Enters the supplied asynchronous context manager.

        If successful, also adds its __aexit__ method as a cleanup
        function and returns the result of the __aenter__ method.
        �'�.zC' object does not support the asynchronous context manager protocolN)�type�
__aenter__�	__aexit__�AttributeError�	TypeError�
__module__�__qualname__r")r�cm�cls�enter�exit�results      r�enterAsyncContextz)IsolatedAsyncioTestCase.enterAsyncContext=s������2�h�h��	'��N�E��=�D�D���	'�	'�	'��U���U�U��1A�U�U�U���"&�
'�	'�����u�R�y�y�����������T�2�t�T�4�8�8�8��
s	�"�,Ac��|j���|j�|j��|�|j��dSr	)r�get_loopr�run�setUp�
_callAsyncrrs r�
_callSetUpz"IsolatedAsyncioTestCase._callSetUpQsL��	
��$�$�&�&�&�� �$�$�T�Z�0�0�0������(�(�(�(�(rc�t�|�|���"tjd|�d�td���dSdS)NzFIt is deprecated to return a value that is not None from a test case (�)�)�
stacklevel)�_callMaybeAsync�warnings�warn�DeprecationWarning)r�methods  r�_callTestMethodz'IsolatedAsyncioTestCase._callTestMethodYsd������'�'�3��M�2�(.�2�2�2�3E�RS�
U�
U�
U�
U�
U�
U�4�3rc�x�|�|j��|j�|j��dSr	)r7rrr5�tearDownrs r�
_callTearDownz%IsolatedAsyncioTestCase._callTearDown^s6������*�+�+�+�� �$�$�T�]�3�3�3�3�3rc�(�|j|g|�Ri|��dSr	)r=)r�functionr r!s    r�_callCleanupz$IsolatedAsyncioTestCase._callCleanupbs+�����X�7��7�7�7��7�7�7�7�7rc��|j�
Jd���tj|��s
J|�d����|j�||i|��|j���S)N�!asyncio runner is not initializedz is not an async function��context�r�inspect�iscoroutinefunctionr5rrs    rr7z"IsolatedAsyncioTestCase._callAsyncesz���"�.�.�0S�.�.�.��*�4�0�0�V�V�T�2V�2V�2V�V�V�0��"�&�&��D�$�!�&�!�!��,�'�
�
�	
rc���|j�
Jd���tj|��r'|j�||i|��|j���S|jj|g|�Ri|��S)NrJrKrMrs    rr=z'IsolatedAsyncioTestCase._callMaybeAsyncms����"�.�.�0S�.�.�.��&�t�,�,�	G��&�*�*���d�%�f�%�%��0�+���
�
0�4�+�/��F�t�F�F�F�v�F�F�Frc�`�|j�
Jd���tjd���}||_dS)Nz%asyncio runner is already initializedT)�debug)r�asyncio�Runner�r�runners  r�_setupAsyncioRunnerz+IsolatedAsyncioTestCase._setupAsyncioRunnerws:���"�*�*�,S�*�*�*���d�+�+�+��$����rc�<�|j}|���dSr	)r�closerUs  r�_tearDownAsyncioRunnerz.IsolatedAsyncioTestCase._tearDownAsyncioRunner|s���$���������rNc����|���	t���|��|���S#|���wxYwr	)rWr
r5rZ)rr1rs  �rr5zIsolatedAsyncioTestCase.run�sZ���� � �"�"�"�	*��7�7�;�;�v�&�&��'�'�)�)�)�)��D�'�'�)�)�)�)���s� A�A"c���|���t�����|���dSr	)rWr
rRrZ)rrs �rrRzIsolatedAsyncioTestCase.debug�s>���� � �"�"�"�
���
�
�����#�#�%�%�%�%�%rc�@�|j�|���dSdSr	)rrZrs r�__del__zIsolatedAsyncioTestCase.__del__�s+����*��'�'�)�)�)�)�)�+�*r)rr	)�__name__r+r,rrrr"r2r8rBrErHr7r=rWrZr5rRr^�
__classcell__)rs@rrr	s=�������4>�>�>�>�>�>�

�
�
�
�
�
�
2�
2�
2����()�)�)�U�U�U�
4�4�4�8�8�8�
�
�
�G�G�G�%�%�%�
���*�*�*�*�*�*�&�&�&�&�&�
*�*�*�*�*�*�*rr)rSr
rNr>�caserrrrr�<module>rbs|������������������������E*�E*�E*�E*�E*�h�E*�E*�E*�E*�E*r__pycache__/runner.cpython-311.pyc000064400000040162152401764000012771 0ustar00�

����yWc���dZddlZddlZddlZddlmZddlmZddlm	Z	dZ
Gd�d	e��ZGd
�dej
��ZGd�d
e��ZdS)z
Running tests�N�)�result)�_SubTest)�registerResultTc�&�eZdZdZd�Zd�Zdd�ZdS)�_WritelnDecoratorz@Used to decorate file-like objects with a handy 'writeln' methodc��||_dS�N)�stream)�selfrs  �:/opt/alt/python-internal/lib/python3.11/unittest/runner.py�__init__z_WritelnDecorator.__init__s
�������c�R�|dvrt|���t|j|��S)N)r�__getstate__)�AttributeError�getattrr)r�attrs  r
�__getattr__z_WritelnDecorator.__getattr__s.���-�-�-� ��&�&�&��t�{�4�(�(�(rNc�^�|r|�|��|�d��dS�N�
)�write)r�args  r
�writelnz_WritelnDecorator.writelns1���	��J�J�s�O�O�O��
�
�4�����rr
)�__name__�
__module__�__qualname__�__doc__rrr�rr
rrsL������J�J����)�)�)�
�����rrc���eZdZdZdZdZ�fd�Zd�Z�fd�Zd�Z	�fd�Z
�fd	�Z�fd
�Z�fd�Z
�fd�Z�fd
�Z�fd�Zd�Zd�Z�xZS)�TextTestResultzhA test result class that can print formatted text results to a stream.

    Used by TextTestRunner.
    zF======================================================================zF----------------------------------------------------------------------c���tt|���|||��||_|dk|_|dk|_||_d|_dS)NrT)�superr"rr�showAll�dots�descriptions�_newline)rrr'�	verbosity�	__class__s    �r
rzTextTestResult.__init__&sU���
�n�d�#�#�,�,�V�\�9�M�M�M���� �1�}�����N��	�(�����
�
�
rc��|���}|jr&|r$d�t|��|f��St|��Sr)�shortDescriptionr'�join�str)r�test�doc_first_lines   r
�getDescriptionzTextTestResult.getDescription.sN���.�.�0�0����	��	��9�9�c�$�i�i��8�9�9�9��t�9�9�rc�8��tt|���|��|jri|j�|�|����|j�d��|j���d|_dSdS)N� ... F)	r$r"�	startTestr%rrr1�flushr(�rr/r*s  �r
r4zTextTestResult.startTest5s����
�n�d�#�#�-�-�d�3�3�3��<�	"��K���d�1�1�$�7�7�8�8�8��K���g�&�&�&��K������!�D�M�M�M�		"�	"rc��t|t��}|s|jr�|js|j���|r|j�d��|j�|�|����|j�d��|j�|��|j���d|_dS)Nz  r3T)�
isinstancerr(rrrr1r5)rr/�status�
is_subtests    r
�
_write_statuszTextTestResult._write_status=s�����h�/�/�
��	'���	'��=�
&���#�#�%�%�%��
(���!�!�$�'�'�'��K���d�1�1�$�7�7�8�8�8��K���g�&�&�&�����F�#�#�#����������
�
�
rc����|��|jrIt|d|j��r|�|d��n�|�|d��np|jrit|d|j��r|j�d��n|j�d��|j���tt|���
|||��dS)Nr�FAIL�ERROR�F�E)r%�
issubclass�failureExceptionr;r&rrr5r$r"�
addSubTest)rr/�subtest�errr*s    �r
rCzTextTestResult.addSubTestJs�����?��|�

$��c�!�f�g�&>�?�?�9��&�&�w��7�7�7�7��&�&�w��8�8�8�8���
$��c�!�f�g�&>�?�?�+��K�%�%�c�*�*�*�*��K�%�%�c�*�*�*���!�!�#�#�#�
�n�d�#�#�.�.�t�W�c�B�B�B�B�Brc���tt|���|��|jr|�|d��dS|jr5|j�d��|j���dSdS)N�ok�.)	r$r"�
addSuccessr%r;r&rrr5r6s  �r
rIzTextTestResult.addSuccessYs����
�n�d�#�#�.�.�t�4�4�4��<�	 ����t�T�*�*�*�*�*�
�Y�	 ��K���c�"�"�"��K��������	 �	 rc���tt|���||��|jr|�|d��dS|jr5|j�d��|j���dSdS)Nr>r@)	r$r"�addErrorr%r;r&rrr5�rr/rEr*s   �r
rKzTextTestResult.addErroras����
�n�d�#�#�,�,�T�3�7�7�7��<�	 ����t�W�-�-�-�-�-�
�Y�	 ��K���c�"�"�"��K��������	 �	 rc���tt|���||��|jr|�|d��dS|jr5|j�d��|j���dSdS)Nr=r?)	r$r"�
addFailurer%r;r&rrr5rLs   �r
rNzTextTestResult.addFailureis����
�n�d�#�#�.�.�t�S�9�9�9��<�	 ����t�V�,�,�,�,�,�
�Y�	 ��K���c�"�"�"��K��������	 �	 rc�6��tt|���||��|jr+|�|d�|����dS|jr5|j�d��|j�	��dSdS)Nz
skipped {0!r}�s)
r$r"�addSkipr%r;�formatr&rrr5)rr/�reasonr*s   �r
rQzTextTestResult.addSkipqs����
�n�d�#�#�+�+�D�&�9�9�9��<�	 ����t�_�%;�%;�F�%C�%C�D�D�D�D�D�
�Y�	 ��K���c�"�"�"��K��������	 �	 rc�J��tt|���||��|jr5|j�d��|j���dS|jr5|j�d��|j���dSdS)Nzexpected failure�x)	r$r"�addExpectedFailurer%rrr5r&rrLs   �r
rVz!TextTestResult.addExpectedFailureys����
�n�d�#�#�6�6�t�S�A�A�A��<�	 ��K��� 2�3�3�3��K��������
�Y�	 ��K���c�"�"�"��K��������	 �	 rc�H��tt|���|��|jr5|j�d��|j���dS|jr5|j�d��|j���dSdS)Nzunexpected success�u)	r$r"�addUnexpectedSuccessr%rrr5r&rr6s  �r
rYz#TextTestResult.addUnexpectedSuccess�s����
�n�d�#�#�8�8��>�>�>��<�	 ��K��� 4�5�5�5��K��������
�Y�	 ��K���c�"�"�"��K��������	 �	 rc��|js|jr2|j���|j���|�d|j��|�d|j��t|dd��}|ro|j�|j	��|D]2}|j�d|�
|�������3|j���dSdS)Nr>r=�unexpectedSuccessesr zUNEXPECTED SUCCESS: )r&r%rrr5�printErrorList�errors�failuresr�
separator1r1)rr[r/s   r
�printErrorszTextTestResult.printErrors�s���9�	 ���	 ��K���!�!�!��K���������G�T�[�1�1�1����F�D�M�2�2�2�%�d�,A�2�F�F���	 ��K�����0�0�0�+�
X�
X����#�#�$V�4�;N�;N�t�;T�;T�$V�$V�W�W�W�W��K��������		 �	 rc�b�|D]�\}}|j�|j��|j�|�d|�|������|j�|j��|j�d|z��|j�����dS)Nz: z%s)rrr_r1�
separator2r5)r�flavourr]r/rEs     r
r\zTextTestResult.printErrorList�s����	 �	 �I�D�#��K�����0�0�0��K���G�G�G�D�4G�4G��4M�4M�4M� N�O�O�O��K�����0�0�0��K����s�
�+�+�+��K�������	 �	 r)rrrrr_rbrr1r4r;rCrIrKrNrQrVrYr`r\�
__classcell__)r*s@r
r"r"sW����������J��J���������"�"�"�"�"����
C�
C�
C�
C�
C� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � rr"c�4�eZdZdZeZ		d
dd�d�Zd�Zd	�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��|�tj}t|��|_||_||_||_||_||_||_	|�	||_
dSdS)z�Construct a TextTestRunner.

        Subclasses should accept **kwargs to ensure compatibility as the
        interface changes.
        N)�sys�stderrrrr'r)�failfast�bufferrg�warnings�resultclass)	rrr'r)rkrlrnrmrgs	         r
rzTextTestRunner.__init__�sf���>��Z�F�'��/�/���(���"��� ��
����"��� ��
��"�*�D����#�"rc�N�|�|j|j|j��Sr
)rnrr'r))rs r
�_makeResultzTextTestRunner._makeResult�s!�������T�->���O�O�Orc���|���}t|��|j|_|j|_|j|_tj��5|jr>tj|j��|jdvrtjdtd���tj��}t|dd��}|�
|��	||��t|dd��}|�
|��n##t|dd��}|�|��wwxYwtj��}ddd��n#1swxYwY||z
}|j
��t|d��r|j�|j��|j}|j�d	||d
krdpd|fz��|j���d
x}	x}
}	t't(|j|j|jf��}|\}	}
}n#t0$rYnwxYwg}
|j��sw|j�d��t)|j��t)|j��}}|r|
�d|z��|r|
�d|z��n|j�d��|r|
�d|z��|	r|
�d|	z��|
r|
�d|
z��|
r2|j�dd�|
���d���n|j�d��|j���|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 %.3fsrrP�r�FAILEDzfailures=%dz	errors=%d�OKz
skipped=%dzexpected failures=%dzunexpected successes=%dz (z, �)r) rprrkrlrgrm�catch_warnings�simplefilter�filterwarnings�DeprecationWarning�time�perf_counterrr`�hasattrrrrb�testsRun�map�len�expectedFailuresr[�skippedr�
wasSuccessfulrr^r]�appendr-r5)rr/r�	startTimerwrx�stopTime�	timeTaken�run�
expectedFailsr[r��results�infos�failed�erroreds                r
r�zTextTestRunner.run�s���!�!�#�#���v�����-������
��>���
�
$�
&�
&�	+�	+��}�
F��%�d�m�4�4�4��=�$9�9�9��+�H�%7�$D�F�F�F�F��)�+�+�I�"�6�>�4�@�@�L��'������
"���V����%�f�m�T�B�B���*��K�M�M�M���&�f�m�T�B�B���*��K�M�M�M�M�+�����(�*�*�H�/	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+�0�y�(�	��������6�<�(�(�	3��K���� 1�2�2�2��o������4� �#��(�"2�s�"8�b�)�D�E�	F�	F�	F��������89�9�
�9�+�g�	B��#�� 7� &� :� &�� 0�1�1�G�;B�7�M�.�����	�	�	��D�	����
��#�v�#�%�%�	$��K���h�'�'�'�!�&�/�2�2�C��
�4F�4F�G�F��
5����]�V�3�4�4�4��
4����[�7�2�3�3�3���K���d�#�#�#��	1��L�L���/�0�0�0��	A��L�L�/�-�?�@�@�@��	J��L�L�2�5H�H�I�I�I��	$��K����4�9�9�U�+;�+;�+;�+;� =�>�>�>�>��K���d�#�#�#���������
s=�A6D=�C;�D=�; D�D=�=E�E�'H�
H�H)NTrFFNN)	rrrrr"rnrrpr�r rr
rfrf�sr��������
!�K�AB�JN�+�#�+�+�+�+�+�(P�P�P�G�G�G�G�Grrf)rrir�rmryr�caser�signalsr�
__unittest�objectr�
TestResultr"rfr rr
�<module>r�s�����
�
�
�
���������������������#�#�#�#�#�#�
�
�
�
�
�
�
��
�
�
� @ �@ �@ �@ �@ �V�&�@ �@ �@ �Ff�f�f�f�f�V�f�f�f�f�fr__pycache__/suite.cpython-311.pyc000064400000042736152401764000012622 0ustar00�

!�#�%,
���dZddlZddlmZddlmZdZd�ZGd�d	e��ZGd
�de��Z	Gd�de��Z
d
�ZGd�de��ZdS)�	TestSuite�N�)�case)�utilTc�>�t||d���}|��dS)Nc��dS�N�r
��9/opt/alt/python-internal/lib/python3.11/unittest/suite.py�<lambda>z!_call_if_exists.<locals>.<lambda>s���r)�getattr)�parent�attr�funcs   r�_call_if_existsrs$���6�4���.�.�D��D�F�F�F�F�Frc�Z�eZdZdZdZdd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�ZdS)�
BaseTestSuitezNA simple test suite that doesn't provide class or module shared fixtures.
    Tr
c�L�g|_d|_|�|��dS�Nr)�_tests�_removed_tests�addTests)�self�testss  r�__init__zBaseTestSuite.__init__s)���������
�
�e�����rc�\�dtj|j���dt|���d�S)N�<z tests=�>)r�strclass�	__class__�list�rs r�__repr__zBaseTestSuite.__repr__s+���"&�-���"?�"?�"?�"?��d�����L�Lrc�z�t||j��stSt|��t|��kSr	)�
isinstancer!�NotImplementedr")r�others  r�__eq__zBaseTestSuite.__eq__s3���%���0�0�	"�!�!��D�z�z�T�%�[�[�(�(rc�*�t|j��Sr	)�iterrr#s r�__iter__zBaseTestSuite.__iter__"s���D�K� � � rc�P�|j}|D]}|r||���z
}�|Sr	)r�countTestCases)r�cases�tests   rr.zBaseTestSuite.countTestCases%s=���#���	/�	/�D��
/���,�,�.�.�.����rc�@�t|��s/td�t|�������t	|t
��r0t
|tjtf��rtd���|j
�|��dS)Nz{} is not callablezNTestCases and TestSuites must be instantiated before passing them to addTest())�callable�	TypeError�format�reprr&�type�
issubclassr�TestCaserr�append�rr0s  r�addTestzBaseTestSuite.addTest,s�����~�~�	E��0�7�7��T�
�
�C�C�D�D�D��d�D�!�!�	@�j��26�-��1K�'M�'M�	@��?�@�@�
@�����4� � � � � rc��t|t��rtd���|D]}|�|���dS)Nz0tests must be an iterable of tests, not a string)r&�strr3r;)rrr0s   rrzBaseTestSuite.addTests6sR���e�S�!�!�	P��N�O�O�O��	�	�D��L�L������	�	rc��t|��D]5\}}|jrn(||��|jr|�|���6|Sr	)�	enumerate�
shouldStop�_cleanup�_removeTestAtIndex)r�result�indexr0s    r�runzBaseTestSuite.run<s\��$�T�?�?�	/�	/�K�E�4�� �
����D��L�L�L��}�
/��'�'��.�.�.���
rc��	|j|}t|d��r"|xj|���z
c_d|j|<dS#t$rYdSwxYw)z2Stop holding a reference to the TestCase at index.r.N)r�hasattrrr.r3)rrDr0s   rrBz BaseTestSuite._removeTestAtIndexEs~��
	&��;�u�%�D��t�-�.�.�
=��#�#�t�':�':�'<�'<�<�#�#�!%�D�K�������	�	�	��D�D�	���s�
A
�
A�Ac��|j|i|��Sr	�rE)r�args�kwdss   r�__call__zBaseTestSuite.__call__Ss���t�x��&��&�&�&rc�8�|D]}|����dS)�7Run the tests without collecting errors in a TestResultN)�debugr:s  rrOzBaseTestSuite.debugVs*���	�	�D��J�J�L�L�L�L�	�	rN)r
)�__name__�
__module__�__qualname__�__doc__rArr$r)r,r.r;rrErBrLrOr
rrrrs����������H�����
M�M�M�)�)�)�
!�!�!����!�!�!�������&�&�&�'�'�'�����rrc�R�eZdZdZd
d�Zd�Zd�Zd�Zd�Z	dd	�Z		dd
�Z
d�Zd�ZdS)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.
    Fc�l�d}t|dd��dur	dx|_}t|��D]�\}}|jrn�t	|��rv|�||��|�||��|�||��|j|_	t|jdd��st|dd��r��|s||��n|�
��|jr|�|����|r2|�d|��|�
|��d|_|S)NF�_testRunEnteredT�_classSetupFailed�_moduleSetUpFailed)rrVr?r@�_isnotsuite�_tearDownPreviousClass�_handleModuleFixture�_handleClassSetUpr!�_previousTestClassrOrArB�_handleModuleTearDown)rrCrO�topLevelrDr0s      rrEz
TestSuite.runfsb�����6�,�e�4�4��=�=�04�4�F�"�X�$�T�?�?�	/�	/�K�E�4�� �
����4� � �
��+�+�D�&�9�9�9��)�)�$��7�7�7��&�&�t�V�4�4�4�,0�N��)��D�N�,?��G�G���F�$8�%�@�@����
���V������
�
�����}�
/��'�'��.�.�.���	+��'�'��f�5�5�5��&�&�v�.�.�.�%*�F�"��
rc�N�t��}|�|d��dS)rNTN)�_DebugResultrE)rrOs  rrOzTestSuite.debug�s%���������������rc���t|dd��}|j}||krdS|jrdSt|dd��rdSd}	d|_n#t$rYnwxYwt|dd��}t|dd��}|��t|d��		|��nt#t$rg}t|t��r�d}	d|_n#t$rYnwxYwtj
|��}	|�||d|	��Yd}~nd}~wwxYw|r6|�4|��|jD]"}
|�||
dd|	|
�	���#t|d
��dS#t|d
��wxYwdS)Nr]�__unittest_skip__F�
setUpClass�doClassCleanups�_setupStdoutTr��info�_restoreStdout)
rr!rXrWr3r�	Exceptionr&rarr �"_createClassOrModuleLevelException�tearDown_exceptions)rr0rC�
previousClass�currentClass�failedrdre�e�	className�exc_infos           rr\zTestSuite._handleClassSetUp�s8����(<�d�C�C�
��~���=�(�(��F��$�	��F��<�!4�e�<�<�	��F���	�-2�L�*�*���	�	�	�
�D�	����
�\�<��>�>�
�!�,�0A�4�H�H���!��F�N�3�3�3�
:�
G��J�L�L�L�L�� �G�G�G�!�&�,�7�7���!�F��9=��6�6��$���������� $�
�l� ;� ;�I��;�;�F�A�<H�<E�G�G�G�G�G�G�G�G�����G�����/�o�9�#�O�%�%�%�$0�$D�/�/���?�?� &����\�9�%-�@�/�/�/�/� ��(8�9�9�9�9�9����(8�9�9�9�9����1"�!sf�A�
A�A�
B�E�
D
�#D�<C�D�
C�D�C�/D�E�D
�
;E�E)c�>�d}t|dd��}|�|j}|S)Nr])rrQ)rrC�previousModulerms    r�_get_previous_modulezTestSuite._get_previous_module�s-������(<�d�C�C�
��$�*�5�N��rc��|�|��}|jj}||krdS|�|��d|_	t
j|}n#t$rYdSwxYwt|dd��}|��t|d��		|��nL#t$r?}t|t��r�d|_|�
||d|��Yd}~nd}~wwxYw|jrD	tj��n/#t$r"}|�
||d|��Yd}~nd}~wwxYwt|d��dS#t|d��wxYwdS)NF�setUpModulerfTri)rur!rQr^rX�sys�modules�KeyErrorrrrjr&rarkr�doModuleCleanups)rr0rCrt�
currentModule�modulerwrps        rr[zTestSuite._handleModuleFixture�s���2�2�6�:�:����1�
��N�*�*��F��"�"�6�*�*�*�%*��!�	��[��/�F�F���	�	�	��F�F�	�����f�m�T�:�:���"��F�N�3�3�3�
:�K��K�M�M�M�M�� �K�K�K�!�&�,�7�7���04�F�-��;�;�F�A�<I�<I�K�K�K�K�K�K�K�K�����	K�����,�O�O��-�/�/�/�/��$�O�O�O��?�?���@M�@M�O�O�O�O�O�O�O�O�����O����
 ��(8�9�9�9�9�9����(8�9�9�9�9����)#�"sl�A�
A(�'A(�
B�E�
C$�%5C�E�C$�$
E�/D�E�
D/�
D*�%E�*D/�/E�ENc�F�|�d|�d�}|�||||��dS)Nz (�))�_addClassOrModuleLevelException)rrC�exc�method_namerrh�	errorNames       rrkz,TestSuite._createClassOrModuleLevelException�s8��"�/�/�f�/�/�/�	��,�,�V�S�)�T�J�J�J�J�Jrc�6�t|��}t|dd��}|�5t|tj��r||t|����dS|s)|�|tj����dS|�||��dS)N�addSkip)	�_ErrorHolderrr&r�SkipTestr=�addErrorrxrr)rrC�	exceptionr�rh�errorr�s       rr�z)TestSuite._addClassOrModuleLevelException�s����Y�'�'���&�)�T�2�2����:�i���#G�#G���G�E�3�y�>�>�*�*�*�*�*��
-�����s�|�~�~�6�6�6�6�6�����t�,�,�,�,�,rc�|�|�|��}|�dS|jrdS	tj|}n#t$rYdSwxYwt|d��	t
|dd��}|�Q	|��nE#t$r8}t|t��r�|�
||d|��Yd}~nd}~wwxYw	tj��nE#t$r8}t|t��r�|�
||d|��Yd}~nd}~wwxYwt|d��dS#t|d��wxYw)Nrf�tearDownModuleri)
rurXrxryrzrrrjr&rarkrr{)rrCrtr}r�rps      rr^zTestSuite._handleModuleTearDown�s����2�2�6�:�:���!��F��$�	��F�	��[��0�F�F���	�	�	��F�F�	����	���/�/�/�	6�$�V�-=�t�D�D�N��)�L�"�N�$�$�$�$�� �L�L�L�!�&�,�7�7����;�;�F�A�<L�<J�L�L�L�L�L�L�L�L�����L����
H��%�'�'�'�'���
H�
H�
H��f�l�3�3����7�7���8H�8F�H�H�H�H�H�H�H�H�����
H����
�F�$4�5�5�5�5�5��O�F�$4�5�5�5�5���so�7�
A�A�D)�-
A8�7D)�8
B:�.B5�0D)�5B:�:D)�>C�D)�
D�.D�
D)�D�D)�)D;c��t|dd��}|j}||ks|�dSt|dd��rdSt|dd��rdSt|dd��rdSt|dd��}t|dd��}|�|�dSt|d��	|�e	|��nY#t$rL}t	|t
��r�t
j|��}|�||d|��Yd}~nd}~wwxYw|�e|��|j	D]S}	t	|t
��r|	d	�t
j|��}|�||	d	d||	�
���Tt|d��dS#t|d��wxYw)Nr]rWFrXrc�
tearDownClassrerfrrgri)
rr!rrjr&rarr rkrl)
rr0rCrmrnr�rerprqrrs
          rrZz TestSuite._tearDownPreviousClasss%����(<�d�C�C�
��~���=�(�(�M�,A��F��=�"5�u�=�=�	��F��6�/��7�7�	��F��=�"5�u�=�=�	��F��
���E�E�
�!�-�1B�D�I�I��� �_�%<��F����/�/�/�	6��(�G�!�M�O�O�O�O�� �G�G�G�!�&�,�7�7��� $�
�m� <� <�I��;�;�F�A�<K�<E�G�G�G�G�G�G�G�G�����	G�����*���!�!�!� -� A�K�K�H�!�&�,�7�7�*�&�q�k�)� $�
�m� <� <�I��;�;�F�H�Q�K�<K�<E�AI�<�K�K�K�K�

�F�$4�5�5�5�5�5��O�F�$4�5�5�5�5���s8�E5�
B#�"E5�#
C9�-AC4�/E5�4C9�9A*E5�5F)Fr	)
rPrQrRrSrErOr\rur[rkr�r^rZr
rrrr\s�������������B���,:�,:�,:�\���#:�#:�#:�L9=�K�K�K�K�.2�
-�
-�
-�
-�!6�!6�!6�F(6�(6�(6�(6�(6rc�F�eZdZdZdZd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�ZdS)r�z�
    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.
    Nc��||_dSr	��description)rr�s  rrz_ErrorHolder.__init__Ts��&����rc��|jSr	r�r#s r�idz_ErrorHolder.idWs����rc��dSr	r
r#s r�shortDescriptionz_ErrorHolder.shortDescriptionZs���trc��d|j�d�S)Nz<ErrorHolder description=rr�r#s rr$z_ErrorHolder.__repr__]s���15�1A�1A�1A�C�Crc�*�|���Sr	)r�r#s r�__str__z_ErrorHolder.__str__`s���w�w�y�y�rc��dSr	r
�rrCs  rrEz_ErrorHolder.runcs	��	
�rc�,�|�|��Sr	rIr�s  rrLz_ErrorHolder.__call__hs���x�x����rc��dSrr
r#s rr.z_ErrorHolder.countTestCasesks���qr)
rPrQrRrS�failureExceptionrr�r�r$r�rErLr.r
rrr�r�Hs�����������'�'�'� � � ����D�D�D����
�
�
�
 � � �����rr�c�J�	t|��n#t$rYdSwxYwdS)z?A crude way to tell apart testcases and suites with duck-typingTF)r+r3)r0s rrYrYns;����T�
�
�
�
�������t�t������5s��
 � c��eZdZdZdZdZdZdS)razCUsed by the TestSuite to hold previous class when running in debug.NF)rPrQrRrSr]rXr@r
rrraraws%������I�I������J�J�Jrra)
rSrx�rr�
__unittestr�objectrrr�rYrar
rr�<module>r�s����
�
�
�
�������������
�
����
I�I�I�I�I�F�I�I�I�Xi6�i6�i6�i6�i6�
�i6�i6�i6�X$�$�$�$�$�6�$�$�$�L��������6�����r__pycache__/mock.cpython-311.opt-1.pyc000064400000374122152401764000013356 0ustar00�

|@���pA���`�dZddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
ddlmZddlmZmZddlmZGd�d	e��Zd
�ee��D��ZdZeZd�Zd
�Zd�Zd�Zd�Z d�Z!dyd�Z"d�Z#d�Z$d�Z%d�Z&dyd�Z'd�Z(d�Z)d�Z*Gd�de+��Z,Gd�de+��Z-e-��Z.e.j/Z/e.j0Z1e.j2Z3hd �Z4d!�Z5Gd"�d#e6��Z7d$�Z8Gd%�d&e+��Z9Gd'�d(e+��Z:Gd)�d*e:��Z;ej<e;j=��Z>Gd+�d,e6��Z?d-�Z@Gd.�d/e:��ZAGd0�d1eAe;��ZBd2�ZCGd3�d4e+��ZDd5�ZEe/dddddfdd6�d7�ZF		dzd8�ZGe/dddddfdd6�d9�ZHGd:�d;e+��ZId<�ZJd=�ZKeFeH_+eIeH_LeGeH_MeKeH_Nd>eH_Od?ZPd@ZQdA�RdB�eQ�S��D����ZTdA�RdC�eQ�S��D����ZUhdD�ZVdE�ZWdF�dA�RePeQeTeUg���S��D��ZXhdG�ZYdHhZZeYeZzZ[eXeVzZ\e\e[zZ]hdI�Z^dJ�dK�dL�dM�dN�Z_e`e`e`e`dOddddPdQddOddR�
ZadS�ZbdT�ZcdU�ZddV�ZeebecedeedW�ZfdX�ZgGdY�dZe:��ZhGd[�d\ehe;��ZiGd]�d^eh��ZjGd_�d`eheB��ZkGda�dbe:��ZlGdc�dde:��ZmGde�dfemejeB��ZnGdg�dhe+��Zoeo��Zpdi�ZqGdj�dker��Zsesd�l��Zt		d{dd6�dm�Zudn�ZvGdo�dpe+��Zwexeu��exepjy��fZzda{da|dq�Z}d|ds�Z~Gdt�dueB��Zdv�Z�Gdw�dx��Z�dS)})�Mock�	MagicMock�patch�sentinel�DEFAULT�ANY�call�create_autospec�	AsyncMock�
FILTER_DIR�NonCallableMock�NonCallableMagicMock�	mock_open�PropertyMock�seal�N)�iscoroutinefunction)�CodeType�
ModuleType�
MethodType)�	safe_repr)�wraps�partial)�RLockc��eZdZdZdS)�InvalidSpecErrorz8Indicates that an invalid value was used as a mock spec.N��__name__�
__module__�__qualname__�__doc__���8/opt/alt/python-internal/lib/python3.11/unittest/mock.pyrr)s������B�B�B�Br"rc�<�h|]}|�d���|��S��_��
startswith)�.0�names  r#�	<setcomp>r+-s)��H�H�H�d�4�?�?�3�3G�3G�H�T�H�H�Hr"Tc���t|��rt|t��sdSt|d��rt	|d��}t|��pt
j|��S)NF�__func__)�_is_instance_mock�
isinstancer
�hasattr�getattrr�inspect�isawaitable��objs r#�
_is_async_objr65sg�������j��i�&@�&@���u��s�J���'��c�:�&�&���s�#�#�?�w�':�3�'?�'?�?r"c�F�t|dd��rt|��SdS)N�__code__F)r1r)�funcs r#�_is_async_funcr:=s)���t�Z��&�&��"�4�(�(�(��ur"c�F�tt|��t��S�N)�
issubclass�typerr4s r#r.r.Ds���d�3�i�i��1�1�1r"c��t|t��p)t|t��ot|t��Sr<)r/�
BaseExceptionr>r=r4s r#�
_is_exceptionrAJs6���3�
�&�&�	A��3����@�*�S�-�"@�"@�r"c�^�t|t��rt|d��r|jS|S�N�mock)r/�
FunctionTypesr0rDr4s r#�
_extract_mockrFQs3���#�}�%�%��'�#�v�*>�*>���x���
r"c��t|t��r|s
|j}d}njt|ttf��rt|t��rd}|j}n/t|t��s	|j}n#t$rYdSwxYw|rt|d��}n|}	|tj|��fS#t$rYdSwxYw)z�
    Given an arbitrary, possibly callable object, try to create a suitable
    signature object.
    Return a (reduced func, signature) tuple, or None.
    TN)
r/r>�__init__�classmethod�staticmethodr-rE�__call__�AttributeErrorrr2�	signature�
ValueError)r9�as_instance�eat_self�sig_funcs    r#�_get_signature_objectrRZs����$�����k���}�����	�D�;��5�	6�	6���d�K�(�(�	��H��}���
��m�
,�
,��	��=�D�D���	�	�	��4�4�	�������4��&�&�������W�&�x�0�0�0�0�������t�t����s$�3A;�;
B	�B	�"B8�8
C�CFc���t|||�����dS�\}��fd�}t||��|t|��_�t|��_dS)Nc�"���j|i|��dSr<��bind)�self�args�kwargs�sigs   �r#�checksigz"_check_signature.<locals>.checksig�� ������$�!�&�!�!�!�!�!r")rR�_copy_func_detailsr>�_mock_check_sig�
__signature__)r9rD�	skipfirst�instancer[rZs     @r#�_check_signaturerb}sr���
��h�	�
:�
:�C�
�{����I�D�#�"�"�"�"�"��t�X�&�&�&�!)�D��J�J��"�D��J�J���r"c	�p�dD]2}	t||t||�����##t$rY�/wxYwdS)N)rr �__text_signature__r�__defaults__�__kwdefaults__)�setattrr1rL)r9�funcopy�	attributes   r#r]r]�sa�����	�	��G�Y���i�(@�(@�A�A�A�A���	�	�	��D�	����
�s�&�
3�3c���t|t��rdSt|tttf��rt|j��St|dd���dSdS)NTrKF)r/r>rJrIr�	_callabler-r1r4s r#rkrk�s^���#�t�����t��#��k�:�>�?�?�'����&�&�&��s�J��%�%�1��t��5r"c�<�t|��ttfvSr<)r>�list�tupler4s r#�_is_listro�s����9�9��u�
�%�%r"c��t|t��st|dd��duS|f|jzD]}|j�d���dS� dS)ztGiven an object, return True if the object is callable.
    For classes, return True if instances would be callable.rKNTF)r/r>r1�__mro__�__dict__�get)r5�bases  r#�_instance_callableru�sn���c�4� � �:��s�J��-�-�T�9�9�����$�����=���Z�(�(�4��4�4�5��5r"c�0��t|t��}t|||��}|�|S|\}��fd�}t||��|j}|���sd}||d�}d|z}	t
|	|��||}
t|
|���|
S)Nc�"���j|i|��dSr<rU)rXrYrZs  �r#r[z _set_signature.<locals>.checksig�r\r"rh)�
_checksig_rDzYdef %s(*args, **kwargs):
    _checksig_(*args, **kwargs)
    return mock(*args, **kwargs))r/r>rRr]r�isidentifier�exec�_setup_func)rD�originalrar`�resultr9r[r*�context�srcrhrZs           @r#�_set_signaturer��s����
�8�T�*�*�I�
"�8�X�y�
A�
A�F�
�~����I�D�#�"�"�"�"�"��t�X�&�&�&���D���������%�t�4�4�G�$�&*�+�C�	�#�w�����d�m�G����s�#�#�#��Nr"c�������_�fd�}�fd�}�fd�}�fd�}�fd�}�fd�}�fd�}	��fd�}
d	�_d
�_d�_t	���_t	���_t	���_�j�_�j	�_	�j
�_
|�_|�_|�_
|	�_|
�_|�_|�_|�_|�_��_dS)Nc����j|i|��Sr<)�assert_called_with�rXrYrDs  �r#r�z'_setup_func.<locals>.assert_called_with�����&�t�&��7��7�7�7r"c����j|i|��Sr<)�
assert_calledr�s  �r#r�z"_setup_func.<locals>.assert_called�s���!�t�!�4�2�6�2�2�2r"c����j|i|��Sr<)�assert_not_calledr�s  �r#r�z&_setup_func.<locals>.assert_not_called�s���%�t�%�t�6�v�6�6�6r"c����j|i|��Sr<)�assert_called_oncer�s  �r#r�z'_setup_func.<locals>.assert_called_once�r�r"c����j|i|��Sr<)�assert_called_once_withr�s  �r#r�z,_setup_func.<locals>.assert_called_once_with�s���+�t�+�T�<�V�<�<�<r"c����j|i|��Sr<)�assert_has_callsr�s  �r#r�z%_setup_func.<locals>.assert_has_calls�s���$�t�$�d�5�f�5�5�5r"c����j|i|��Sr<)�assert_any_callr�s  �r#r�z$_setup_func.<locals>.assert_any_call�s���#�t�#�T�4�V�4�4�4r"c����t���_t���_�����j}t|��r|�ur|���dSdSdSr<)�	_CallList�method_calls�
mock_calls�
reset_mock�return_valuer.)�retrhrDs ��r#r�z_setup_func.<locals>.reset_mock�so���(�{�{���&�[�[����������"���S�!�!�	�#��+�+��N�N������	�	�+�+r"Fr)rD�called�
call_count�	call_argsr��call_args_listr�r�r��side_effect�_mock_childrenr�r�r�r�r�r�r�r�r_�_mock_delegate)rhrDrZr�r�r�r�r�r�r�r�s``         r#r{r{�s������G�L�8�8�8�8�8�3�3�3�3�3�7�7�7�7�7�8�8�8�8�8�=�=�=�=�=�6�6�6�6�6�5�5�5�5�5��������G�N��G���G��&�[�[�G��$�;�;�G��"���G���,�G���*�G��!�0�G��!3�G��&=�G�#�/�G��-�G��#�G��)�G�� 1�G��!3�G���G��!�D���r"c	����tjj�_d�_d�_t���_�fd�}dD]!}t�|t||�����"dS)Nrc�:��t�j|��|i|��Sr<)r1rD)�attrrXrYrDs   �r#�wrapperz"_setup_async_mock.<locals>.wrapper
s$���'�w�t�y�$�'�'��8��8�8�8r")�assert_awaited�assert_awaited_once�assert_awaited_with�assert_awaited_once_with�assert_any_await�assert_has_awaits�assert_not_awaited)	�asyncio�
coroutines�
_is_coroutine�await_count�
await_argsr��await_args_listrgr)rDr�ris`  r#�_setup_async_mockr�s���� �+�9�D���D���D�O�$�;�;�D��
9�9�9�9�9�,�>�>�	�	��i���)�!<�!<�=�=�=�=�>�>r"c�$�d|dd�z|kS)N�__%s__����r!�r*s r#�	_is_magicr�s���d�1�R�4�j� �D�(�(r"c�$�eZdZdZd�Zd�Zd�ZdS)�_SentinelObjectz!A unique, named, sentinel object.c��||_dSr<r��rWr*s  r#rHz_SentinelObject.__init__"s
����	�	�	r"c��d|jzS�Nzsentinel.%sr��rWs r#�__repr__z_SentinelObject.__repr__%����t�y�(�(r"c��d|jzSr�r�r�s r#�
__reduce__z_SentinelObject.__reduce__(r�r"N)rrrr rHr�r�r!r"r#r�r� sG������'�'����)�)�)�)�)�)�)�)r"r�c�$�eZdZdZd�Zd�Zd�ZdS)�	_SentinelzAAccess attributes to return a named object, usable as a sentinel.c��i|_dSr<)�
_sentinelsr�s r#rHz_Sentinel.__init__.s
������r"c�l�|dkrt�|j�|t|����S)N�	__bases__)rLr��
setdefaultr�r�s  r#�__getattr__z_Sentinel.__getattr__1s3���;��� � ���)�)�$���0E�0E�F�F�Fr"c��dS)Nrr!r�s r#r�z_Sentinel.__reduce__7s���zr"N)rrrr rHr�r�r!r"r#r�r�,sJ������K�K����G�G�G�����r"r�>�
_mock_namer��_mock_parentr��_mock_new_name�_mock_new_parent�_mock_side_effect�_mock_return_valuec�x�t�|��d|z}||fd�}||fd�}t||��S)N�_mock_c�T�|j}|�t||��St||��Sr<)r�r1)rWr*�	_the_namerZs    r#�_getz"_delegating_property.<locals>._getLs/���!���;��4��+�+�+��s�D�!�!�!r"c�R�|j}|�||j|<dSt|||��dSr<)r�rrrg)rW�valuer*r�rZs     r#�_setz"_delegating_property.<locals>._setQs9���!���;�',�D�M�)�$�$�$��C��u�%�%�%�%�%r")�_allowed_names�add�property)r*r�r�r�s    r#�_delegating_propertyr�Ise�����t�����4��I��	�"�"�"�"�
 $�y�&�&�&�&��D�$���r"c��eZdZd�Zd�ZdS)r�c��t|t��st�||��St|��}t|��}||krdSt	d||z
dz��D]}||||z�}||krdS�dS)NFr�T)r/rm�__contains__�len�range)rWr��	len_value�len_self�i�sub_lists      r#r�z_CallList.__contains__^s����%��&�&�	2��$�$�T�5�1�1�1���J�J�	��t�9�9���x����5��q�(�Y�.��2�3�3�	�	�A��A�a�	�k�M�*�H��5� � ��t�t�!��ur"c�D�tjt|����Sr<)�pprint�pformatrmr�s r#r�z_CallList.__repr__ls���~�d�4�j�j�)�)�)r"N)rrrr�r�r!r"r#r�r�\s2���������*�*�*�*�*r"r�c���t|��}t|��sdS|js|js|j�|j�dS|}|�||urdS|j}|�|r||_||_|r||_||_dS)NFT)rFr.r�r�r�r�)�parentr�r*�new_name�_parents     r#�_check_and_set_parentr�ps����%� � �E��U�#�#���u�	�	��U�1��	�	�	'�	�	�	+��u��G�
�
��e����5��*���
��(�!'���'���� �#�������4r"c��eZdZd�Zd�ZdS)�	_MockIterc�.�t|��|_dSr<)�iterr5)rWr5s  r#rHz_MockIter.__init__�s����9�9����r"c�*�t|j��Sr<)�nextr5r�s r#�__next__z_MockIter.__next__�s���D�H�~�~�r"N)rrrrHr�r!r"r#r�r��s2�������������r"r�c��eZdZeZdZd�ZdS)�BaseNc��dSr<r!�rWrXrYs   r#rHz
Base.__init__�s���r")rrrrr�r�rHr!r"r#r�r��s/������ ����
�
�
�
�
r"r�c��eZdZdZe��Zd�Z			d-d�Zd�Zd.d�Z			d/d	�Z
d
�Zd�ZdZ
eeee
��Zed
���Zed��Zed��Zed��Zed��Zed��Zd�Zd�Zeee��Zd0ddd�d�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d1d �Z#d!�Z$d"�Z%d#�Z&d$�Z'd%�Z(d&�Z)d'�Z*d.d(�Z+d)�Z,d*�Z-d2d,�Z.dS)3rz A non-callable version of `Mock`c�z�|f}t|t��s]tj|g|�Ri|��j}|�d|�d����}|�t
|��r	t|f}t|j|d|j	i��}tt|���|��}|S)N�spec_set�specr )
r=�AsyncMockMixin�	_MOCK_SIG�bind_partial�	argumentsrsr6r>rr �_safe_superr�__new__)�clsrX�kw�bases�
bound_args�spec_arg�newras        r#rzNonCallableMock.__new__�s�������#�~�.�.�	.�"�/��A�d�A�A�A�b�A�A�K�J�!�~�~�j�*�.�.��2H�2H�I�I�H��#�
�h�(?�(?�#�'��-���3�<���C�K�(@�A�A�����4�4�<�<�S�A�A���r"N�Fc��|�|}|j}
||
d<||
d<||
d<||
d<d|
d<|�|}d}|
�|du}
|�|||	|
��i|
d<||
d	<d|
d
<d|
d<d|
d<d
|
d<t��|
d<t��|
d<t��|
d<||
d<|r
|jdi|��t	t
|���||||||��dS)Nr�r�r�r�F�_mock_sealedTr��_mock_wrapsr��_mock_called�_mock_call_argsr�_mock_call_count�_mock_call_args_list�_mock_mock_callsr��_mock_unsafer!)rr�_mock_add_specr��configure_mockrrrH)rWr�rr*r�r��_spec_state�	_new_name�_new_parent�_spec_as_instance�	_eat_self�unsaferYrrs              r#rHzNonCallableMock.__init__�sV��
�� �K��=��#)��� �!%����%.��!�"�'2��#�$�#(��� ����D��H����d�*�I����D�(�,=�y�I�I�I�%'��!�"�"'����%)��!�"�#(��� �&*��"�#�'(��#�$�+4�;�;��'�(�'0�{�{��#�$�#,�;�;��� �#)��� ��	*��D��)�)�&�)�)�)��O�T�*�*�3�3��%��x���	
�	
�	
�	
�	
r"c�~�t|��}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)rFr�r�r�r�rg)rWrDri�
inner_mocks    r#�attach_mockzNonCallableMock.attach_mock�sI��
#�4�(�(�
�"&�
��&*�
�#� "�
��$(�
�!���i��&�&�&�&�&r"c�2�|�||��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�rWr�r�s   r#�
mock_add_speczNonCallableMock.mock_add_spec�s ��	
���D�(�+�+�+�+�+r"c���t|��rtd|�d����d}d}g}t|��D]5}tt	||d����r|�|���6|�`t
|��sQt|t��r|}nt|��}t|||��}	|	o|	d}t|��}|j
}
||
d<||
d<||
d<||
d<||
d<dS)	Nz#Cannot spec a Mock object. [object=�]r��_spec_class�	_spec_set�_spec_signature�
_mock_methods�_spec_asyncs)r.r�dirrr1�appendror/r>rRrr)rWr�r�rrr&r(r*r��resrrs           r#rzNonCallableMock._mock_add_spec�s'���T�"�"�	T�"�#R��#R�#R�#R�S�S�S���������I�I�	*�	*�D�"�7�4��t�#<�#<�=�=�
*��#�#�D�)�)�)����H�T�N�N���$��%�%�
)�"���"�4�j�j��'��(9�9�F�F�C�!�n�c�!�f�O��t�9�9�D��=��"-���� (����&5��"�#�$(���!�#/��� � � r"c��|j}|j�|jj}|tur%|j�|�|d���}||_|S)N�()�rr)r�r�r�rr�_get_child_mock)rWr�s  r#�__get_return_valuez"NonCallableMock.__get_return_values]���%����*��%�2�C��'�>�>�d�.�6��&�&� �D�'���C�!$�D���
r"c�b�|j�||j_dS||_t||dd��dS)Nr/)r�r�r�r�)rWr�s  r#�__set_return_valuez"NonCallableMock.__set_return_value%s>����*�/4�D��,�,�,�&+�D�#�!�$��t�T�:�:�:�:�:r"z1The value to be returned when the mock is called.c�<�|j�t|��S|jSr<)r&r>r�s r#�	__class__zNonCallableMock.__class__1s ����#���:�:����r"r�r�r�r�r�c���|j}|�|jS|j}|�It|��s:t	|t
��s%t
|��st|��}||_|Sr<)r�r�r��callabler/r�rA)rW�	delegated�sfs   r#�__get_side_effectz!NonCallableMock.__get_side_effect>sj���'�	����)�)�
�
"���N�8�B�<�<�N�"�2�y�1�1�
�:G��:K�:K�
��2���B�$&�I�!��	r"c�V�t|��}|j}|�	||_dS||_dSr<)�	_try_iterr�r�r�)rWr�r9s   r#�__set_side_effectz!NonCallableMock.__set_side_effectIs9���%� � ���'�	���%*�D�"�"�"�$)�I�!�!�!r"�r�r�c�N�|�g}t|��|vrdS|�t|����d|_d|_d|_t��|_t��|_t��|_|rt|_
|rd|_|j�
��D]9}t|t��s	|t ur�!|�|||����:|j
}t%|��r||ur|�|��dSdSdS)z-Restore the mock object to its initial state.NFrr?)�idr,r�r�r�r�r�r�r�rr�r�r��valuesr/�
_SpecState�_deletedr�r.)rW�visitedr�r��childr�s      r#r�zNonCallableMock.reset_mockTs5���?��G�
�d�8�8�w����F����r�$�x�x� � � ����������#�+�+���'�k�k���%�K�K����	.�&-�D�#��	*�%)�D�"��(�/�/�1�1�	Z�	Z�E��%��,�,�
���0A�0A�����W�<�[��Y�Y�Y�Y��%���S�!�!�	$�c��o�o��N�N�7�#�#�#�#�#�	$�	$�o�or"c��t|���d����D]V\}}|�d��}|���}|}|D]}t	||��}�t|||���WdS)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)c�8�|d�d��S)Nr�.)�count)�entrys r#�<lambda>z0NonCallableMock.configure_mock.<locals>.<lambda>s���q�����1D�1D�r")�keyrIN)�sorted�items�split�popr1rg)rWrY�arg�valrX�finalr5rKs        r#rzNonCallableMock.configure_mockrs����v�|�|�~�~�$E�#D�	F�F�F�
	%�
	%�H�C��
�9�9�S�>�>�D��H�H�J�J�E��C��
*�
*���c�5�)�)����C���$�$�$�$�
	%�
	%r"c
��|dvrt|���|j�%||jvs	|tvrtd|z���nt|��rt|���|js:|jr	||jvr*|�d��rt|�d|�d����tj5|j�	|��}|turt|���|�Cd}|j�t|j|��}|�
|||||���}||j|<n�t|t��rv	t!|j|j|j|j|j��}n>#t,$r1|jdp|}t-d|�d	|�d
|�d|j�d�	���wxYw||j|<ddd��n#1swxYwY|S)
N>rr)zMock object has no attribute %r)�assert�assret�asert�aseert�assrtz6 is not a valid assertion. Use a spec for the mock if z is meant to be an attribute.)r�r*rrrr��Cannot autospec attr �
 from target �, as it has already been mocked out. [target=�, attr=r%)rLr)�_all_magicsr�rr(r�_lockr�rsrDrr1r1r/rCr	r�r�rar�r*rrr)rWr*r}r�target_names     r#r�zNonCallableMock.__getattr__�s����4�4�4� ��&�&�&�
�
�
+��4�-�-�-���1D�1D�$�%F��%M�N�N�N�2E�
�t�_�_�	'� ��&�&�&�� �	N�$�*<�	N��D�L^�@^�@^����O�P�P�
N�$��M�M�'+�M�M�M�N�N�N��
"�	4�	4��(�,�,�T�2�2�F���!�!�$�T�*�*�*������#�/�$�D�$4�d�;�;�E��-�-��d�%�4� $�.����.4��#�D�)�)��F�J�/�/�
4�
D�,���V�_�f�o��
�v�{���F�F��(�D�D�D�"&�-��"=�"E��K�*�C��C�C�&�C�C�#'�C�C�28�+�C�C�C�D�D�D�D����.4��#�D�)�;	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4����	4�	4�	4�	4�>�
s+�+B
F:�9,E&�%F:�&;F!�!
F:�:F>�F>c�n�|jg}|j}|}d}|dgkrd}|�7|}|�|j|z��d}|jdkrd}|j}|�7tt	|����}|jpd}t
|��dkr|ddvr|dz
}||d<d�|��S)NrIr/rrDr�)r/z().r)r�r�r,rm�reversedr�r��join)rW�
_name_listr��last�dot�_firsts      r#�_extract_mock_namez"NonCallableMock._extract_mock_name�s����)�*�
��'�������$�����C��!��D����g�4�s�:�;�;�;��C��%��-�-����.�G��!��(�:�.�.�/�/�
���*�F���z�?�?�Q����!�}�M�1�1��#�
���
�1�
��w�w�z�"�"�"r"c���|���}d}|dvrd|z}d}|j�d}|jrd}||jjz}dt	|��j�|�|�dt|���d�S)	Nr)rDzmock.z name=%rz spec=%rz spec_set=%r�<z id='z'>)rir&r'rr>rA)rWr*�name_string�spec_strings    r#r�zNonCallableMock.__repr__�s����&�&�(�(�����(�(�(�$�t�+�K�����'�$�K��~�
-�,��%��(8�(A�A�K����J�J����K��K�K��t�H�H�H�H�	
�	
r"c�v�tst�|��S|jpg}t	t|����}t
|j��}d�|j�	��D��}d�|D��}d�|D��}tt||z|z|z����S)z8Filter the output of `dir(mock)` to only useful members.c�*�g|]\}}|tu�|��Sr!)rD)r)�m_name�m_values   r#�
<listcomp>z+NonCallableMock.__dir__.<locals>.<listcomp>�s1��(�(�(�&�v�w��h�&�&�
�&�&�&r"c�<�g|]}|�d���|��Sr%r'�r)�es  r#rrz+NonCallableMock.__dir__.<locals>.<listcomp>�s)��C�C�C�1����c�1B�1B�C�Q�C�C�Cr"c�Z�g|](}|�d��rt|���&|��)Sr%)r(r�rts  r#rrz+NonCallableMock.__dir__.<locals>.<listcomp>�sE��#�#�#�1����c�1B�1B�#��q�\�\�#�Q�#�#�#r")r�object�__dir__r)r+r>rmrrr�rOrN�set)rW�extras�	from_type�	from_dict�from_child_mockss     r#rxzNonCallableMock.__dir__�s����	(��>�>�$�'�'�'��#�)�r����T�
�
�O�O�	����'�'�	�(�(�*.�*=�*C�*C�*E�*E�(�(�(��D�C�	�C�C�C�	�#�#�	�#�#�#�	��c�&�9�,�y�8�;K�K�L�L�M�M�Mr"c�T���|tvrt��||��S�jr+�j�$|�jvr|�jvrt
d|z���|tvrd|z}t
|���|tvr��j�|�jvrt
d|z���t|��s5tt���|t||����|���fd�}nft�|d|��tt���||��|�j|<n+|dkr	|�_dSt�|||��r
|�j|<�jr;t#�|��s+�����d|��}t
d|�����t��||��S)Nz!Mock object has no attribute '%s'z.Attempting to set unsupported magic method %r.c�����g|�Ri|��Sr<r!)rXrr|rWs  ��r#rLz-NonCallableMock.__setattr__.<locals>.<lambda>s!���H�H�T�,G�D�,G�,G�,G�B�,G�,G�r"r6rIzCannot set )r�rw�__setattr__r'r)rrrL�_unsupported_magicsr_r.rgr>�_get_methodr�r�r&r
r0ri)rWr*r��msg�	mock_namer|s`    @r#r�zNonCallableMock.__setattr__�s������>�!�!��%�%�d�D�%�8�8�8��n�	2��!3�!?���*�*�*���
�%�%� �!D�t�!K�L�L�L�
�(�
(�
(�B�T�I�C� ��%�%�%�
�[�
 �
 ��!�-�$�d�>P�2P�2P�$�%H�4�%O�P�P�P�$�U�+�+�	
2���T�
�
�D�+�d�E�*B�*B�C�C�C� ��G�G�G�G�G���&�d�E�4��>�>�>���T�
�
�D�%�0�0�0�,1��#�D�)�)�
�[�
 �
 �$�D���F�$�T�5�$��=�=�
2�,1��#�D�)���	<�W�T�4�%8�%8�	<��2�2�4�4�=�=�t�=�=�I� �!:�y�!:�!:�;�;�;��!�!�$��e�4�4�4r"c��|tvr>|t|��jvr(tt|��|��||jvrdS|j�|t��}||jvr)tt|���	|��n|turt|���|tur|j|=t|j|<dSr<)r_r>rr�delattrr�rs�_missingrr�__delattr__rDrL)rWr*r5s   r#r�zNonCallableMock.__delattr__!s����;���4�4��:�:�+>�#>�#>��D��J�J��%�%�%��4�=�(�(����!�%�%�d�H�5�5���4�=� � ����.�.�:�:�4�@�@�@�@�
�H�_�_� ��&�&�&��h����#�D�)�$,���D�!�!�!r"c�6�|jpd}t|||��SrC)r��_format_call_signature�rWrXrYr*s    r#�_format_mock_call_signaturez+NonCallableMock._format_mock_call_signature3s ����(�&��%�d�D�&�9�9�9r"rc�d�d}|�||��}|j}|j|�}||||fzS)Nz0expected %s not found.
Expected: %s
  Actual: %s)r�r�)rWrXrY�action�message�expected_stringr��
actual_strings        r#�_format_mock_failure_messagez,NonCallableMock._format_mock_failure_message8sD��F���:�:�4��H�H���N�	�8��8�)�D�
��&�/�=�A�A�Ar"c��|s|jSd}|�dd���d��}|j}|D]M}|�|��}|�t|t��rnt|��}|j}|j}�N|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/rrI)r(�replacerPr�rsr/rCrF)rWr*rZ�names�childrenrFs      r#�_get_call_signature_from_namez-NonCallableMock._get_call_signature_from_name@s����	(��'�'������T�2�&�&�,�,�S�1�1���&���
	,�
	,�D��L�L��&�&�E��}�
�5�*� =� =�}���
&�e�,�,�� �/���+����
r"c��t|t��r/t|��dkr|�|d��}n|j}|�vt|��dkrd}|\}}n|\}}}	|j|i|��}t
||j|j��S#t$r}|�
d��cYd}~Sd}~wwxYw|S)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/rnr�r�r(rVrrXrY�	TypeError�with_traceback)rW�_callrZr*rXrY�
bound_callrus        r#�
_call_matcherzNonCallableMock._call_matcheras����e�U�#�#�	'��E�
�
�Q����4�4�U�1�X�>�>�C�C��&�C��?��5�z�z�Q�����$���f�f�%*�"��d�F�
.�%�S�X�t�6�v�6�6�
��D�*�/�:�3D�E�E�E���
.�
.�
.��'�'��-�-�-�-�-�-�-�-�����
.�����Ls�0'B�
C�"B<�6C�<Cc��|jdkr8d|jpd�d|j�d|�����}t|���dS)z/assert that the mock was never called.
        r�
Expected 'rDz"' to not have been called. Called � times.N�r�r��_calls_repr�AssertionError�rWr�s  r#r�z!NonCallableMock.assert_not_called|s^���?�a�����o�/��/�/��o�o�o��&�&�(�(�(�*�C�!��%�%�%� �r"c�R�|jdkrd|jpdz}t|���dS)z6assert that the mock was called at least once
        rz"Expected '%s' to have been called.rDN)r�r�r�r�s  r#r�zNonCallableMock.assert_called�s;���?�a���7��O�-�v�/�C� ��%�%�%� �r"c��|jdks8d|jpd�d|j�d|�����}t|���dS)z3assert that the mock was called only once.
        r�r�rDz#' to have been called once. Called r�Nr�r�s  r#r�z"NonCallableMock.assert_called_once�s^����!�#�#�#��o�/��/�/��o�o�o��&�&�(�(�(�*�C�!��%�%�%�$�#r"c�t�����j�/������}d}d|�d|��}t|������fd�}��t	��fd�����}���j��}||kr1t|t��r|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.z#expected call not found.
Expected: z
  Actual: c�4��������}|Sr<�r��r�rXrYrWs ���r#�_error_messagez:NonCallableMock.assert_called_with.<locals>._error_message�s����3�3�D�&�A�A�C��Jr"T��two)r�r�r�r��_Callr/�	Exception)rWrXrY�expected�actual�
error_messager��causes```     r#r�z"NonCallableMock.assert_called_with�s������
�>�!��7�7��f�E�E�H�"�F�F��x�x���)�M� ��/�/�/�	�	�	�	�	�	�	��%�%�e�T�6�N��&E�&E�&E�F�F���#�#�D�N�3�3���X��� *�8�Y� ?� ?�I�H�H�T�E� ���!1�!1�2�2��=��r"c��|jdks8d|jpd�d|j�d|�����}t|���|j|i|��S)ziassert that the mock was called exactly once and that that call was
        with the specified arguments.r�r�rDz' to be called once. Called r�)r�r�r�r�r��rWrXrYr�s    r#r�z'NonCallableMock.assert_called_once_with�sn����!�#�#�#��o�/��/�/��o�o�o��&�&�(�(�(�*�C�!��%�%�%�&�t�&��7��7�7�7r"c����fd�|D��}td�|D��d��}t�fd��jD����}|su||vro|�d}nd�d�|D����}t	|�dt|�����d	�
���d������|�dSt|��}g}|D]=}	|�|���#t$r|�
|��Y�:wxYw|r-t	�jpd�d
t|���d|�d���|�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`.c�:��g|]}��|����Sr!�r��r)�crWs  �r#rrz4NonCallableMock.assert_has_calls.<locals>.<listcomp>��'���9�9�9�a�D�&�&�q�)�)�9�9�9r"c3�DK�|]}t|t���|V��dSr<�r/r�rts  r#�	<genexpr>z3NonCallableMock.assert_has_calls.<locals>.<genexpr>��1����F�F�A�Z��9�-E�-E�F�a�F�F�F�F�F�Fr"Nc3�B�K�|]}��|��V��dSr<r�r�s  �r#r�z3NonCallableMock.assert_has_calls.<locals>.<genexpr>�s1�����M�M��d�0�0��3�3�M�M�M�M�M�Mr"zCalls not found.z+Error processing expected calls.
Errors: {}c�@�g|]}t|t��r|nd��Sr<r�rts  r#rrz4NonCallableMock.assert_has_calls.<locals>.<listcomp>��;��$7�$7�$7�()�*4�A�y�)A�)A�$K�A�A�t�$7�$7�$7r"�
Expected: z  Actual)�prefixrIrDz does not contain all of z in its call list, found z instead)
r�r�r��formatr�r��rstriprm�removerNr,r�rn)	rW�calls�	any_orderr�r��	all_calls�problem�	not_found�kalls	`        r#r�z NonCallableMock.assert_has_calls�s����:�9�9�9�5�9�9�9���F�F��F�F�F��M�M���M�M�M�M�T�_�M�M�M�M�M�	��	��y�(�(��=�0�G�G� ,�-3�V�$7�$7�-5�$7�$7�$7�.8�.8��%��I�I�!*�5�!1�!1�I��'�'�z�'�:�:�A�A�#�F�F�I�I����	�

�F���O�O�	��	��	'�	'�D�
'�� � ��&�&�&�&���
'�
'�
'�� � ��&�&�&�&�&�
'�����	� �&*�o�&?��&?�&?�&+�I�&6�&6�&6�&6�	�	�	�C����	
�	�	s�C-�-D�Dc�$����t||fd�����}t|t��r|nd}�fd��jD��}|s|t|��vr)��||��}td|z��|�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.Tr�Nc�:��g|]}��|����Sr!r�r�s  �r#rrz3NonCallableMock.assert_any_call.<locals>.<listcomp>�s'���E�E�E�A�$�$�$�Q�'�'�E�E�Er"z%s call not found)r�r�r/r�r��_AnyComparerr�r��rWrXrYr�r�r�r�s`      r#r�zNonCallableMock.assert_any_call�s�����%�%�e�T�6�N��&E�&E�&E�F�F��&�x��;�;�E�����E�E�E�E��1D�E�E�E���	�H�L��$8�$8�8�8�"�>�>�t�V�L�L�O� �#�o�5����
�9�8r"c��|jr7d|vrd|d��nd}|���|z}t|���|�d��}||jdvrtdi|��St
|��}t|t��r|tvrt
}n�t|t��r)|tvs|jr||jvrt}ndt
}n\t|t��s:t|t��rt}n*t|t��rt }n
|jd}|di|��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*rIr/rr*r�r!)r
rirLrsrrr
r>r=r�_async_method_magicsr��_all_sync_magicsr)�
CallableMixinr
rrrq)rWrrir�r�_type�klasss       r#r1zNonCallableMock._get_child_mock�s[����	,�,2�b�L�L�(�B�v�J�(�(�(�d�I��/�/�1�1�I�=�I� ��+�+�+��F�F�;�'�'�	���
�n�5�5�5��?�?�r�?�?�"��T�
�
���e�Y�'�'�	%�I�9M�,M�,M��E�E�
��~�
.�
.�
	%��-�-�-��&�.�+4��8J�+J�+J�!���!����E�=�1�1�	%��%�!5�6�6�
�!����E�?�3�3�
�����M�!�$�E��u�{�{�r�{�{�r"�Callsc�J�|jsdSd|�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: rI)r�r)rWr�s  r#r�zNonCallableMock._calls_reprs6����	��2�;�F�;�;�i���8�8�;�;�;�;r")NNNNNNrNFNF�F)FFr<)r)r�)/rrrr rr`rrHrr#r�"_NonCallableMock__get_return_value�"_NonCallableMock__set_return_value�"_NonCallableMock__return_value_docr�r�r6r�r�r�r�r�r��!_NonCallableMock__get_side_effect�!_NonCallableMock__set_side_effectr�r�rr�rir�rxr�r�r�r�r�r�r�r�r�r�r�r�r�r1r�r!r"r#rr�s�������*�*�
�E�G�G�E�
�
�
�">B�EI�<A�*
�*
�*
�*
�Z'�'�'�,�,�,�,�@E�!&�0�0�0�0�>
�
�
�;�;�;�M���8�.�0B�.�0�0�L�� � ��X� �
"�
!�(�
+�
+�F�%�%�l�3�3�J�$�$�[�1�1�I�)�)�*:�;�;�N�%�%�l�3�3�J�	�	�	�*�*�*��(�,�.?�@�@�K�$�u�%�$�$�$�$�$�<%�%�%�,-�-�-�`#�#�#�6
�
�
�*N�N�N�$$5�$5�$5�N-�-�-�$:�:�:�
B�B�B�B����B���6&�&�&�&�&�&�&�&�&�>�>�>�,	8�	8�	8�*�*�*�*�Z
�
�
� #�#�#�L
<�
<�
<�
<�
<�
<r"rc��eZdZdZd�ZdS)r�z�A list which checks if it contains a call which may have an
    argument of ANY, flipping the components of item and self from
    their traditional locations so that ANY is guaranteed to be on
    the left.c�d�|D],}td�t||��D����rdS�-dS)Nc� �g|]\}}||k��Sr!r!)r)r�r�s   r#rrz-_AnyComparer.__contains__.<locals>.<listcomp>5s1�����$�H�f��F�"���r"TF)�all�zip)rW�itemr�s   r#r�z_AnyComparer.__contains__2s^���	�	�E����(+�D�%�(8�(8������
��t�t�	
�
�ur"N)rrrr r�r!r"r#r�r�-s-������������r"r�c��|�|St|��r|St|��r|S	t|��S#t$r|cYSwxYwr<)rArkr�r�r4s r#r=r==sk��
�{��
��S�����
���~�~���
���C�y�y��������
�
�
����s�7�A�Ac
�H�eZdZddedddddddf
d�Zd�Zd�Zd�Zd�Zd�Z	dS)	r�Nrc
�x�||jd<tt|��j|||||||	|
fi|��||_dS)Nr�)rrrr�rHr�)rWr�r�r�rr*r�r�rrrrYs            r#rHzCallableMixin.__init__Nsa��/;��
�*�+�1��M�4�(�(�1��%��x����K�	
�	
�39�	
�	
�	
�
'����r"c��dSr<r!r�s   r#r^zCallableMixin._mock_check_sigZs���r"c�P�|j|i|��|j|i|��|j|i|��Sr<)r^�_increment_mock_call�
_mock_callr�s   r#rKzCallableMixin.__call___sK��	���d�-�f�-�-�-�!��!�4�2�6�2�2�2��t���/��/�/�/r"c��|j|i|��Sr<)�_execute_mock_callr�s   r#r�zCallableMixin._mock_callgs��&�t�&��7��7�7�7r"c�~�d|_|xjdz
c_t||fd���}||_|j�|��|jdu}|j}|j}|dk}|j	�td||f����|j
}|��|rB|j�t|||f����|jdu}|r
|jdz|z}t|||f��}	|j	�|	��|jr|rd}
nd}
|jdk}|j|
z|z}|j
}|��dSdS)NTr�r�r/rrI)r�r�r�r�r�r,r�r�r�r�r�r�)rWrXrYr��do_method_calls�method_call_name�mock_call_name�	is_a_callr�this_mock_callrgs           r#r�z"CallableMixin._increment_mock_calljs���������1����
�t�V�n�$�/�/�/�������"�"�5�)�)�)��+�4�7���?���,��"�d�*�	�����u�b�$��%7�8�8�9�9�9��+���%��
W��(�/�/��7G��v�6V�0W�0W�X�X�X�"-�":�$�"F��"�W�'2�'=��'C�FV�'V�$�#�N�D�&�#A�B�B�N��"�)�)�.�9�9�9��)�
S����C�C��C�'�6�$�>�	�!,�!;�c�!A�N�!R��&�6�K�-�%�%�%�%�%r"c�^�|j}|�Tt|��r|�t|��s!t|��}t|��r|�n||i|��}|tur|S|jtur|jS|jr|jjtur|jS|j�
|j|i|��S|jSr<)	r�rArkr�rr�r�r�r)rWrXrY�effectr}s     r#r�z CallableMixin._execute_mock_call�s����!�����V�$�$�
1����v�&�&�
1��f���� ��(�(�!� �L�!� ���0��0�0���W�$�$��
��"�'�1�1��$�$���	%�4�#6�#C�7�#R�#R��$�$���'�#�4�#�T�4�V�4�4�4�� � r")
rrrrrHr^rKr�r�r�r!r"r#r�r�Ls������� �d���$��d�!�R�T�	'�	'�	'�	'�
�
�
�
0�0�0�8�8�8�,7�,7�,7�\!�!�!�!�!r"r�c��eZdZdZdS)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.

    * `unsafe`: By default, accessing any attribute whose name starts with
      *assert*, *assret*, *asert*, *aseert* or *assrt* will raise an
       AttributeError. Passing `unsafe=True` will allow access to
      these attributes.

    * `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.
    Nrr!r"r#rr�s������5�5�5�5r"rc�@�d}|D]}||vrt|�d�����dS)N)�	autospect�	auto_spec�set_specz5 might be a typo; use unsafe=True if this is intended)�RuntimeError)�kwargs_to_check�typos�typos   r#�_check_spec_arg_typosr�sN��2�E������?�"�"���P�P�P���
�#��r"c�~�eZdZdZgZdd�d�Zd�Zd�Zd�Ze	j
d���Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�ZdS)�_patchNF�rc
��|�)|turtd���|�td���|
st|	��t|��rt	d|�d|�d����t|��rt	d|�d|�d����||_||_||_||_||_	||_
d|_||_||_
|	|_g|_dS)Nz,Cannot use 'new' and 'new_callable' togetherz1Cannot use 'autospec' and 'new_callable' togetherzCannot spec attr z0 as the spec has already been mocked out. [spec=r%z? as the spec_set target has already been mocked out. [spec_set=F)rrNrr.r�getterrir
�new_callabler��create�	has_localr��autospecrY�additional_patchers)rWrrir
r�rr�r
rrYrs           r#rHz_patch.__init__sV���#��'�!�!� �B�����#� �G�����	*�!�&�)�)�)��T�"�"�	A�"�@�I�@�@�6:�@�@�@�A�A�
A��X�&�&�	P�"�O�I�O�O�AI�O�O�O�P�P�
P����"������(�����	������� ��
� ��
����#%�� � � r"c���t|j|j|j|j|j|j|j|j|j	�	�	}|j
|_
d�|jD��|_|S)Nc�6�g|]}|�����Sr!)�copy)r)�ps  r#rrz_patch.copy.<locals>.<listcomp>,s-��'
�'
�'
��A�F�F�H�H�'
�'
�'
r")rrrir
r�rr�r
rrY�attribute_namer)rW�patchers  r#rz_patch.copy%sq����K�����4�9��K����M�4�,�d�k�
�
��
"&�!4���'
�'
�"�6�'
�'
�'
��#��r"c���t|t��r|�|��Stj|��r|�|��S|�|��Sr<�r/r>�decorate_classr2r�decorate_async_callable�decorate_callable)rWr9s  r#rKz_patch.__call__2sc���d�D�!�!�	-��&�&�t�,�,�,��&�t�,�,�	6��/�/��5�5�5��%�%�d�+�+�+r"c��t|��D]q}|�tj��s�"t	||��}t|d��s�C|���}t||||�����r|S�NrK)r+r(r�TEST_PREFIXr1r0rrg)rWr�r��
attr_valuers     r#rz_patch.decorate_class:s�����J�J�		6�		6�D��?�?�5�#4�5�5�
�� ���-�-�J��:�z�2�2�
���i�i�k�k�G��E�4����!4�!4�5�5�5�5��r"c#�TK�g}tj��5}|jD]W}|�|��}|j�|�|���4|jtur|�|���X|t|��z
}||fV�ddd��dS#1swxYwYdSr<)
�
contextlib�	ExitStack�	patchings�
enter_contextr�updater
rr,rn)rW�patchedrX�keywargs�
extra_args�
exit_stack�patchingrRs        r#�decoration_helperz_patch.decoration_helperHs�����
�
�
!�
#�
#�		#�z�#�-�
+�
+�� �.�.�x�8�8���*�6��O�O�C�(�(�(�(��\�W�,�,��%�%�c�*�*�*���E�*�%�%�%�D���"�"�"�"�		#�		#�		#�		#�		#�		#�		#�		#�		#�		#�		#�		#����		#�		#�		#�		#�		#�		#s�A8B�B!�$B!c�����t�d��r�j�����St������fd�����g�_�S)Nrc�|�����||��5\}}�|i|��cddd��S#1swxYwYdSr<�r&�rXr"�newargs�newkeywargsr9r!rWs    ���r#r!z)_patch.decorate_callable.<locals>.patched]s�����'�'��(,�(0�2�2�
5�5K�g�{��t�W�4��4�4�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5����
5�
5�
5�
5�
5�
5s�1�5�5�r0rr,r�rWr9r!s``@r#rz_patch.decorate_callableWsv������4��%�%�	��N�!�!�$�'�'�'��K�	�t���	5�	5�	5�	5�	5�	5�
��	5�"�F����r"c�����t�d��r�j�����St������fd�����g�_�S)Nrc���K����||��5\}}�|i|���d{V��cddd��S#1swxYwYdSr<r)r*s    ���r#r!z/_patch.decorate_async_callable.<locals>.patchedns�������'�'��(,�(0�2�2�
;�5K�g�{�!�T�7�:�k�:�:�:�:�:�:�:�:�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;����
;�
;�
;�
;�
;�
;s
�9�=�=r-r.s``@r#rz_patch.decorate_async_callablehsv������4��%�%�	��N�!�!�$�'�'�'��K�	�t���	;�	;�	;�	;�	;�	;�
��	;�"�F����r"c�`�|���}|j}t}d}	|j|}d}n-#tt
f$rt
||t��}YnwxYw|tvrt|t��rd|_
|j
s|turt	|�d|�����||fS)NFTz does not have the attribute )rrirrrrL�KeyErrorr1�	_builtinsr/rr)rW�targetr*r|�locals     r#�get_originalz_patch.get_originalys����������~������	���t�,�H��E�E����)�	6�	6�	6��v�t�W�5�5�H�H�H�	6����
�9����F�J�!?�!?���D�K��{�	�x�7�2�2� �7=�v�v�t�t�D���
����s�
6�'A �A c��|j|j|j}}}|j|j}}|j}|���|_|durd}|durd}|durd}|�|�td���|�|�|dvrtd���|�	��\}}|tu�r�|���d}	|dur|}|dur|}d}n|�	|dur|}d}n|dur|}|�|�/|turtd���t|t��rd}	|�t|��rt}
nt}
i}|�|}
nN|�|�J|}|�|}t!|��rd|v}
nt#|��}
t|��rt}
n	|
rt$}
|�||d	<|�||d
<t|
t��r&t'|
t(��r|jr
|j|d<|�|��|
di|��}|	r_t/|��rP|}|�|}t!|��st1|��st$}
|�d��|
d|dd
�|��|_n�|��|turtd���|turtd���t7|��}|dur|}t/|j��r#t9d|j�d|j�d|�d����t/|��rAt;|jd|j��}t9d|j�d|�d|j�d|�d�	���t=|f||jd�|��}n|rtd���|}||_||_ tCj"��|_#	tI|j|j|��|j%�ci}|jtur
|||j%<|j&D]?}|j#�'|��}|jtur|�|���@|S|S#|j(tSj*���s�YdSxYw)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=TruerKr�r�r*r/r0zBautospec creates the mock for you. Can't specify autospec and new.z%Can't use 'autospec' with create=Truer[z: as the patch target has already been mocked out. [target=r^r%rr\r])r��_namez.Can't pass kwargs to a mock we aren't creatingr!)+r
r�r�r
rYrrr4r�r6rr/r>r6r
rror8r
r=rrir r.rurQr��boolrr1r	�
temp_original�is_localrr�_exit_stackrgrrr�__exit__�sys�exc_info)rWr
r�r�r
rYrr|r5�inherit�Klass�_kwargs�	this_spec�not_callablera�new_attrr#r%rRs                   r#�	__enter__z_patch.__enter__�s���"�h��	�4�=�8�T���=�$�+�&���(���k�k�m�m����5�=�=��D��u����H��u����H���� 4��=�>�>�>�
�
��!5��L�(�(��T�U�U�U��+�+�-�-���%��'�>�>�h�.��G��t�|�|����t�#�#�'�H��D���!��t�#�#�#�H��D���T�!�!�#����8�#7��w�&�&�#�$G�H�H�H��h��-�-�#�"�G��|�
�h� 7� 7�|�!���!���G��'�$����!�X�%9� �	��'� (�I��I�&�&�;�#-�Y�#>�L�L�'/�	�':�':�#:�L� ��+�+�1�%�E�E�!�1�0�E���"&�����#�&.��
�#��5�$�'�'�
1��5�/�2�2�
1�7;�~�
1�"&�.�����N�N�6�"�"�"��%�"�"�'�"�"�C��
4�,�S�1�1�
4�!�	��'� (�I� ��+�+�1�&�y�1�1�1�0�E����F�#�#�#�#(�5�$4�S�D�$4�$4�+2�$4�$4�� ��
�
!��'�!�!��(�����7�"�"�� G�H�H�H��H�~�~�H��4���#�� ���-�-�
D�&�C�D�N�C�C�#�{�C�C�5=�C�C�C�D�D�D�!��*�*�
D�%�d�k�:�t�{�K�K��&�C�D�N�C�C�"�C�C�#�{�C�C�5=�C�C�C�D�D�D�
"�(�B�X�(,��B�B�:@�B�B�C�C�
�	N��L�M�M�M���%�����
�%�/�1�1���	��D�K����:�:�:��"�.��
��8�w�&�&�7:�J�t�2�3� $� 8�/�/�H��*�8�8��B�B�C��|�w�.�.�"�)�)�#�.�.�.��!�!��J��	� �4�=�#�,�.�.�1�
��
�
�
���s�BO�O�O<c�h�|jr/|jtur!t|j|j|j��ndt
|j|j��|jsCt|j|j��r	|jdvr t|j|j|j��|`|`|`|j	}|`	|j
|�S)zUndo the patch.)r rre�__annotations__rf)r;r:rrgr4rir�rr0r<r=)rWr?r$s   r#r=z_patch.__exit__#s����=�		I�T�/�w�>�>��D�K����1C�D�D�D�D��D�K���0�0�0��;�
I����T�^�(L�(L�
I���+=�=�=����T�^�T�5G�H�H�H����M��K��%�
���"�z�"�H�-�-r"c�b�|���}|j�|��|S�z-Activate a patch, returning any created mock.)rF�_active_patchesr,�rWr}s  r#�startz_patch.start8s-�����!�!����#�#�D�)�)�)��
r"c��	|j�|��n#t$rYdSwxYw|�ddd��S�zStop an active patch.N)rKr�rNr=r�s r#�stopz_patch.stop?s[��	�� �'�'��-�-�-�-���	�	�	��4�4�	�����}�}�T�4��.�.�.s��
+�+)rrrrrKrHrrKrr�contextmanagerr&rrr6rFr=rMrPr!r"r#rr�s��������N��O�AF�"&�"&�"&�"&�"&�J
�
�
�,�,�,������#�#���#����"���"���0P�P�P�d.�.�.�*���/�/�/�/�/r"rc���	|�dd��\}}n-#tttf$rtd|�����wxYwt	t
j|��|fS)NrIr�z,Need a valid target to patch. You supplied: )�rsplitr�rNrLr�pkgutil�resolve_name)r4ris  r#�_get_targetrVKs���G�"�M�M�#�q�1�1���	�	���z�>�2�G�G�G��E�6�E�E�G�G�	G�G�����7�'��0�0�)�;�;s	��*Arc���t���turt��d�����fd�}
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 strc����Sr<r!�r4s�r#rLz_patch_object.<locals>.<lambda>js���V�r"r)r>�strr�r)r4rir
r�rr�r
rrrYrs`          r#�
_patch_objectr[Tsn���$�F�|�|�s�����L�L�L�
�
�	
��^�^�^�F���	�3��f��(�L�&�����r"c���t���turttj���}n�fd�}|std���t
|�����}|d\}	}
t||	|
|||||i�	�	}|	|_	|dd�D]=\}	}
t||	|
|||||i�	�	}|	|_	|j
�|���>|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.
    c����Sr<r!rYs�r#rLz!_patch_multiple.<locals>.<lambda>�s����r"z=Must supply at least one keyword argument with patch.multiplerr�N)r>rZrrTrUrNrmrOrrrr,)
r4r�rr�r
rrYrrOrir
r�this_patchers
`            r#�_patch_multipler_qs
���,�F�|�|�s�����-�v�6�6���������
��K�
�
�	
�
������ � �E��1�X�N�I�s���	�3��f�h��,����G�'�G������)�9�9��	�3���I�s�D�&�(��l�B�
�
��'0��#��#�*�*�<�8�8�8�8��Nr"c�X�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 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 will raise a `RuntimeError` if passed some common misspellings of
    the arguments autospec and spec_set. Pass the argument `unsafe` with the
    value True to disable that check.

    `patch` takes arbitrary keyword arguments. These will be passed to
    `AsyncMock` if the patched object is asynchronous, to `MagicMock`
    otherwise or to `new_callable` if specified.

    `patch.dict(...)`, `patch.multiple(...)` and `patch.object(...)` are
    available for alternate use-cases.
    r)rVr)r4r
r�rr�r
rrrYrris           r#rr�sD��V$�F�+�+��F�I���	�3��f��(�L�&�����r"c�V�eZdZdZdd�Zd�Zd�Zd�Zd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
d�ZdS)�_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.
    r!Fc��||_t|��|_|j�|��||_d|_dSr<)�in_dict�dictrBr �clear�	_original)rWrdrBrfrYs     r#rHz_patch_dict.__init__s>������6�l�l�������6�"�"�"���
�����r"c���t|t��r|�|��Stj|��r|�|��S|�|��Sr<r)rW�fs  r#rKz_patch_dict.__call__sc���a����	*��&�&�q�)�)�)��&�q�)�)�	3��/�/��2�2�2��%�%�a�(�(�(r"c�@���t�����fd���}|S)Nc�������	�|i|������S#����wxYwr<�rb�
_unpatch_dict�rXrrirWs  ��r#�_innerz-_patch_dict.decorate_callable.<locals>._inner#sV���������
%��q�$�~�"�~�~��"�"�$�$�$�$���"�"�$�$�$�$���s	�3�A	�r�rWriros`` r#rz_patch_dict.decorate_callable"�9����	�q���	%�	%�	%�	%�	%�
��	%��
r"c�@���t�����fd���}|S)Nc���K�����	�|i|���d{V��	����S#����wxYwr<rlrns  ��r#roz3_patch_dict.decorate_async_callable.<locals>._inner/so�����������
%��Q��^��^�^�+�+�+�+�+�+�+��"�"�$�$�$�$���"�"�$�$�$�$���s	�
<�Arprqs`` r#rz#_patch_dict.decorate_async_callable.rrr"c� �t|��D]}}t||��}|�tj��rLt|d��r<t
|j|j|j	��}||��}t|||���~|Sr)r+r1r(rrr0rbrdrBrfrg)rWr�r�r�	decorator�	decorateds      r#rz_patch_dict.decorate_class:s�����J�J�	0�	0�D� ���-�-�J����� 1�2�2�
0���Z�0�0�
0�'���d�k�4�:�N�N�	�%�I�j�1�1�	���t�Y�/�/�/���r"c�8�|���|jS)zPatch the dict.)rbrdr�s r#rFz_patch_dict.__enter__Es���������|�r"c��|j}t|jt��rt	j|j��|_|j}|j}	|���}n"#t$ri}|D]
}||||<�YnwxYw||_	|rt|��	|�|��dS#t$r|D]
}||||<�YdSwxYwr<)rBr/rdrZrTrUrfrrLrg�_clear_dictr )rWrBrdrfr|rMs      r#rbz_patch_dict._patch_dictKs!������d�l�C�(�(�	>�"�/���=�=�D�L��,���
��	-��|�|�~�~�H�H���	-�	-�	-��H��
-�
-�� '�����
�
�
-�
-�		-����"����	!��� � � �	+��N�N�6�"�"�"�"�"���	+�	+�	+��
+�
+��%�c�{�����
+�
+�
+�	+���s$�A$�$B�B�B6�6C�Cc��|j}|j}t|��	|�|��dS#t$r|D]
}||||<�YdSwxYwr<)rdrgrzr rL)rWrdr|rMs    r#rmz_patch_dict._unpatch_dictgs����,���>���G����	-��N�N�8�$�$�$�$�$���	-�	-�	-��
-�
-��'��}�����
-�
-�
-�	-���s�6�A�Ac�<�|j�|���dS)zUnpatch the dict.NF)rgrm)rWrXs  r#r=z_patch_dict.__exit__ts!���>�%���� � � ��ur"c�l�|���}tj�|��|SrJ)rFrrKr,rLs  r#rMz_patch_dict.start{s-�����!�!����%�%�d�+�+�+��
r"c��	tj�|��n#t$rYdSwxYw|�ddd��SrO)rrKr�rNr=r�s r#rPz_patch_dict.stop�s[��	��"�)�)�$�/�/�/�/���	�	�	��4�4�	�����}�}�T�4��.�.�.s�"�
0�0N)r!F)rrrr rHrKrrrrFrbrmr=rMrPr!r"r#rbrb�s���������8����)�)�)�	�	�	�	�	�	�������+�+�+�8
-�
-�
-�������/�/�/�/�/r"rbc��	|���dS#t$rt|��}|D]}||=�YdSwxYwr<)rfrLrm)rd�keysrMs   r#rzrz�se����
�
������������G�}�}���	�	�C�����	�	�	����s��!=�=c�f�ttj��D]}|����dS)z7Stop all active patches. LIFO to unroll nested patches.N)rcrrKrP)rs r#�_patch_stopallr��s5���&�0�1�1����
�
�
������r"�testz�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 zDadd sub mul matmul truediv floordiv mod lshift rshift and xor or pow� c#� K�|]	}d|zV��
dS)zi%sNr!�r)�ns  r#r�r��s&����7�7��5�1�9�7�7�7�7�7�7r"c#� K�|]	}d|zV��
dS)zr%sNr!r�s  r#r�r��s&����5�5�q����5�5�5�5�5�5r">rx�__get__�__set__r��
__delete__�
__format__r��__missing__�__getstate__�__reversed__�__setstate__�
__getformat__�
__reduce_ex__�__getnewargs__�__subclasses__�__getinitargs__�__getnewargs_ex__c� ���fd�}||_|S)z:Turns a callable object (like a mock) into a real functionc����|g|�Ri|��Sr<r!)rWrXrr9s   �r#�methodz_get_method.<locals>.method�s#����t�D�&�4�&�&�&�2�&�&�&r")r)r*r9r�s ` r#r�r��s(���'�'�'�'�'��F�O��Mr"c��h|]}d|z��S)r�r!)r)r�s  r#r+r+�s*����� �H�v����r">�	__aexit__�	__anext__�
__aenter__�	__aiter__>�__del__rrHr��__prepare__r��__instancecheck__�__subclasscheck__c�6�t�|��Sr<)rw�__hash__r�s r#rLrL�s��V�_�_�T�2�2�r"c�6�t�|��Sr<)rw�__str__r�s r#rLrL�s��F�N�N�4�0�0�r"c�6�t�|��Sr<)rw�
__sizeof__r�s r#rLrL�s��v�0�0��6�6�r"c�x�t|��j�d|����dt|����S)N�/)r>rrirAr�s r#rLrL�s;��$�t�*�*�"5�^�^��8O�8O�8Q�8Q�^�^�TV�W[�T\�T\�^�^�r")r�r�r��
__fspath__r�y�?g�?)
�__lt__�__gt__�__le__�__ge__�__int__r��__len__r=�__complex__�	__float__�__bool__�	__index__r�c����fd�}|S)Nc�L���jj}|tur|S�|urdStS�NT)�__eq__r�r�NotImplemented)�other�ret_valrWs  �r#r�z_get_eq.<locals>.__eq__�s1����+�0���'�!�!��N��5�=�=��4��r"r!)rWr�s` r#�_get_eqr��s#���������Mr"c����fd�}|S)Nc�R���jjturtS�|urdStS�NF)�__ne__r�rr�)r�rWs �r#r�z_get_ne.<locals>.__ne__s,����;�)��8�8��N��5�=�=��5��r"r!)rWr�s` r#�_get_ner�s#���������Mr"c����fd�}|S)Nc�j���jj}|turtg��St|��Sr<)�__iter__r�rr��r�rWs �r#r�z_get_iter.<locals>.__iter__s1����-�2���g�����8�8�O��G�}�}�r"r!)rWr�s` r#�	_get_iterr�
s#���������Or"c����fd�}|S)Nc����jj}|turtt	g����Stt	|����Sr<)r�r�r�_AsyncIteratorr�r�s �r#r�z"_get_async_iter.<locals>.__aiter__s@����.�3���g���!�$�r�(�(�+�+�+��d�7�m�m�,�,�,r"r!)rWr�s` r#�_get_async_iterr�s$���-�-�-�-�-�
�r")r�r�r�r�c�&�t�|t��}|tur	||_dSt�|��}|�||��}||_dSt
�|��}|�||��|_dSdSr<)�_return_valuesrsrr��_calculate_return_value�_side_effect_methodsr�)rDr�r*�fixed�return_calculatorr��
side_effectors       r#�_set_return_valuer�(s������t�W�-�-�E��G���#�����/�3�3�D�9�9���$�(�(��.�.��*�����(�,�,�T�2�2�M�� �*�]�4�0�0�����!� r"c��eZdZd�Zd�ZdS)�
MagicMixinc��|���tt|��j|i|��|���dSr<)�_mock_set_magicsrr�rH�rWrXrs   r#rHzMagicMixin.__init__;sN��������.��J��%�%�.��;��;�;�;��������r"c	��ttz}|}t|dd���X|�|j��}t��}||z
}|D](}|t
|��jvrt||���)|tt
|��j��z
}t
|��}|D]!}t||t||�����"dS)Nr))�_magicsr�r1�intersectionr)ryr>rrr�rg�
MagicProxy)rW�orig_magics�these_magics�
remove_magicsrKr�s      r#r�zMagicMixin._mock_set_magicsAs���� 4�4��"���4��$�/�/�;�&�3�3�D�4F�G�G�L��E�E�M�'�,�6�M�&�
)�
)���D��J�J�/�/�/��D�%�(�(�(��$�c�$�t�*�*�*=�&>�&>�>���T�
�
��!�	;�	;�E��E�5�*�U�D�"9�"9�:�:�:�:�	;�	;r"N)rrrrHr�r!r"r#r�r�:s2������ � � �;�;�;�;�;r"r�c��eZdZdZdd�ZdS)r
z-A version of `MagicMock` that isn't callable.Fc�Z�|�||��|���dSr!�rr�r"s   r#r#z"NonCallableMagicMock.mock_add_spec[�2��	
���D�(�+�+�+��������r"Nr��rrrr r#r!r"r#r
r
Ys.������7�7� � � � � � r"r
c��eZdZd�ZdS)�AsyncMagicMixinc��|���tt|��j|i|��|���dSr<)r�rr�rHr�s   r#rHzAsyncMagicMixin.__init__fsN��������3��O�T�*�*�3�T�@�R�@�@�@��������r"N�rrrrHr!r"r#r�r�es#������ � � � � r"r�c��eZdZdZdd�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`.
    Fc�Z�|�||��|���dSr!r�r"s   r#r#zMagicMock.mock_add_specvr�r"Nr�r�r!r"r#rrks2������	�	� � � � � � r"rc�"�eZdZd�Zd�Zdd�ZdS)r�c�"�||_||_dSr<�r*r�)rWr*r�s   r#rHzMagicProxy.__init__�s����	�����r"c��|j}|j}|�|||���}t|||��t	|||��|S)N)r*rr)r*r�r1rgr�)rWrKr��ms    r#�create_mockzMagicProxy.create_mock�sZ���	������"�"���/5�
#�
7�
7�����q�!�!�!��&�!�U�+�+�+��r"Nc�*�|���Sr<)r�)rWr5r�s   r#r�zMagicProxy.__get__�s�����!�!�!r"r<)rrrrHr�r�r!r"r#r�r��sF������������"�"�"�"�"�"r"r�c���eZdZed��Zed��Zed��Z�fd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
dd�Zd
�Z�fd�Z�xZS)r�r�r�r�c����t��j|i|��tjj|jd<d|jd<d|jd<t
��|jd<tt���}tj
tjztjz|_
d|_d|_d|_d|_||jd<d	|jd
<t%��|jd<i|jd<d|jd
<dS)Nr�r�_mock_await_count�_mock_await_args�_mock_await_args_list�r�)rXrYr8r
rrerfrH)�superrHr�r�r�rrr�rrr2�CO_COROUTINE�
CO_VARARGS�CO_VARKEYWORDS�co_flags�co_argcount�co_varnames�co_posonlyargcount�co_kwonlyargcountrn)rWrXrY�	code_mockr6s    �r#rHzAsyncMockMixin.__init__�s���������$�)�&�)�)�)�*1�);�)I��
�o�&�-.��
�)�*�,0��
�(�)�1:����
�-�.�#�X�6�6�6�	�� �� �
!��$�
%�	��
!"�	�� 2�	��'(�	�$�&'�	�#�$-��
�j�!�$/��
�j�!�(-����
�n�%�*,��
�&�'�+/��
�'�(�(�(r"c��`K�t||fd���}|xjdz
c_||_|j�|��|j}|��t
|��r|�t|��s8	t|��}n#t$rt�wxYwt
|��r|�n&t|��r||i|���d{V��}n||i|��}|tur|S|j
tur|jS|j�4t|j��r|j|i|���d{V��S|j|i|��S|jS)NTr�r�)r�r�r�r�r,r�rArkr��
StopIteration�StopAsyncIterationrrr�r�r)rWrXrYr�r�r}s      r#r�z!AsyncMockMixin._execute_mock_call�s������t�V�n�$�/�/�/�����A���������#�#�E�*�*�*��!�����V�$�$�
1����v�&�&�
1�-�!�&�\�\�F�F��$�-�-�-�-�,�-����!��(�(�!� �L�!�$�V�,�,�
1�%�v�t�6�v�6�6�6�6�6�6�6�6������0��0�0���W�$�$��
��"�'�1�1��$�$���'�"�4�#3�4�4�
?�-�T�-�t�>�v�>�>�>�>�>�>�>�>�>�#�4�#�T�4�V�4�4�4�� � s�1B�Bc�T�|jdkrd|jpd�d�}t|���dS)zA
        Assert that the mock was awaited at least once.
        r�	Expected rDz to have been awaited.N�r�r�r�r�s  r#r�zAsyncMockMixin.assert_awaited�s?����q� � �O�d�o�7��O�O�O�C� ��%�%�%�!� r"c�d�|jdks$d|jpd�d|j�d�}t|���dS)z@
        Assert that the mock was awaited exactly once.
        r�rrD�$ to have been awaited once. Awaited r�Nrr�s  r#r�z"AsyncMockMixin.assert_awaited_once�sW����1�$�$�9�t��8�&�9�9�#�/�9�9�9�C� ��%�%�%�%�$r"c�h�����j�)������}td|�d�������fd�}��t	��fd�����}���j��}||kr1t|t��r|nd}t|����|�dS)zN
        Assert that the last await was with the specified arguments.
        NzExpected await: z
Not awaitedc�8������d���}|S)N�await)r�r�r�s ���r#r�z:AsyncMockMixin.assert_awaited_with.<locals>._error_message�s"����3�3�D�&��3�Q�Q�C��Jr"Tr�)r�r�r�r�r�r/r�)rWrXrYr�r�r�r�s```    r#r�z"AsyncMockMixin.assert_awaited_with�s�������?�"��7�7��f�E�E�H� �!K�H�!K�!K�!K�L�L�L�	�	�	�	�	�	�	��%�%�e�T�6�N��&E�&E�&E�F�F���#�#�D�O�4�4���X��� *�8�Y� ?� ?�I�H�H�T�E� ���!1�!1�2�2��=��r"c�z�|jdks$d|jpd�d|j�d�}t|���|j|i|��S)zi
        Assert that the mock was awaited exactly once and with the specified
        arguments.
        r�rrDr	r�)r�r�r�r�r�s    r#r�z'AsyncMockMixin.assert_awaited_once_with�sg��
��1�$�$�9�t��8�&�9�9�#�/�9�9�9�C� ��%�%�%�'�t�'��8��8�8�8r"c�$����t||fd�����}t|t��r|nd}�fd��jD��}|s|t|��vr)��||��}td|z��|�dS)zU
        Assert the mock has ever been awaited with the specified arguments.
        Tr�Nc�:��g|]}��|����Sr!r�r�s  �r#rrz3AsyncMockMixin.assert_any_await.<locals>.<listcomp>	s'���F�F�F�A�$�$�$�Q�'�'�F�F�Fr"z%s await not found)r�r�r/r�r�r�r�r�r�s`      r#r�zAsyncMockMixin.assert_any_await
	s�����%�%�e�T�6�N��&E�&E�&E�F�F��&�x��;�;�E�����F�F�F�F��1E�F�F�F���	�H�L��$8�$8�8�8�"�>�>�t�V�L�L�O� �$��6����
�9�8r"Fc�*���fd�|D��}td�|D��d��}t�fd��jD����}|sT||vrN|�d}nd�d�|D����}t	|�dt|���d	�j����|�dSt|��}g}|D]=}	|�|���#t$r|�|��Y�:wxYw|r t	t|���d
���|�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`.
        c�:��g|]}��|����Sr!r�r�s  �r#rrz4AsyncMockMixin.assert_has_awaits.<locals>.<listcomp>#	r�r"c3�DK�|]}t|t���|V��dSr<r�rts  r#r�z3AsyncMockMixin.assert_has_awaits.<locals>.<genexpr>$	r�r"Nc3�B�K�|]}��|��V��dSr<r�r�s  �r#r�z3AsyncMockMixin.assert_has_awaits.<locals>.<genexpr>%	s1�����S�S��t�1�1�!�4�4�S�S�S�S�S�Sr"zAwaits not found.z,Error processing expected awaits.
Errors: {}c�@�g|]}t|t��r|nd��Sr<r�rts  r#rrz4AsyncMockMixin.assert_has_awaits.<locals>.<listcomp>-	r�r"r�z	
Actual: z not all found in await list)
r�r�r�r�r�rmr�rNr,rn)	rWr�r�r�r��
all_awaitsr�r�r�s	`        r#r�z AsyncMockMixin.assert_has_awaits	s����:�9�9�9�5�9�9�9���F�F��F�F�F��M�M���S�S�S�S�d�>R�S�S�S�S�S�
��	��z�)�)��=�1�G�G� ,�-3�V�$7�$7�-5�$7�$7�$7�.8�.8��%��6�6�!*�5�!1�!1�6�6�#�3�6�6����	�

�F��*�%�%�
��	��	'�	'�D�
'��!�!�$�'�'�'�'���
'�
'�
'�� � ��&�&�&�&�&�
'�����	� �49�)�4D�4D�4D�4D�F����
�	�	s�6C�C.�-C.c�d�|jdkr$d|jpd�d|j�d�}t|���dS)z9
        Assert that the mock was never awaited.
        rrrDz# to not have been awaited. Awaited r�Nrr�s  r#r�z!AsyncMockMixin.assert_not_awaitedC	sW����q� � �9�t��8�&�9�9�#�/�9�9�9�C� ��%�%�%�!� r"c�|��t��j|i|��d|_d|_t	��|_dS)z0
        See :func:`.Mock.reset_mock()`
        rN)r�r�r�r�r�r�)rWrXrYr6s   �r#r�zAsyncMockMixin.reset_mockL	sB���	�����D�+�F�+�+�+�������(�{�{����r"r�)rrrr�r�r�r�rHr�r�r�r�r�r�r�r�r��
__classcell__)r6s@r#r�r��s�������&�&�}�5�5�K�%�%�l�3�3�J�*�*�+<�=�=�O�0�0�0�0�0�8&!�&!�&!�P&�&�&�&�&�&�>�>�>�$	9�	9�	9����*�*�*�*�X&�&�&�+�+�+�+�+�+�+�+�+r"r�c��eZdZdZdS)r
aY
    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()
    >>> 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.
    Nrr!r"r#r
r
V	s������'�'�'�'r"r
c�$�eZdZdZd�Zd�Zd�ZdS)�_ANYz2A helper object that compares equal to everything.c��dSr�r!�rWr�s  r#r�z_ANY.__eq__�	s���tr"c��dSr�r!rs  r#r�z_ANY.__ne__�	s���ur"c��dS)Nz<ANY>r!r�s r#r�z
_ANY.__repr__�	s���wr"N)rrrr r�r�r�r!r"r#rr�	sG������8�8�����������r"rc���d|z}d}d�d�|D����}d�d�|���D����}|r|}|r|r|dz
}||z
}||zS)Nz%s(%%s)rz, c�,�g|]}t|����Sr!)�repr)r)rRs  r#rrz*_format_call_signature.<locals>.<listcomp>�	s��7�7�7�3�T�#�Y�Y�7�7�7r"c�"�g|]\}}|�d|����
S)�=r!)r)rMr�s   r#rrz*_format_call_signature.<locals>.<listcomp>�	s4�����#-�3��3�3�3������r")rdrO)r*rXrYr��formatted_args�args_string�
kwargs_strings       r#r�r��	s����$��G��N��)�)�7�7�$�7�7�7�8�8�K��I�I���17����������M��%�$���(��	#��d�"�N��-�'���^�#�#r"c��eZdZdZ		dd�Z		dd�Zd	�ZejZd
�Z	d�Z
d�Zd
�Ze
d���Ze
d���Zd�Zd�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!rNFTc��d}i}t|��}|dkr|\}}}n~|dkr<|\}	}
t|	t��r|	}t|
t��r|
}nD|
}nA|	|
}}n<|dkr6|\}t|t��r|}nt|t��r|}n|}|rt�|||f��St�||||f��S)Nr!�r�r�)r�r/rZrnr)rr�r*r�r��	from_kallrXrY�_len�first�seconds           r#rz
_Call.__new__�	s�������5�z�z���1�9�9�!&��D�$���
�Q�Y�Y�!�M�E�6��%��%�%�
-����f�e�,�,�$�!�D�D�#�F�F�$�f�f���
�Q�Y�Y��F�E��%��%�%�
�����E�5�)�)�
�������	6��=�=��t�V�n�5�5�5��}�}�S�4��v�"6�7�7�7r"c�0�||_||_||_dSr<)r�r��_mock_from_kall)rWr�r*r�r�r+s      r#rHz_Call.__init__�	s�����"���(����r"c�r�	t|��}n#t$r
tcYSwxYwd}t|��dkr|\}}n|\}}}t|dd��r#t|dd��r|j|jkrdSd}|dkrdi}}n�|dkr|\}}}n�|dkr?|\}	t|	t��r|	}i}nit|	t��r|	}di}}nMd}|	}nH|dkr@|\}
}t|
t��r!|
}t|t��r|i}}nd|}}n|
|}}ndS|r||krdS||f||fkS)	Nrr�r�Frr!r*r�)r�r�r�r1r�r/rnrZ)rWr��	len_other�	self_name�	self_args�self_kwargs�
other_name�
other_args�other_kwargsr�r-r.s            r#r�z_Call.__eq__�	s���	"��E�
�
�I�I���	"�	"�	"�!�!�!�!�	"�����	��t�9�9��>�>�%)�"�I�{�{�04�-�I�y�+��D�.�$�/�/�	�G�E�>�SW�4X�4X�	��%��);�;�;��5��
���>�>�')�2��J�J�
�!�^�^�38�0�J�
�L�L�
�!�^�^��F�E��%��'�'�
%�"�
�!����E�3�'�'�
%�"�
�+-�r�L�
�
��
�$���
�!�^�^�!�M�E�6��%��%�%�
9�"�
��f�e�,�,�:�/5�r��J�J�/1�6��J�J�+0�&�L�
�
��5��	��y�0�0��5��L�)�i��-E�E�Es��&�&c��|j�td||fd���S|jdz}t|j||f||���S)Nrr/r�r��r�r�r�s    r#rKz_Call.__call__
sN���?�"��"�d�F�+�$�7�7�7�7����%���d�o�t�V�4�4��M�M�M�Mr"c�n�|j�t|d���S|j�d|��}t||d���S)NF)r*r+rI)r*r�r+r:)rWr�r*s   r#r�z_Call.__getattr__
sD���?�"��d�e�4�4�4�4��/�/�/�4�4�0���$�t�u�=�=�=�=r"c�b�|tjvrt�t�||��Sr<)rnrrrL�__getattribute__)rWr�s  r#r=z_Call.__getattribute__$
s+���5�>�!�!� � ��%�%�d�D�1�1�1r"c�H�t|��dkr|\}}n|\}}}||fS)Nr�)r�r�s    r#�_get_call_argumentsz_Call._get_call_arguments*
s2���t�9�9��>�>��L�D�&�&�!%��D�$���V�|�r"c�6�|���dS�Nr�r?r�s r#rXz
_Call.args2
����'�'�)�)�!�,�,r"c�6�|���dS)Nr�rBr�s r#rYz_Call.kwargs6
rCr"c��|js%|jpd}|�d��rd|z}|St|��dkrd}|\}}n+|\}}}|sd}n |�d��sd|z}nd|z}t	|||��S)Nrr/zcall%sr�zcall.%s)r0r�r(r�r�)rWr*rXrYs    r#r�z_Call.__repr__:
s����#�	��?�,�f�D����t�$�$�
'��$����K��t�9�9��>�>��D��L�D�&�&�!%��D�$���
'�����_�_�T�*�*�
'� �4�'����$���%�d�D�&�9�9�9r"c��g}|}|�%|jr|�|��|j}|�%tt	|����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.)r0r,r�r�rc)rW�vals�things   r#�	call_listz_Call.call_listO
sW���������$�
#����E�"�"�"��&�E�����$���(�(�(r")r!rNFT)r!NNFT)rrrr rrHr�rwr�rKr�r=r?r�rXrYr�rIr!r"r#r�r��	s��������$:?��8�8�8�8�@>C��)�)�)�)�2F�2F�2F�j�]�F�N�N�N�>�>�>�2�2�2�����-�-��X�-��-�-��X�-�:�:�:�*
)�
)�
)�
)�
)r"r�)r+c	�$�t|��rt|��}t|t��}t|��rt	d|�d����t|��}d|i}	|rd|i}	n|�i}	|	r|rd|	d<|st
|��|	�|��t}
tj
|��ri}	nL|r|rtd���t}
n1t|��st}
n|r|rt|��st}
|	�d	|��}|}|�d
}|
d||||d�|	��}t|t"��r"t%||��}|rt'|��nt)||||��|�|s
||j|<|�d��}
|r |sd
|vrt/||dd||
���|_t3|��D�];}t5|��r�	t7||��}n#t8$rY�1wxYwd|i}|
r&t;|
|��r|�|���|rd|i}t|t"��st=|||||��}||j|<n{|}t|t"��r|j}tA|||��}||d<tC|��rt}nt}|d||||d�|��}||j|<t)|||���t|t"��rtE|||����=|S)aCreate 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` will raise a `RuntimeError` if passed some common
    misspellings of the arguments autospec and spec_set. Pass the argument
    `unsafe` with the value True to disable that check.

    `create_autospec` also takes arbitrary keyword arguments that are passed to
    the constructor of the created mock.z'Cannot autospec a Mock object. [object=r%r�r�NTrzJInstance can not be True when create_autospec is mocking an async functionr*r)r�rrr*rr�r/)rar8r�rrpr)r�r*rr)r`r!)#ror>r/r.rr:rr rr2�isdatadescriptorr�r
rkr
rurQrEr�r�rbr�rsr	r�r+r�r1rLr0rCrD�
_must_skiprrg)r�r�rar�r8rrY�is_type�
is_async_funcrBrArrD�wrappedrKr|r
r�r`�child_klasss                    r#r	r	_
s��.��~�~���D�z�z����t�$�$�G�����5�� 4�*.� 4� 4� 4�5�5�	5�"�4�(�(�M��t�n�G����t�$���	
�����,�8�,�'+��#�$��&��f�%�%�%��N�N�6�����E����%�%�%����	�%��	?�� >�?�?�
?����
�t�_�_�%�$���	�%�X�%�&8��&>�&>�%�$���K�K���&�&�E��I����	��5�(��W�	��(�(�&�(�(�D��$�
�&�&�8��d�D�)�)���	$��d�#�#�#����t�W�h�7�7�7���8��(,���u�%��j�j��!�!�G��;�x�;�N�&�$@�$@�+�D�(�T�26��29�;�;�;����T���3&�3&���U���	��	��t�U�+�+�H�H���	�	�	��H�	�����(�#���	*�w�w��.�.�	*��M�M��M�)�)�)��	,� �(�+�F��(�M�2�2�	A��X�x��u�h�G�G�C�),�D���&�&��F��$�
�.�.�
#����"�4���8�8�I�"+�F�;��"�8�,�,�
(�'���'���+�(�V�%�5�*0�(�(� &�(�(�C�*-�D���&��X�s�i�@�@�@�@��c�=�)�)�	&��D�%��%�%�%���Ks�'G8�8
H�Hc�D�t|t��s|t|di��vrdS|j}|jD]f}|j�|t��}|tur�,t|ttf��rdSt|t��r|cSdS|S)z[
    Return whether we should skip the first argument on spec's `entry`
    attribute.
    rrF)r/r>r1r6rqrrrsrrJrIrE)r�rKrMr�r}s     r#rLrL�
s���
�d�D�!�!���G�D�*�b�1�1�1�1��5��~���������#�#�E�7�3�3���W�����f�|�[�9�:�:�	��5�5�
��
�
.�
.�	��N�N�N��5�5��Nr"c��eZdZ		dd�ZdS)rCFNc�Z�||_||_||_||_||_||_dSr<)r��idsr�r�rar*)rWr�r�r�r*rTras       r#rHz_SpecState.__init__s0����	���� ��
���� ��
���	�	�	r")FNNNFr�r!r"r#rCrC
s.������48�/4������r"rCc�|�t|t��rtj|��Stj|��Sr<)r/�bytes�io�BytesIO�StringIO)�	read_datas r#�
_to_streamr[%s4���)�U�#�#�&��z�)�$�$�$��{�9�%�%�%r"rc	�V���	�
��t���}|dg�
�
�fd�}�
�fd�}��
fd��	�
�fd���
�fd�}t�dddl}tt	t|j�����t	t|j��������at�2ddl}tt	t|j
������a	|�tdt�	��}tt�
�����j_
d�j_
d�j_
d�j_
d�j_
|�j_�	���
d<�
d�j_|�j_��j_|�j_�	�
��fd�}||_�|_
|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.
    Nc�Z���jj��jjS�dj|i|��SrA)�	readlinesr��rXrY�_state�handles  ��r#�_readlines_side_effectz)mock_open.<locals>._readlines_side_effect;s7�����(�4��#�0�0�"�v�a�y�"�D�3�F�3�3�3r"c�Z���jj��jjS�dj|i|��SrA)�readr�r_s  ��r#�_read_side_effectz$mock_open.<locals>._read_side_effect@s4����;�#�/��;�+�+��v�a�y�~�t�.�v�.�.�.r"c?�V�K����Ed{V��	�dj|i|��V���NTr)�readline)rXrY�_iter_side_effectr`s  ��r#�_readline_side_effectz(mock_open.<locals>._readline_side_effectEsT�����$�$�&�&�&�&�&�&�&�&�&�	6�$�&��)�$�d�5�f�5�5�5�5�5�	6r"c3�b�K��jj�	�jjV���dD]}|V��dSrg)rhr�)�liner`ras ��r#riz$mock_open.<locals>._iter_side_effectJsU������?�'�3�
3��o�2�2�2�2�
3��1�I�	�	�D��J�J�J�J�	�	r"c�^���jj��jjSt�d��SrA)rhr�r�)r`ras��r#�_next_side_effectz$mock_open.<locals>._next_side_effectQs)����?�'�3��?�/�/��F�1�I���r"r�open)r*r�)r�r�c���t����d<�jj�dkr����d<�d�j_tS)Nrr�)r[rhr�r)rXrYrjr`rarZs  ����r#�
reset_datazmock_open.<locals>.reset_dataqsM����y�)�)��q�	��?�&�&��)�3�3�-�-�/�/�F�1�I�*0��)�F�O�'��r")r[�	file_spec�_iormryr+�
TextIOWrapper�unionrX�	open_specrorrFr��writerdrhr^r�r�r�)rDrZ�
_read_datarbrernrsrqrirjr`ras `      @@@@r#rr,s��������I�&�&�J��$�
�F�4�4�4�4�4�4�
/�/�/�/�/�/�
6�6�6�6�6�6�
���������������
�
�
���S��!2�3�3�4�4�:�:�3�s�3�;�?O�?O�;P�;P�Q�Q�R�R�	����
�
�
���S���]�]�+�+�,�,�	��|��f�9�5�5�5��
�I�
&�
&�
&�F�$*�F��!� $�F�L��#�F�K��#'�F�O� �$(�F��!�/�F�K��%�%�'�'�F�1�I�"(��)�F�O��#9�F�� �"3�F�O��"3�F�O����������"�D���D���Kr"c�&�eZdZdZd�Zdd�Zd�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.
    c��tdi|��S)Nr!)r)rWrYs  r#r1zPropertyMock._get_child_mock�s���"�"�6�"�"�"r"Nc��|��Sr<r!)rWr5�obj_types   r#r�zPropertyMock.__get__�s
���t�v�v�
r"c��||��dSr<r!)rWr5rSs   r#r�zPropertyMock.__set__�s����S�	�	�	�	�	r"r<)rrrr r1r�r�r!r"r#rr~sP��������#�#�#���������r"rc�4�d|_t|��D]�}	t||��}n#t$rY� wxYwt	|t
��s�:t	|j�|��t��r�h|j	|urt|����dS)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+r1rLr/rr�rsrCr�r)rDr�r�s   r#rr�s����D���D�	�	�
�
��	���d�#�#�A�A���	�	�	��H�	�����!�_�-�-�	���a�&�*�*�4�0�0�*�=�=�	�����%�%���G�G�G��
�
s�+�
8�8c��eZdZdZd�Zd�ZdS)r�z8
    Wraps an iterator in an asynchronous iterator.
    c�t�||_tt���}tj|_||jd<dS)Nr�r8)�iteratorrrr2�CO_ITERABLE_COROUTINEr�rr)rWr�rs   r#rHz_AsyncIterator.__init__�s6�� ��
�#�X�6�6�6�	�$�:�	��$-��
�j�!�!�!r"c��^K�	t|j��S#t$rYnwxYwt�r<)r�r�rrr�s r#r�z_AsyncIterator.__anext__�sA����	���
�&�&�&���	�	�	��D�	���� � s��
%�%N)rrrr rHr�r!r"r#r�r��s<��������.�.�.�!�!�!�!�!r"r�r�)NFNNN)FFNN)Nr)��__all__r�rrWr2r�r>�builtinsrTr�typesrrr�
unittest.utilr�	functoolsrr�	threadingrr�rr+r3rr�rr6r:r.rArFrRrbr]rkrorur�r{r�r�rwr�r�rr�MISSINGr��DELETEDrDr�r�rmr�r�r�r�rrMrHrr�r=r�rrrrVr[r_rrbrzr�re�multiple�stopallr�
magic_methods�numericsrdrP�inplace�right�
_non_defaultsr�r�r��_sync_async_magics�
_async_magicsr�r_r�r�r�r�r�r�r�r�r�r�r�r
r�rr�r�r
rrr�rnr�rr	rLrCr>r�rErrrvr[rrrr�r!r"r#�<module>r�s5
����&��������	�	�	�	�����
�
�
�
�
�
�
�
���������'�'�'�'�'�'�2�2�2�2�2�2�2�2�2�2�#�#�#�#�#�#�$�$�$�$�$�$�$�$�������C�C�C�C�C�y�C�C�C�
I�H�c�c�(�m�m�H�H�H�	�
�
���@�@�@����2�2�2������� � � �F	#�	#�	#�	#�
�
�
����&�&�&��������6."�."�."�b>�>�>�6)�)�)�	)�	)�	)�	)�	)�f�	)�	)�	)�����������9�;�;��
�
������������ � � �&*�*�*�*�*��*�*�*�(���6���������
�
�
�
�
�6�
�
�
�N
<�N
<�N
<�N
<�N
<�d�N
<�N
<�N
<�b
�G��o�6�7�7�	�
�
�
�
�
�4�
�
�
� ���g!�g!�g!�g!�g!�D�g!�g!�g!�V6�6�6�6�6�=�/�6�6�6�v���L/�L/�L/�L/�L/�V�L/�L/�L/�`
<�<�<� '�T��t�d���&+������:?C�04�.�.�.�.�d�$�u���4�O�CH�O�O�O�O�O�dV/�V/�V/�V/�V/�&�V/�V/�V/�r���������
��
� �����
����
��"K�	��(�(�7�7�h�n�n�&6�&6�7�7�7�
7�
7�����5�5�H�N�N�$4�$4�5�5�5�5�5�����
�������H�H�m�X�w��
6�7�7�=�=�?�?�����@�?�?��!�]��$�'9�9�
��]�*����.������3�2�0�0�6�6�^�^�	�������������������"��������������� �	���1�1�1�$;�;�;�;�;��;�;�;�>	 �	 �	 �	 �	 �:��	 �	 �	 � � � � � �j� � � � � � � � �
�D� � � �,"�"�"�"�"��"�"�"�$@+�@+�@+�@+�@+�T�@+�@+�@+�F(�(�(�(�(����(�(�(�V
�
�
�
�
�6�
�
�
��d�f�f��$�$�$�$v)�v)�v)�v)�v)�E�v)�v)�v)�r
�u�u�����CG��O�*/�O�O�O�O�O�d���8	�	�	�	�	��	�	�	�	�D�����D�����	�
�
�	��	�&�&�&�O�O�O�O�d�����4����$���0!�!�!�!�!�!�!�!�!�!r"__pycache__/case.cpython-311.pyc000064400000233262152401764000012400 0ustar00�

�K��4b���B�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZmZmZmZmZdZe��ZdZGd�d	e��ZGd
�de��ZGd�d
e��ZGd�de��Zd�Zd�Zd�Zd�ZgZ d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'd�Z(Gd�d��Z)Gd�de)��Z*Gd �d!e*��Z+Gd"�d#e*��Z,Gd$�d%ej-��Z.Gd&�d'e��Z/Gd(�d)e/��Z0Gd*�d+e/��Z1dS),zTest 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��eZdZdZdS)�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__���8/opt/alt/python-internal/lib/python3.11/unittest/case.pyrrs���������rrc��eZdZdZdS)�_ShouldStopz
    The test should stop.
    Nrrrrrr!����������rrc��eZdZdZdS)�_UnexpectedSuccessz7
    The test was supposed to fail, but it didn't!
    Nrrrrrr&rrrc�8�eZdZdd�Zejdd���ZdS)�_OutcomeNc�h�d|_||_t|d��|_d|_d|_dS)NF�
addSubTestT)�expecting_failurer�hasattr�result_supports_subtests�success�expectedFailure)�selfrs  r�__init__z_Outcome.__init__-s8��!&������(/���(E�(E��%����#����rFc#�BK�|j}d|_	dV�|r(|jr!|j�|j|d��n�#t$r�t
$r4}d|_t
|j|t|����Yd}~nzd}~wt$rYnktj
��}|jr||_nAd|_|r"|j�|j||��nt|j||��d}YnxYw|jo||_dS#|jo||_wxYw)NTF)r rr�	test_case�KeyboardInterruptr�_addSkip�strr�sys�exc_inforr!�	_addError)r"r%�subTest�old_success�er*s      r�testPartExecutorz_Outcome.testPartExecutor4sq�����l�����	8��E�E�E�,�
M�4�<�
M���&�&�y�':�I�t�L�L�L���-!�	�	�	���	5�	5�	5� �D�L��T�[�)�S��V�V�4�4�4�4�4�4�4�4������	�	�	��D�	��|�~�~�H��%�
@�'/��$�$�$����@��K�*�*�9�+>�	�8�T�T�T�T��d�k�9�h�?�?�?��H�H�H����
 �<�7�K�D�L�L�L��4�<�7�K�D�L�7�7�7�7s;�A�+D�C;�*B�?D�
C;�D�A&C;�9D�D�N)F)r
rrr#�
contextlib�contextmanagerr/rrrrr,sL������$�$�$�$���8�8�8���8�8�8rrc��t|dd��}|�|||��dStjdtd��|j|��dS)N�addSkipz4TestResult has no addSkip method, skips not reported�)�getattr�warnings�warn�RuntimeWarning�
addSuccess)rr%�reasonr4s    rr'r'Usf���f�i��.�.�G�����	�6�"�"�"�"�"��
�L�$�a�	)�	)�	)����)�$�$�$�$�$rc��|�C|�Ct|d|j��r|j||��dS|j||��dSdSdS)Nr)�
issubclass�failureException�
addFailure�addError)r�testr*s   rr+r+^si��
��h�2��h�q�k�4�#8�9�9�	,��F��d�H�-�-�-�-�-��F�O�D�(�+�+�+�+�+�	��2�2rc��|Sr0r)�objs r�_idrDes���Jrc���t|��}	|j}|j}n/#t$r"t	d|j�d|j�d���d�wxYw||��}|||ddd��|S)N�'�.z6' object does not support the context manager protocol)�type�	__enter__�__exit__�AttributeError�	TypeErrorrr)�cm�
addcleanup�cls�enter�exitrs      r�_enter_contextrRis����r�(�(�C�O��
���|�����O�O�O��D�C�N�D�D�S�-=�D�D�D�E�E�JN�	O�O�����U�2�Y�Y�F��J�t�R��t�T�*�*�*��Ms	� �,Ac�@�t�|||f��dS)znSame as addCleanup, except the cleanup items are called even if
    setUpModule fails (unlike tearDownModule).N)�_module_cleanups�append)�function�args�kwargss   r�addModuleCleanuprYys%�����X�t�V�4�5�5�5�5�5rc�,�t|t��S)z&Same as enterContext, but module-wide.)rRrY)rMs r�enterModuleContextr[~s���"�.�/�/�/rc���g}trZt���\}}}	||i|��n,#t$r}|�|��Yd}~nd}~wwxYwt�Z|r|d�dS)zWExecute all module cleanup functions. Normally called for you after
    tearDownModule.Nr)rT�pop�	ExceptionrU)�
exceptionsrVrWrX�excs     r�doModuleCleanupsra�s����J�
�#�!1�!5�!5�!7�!7���$��	#��H�d�%�f�%�%�%�%���	#�	#�	#����c�"�"�"�"�"�"�"�"�����	#����	�#�����m���s�1�
A�A�Ac�d���fd�}t�tj��r�}d�||��S|S)z&
    Unconditionally skip a test.
    c���t|t��s!tj|���fd���}|}d|_�|_|S)Nc�"��t����r0�r)rWrXr;s  �r�skip_wrapperz-skip.<locals>.decorator.<locals>.skip_wrapper�s����v�&�&�&rT)�
isinstancerH�	functools�wraps�__unittest_skip__�__unittest_skip_why__)�	test_itemrfr;s  �r�	decoratorzskip.<locals>.decorator�s^����)�T�*�*�	%�
�_�Y�
'�
'�
'�
'�
'�
'�(�
'�
'�$�I�&*�	�#�*0�	�'��r�)rg�types�FunctionType)r;rmrls`  r�skiprq�sS���	�	�	�	�	��&�%�,�-�-�$��	����y��#�#�#��rc�2�|rt|��StS)z/
    Skip a test if the condition is true.
    �rqrD��	conditionr;s  r�skipIfrv�s�����F�|�|���Jrc�2�|st|��StS)z3
    Skip a test unless the condition is true.
    rsrts  r�
skipUnlessrx�s�����F�|�|���Jrc��d|_|S)NT)�__unittest_expecting_failure__)rls rr!r!�s��/3�I�,��rc���t|t��rt�fd�|D����St|t��ot	|���S)Nc3�8�K�|]}t|���V��dSr0)�_is_subtype)�.0r.�basetypes  �r�	<genexpr>z_is_subtype.<locals>.<genexpr>�s-�����>�>��;�q�(�+�+�>�>�>�>�>�>r)rg�tuple�allrHr=)�expectedrs `rr}r}�sW����(�E�"�"�?��>�>�>�>�X�>�>�>�>�>�>��h��%�%�H�*�X�x�*H�*H�Hrc��eZdZd�Zd�ZdS)�_BaseTestCaseContextc��||_dSr0)r%)r"r%s  rr#z_BaseTestCaseContext.__init__�s
��"����rc�v�|j�|j|��}|j�|���r0)r%�_formatMessage�msgr>)r"�standardMsgr�s   r�
_raiseFailurez"_BaseTestCaseContext._raiseFailure�s1���n�+�+�D�H�k�B�B���n�-�-�c�2�2�2rN)r
rrr#r�rrrr�r��s2������#�#�#�3�3�3�3�3rr�c��eZdZdd�Zd�ZdS)�_AssertRaisesBaseContextNc��t�||��||_||_|�t	j|��}||_d|_d|_dSr0)	r�r#r�r%�re�compile�expected_regex�obj_namer�)r"r�r%r�s    rr#z!_AssertRaisesBaseContext.__init__�sU���%�%�d�I�6�6�6� ��
�"����%��Z��7�7�N�,�����
�����rc���	t|j|j��st|�d|j�����|sM|�dd��|_|r,ttt|�����d����|d}S|^}}	|j	|_
n$#t$rt|��|_
YnwxYw|5||i|��ddd��n#1swxYwYd}dS#d}wxYw)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() arg 1 must be r�Nz1 is an invalid keyword argument for this function)
r}r��
_base_typerL�_base_type_strr]r��next�iterr
r�rKr()r"�namerWrX�callable_objs     r�handlez_AssertRaisesBaseContext.handle�sz��	��t�}�d�o�>�>�
=��!%���t�':�':�!<�=�=�=��
�!�:�:�e�T�2�2����M�#�7;�D��L�L�7I�7I�7I�7I�%L�M�M�M���D�D�#'��L�4�
2� ,� 5��
�
��!�
2�
2�
2� #�L� 1� 1��
�
�
�
2�����
.�
.���d�-�f�-�-�-�
.�
.�
.�
.�
.�
.�
.�
.�
.�
.�
.����
.�
.�
.�
.��D�D�D��4�D�K�K�K�KsZ�A?C �C �	B�C �B7�4C �6B7�7C �<	C�C �C�C �C�C � C$r0)r
rrr#r�rrrr�r��s7��������������rr�c�F�eZdZdZeZdZd�Zd�Ze	e
j��ZdS)�_AssertRaisesContextzCA context manager used to implement TestCase.assertRaises* methods.z-an exception type or tuple of exception typesc��|Sr0r�r"s rrIz_AssertRaisesContext.__enter__�s���rc��|��	|jj}n$#t$rt|j��}YnwxYw|jr/|�d�||j����n=|�d�|����ntj|��t||j��sdS|�
d��|_|j�dS|j}|�
t|����s;|�d�|jt|������dS)Nz{} not raised by {}z
{} not raisedFT�"{}" does not match "{}")r�r
rKr(r�r��format�	traceback�clear_framesr=�with_traceback�	exceptionr��search�pattern)r"�exc_type�	exc_value�tb�exc_namer�s      rrJz_AssertRaisesContext.__exit__�se����
.��=�1����!�
.�
.�
.��t�}�-�-����
.�����}�
E��"�"�#8�#?�#?��@D�
�$O�$O�P�P�P�P��"�"�?�#9�#9�(�#C�#C�D�D�D�D��"�2�&�&�&��(�D�M�2�2�	��5�"�1�1�$�7�7�����&��4��,���$�$�S��^�^�4�4�	>����9�@�@�#�+�S��^�^� =� =�
>�
>�
>��ts��2�2N)
r
rrr�
BaseExceptionr�r�rIrJ�classmethodro�GenericAlias�__class_getitem__rrrr�r��sS������M�M��J�D�N�������6$��E�$6�7�7���rr�c�&�eZdZdZeZdZd�Zd�ZdS)�_AssertWarnsContextzBA context manager used to implement TestCase.assertWarns* methods.z(a warning type or tuple of warning typesc�6�ttj�����D]}t	|dd��ri|_�t
jd���|_|j�	��|_t
j
d|j��|S)N�__warningregistry__T)�record�always)�listr)�modules�valuesr6r�r7�catch_warnings�warnings_managerrI�simplefilterr�)r"�vs  rrIz_AssertWarnsContext.__enter__ s����c�k�(�(�*�*�+�+�	+�	+�A��q�/��6�6�
+�(*��%�� (� 7�t� D� D� D����-�7�7�9�9��
���h��
�6�6�6��rc���|j�|||��|�dS	|jj}n$#t$rt|j��}YnwxYwd}|jD]s}|j}t||j��s�|�|}|j	�(|j	�
t|����s�R||_|j|_|j
|_
dS|�@|�d�|j	jt|������|jr0|�d�||j����dS|�d�|����dS)Nr�z{} not triggered by {}z{} not triggered)r�rJr�r
rKr(r7�messagergr�r��warning�filename�linenor�r�r�r�)r"r�r�r�r��first_matching�m�ws        rrJz_AssertWarnsContext.__exit__+s�����&�&�x��B�?�?�?����F�	*��}�-�H�H���	*�	*�	*��4�=�)�)�H�H�H�	*��������
	�
	�A��	�A��a���/�/�
���%�!"���#�/��'�.�.�s�1�v�v�6�6�0���D�L��J�D�M��(�D�K��F�F��%����9�@�@��(�0�#�n�2E�2E� G� G�
H�
H�
H��=�	D����7�>�>�x�?C�}� N� N�
O�
O�
O�
O�
O�
���1�8�8��B�B�C�C�C�C�Cs�/�A�AN)	r
rrr�Warningr�r�rIrJrrrr�r�sG������L�L��J�?�N�	�	�	� D� D� D� D� Drr�c��eZdZd�ZdS)�_OrderedChainMapc#�~K�t��}|jD]$}|D]}||vr|�|��|V�� �%dSr0)�set�maps�add)r"�seen�mapping�ks    r�__iter__z_OrderedChainMap.__iter__Os`�����u�u���y�	�	�G��
�
���D�=�=��H�H�Q�K�K�K��G�G�G��
�	�	rN)r
rrr�rrrr�r�Ns#����������rr�c���eZdZdZeZdZdZdZ�fd�Z	dOd�Z
d�Zd	�Zd
�Z
ed���Zed���Zd
�Zd�Zed���Zed���Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zejefd���Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&dPd!�Z'd"�Z(ed#���Z)d$�Z*d%�Z+d&�Z,dPd'�Z-dPd(�Z.dPd)�Z/d*�Z0d+�Z1d,�Z2dQd-�Z3dQd.�Z4d/�Z5dPd0�Z6dPd1�Z7dPd2�Z8		dRd3�Z9		dRd4�Z:dQd5�Z;d6�Z<dPd7�Z=dPd8�Z>dPd9�Z?dPd:�Z@dPd;�ZAdPd<�ZBdPd=�ZCdPd>�ZDdPd?�ZEdPd@�ZFdPdA�ZGdPdB�ZHdPdC�ZIdPdD�ZJdPdE�ZKdPdF�ZLdPdG�ZMdPdH�ZNdPdI�ZOdJ�ZPdK�ZQdPdL�ZRdPdM�ZSdN�ZTeTe7��xZUZVeTe8��xZWZXeTe9��xZYZZeTe:��xZ[Z\eTe/��xZ]Z^eTe1��Z_eTe.��Z`eTeP��ZaeTeR��ZbeTeS��Zc�xZdS)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�ic�V��d|_g|_t��j|i|��dS)NF)�_classSetupFailed�_class_cleanups�super�__init_subclass__)rOrWrX�	__class__s   �rr�zTestCase.__init_subclass__�s5��� %��� ���!����!�4�2�6�2�2�2�2�2r�runTestc�:�||_d|_d|_	t||��}|j|_n0#t
$r#|dkrt
d|j�d|�����YnwxYwg|_d|_	i|_
|�td��|�td��|�td��|�td	��|�t d	��|�t"d
��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 �: �assertDictEqual�assertListEqual�assertTupleEqual�assertSetEqual�assertMultiLineEqual)�_testMethodName�_outcome�_testMethodDocr6rrK�
ValueErrorr��	_cleanups�_subtest�_type_equality_funcs�addTypeEqualityFunc�dictr�r�r��	frozensetr()r"�
methodName�
testMethods   rr#zTestCase.__init__�sA��
 *�����
�'���		5� ��z�2�2�J�#-�"4�D�����	4�	4�	4��Y�&�&�!�j��~�~�~�z�z�"3�4�4�4�'�&�	4���������
�
%'��!�� � ��'8�9�9�9�� � ��'8�9�9�9�� � ��(:�;�;�;�� � ��&6�7�7�7�� � ��,<�=�=�=�� � ��&<�=�=�=�=�=s�4�*A!� A!c��||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�)r"�typeobjrVs   rr�zTestCase.addTypeEqualityFunc�s��.6��!�'�*�*�*rc�@�|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).N)r�rU�r"rVrWrXs    r�
addCleanupzTestCase.addCleanup�s'��	
����x��v�6�7�7�7�7�7rc�,�t||j��S)z�Enters the supplied context manager.

        If successful, also adds its __exit__ method as a cleanup
        function and returns the result of the __enter__ method.
        )rRr�)r"rMs  r�enterContextzTestCase.enterContext�s���b�$�/�2�2�2rc�@�|j�|||f��dS)zpSame as addCleanup, except the cleanup items are called even if
        setUpClass fails (unlike tearDownClass).N)r�rU�rOrVrWrXs    r�addClassCleanupzTestCase.addClassCleanup�s(��	��"�"�H�d�F�#;�<�<�<�<�<rc�,�t||j��S)z%Same as enterContext, but class-wide.)rRr�)rOrMs  r�enterClassContextzTestCase.enterClassContext�s���b�#�"5�6�6�6rc��dS)zAHook method for setting up the test fixture before exercising it.Nrr�s r�setUpzTestCase.setUp�����rc��dS)zAHook method for deconstructing the test fixture after testing it.Nrr�s r�tearDownzTestCase.tearDown�r�rc��dS)zKHook method for setting up class fixture before running tests in the class.Nr�rOs r�
setUpClasszTestCase.setUpClass�����rc��dS)zVHook method for deconstructing the class fixture after running all tests in the class.Nrr�s r�
tearDownClasszTestCase.tearDownClass�rrc��dS)Nrrr�s r�countTestCaseszTestCase.countTestCases�s���qrc�(�tj��Sr0)r�
TestResultr�s r�defaultTestResultzTestCase.defaultTestResult�s��� �"�"�"rc��|j}|r?|����d��d���ndS)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"�docs  r�shortDescriptionzTestCase.shortDescription�sC���!��58�B�s�y�y�{�{� � ��&�&�q�)�/�/�1�1�1�d�Brc�>�t|j���d|j��S)NrG�rr�r�r�s r�idzTestCase.id�s#��"�4�>�2�2�2�2�D�4H�4H�I�Irc�l�t|��t|��urtS|j|jkSr0)rH�NotImplementedr��r"�others  r�__eq__zTestCase.__eq__�s0����:�:�T�%�[�[�(�(�!�!��#�u�'<�<�<rc�H�tt|��|jf��Sr0)�hashrHr�r�s r�__hash__zTestCase.__hash__�s���T�$�Z�Z��!5�6�7�7�7rc�P�|j�dt|j���d|j�d�S)N� (rG�))r�rr�r�s r�__str__zTestCase.__str__s1��#�3�3�3�X�d�n�5M�5M�5M�5M�t�Oc�Oc�Oc�d�drc�B�dt|j���d|j�d�S)N�<z testMethod=�>rr�s r�__repr__zTestCase.__repr__s.������(�(�(�(�$�*>�*>�*>�@�	@rc+��K�|j�|jjsdV�dS|j}|�t|��}n|j�|��}t
|||��|_	|j�|jd���5dV�ddd��n#1swxYwY|jjs|jj	}|�|j
rt�n|jjrt�||_dS#||_wxYw)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/r r�failfastrr!)r"r�r#�parent�
params_maprs      rr,zTestCase.subTestsI�����=� ��
�(N� ��E�E�E��F�����>�)�&�1�1�J�J���0�0��8�8�J� ��s�J�7�7��
�	#���/�/��
�t�/�L�L�
�
�����
�
�
�
�
�
�
�
�
�
�
����
�
�
�
��=�(�
"���-���%�&�/�%�%�%����.�
"�"�!�"�D�M�M�M��F�D�M�"�"�"�"s0�&!C(�B�C(�B�C(�B� ?C(�(	C1c��	|j}|||��dS#t$r.tjdt��|j|��YdSwxYw)Nz@TestResult has no addExpectedFailure method, reporting as passes)�addExpectedFailurerKr7r8r9r:)r"rr*r*s    r�_addExpectedFailurezTestCase._addExpectedFailure&s~��	/�!'�!:��
��t�X�.�.�.�.�.���	$�	$�	$��M�\�(�
*�
*�
*��F��d�#�#�#�#�#�#�	$���s��4A�Ac��	|j}||��dS#t$rXtjdt��	t
d�#t
$r'|j|tj����YYdSwxYwwxYw)NzCTestResult has no addUnexpectedSuccess method, reporting as failure)	�addUnexpectedSuccessrKr7r8r9rr?r)r*)r"rr-s   r�_addUnexpectedSuccesszTestCase._addUnexpectedSuccess0s���	'�#)�#>� �
!� ��&�&�&�&�&���	8�	8�	8��M�_�(�
*�
*�
*�
8�(�d�2��%�
8�
8�
8�!��!�$�����7�7�7�7�7�7�7�
8����	8���s&��$A8�A�,A4�/A8�3A4�4A8c�.�|���dSr0)r�r�s r�
_callSetUpzTestCase._callSetUp?s���
�
�����rc�^�|���"tjd|�d�td���dSdS)NzFIt is deprecated to return a value that is not None from a test case (r�)�
stacklevel)r7r8�DeprecationWarning)r"�methods  r�_callTestMethodzTestCase._callTestMethodBs\���6�8�8���M�2�(.�2�2�2�3E�RS�
U�
U�
U�
U�
U�
U� �rc�.�|���dSr0)r�r�s r�
_callTearDownzTestCase._callTearDownGs���
�
�����rc��||i|��dSr0rr�s    r�_callCleanupzTestCase._callCleanupJs����$�!�&�!�!�!�!�!rNc��|�C|���}t|dd��}t|dd��}|�
|��nd}|j|��	t||j��}t|jdd��st|dd��rWt|jdd��pt|dd��}t|||��||j|��|�|��SSt|dd��pt|dd��}t|��}	||_|�	|��5|�
��ddd��n#1swxYwY|jr�||_|�	|��5|�
|��ddd��n#1swxYwYd|_|�	|��5|���ddd��n#1swxYwY|���|jrK|r9|jr|�||j��n&|�|��n|j|��|d|_d}d|_|j|��|�|��SS#d|_d}d|_wxYw#|j|��|�|��wwxYw)N�startTestRun�stopTestRunrjFrkrnrz)rr6�	startTestr�r�r'�stopTestrr�r/r0r rr6r8�
doCleanupsr!r+r.r:)r"rr<r=r��skip_whyr�outcomes        r�runzTestCase.runMs����>��+�+�-�-�F�"�6�>�4�@�@�L�!�&�-��>�>�K��'��������K��������2	� ��t�';�<�<�J����(;�U�C�C�
��
�$7��?�?�
�$�D�N�4K�R�P�P�P�&�z�3J�B�O�O�����x�0�0�0��P
�F�O�D�!�!�!��&���
�
�
�
�'�M��>��F�F�M��
�$D�e�L�L�
��v�&�&�G�
%� '��
��-�-�d�3�3�&�&��O�O�%�%�%�&�&�&�&�&�&�&�&�&�&�&����&�&�&�&��?�-�0A�G�-� �1�1�$�7�7�9�9��,�,�Z�8�8�8�9�9�9�9�9�9�9�9�9�9�9����9�9�9�9�05�G�-� �1�1�$�7�7�-�-��*�*�,�,�,�-�-�-�-�-�-�-�-�-�-�-����-�-�-�-����!�!�!��?�0�(�0�"�2�?� �4�4�V�W�=T�U�U�U�U� �6�6�v�>�>�>�>�)��)�$�/�/�/��+/��'���!%��
�
�F�O�D�!�!�!��&���
�
�
�
�'��+/��'���!%��
�$�$�$�$��
�F�O�D�!�!�!��&���
�
�
�
�'���s��A5J(�,1J(�J�:E�J�E�J�"E�#&J�	F+�J�+F/�/J�2F/�3J�G3�'J�3G7�7J�:G7�;A*J�%J(�J%�%J(�(Kc��|jp
t��}|jrb|j���\}}}|�|��5|j|g|�Ri|��ddd��n#1swxYwY|j�b|jS)zNExecute all cleanup functions. Normally called for you after
        tearDown.N)r�rr�r]r/r:r )r"rBrVrWrXs     rr@zTestCase.doCleanups�s����-�-�8�:�:���n�	=�%)�^�%7�%7�%9�%9�"�H�d�F��)�)�$�/�/�
=�
=�!��!�(�<�T�<�<�<�V�<�<�<�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=����
=�
=�
=�
=��n�	=���s�A-�-A1�4A1c��g|_|jrk|j���\}}}	||i|��n;#t$r.|j�tj����YnwxYw|j�idSdS)zYExecute all class cleanup functions. Normally called for you after
        tearDownClass.N)�tearDown_exceptionsr�r]r^rUr)r*r�s    r�doClassCleanupszTestCase.doClassCleanups�s���#%����!�	?�%(�%8�%<�%<�%>�%>�"�H�d�F�
?���$�)�&�)�)�)�)���
?�
?�
?��'�.�.�s�|�~�~�>�>�>�>�>�
?����	�!�	?�	?�	?�	?�	?s�6�5A.�-A.c��|j|i|��Sr0)rC)r"rW�kwdss   r�__call__zTestCase.__call__�s���t�x��&��&�&�&rc���t||j��}t|jdd��st|dd��r6t|jdd��pt|dd��}t|���|���|�|��|���|jr7|j���\}}}|j	|g|�Ri|��|j�5dSdS)z6Run the test without collecting errors in a TestResultrjFrkrnN)
r6r�r�rr0r6r8r�r]r:)r"r�rArVrWrXs      r�debugzTestCase.debug�s���T�4�#7�8�8�
��D�N�$7��?�?�	%��J� 3�U�;�;�	%� ���0G��L�L�L�"�:�/F��K�K�
��8�$�$�$����������Z�(�(�(��������n�	9�%)�^�%7�%7�%9�%9�"�H�d�F��D��h�8��8�8�8��8�8�8��n�	9�	9�	9�	9�	9rc� �t|���)zSkip this test.re)r"r;s  r�skipTestzTestCase.skipTest�s���v���rc�,�|�|���)z)Fail immediately, with the given message.)r>)r"r�s  r�failz
TestCase.fail�s���#�#�C�(�(�(rc��|r;|�|dt|��z��}|�|���dS)z#Check that the expression is false.z%s is not falseN�r�rr>�r"�exprr�s   r�assertFalsezTestCase.assertFalse�sI���	-��%�%�c�+<�y����+N�O�O�C��'�'��,�,�,�	-�	-rc��|s;|�|dt|��z��}|�|���dS)z"Check that the expression is true.z%s is not trueNrRrSs   r�
assertTruezTestCase.assertTrue�sI���	-��%�%�c�+;�i��o�o�+M�N�N�C��'�'��,�,�,�	-�	-rc��|js|p|S|�|S	|�d|��S#t$r$t|���dt|����cYSwxYw)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 : )�longMessage�UnicodeDecodeErrorr)r"r�r�s   rr�zTestCase._formatMessage�s�����	&��%�+�%��;���	I�!,���S�S�1�1��!�	I�	I�	I�!*�;�!7�!7�!7�!7��3����H�H�H�H�	I���s��+A�Ac�d�t||��}	|�d||��d}S#d}wxYw)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_exceptionrWrX�contexts     rr\zTestCase.assertRaises�sB��4'�'9�4�@�@��	��>�>�.�$��?�?��G�G��d�G�N�N�N�Ns�+�/c�P�t||��}|�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�r�r�)r"�expected_warningrWrXr_s     rrazTestCase.assertWarnss*��8&�&6��=�=���~�~�m�T�6�:�:�:rc�,�ddlm}||||d���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��_AssertLogsContextF��no_logs��_logrf�r"�logger�levelrfs    r�
assertLogszTestCase.assertLogs"s0��*	-�,�,�,�,�,�!�!�$���u�E�E�E�Erc�,�ddlm}||||d���S)z� Fail unless no log messages of level *level* or higher are emitted
        on *logger_name* or its children.

        This method must be used as a context manager.
        rreTrgrirks    r�assertNoLogszTestCase.assertNoLogs:s0��	-�,�,�,�,�,�!�!�$���t�D�D�D�Drc���t|��t|��urP|j�t|����}|�'t|t��rt||��}|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.
        )rHr��getrgr(r6�_baseAssertEqual)r"�first�second�asserters    r�_getAssertEqualityFunczTestCase._getAssertEqualityFuncCsl��"��;�;�$�v�,�,�&�&��0�4�4�T�%�[�[�A�A�H��#��h��,�,�7�&�t�X�6�6�H����$�$rc��||ks>dt||��z}|�||��}|�|���dS)z:The default assertEqual implementation, not type specific.�%s != %sN)r	r�r>)r"rtrur�r�s     rrszTestCase._baseAssertEqual]sP������$�';�E�6�'J�'J�J�K��%�%�c�;�7�7�C��'�'��,�,�,��rc�N�|�||��}||||���dS)z[Fail if the two objects are unequal as determined by the '=='
           operator.
        )r�N)rw)r"rtrur��assertion_funcs     r�assertEqualzTestCase.assertEqualds6���4�4�U�F�C�C����u�f�#�.�.�.�.�.�.rc��||ksJ|�|t|���dt|������}|�|���dS)zYFail if the two objects are equal as determined by the '!='
           operator.
        � == NrR)r"rtrur�s    r�assertNotEqualzTestCase.assertNotEqualkse�������%�%�c��5�9I�9I�9I�9I�:C�F�:K�:K�:K�,M�N�N�C��'�'��,�,�,��rc	���||krdS|�|�td���t||z
��}|�K||krdSt|���dt|���dt|���dt|���d�}nO|�d}t||��dkrdSt|���dt|���d|�d	t|���d�}|�||��}|�|���)
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 != � within � delta (� difference)�rz	 places (�rL�absr�roundr�r>�r"rtru�placesr��delta�diffr�s        r�assertAlmostEqualzTestCase.assertAlmostEqualts,���F�?�?��F����!3��>�?�?�?��5�6�>�"�"�����u�}�}����%� � � � ��&�!�!�!�!��%� � � � ��$�����	!�K�K��~����T�6�"�"�a�'�'����%� � � � ��&�!�!�!�!�����$�����	!�K�
�!�!�#�{�3�3���#�#�C�(�(�(rc	���|�|�td���t||z
��}|�Q||ks||krdSt|���dt|���dt|���dt|���d�}nE|�d}||kst||��dkrdSt|���dt|���d|�d	�}|�||��}|�|���)
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.
        Nr�r~r�r�r�r�rz placesr�r�s        r�assertNotAlmostEqualzTestCase.assertNotAlmostEqual�s�����!3��>�?�?�?��5�6�>�"�"�����V�O�O��������%� � � � ��&�!�!�!�!��%� � � � ��$�����	!�K�K��~����V�O�O��t�V�)<�)<��)A�)A���9B�5�9I�9I�9I�9I�9B�6�9J�9J�9J�9J�9?���A�K��!�!�#�{�3�3���#�#�C�(�(�(rc	��|�x|j}t||��s(|�d|�dt|�������t||��s(|�d|�dt|�������nd}d}	t	|��}n#t
tf$rd|z}YnwxYw|�-	t	|��}n#t
tf$rd|z}YnwxYw|���||krdSd|���ft||��zz}tt||����D]�}		||	}
n(#t
ttf$r|d	|	|fzz
}Yn�wxYw	||	}n(#t
ttf$r|d
|	|fzz
}YnQwxYw|
|kr|d|	ft|
|��zzz
}n+��||kr$|�"t|��t|��krdS||krS|d|||z
fzz
}	|d
|t||��fzz
}n�#t
ttf$r
|d||fzz
}Yn]wxYw||krS|d|||z
fzz
}	|d
|t||��fzz
}n'#t
ttf$r
|d||fzz
}YnwxYw|}dd�
tjt!j|�����t!j|���������z}
|�||
��}|�||��}|�|��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 r�zSecond sequence is not a �sequencez(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
rgr>r�lenrL�NotImplementedError�
capitalizer	�range�min�
IndexErrorrH�join�difflib�ndiff�pprint�pformat�
splitlines�_truncateMessager�rP)r"�seq1�seq2r��seq_type�
seq_type_name�	differing�len1�len2�i�item1�item2r��diffMsgs              r�assertSequenceEqualzTestCase.assertSequenceEqual�s�����$�-�M��d�H�-�-�
L��+�+�+�+8�=�=�)�D�/�/�/�-K�L�L�L��d�H�-�-�
L��+�+�+�+8�=�=�)�D�/�/�/�-K�L�L�L�
L�'�M��	�	#��t�9�9�D�D���.�/�	#�	#�	#�B�!�#�I�I�I�	#������
'��4�y�y�����2�3�
'�
'�
'�G�%�'�	�	�	�
'�������t�|�|���0�"�-�-�/�/�1�(��t�4�4�5�6�I��3�t�T�?�?�+�+�
�
��� ��G�E�E��!�:�/B�C�����"N�"#�]�!3�#4�5�I��E�E�����
� ��G�E�E��!�:�/B�C�����"O�"#�]�!3�#4�5�I��E�E�����
�E�>�>��"K�#$�$�)=�e�U�)K�)K�"K�#M�N�I��E�"�
�D�L�L�X�%5���J�J�$�t�*�*�,�,��F��d�{�{��+�.;�T�D�[�-I�J�K�	�K��"A�#'��4��:�)>�)>�"?�#@�A�I�I��!�:�/B�C�K�K�K��#2�59�=�4I�#J�K�I�I�I�K���������+�.;�T�D�[�-I�J�K�	�L��"A�#'��4��:�)>�)>�"?�#@�A�I�I��!�:�/B�C�L�L�L��#3�6:�M�5J�#K�L�I�I�I�L���� �������M�&�.��.�.�9�9�;�;� �.��.�.�9�9�;�;�
=�
=�>�>�>���+�+�K��A�A���!�!�#�{�3�3���	�	�#�����sl�B�B)�(B)�/B?�?C�C�/D8�8!E�E�!E*�*!F�F�3H�!H5�4H5�I*�*!J�
Jc�x�|j}|�t|��|kr||zS|tt|��zzSr0)�maxDiffr��DIFF_OMITTED)r"r�r��max_diffs    rr�zTestCase._truncateMessage's?���<����s�4�y�y�H�4�4��T�>�!��,��T���2�3�3rc�B�|�|||t���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�)r"�list1�list2r�s    rr�zTestCase.assertListEqual-s'��	
� � ���s�T� �B�B�B�B�Brc�B�|�|||t���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.
        r�N)r�r�)r"�tuple1�tuple2r�s    rr�zTestCase.assertTupleEqual9s'��	
� � ����u� �E�E�E�E�Erc�J�	|�|��}nY#t$r"}|�d|z��Yd}~n2d}~wt$r"}|�d|z��Yd}~nd}~wwxYw	|�|��}nY#t$r"}|�d|z��Yd}~n2d}~wt$r"}|�d|z��Yd}~nd}~wwxYw|s|sdSg}|r<|�d��|D]$}|�t|�����%|r<|�d��|D]$}|�t|�����%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	)�
differencerLrPrKrU�reprr�r�)
r"�set1�set2r��difference1r.�difference2�lines�itemr�s
          rr�zTestCase.assertSetEqualDs&��	P��/�/�$�/�/�K�K���	M�	M�	M��I�I�G�!�K�L�L�L�L�L�L�L�L������	P�	P�	P��I�I�J�Q�N�O�O�O�O�O�O�O�O�����	P����	Q��/�/�$�/�/�K�K���	M�	M�	M��I�I�G�!�K�L�L�L�L�L�L�L�L������	Q�	Q�	Q��I�I�K�a�O�P�P�P�P�P�P�P�P�����	Q�����	�{�	��F����	)��L�L�E�F�F�F�#�
)�
)�����T�$�Z�Z�(�(�(�(��	)��L�L�E�F�F�F�#�
)�
)�����T�$�Z�Z�(�(�(�(��i�i��&�&���	�	�$�%�%�c�;�7�7�8�8�8�8�8sB��
A.�?�
A.�A)�)A.�2B�
C�B/�/
C�<C�Cc��||vrLt|���dt|����}|�|�||����dSdS)zDJust like self.assertTrue(a in b), but with a nicer default message.� not found in N�rrPr��r"�member�	containerr�r�s     r�assertInzTestCase.assertInosd����"�"�2;�F�2C�2C�2C�2C�2;�I�2F�2F�2F�H�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<�#�"rc��||vrLt|���dt|����}|�|�||����dSdS)zHJust like self.assertTrue(a not in b), but with a nicer default message.z unexpectedly found in Nr�r�s     r�assertNotInzTestCase.assertNotInvsd���Y���;D�V�;L�;L�;L�;L�8A�)�8L�8L�8L�N�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��rc��||urLt|���dt|����}|�|�||����dSdS)zDJust like self.assertTrue(a is b), but with a nicer default message.z is not Nr��r"�expr1�expr2r�r�s     r�assertIszTestCase.assertIs}sc������,5�e�,<�,<�,<�,<�-6�u�-=�-=�-=�?�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��rc��||ur=dt|����}|�|�||����dSdS)zHJust like self.assertTrue(a is not b), but with a nicer default message.zunexpectedly identical: Nr�r�s     r�assertIsNotzTestCase.assertIsNot�sO���E�>�>�>�:C�E�:J�:J�:J�L�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��>rc	��|�|td��|�|td��||kr�dt||��z}dd�t	jt
j|�����t
j|���������z}|�	||��}|�
|�||����dSdS)Nz"First argument is not a dictionaryz#Second argument is not a dictionaryryr	)�assertIsInstancer�r	r�r�r�r�r�r�r�rPr�)r"�d1�d2r�r�r�s      rr�zTestCase.assertDictEqual�s������b�$�(L�M�M�M����b�$�(M�N�N�N�
��8�8�$�';�B��'C�'C�C�K��4�9�9�W�]�!�>�"�-�-�8�8�:�:�!�>�"�-�-�8�8�:�:�&<�&<�=�=�=�D��/�/��T�B�B�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<�
�8rc�H�tjdt��g}g}|���D]u\}}||vr|�|���|||krJ|�t|���dt|���dt||�������v|s|sdSd}|r"dd�d�|D����z}|r"|r|d	z
}|d
d�|��zz
}|�|�||����dS)z2Checks whether dictionary is a superset of subset.z&assertDictContainsSubset is deprecatedz, expected: z
, actual: NrnzMissing: %s�,c3�4K�|]}t|��V��dSr0)r)r~r�s  rr�z4TestCase.assertDictContainsSubset.<locals>.<genexpr>�s8����3=�3=�A�9�Q�<�<�3=�3=�3=�3=�3=�3=rz; zMismatched values: %s)	r7r8r4�itemsrUrr�rPr�)	r"�subset�
dictionaryr��missing�
mismatched�key�valuer�s	         r�assertDictContainsSubsetz!TestCase.assertDictContainsSubset�sz���
�>�(�	*�	*�	*����
� �,�,�.�.�	@�	@�J�C���*�$�$����s�#�#�#�#��*�S�/�)�)��!�!�#,�S�>�>�>�>�9�U�3C�3C�3C�3C�#,�Z��_�#=�#=�#=�#?�@�@�@���	�:�	��F����	=�'�#�(�(�3=�3=�4;�3=�3=�3=�+=�+=�=�K��	J��
$��t�#���2�S�X�X�j�5I�5I�I�I�K��	�	�$�%�%�c�;�7�7�8�8�8�8�8rc���t|��t|��}}	tj|��}tj|��}||krdSt||��}n #t$rt||��}YnwxYw|rfd}d�|D��}d�|��}	|�||	��}|�||��}|�	|��dSdS)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:
c��g|]}d|z��S)z First has %d, Second has %d:  %rr)r~r�s  r�
<listcomp>z-TestCase.assertCountEqual.<locals>.<listcomp>�s��W�W�W�4�7�$�>�W�W�Wrr	)
r��collections�CounterrrLrr�r�r�rP)
r"rtrur��	first_seq�
second_seq�differencesr�r�r�s
          r�assertCountEqualzTestCase.assertCountEqual�s��!%�U���T�&�\�\�:�	�		F��'�	�2�2�E� �(��4�4�F�
������.�y�*�E�E�K�K��
�	I�	I�	I�1�)�Z�H�H�K�K�K�	I�����	�<�K�W�W�;�W�W�W�E��i�i��&�&�G��/�/��W�E�E�K��%�%�c�;�7�7�C��I�I�c�N�N�N�N�N�
	�	s�(A!�!A>�=A>c���|�|td��|�|td��||k�r*t|��|jkst|��|jkr|�|||��|�d���}|�d���}t|��dkr%|�d��|kr|dzg}|dzg}dt||��z}dd	�tj
||����z}|�||��}|�|�
||����d
Sd
S)z-Assert that two multi-line strings are equal.zFirst argument is not a stringzSecond argument is not a stringT)�keependsrz
r	ryrnN)r�r(r��_diffThresholdrsr�r
r	r�r�r�r�rPr�)r"rtrur��
firstlines�secondlinesr�r�s        rr�zTestCase.assertMultiLineEqual�sa�����e�S�*J�K�K�K����f�c�+L�M�M�M��F�?�?��E�
�
�T�0�0�0��F���d�1�1�1��%�%�e�V�S�9�9�9��)�)�4�)�8�8�J� �+�+�T�+�:�:�K��:���!�#�#����F�(;�(;�u�(D�(D�#�d�l�^�
�%��}�o��$�';�E�6�'J�'J�J�K��"�'�'�'�-�
�K�"H�"H�I�I�I�D��/�/��T�B�B�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��?rc��||ksLt|���dt|����}|�|�||����dSdS)zCJust like self.assertTrue(a < b), but with a nicer default message.z not less than Nr��r"�a�br�r�s     r�
assertLesszTestCase.assertLess�sV���1�u�u�3<�Q�<�<�<�<��1����N�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��urc��||ksLt|���dt|����}|�|�||����dSdS)zDJust like self.assertTrue(a <= b), but with a nicer default message.z not less than or equal to Nr�r�s     r�assertLessEqualzTestCase.assertLessEqual�sW���A�v�v�?H��|�|�|�|�Y�WX�\�\�\�Z�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��vrc��||ksLt|���dt|����}|�|�||����dSdS)zCJust like self.assertTrue(a > b), but with a nicer default message.z not greater than Nr�r�s     r�
assertGreaterzTestCase.assertGreater�sV���1�u�u�6?��l�l�l�l�I�a�L�L�L�Q�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��urc��||ksLt|���dt|����}|�|�||����dSdS)zDJust like self.assertTrue(a >= b), but with a nicer default message.z not greater than or equal to Nr�r�s     r�assertGreaterEqualzTestCase.assertGreaterEqual�s[���A�v�v�BK�A�,�,�,�,�PY�Z[�P\�P\�P\�]�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��vrc��|�=t|���d�}|�|�||����dSdS)zCSame as self.assertTrue(obj is None), with a nicer default message.Nz is not Noner��r"rCr�r�s    r�assertIsNonezTestCase.assertIsNone�sH���?�.7��n�n�n�n�>�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��?rc�d�|�-d}|�|�||����dSdS)z(Included for symmetry with assertIsNone.Nzunexpectedly None)rPr�r�s    r�assertIsNotNonezTestCase.assertIsNotNones;���;�-�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��;rc��t||��s?t|���d|��}|�|�||����dSdS)zTSame as self.assertTrue(isinstance(obj, cls)), with a nicer
        default message.z is not an instance of N�rgrrPr��r"rCrOr�r�s     rr�zTestCase.assertIsInstances^���#�s�#�#�	=�;D�S�>�>�>�>�3�3�O�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<�	=�	=rc��t||��r?t|���d|��}|�|�||����dSdS)z,Included for symmetry with assertIsInstance.z is an instance of Nr�r�s     r�assertNotIsInstancezTestCase.assertNotIsInstances\���c�3���	=�7@��~�~�~�~�s�s�K�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<�	=�	=rc�R�t|||��}|�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])r"r^r�rWrXr_s      rrzTestCase.assertRaisesRegexs-��'�'9�4��P�P���~�~�1�4��@�@�@rc�R�t|||��}|�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.
        �assertWarnsRegexrb)r"rcr�rWrXr_s      rrzTestCase.assertWarnsRegex(s-�� &�&6��n�M�M���~�~�0�$��?�?�?rc��t|ttf��r |s
Jd���tj|��}|�|��s8d|j�d|��}|�||��}|�|���dS)z=Fail the test unless the text matches the regular expression.z!expected_regex must not be empty.zRegex didn't match: r�N)	rgr(�bytesr�r�r�r�r�r>)r"�textr�r�r�s     r�assertRegexzTestCase.assertRegex;s����n�s�E�l�3�3�	8�!�F�F�#F�F�F�>��Z��7�7�N��$�$�T�*�*�	-�	-��&�&�&���.�K��%�%�c�;�7�7�C��'�'��,�,�,�	-�	-rc�b�t|ttf��rtj|��}|�|��}|rgd||���|�����d|j�d|��}|�	||��}|�
|���dS)z9Fail the test if the text matches the regular expression.zRegex matched: z	 matches z in N)rgr(rr�r�r��start�endr�r�r>)r"r�unexpected_regexr��matchr�s      r�assertNotRegexzTestCase.assertNotRegexGs����&��e��5�5�	<�!�z�*:�;�;�� �'�'��-�-���	-�	-��U�[�[�]�]�U�Y�Y�[�[�0�1�1�1� �(�(�(����K�
�%�%�c�;�7�7�C��'�'��,�,�,�	-�	-rc����fd�}|S)Nc�z��tjd��j��td���|i|��S)NzPlease use {0} instead.r5)r7r8r�r
r4)rWrX�
original_funcs  �r�deprecated_funcz,TestCase._deprecate.<locals>.deprecated_funcWsG����M�)�0�0��1G�H�H�"�A�
'�
'�
'�!�=�$�1�&�1�1�1rr)rrs` r�
_deprecatezTestCase._deprecateVs$���	2�	2�	2�	2�	2�
�r)r�r0)NN�NNN)er
rrr�AssertionErrorr>rYr�r�r�r#r�r�r�r�r�r�r�r�r�rrrrrrrrr!r1r2�_subtest_msg_sentinelr,r+r.r0r6r8r:rCr@rGrJrLrNrPrUrWr�r\rarnrprwrsr|rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr�failUnlessEqual�assertEquals�failIfEqual�assertNotEquals�failUnlessAlmostEqual�assertAlmostEquals�failIfAlmostEqual�assertNotAlmostEquals�
failUnless�assert_�failUnlessRaises�failIf�assertRaisesRegexp�assertRegexpMatches�assertNotRegexpMatches�
__classcell__�r�s@rr�r�Xs����������@&���K��G��N�3�3�3�3�3�>�>�>�>�@
6�
6�
6�8�8�8�3�3�3��=�=��[�=�
�7�7��[�7�
�
�
�
�
�
��V�V��[�V��a�a��[�a����#�#�#�C�C�C�J�J�J�=�=�=�8�8�8�e�e�e�@�@�@���/�#�#�#���#�</�/�/�
'�
'�
'����U�U�U�
���"�"�"�=�=�=�=�~����	?�	?��[�	?�'�'�'�9�9�9�"���)�)�)�)�-�-�-�-�-�-�-�-�I�I�I�*���B;�;�;�>F�F�F�F�0E�E�E�E�%�%�%�4-�-�-�-�/�/�/�/�-�-�-�-�AE� $�+)�+)�+)�+)�ZDH�#'�!)�!)�!)�!)�Fa�a�a�a�F4�4�4�
C�
C�
C�
C�	F�	F�	F�	F�)9�)9�)9�)9�V=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�
=�
=�
=�
=�9�9�9�9�:����@=�=�=�=�(=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�A�A�A� @�@�@�&
-�
-�
-�
-�-�-�-�-����&0�Z��%<�%<�<�O�l�$.�J�~�$>�$>�>�K�/�1;��<M�1N�1N�N��.�0:�
�;O�0P�0P�P��-�%�:�j�1�1�1�J��!�z�,�/�/��
�Z��
$�
$�F�#��$5�6�6��$�*�[�1�1��'�Z��7�7�����rr�c�Z��eZdZdZd
�fd�	Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
�xZS)�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.
    Nc���tt|�����||_||_||_||_dSr0)r�r)r#�
_setUpFunc�
_tearDownFunc�	_testFunc�_description)r"�testFuncr�r��descriptionr�s     �rr#zFunctionTestCase.__init__usD���
���%�%�.�.�0�0�0����%���!���'����rc�@�|j�|���dSdSr0)r+r�s rr�zFunctionTestCase.setUp|s(���?�&��O�O������'�&rc�@�|j�|���dSdSr0)r,r�s rr�zFunctionTestCase.tearDown�s+����)���� � � � � �*�)rc�.�|���dSr0)r-r�s rr�zFunctionTestCase.runTest�s���������rc��|jjSr0)r-r
r�s rrzFunctionTestCase.id�s
���~�&�&rc��t||j��stS|j|jko/|j|jko|j|jko|j|jkSr0)rgr�rr+r,r-r.rs  rrzFunctionTestCase.__eq__�sg���%���0�0�	"�!�!���%�"2�2�7��!�U�%8�8�7��~���0�7�� �E�$6�6�	7rc�l�tt|��|j|j|j|jf��Sr0)rrHr+r,r-r.r�s rrzFunctionTestCase.__hash__�s4���T�$�Z�Z���$�2D��^�T�%6�8�9�9�	9rc�J�t|j���d|jj�d�S)Nrr)rr�r-r
r�s rrzFunctionTestCase.__str__�s-��$�T�^�4�4�4�4� �N�3�3�3�5�	5rc�B�dt|j���d|j�d�S)Nrz tec=r )rr�r-r�s rr!zFunctionTestCase.__repr__�s*��� (��� 8� 8� 8� 8�%)�^�^�^�5�	5rc��|j�|jS|jj}|r-|�d��d���pdS)Nr	r)r.r-rrr
rs  rrz!FunctionTestCase.shortDescription�sI����(��$�$��n�$���1�s�y�y����q�)�/�/�1�1�9�T�9rr)r
rrrr#r�r�r�rrrrr!rr&r's@rr)r)ls����������(�(�(�(�(�(����!�!�!����'�'�'�7�7�7�9�9�9�5�5�5�5�5�5�:�:�:�:�:�:�:rr)c�<��eZdZ�fd�Zd�Zd�Zd�Zd�Zd�Z�xZ	S)r%c���t�����||_||_||_|j|_dSr0)r�r#�_messager%r#r>)r"r%r�r#r�s    �rr#z_SubTest.__init__�s?���
����������
�"������ )� :����rc� �td���)Nzsubtests cannot be run directly)r�r�s rr�z_SubTest.runTest�s��!�"C�D�D�Drc�t�g}|jtur-|�d�|j����|jr^d�d�|j���D����}|�d�|����d�|��pdS)Nz[{}]z, c3�HK�|]\}}d�||��V��dS)z{}={!r}N)r�)r~r�r�s   rr�z+_SubTest._subDescription.<locals>.<genexpr>�sJ����$3�$3��Q��� � ��A�&�&�$3�$3�$3�$3�$3�$3rz({})� z(<subtest>))r<rrUr�r#r�r�)r"�parts�params_descs   r�_subDescriptionz_SubTest._subDescription�s������=� 5�5�5��L�L����t�}�5�5�6�6�6��;�	5��)�)�$3�$3�"�k�/�/�1�1�$3�$3�$3�3�3�K�
�L�L����{�3�3�4�4�4��x�x����/�-�/rc��d�|j���|�����S�Nz{} {})r�r%rrCr�s rrz_SubTest.id�s0���~�~�d�n�/�/�1�1�4�3G�3G�3I�3I�J�J�Jrc�4�|j���S)zlReturns a one-line description of the subtest, or None if no
        description has been provided.
        )r%rr�s rrz_SubTest.shortDescription�s���~�.�.�0�0�0rc�\�d�|j|�����SrE)r�r%rCr�s rrz_SubTest.__str__�s$���~�~�d�n�d�.B�.B�.D�.D�E�E�Er)
r
rrr#r�rCrrrr&r's@rr%r%�s��������;�;�;�;�;�E�E�E�	0�	0�	0�K�K�K�1�1�1�F�F�F�F�F�F�Frr%)2rr)rhr�r�r�r7r�r1r�rornr�utilrrrrr	�
__unittest�objectrr�r^rrrrr'r+rDrRrTrYr[rarqrvrxr!r}r�r�r�r��ChainMapr�r�r)r%rrr�<module>rLs�����
�
�
�
���������
�
�
�
�	�	�	�	���������������������������?�?�?�?�?�?�?�?�?�?�?�?�?�?��
������7�������y���������)����
���������&8�&8�&8�&8�&8�v�&8�&8�&8�R%�%�%�,�,�,���������6�6�6�
0�0�0�

�
�
� ���(���������I�I�I�
3�3�3�3�3�3�3�3�'�'�'�'�'�3�'�'�'�T$8�$8�$8�$8�$8�3�$8�$8�$8�N1D�1D�1D�1D�1D�2�1D�1D�1D�h�����{�+����P8�P8�P8�P8�P8�v�P8�P8�P8�h 7:�7:�7:�7:�7:�x�7:�7:�7:�t!F�!F�!F�!F�!F�x�!F�!F�!F�!F�!Fr__pycache__/_log.cpython-311.opt-2.pyc000064400000011074152401764000013340 0ustar00�

0���L�{���ddlZddlZddlmZejdddg��ZGd�dej��ZGd	�d
e��ZdS)�N�)�_BaseTestCaseContext�_LoggingWatcher�records�outputc�"�eZdZ	d�Zd�Zd�ZdS)�_CapturingHandlerc�n�tj�|��tgg��|_dS�N)�logging�Handler�__init__r�watcher��selfs �8/opt/alt/python-internal/lib/python3.11/unittest/_log.pyrz_CapturingHandler.__init__s-���� � ��&�&�&�&�r�2�.�.�����c��dSr�rs r�flushz_CapturingHandler.flushs���rc��|jj�|��|�|��}|jj�|��dSr)rr�append�formatr)r�record�msgs   r�emitz_CapturingHandler.emitsK�����#�#�F�+�+�+��k�k�&�!�!�����"�"�3�'�'�'�'�'rN)�__name__�
__module__�__qualname__rrrrrrr	r	
sF�������/�/�/�
�
�
�(�(�(�(�(rr	c�&�eZdZ	dZd�Zd�Zd�ZdS)�_AssertLogsContextz"%(levelname)s:%(name)s:%(message)sc���tj||��||_|r&tj�||��|_ntj|_d|_||_	dSr)
rr�logger_namer�_nameToLevel�get�level�INFOr�no_logs)r�	test_caser#r&r(s     rrz_AssertLogsContext.__init__!s\���%�d�I�6�6�6�&����	&� �-�1�1�%��?�?�D�J�J� ��D�J��������rc�,�t|jtj��r|jx}|_n tj|j��x}|_tj|j��}t��}|�	|j
��|�|��|j|_|j
dd�|_|j
|_|j|_|g|_
|�	|j
��d|_|jrdS|jS)NF)�
isinstancer#r�Logger�logger�	getLogger�	Formatter�LOGGING_FORMATr	�setLevelr&�setFormatterr�handlers�old_handlers�	old_level�	propagate�
old_propagater()rr-�	formatter�handlers    r�	__enter__z_AssertLogsContext.__enter__+s����d�&���7�7�	G�#'�#3�3�F�T�[�[�#*�#4�T�5E�#F�#F�F�F�T�[��%�d�&9�:�:�	�#�%�%�������$�$�$����Y�'�'�'�����"�O�A�A�A�.�������#�-���"�)�������
�#�#�#� ����<�	��F���rc��|j|j_|j|j_|j�|j��|�dS|jrSt|j	j
��dkr4|�d�|j	j
����dSdSt|j	j
��dkrL|�d�tj|j��|jj����dSdS)NFrzUnexpected logs found: {!r}z-no logs of level {} or higher triggered on {})r4r-r3r7r6r1r5r(�lenrr�
_raiseFailurerrr�getLevelNamer&�name)r�exc_type�	exc_value�tbs    r�__exit__z_AssertLogsContext.__exit__?s��#�0���� $� 2��������T�^�,�,�,����5��<�	Q��4�<�'�(�(�1�,�,��"�"�1�8�8���+��������-�,��4�<�'�(�(�A�-�-��"�"�C��V�G�0���<�<�d�k�>N�O�O�Q�Q�Q�Q�Q�.�-rN)rrrr0rr:rCrrrr!r!sN������@�9�N�������(Q�Q�Q�Q�Qrr!)	r�collections�caser�
namedtuplerr
r	r!rrr�<module>rGs�����������&�&�&�&�&�&�)�+�(�):�*3�X�)>�@�@��(�(�(�(�(���(�(�(�$:Q�:Q�:Q�:Q�:Q�-�:Q�:Q�:Q�:Q�:Qr__pycache__/signals.cpython-311.opt-1.pyc000064400000007471152401764000014065 0ustar00�

;/�R�|��~�ddlZddlZddlmZdZGd�de��Zej��Zd�Z	d�Z
dad�Zd
d	�Z
dS)�N)�wrapsTc��eZdZd�Zd�ZdS)�_InterruptHandlerc���d|_||_t|t��r@|tjkr
tj}n#|tjkrd�}ntd���||_	dS)NFc��dS�N�)�
unused_signum�unused_frames  �;/opt/alt/python-internal/lib/python3.11/unittest/signals.py�default_handlerz3_InterruptHandler.__init__.<locals>.default_handlers���D�zYexpected 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
)�selfr
s  r�__init__z_InterruptHandler.__init__
s������ /����o�s�+�+�	3��&�.�0�0�"(�"<��� �F�N�2�2����� �!2�3�3�3� /����rc��tjtj��}||ur|�||��|jr|�||��d|_t
���D]}|����dS)NT)r�	getsignal�SIGINTr
r�_results�keys�stop)r�signum�frame�installed_handler�results     r�__call__z_InterruptHandler.__call__s���"�,�V�]�;�;���D�(�(�
� � ���/�/�/��;�	0�� � ���/�/�/�����m�m�o�o�	�	�F��K�K�M�M�M�M�	�	rN)�__name__�
__module__�__qualname__rr$r	rrrr	s2������/�/�/�$����rrc��dt|<dS)N�)r�r#s r�registerResultr+*s���H�V���rc�R�tt�|d����Sr)�boolr�popr*s r�removeResultr/-s������V�T�*�*�+�+�+rc��t�Stjtj��}t	|��atjtjt��dSdSr)�_interrupt_handlerrrrr)r
s r�installHandlerr21sK���!� �*�6�=�9�9��.��?�?���
�f�m�%7�8�8�8�8�8�"�!rc�����t����fd���}|St�+tjtjtj��dSdS)Nc����tjtj��}t��	�|i|��tjtj|��S#tjtj|��wxYwr)rrr�
removeHandler)�args�kwargs�initial�methods   �r�innerzremoveHandler.<locals>.inner;sf����&�v�}�5�5�G��O�O�O�
6��v�t�.�v�.�.��
�f�m�W�5�5�5�5���
�f�m�W�5�5�5�5���s�A�!A7)rr1rrr)r9r:s` rr5r59sg���
��	�v���	6�	6�	6�	6�
��	6����%��
�f�m�%7�%H�I�I�I�I�I�&�%rr)r�weakref�	functoolsr�
__unittest�objectr�WeakKeyDictionaryrr+r/r1r2r5r	rr�<module>r@s���
�
�
�
�����������
�
����������@%�7�$�&�&�����,�,�,���9�9�9�J�J�J�J�J�Jr__pycache__/case.cpython-311.opt-1.pyc000064400000233143152401764000013335 0ustar00�

�K��4b���B�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZmZmZmZmZdZe��ZdZGd�d	e��ZGd
�de��ZGd�d
e��ZGd�de��Zd�Zd�Zd�Zd�ZgZ d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'd�Z(Gd�d��Z)Gd�de)��Z*Gd �d!e*��Z+Gd"�d#e*��Z,Gd$�d%ej-��Z.Gd&�d'e��Z/Gd(�d)e/��Z0Gd*�d+e/��Z1dS),zTest 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��eZdZdZdS)�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__���8/opt/alt/python-internal/lib/python3.11/unittest/case.pyrrs���������rrc��eZdZdZdS)�_ShouldStopz
    The test should stop.
    Nrrrrrr!����������rrc��eZdZdZdS)�_UnexpectedSuccessz7
    The test was supposed to fail, but it didn't!
    Nrrrrrr&rrrc�8�eZdZdd�Zejdd���ZdS)�_OutcomeNc�h�d|_||_t|d��|_d|_d|_dS)NF�
addSubTestT)�expecting_failurer�hasattr�result_supports_subtests�success�expectedFailure)�selfrs  r�__init__z_Outcome.__init__-s8��!&������(/���(E�(E��%����#����rFc#�BK�|j}d|_	dV�|r(|jr!|j�|j|d��n�#t$r�t
$r4}d|_t
|j|t|����Yd}~nzd}~wt$rYnktj
��}|jr||_nAd|_|r"|j�|j||��nt|j||��d}YnxYw|jo||_dS#|jo||_wxYw)NTF)r rr�	test_case�KeyboardInterruptr�_addSkip�strr�sys�exc_inforr!�	_addError)r"r%�subTest�old_success�er*s      r�testPartExecutorz_Outcome.testPartExecutor4sq�����l�����	8��E�E�E�,�
M�4�<�
M���&�&�y�':�I�t�L�L�L���-!�	�	�	���	5�	5�	5� �D�L��T�[�)�S��V�V�4�4�4�4�4�4�4�4������	�	�	��D�	��|�~�~�H��%�
@�'/��$�$�$����@��K�*�*�9�+>�	�8�T�T�T�T��d�k�9�h�?�?�?��H�H�H����
 �<�7�K�D�L�L�L��4�<�7�K�D�L�7�7�7�7s;�A�+D�C;�*B�?D�
C;�D�A&C;�9D�D�N)F)r
rrr#�
contextlib�contextmanagerr/rrrrr,sL������$�$�$�$���8�8�8���8�8�8rrc��t|dd��}|�|||��dStjdtd��|j|��dS)N�addSkipz4TestResult has no addSkip method, skips not reported�)�getattr�warnings�warn�RuntimeWarning�
addSuccess)rr%�reasonr4s    rr'r'Usf���f�i��.�.�G�����	�6�"�"�"�"�"��
�L�$�a�	)�	)�	)����)�$�$�$�$�$rc��|�C|�Ct|d|j��r|j||��dS|j||��dSdSdS)Nr)�
issubclass�failureException�
addFailure�addError)r�testr*s   rr+r+^si��
��h�2��h�q�k�4�#8�9�9�	,��F��d�H�-�-�-�-�-��F�O�D�(�+�+�+�+�+�	��2�2rc��|Sr0r)�objs r�_idrDes���Jrc���t|��}	|j}|j}n/#t$r"t	d|j�d|j�d���d�wxYw||��}|||ddd��|S)N�'�.z6' object does not support the context manager protocol)�type�	__enter__�__exit__�AttributeError�	TypeErrorrr)�cm�
addcleanup�cls�enter�exitrs      r�_enter_contextrRis����r�(�(�C�O��
���|�����O�O�O��D�C�N�D�D�S�-=�D�D�D�E�E�JN�	O�O�����U�2�Y�Y�F��J�t�R��t�T�*�*�*��Ms	� �,Ac�@�t�|||f��dS)znSame as addCleanup, except the cleanup items are called even if
    setUpModule fails (unlike tearDownModule).N)�_module_cleanups�append)�function�args�kwargss   r�addModuleCleanuprYys%�����X�t�V�4�5�5�5�5�5rc�,�t|t��S)z&Same as enterContext, but module-wide.)rRrY)rMs r�enterModuleContextr[~s���"�.�/�/�/rc���g}trZt���\}}}	||i|��n,#t$r}|�|��Yd}~nd}~wwxYwt�Z|r|d�dS)zWExecute all module cleanup functions. Normally called for you after
    tearDownModule.Nr)rT�pop�	ExceptionrU)�
exceptionsrVrWrX�excs     r�doModuleCleanupsra�s����J�
�#�!1�!5�!5�!7�!7���$��	#��H�d�%�f�%�%�%�%���	#�	#�	#����c�"�"�"�"�"�"�"�"�����	#����	�#�����m���s�1�
A�A�Ac�d���fd�}t�tj��r�}d�||��S|S)z&
    Unconditionally skip a test.
    c���t|t��s!tj|���fd���}|}d|_�|_|S)Nc�"��t����r0�r)rWrXr;s  �r�skip_wrapperz-skip.<locals>.decorator.<locals>.skip_wrapper�s����v�&�&�&rT)�
isinstancerH�	functools�wraps�__unittest_skip__�__unittest_skip_why__)�	test_itemrfr;s  �r�	decoratorzskip.<locals>.decorator�s^����)�T�*�*�	%�
�_�Y�
'�
'�
'�
'�
'�
'�(�
'�
'�$�I�&*�	�#�*0�	�'��r�)rg�types�FunctionType)r;rmrls`  r�skiprq�sS���	�	�	�	�	��&�%�,�-�-�$��	����y��#�#�#��rc�2�|rt|��StS)z/
    Skip a test if the condition is true.
    �rqrD��	conditionr;s  r�skipIfrv�s�����F�|�|���Jrc�2�|st|��StS)z3
    Skip a test unless the condition is true.
    rsrts  r�
skipUnlessrx�s�����F�|�|���Jrc��d|_|S)NT)�__unittest_expecting_failure__)rls rr!r!�s��/3�I�,��rc���t|t��rt�fd�|D����St|t��ot	|���S)Nc3�8�K�|]}t|���V��dSr0)�_is_subtype)�.0r.�basetypes  �r�	<genexpr>z_is_subtype.<locals>.<genexpr>�s-�����>�>��;�q�(�+�+�>�>�>�>�>�>r)rg�tuple�allrHr=)�expectedrs `rr}r}�sW����(�E�"�"�?��>�>�>�>�X�>�>�>�>�>�>��h��%�%�H�*�X�x�*H�*H�Hrc��eZdZd�Zd�ZdS)�_BaseTestCaseContextc��||_dSr0)r%)r"r%s  rr#z_BaseTestCaseContext.__init__�s
��"����rc�v�|j�|j|��}|j�|���r0)r%�_formatMessage�msgr>)r"�standardMsgr�s   r�
_raiseFailurez"_BaseTestCaseContext._raiseFailure�s1���n�+�+�D�H�k�B�B���n�-�-�c�2�2�2rN)r
rrr#r�rrrr�r��s2������#�#�#�3�3�3�3�3rr�c��eZdZdd�Zd�ZdS)�_AssertRaisesBaseContextNc��t�||��||_||_|�t	j|��}||_d|_d|_dSr0)	r�r#r�r%�re�compile�expected_regex�obj_namer�)r"r�r%r�s    rr#z!_AssertRaisesBaseContext.__init__�sU���%�%�d�I�6�6�6� ��
�"����%��Z��7�7�N�,�����
�����rc���	t|j|j��st|�d|j�����|sM|�dd��|_|r,ttt|�����d����|d}S|^}}	|j	|_
n$#t$rt|��|_
YnwxYw|5||i|��ddd��n#1swxYwYd}dS#d}wxYw)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() arg 1 must be r�Nz1 is an invalid keyword argument for this function)
r}r��
_base_typerL�_base_type_strr]r��next�iterr
r�rKr()r"�namerWrX�callable_objs     r�handlez_AssertRaisesBaseContext.handle�sz��	��t�}�d�o�>�>�
=��!%���t�':�':�!<�=�=�=��
�!�:�:�e�T�2�2����M�#�7;�D��L�L�7I�7I�7I�7I�%L�M�M�M���D�D�#'��L�4�
2� ,� 5��
�
��!�
2�
2�
2� #�L� 1� 1��
�
�
�
2�����
.�
.���d�-�f�-�-�-�
.�
.�
.�
.�
.�
.�
.�
.�
.�
.�
.����
.�
.�
.�
.��D�D�D��4�D�K�K�K�KsZ�A?C �C �	B�C �B7�4C �6B7�7C �<	C�C �C�C �C�C � C$r0)r
rrr#r�rrrr�r��s7��������������rr�c�F�eZdZdZeZdZd�Zd�Ze	e
j��ZdS)�_AssertRaisesContextzCA context manager used to implement TestCase.assertRaises* methods.z-an exception type or tuple of exception typesc��|Sr0r�r"s rrIz_AssertRaisesContext.__enter__�s���rc��|��	|jj}n$#t$rt|j��}YnwxYw|jr/|�d�||j����n=|�d�|����ntj|��t||j��sdS|�
d��|_|j�dS|j}|�
t|����s;|�d�|jt|������dS)Nz{} not raised by {}z
{} not raisedFT�"{}" does not match "{}")r�r
rKr(r�r��format�	traceback�clear_framesr=�with_traceback�	exceptionr��search�pattern)r"�exc_type�	exc_value�tb�exc_namer�s      rrJz_AssertRaisesContext.__exit__�se����
.��=�1����!�
.�
.�
.��t�}�-�-����
.�����}�
E��"�"�#8�#?�#?��@D�
�$O�$O�P�P�P�P��"�"�?�#9�#9�(�#C�#C�D�D�D�D��"�2�&�&�&��(�D�M�2�2�	��5�"�1�1�$�7�7�����&��4��,���$�$�S��^�^�4�4�	>����9�@�@�#�+�S��^�^� =� =�
>�
>�
>��ts��2�2N)
r
rrr�
BaseExceptionr�r�rIrJ�classmethodro�GenericAlias�__class_getitem__rrrr�r��sS������M�M��J�D�N�������6$��E�$6�7�7���rr�c�&�eZdZdZeZdZd�Zd�ZdS)�_AssertWarnsContextzBA context manager used to implement TestCase.assertWarns* methods.z(a warning type or tuple of warning typesc�6�ttj�����D]}t	|dd��ri|_�t
jd���|_|j�	��|_t
j
d|j��|S)N�__warningregistry__T)�record�always)�listr)�modules�valuesr6r�r7�catch_warnings�warnings_managerrI�simplefilterr�)r"�vs  rrIz_AssertWarnsContext.__enter__ s����c�k�(�(�*�*�+�+�	+�	+�A��q�/��6�6�
+�(*��%�� (� 7�t� D� D� D����-�7�7�9�9��
���h��
�6�6�6��rc���|j�|||��|�dS	|jj}n$#t$rt|j��}YnwxYwd}|jD]s}|j}t||j��s�|�|}|j	�(|j	�
t|����s�R||_|j|_|j
|_
dS|�@|�d�|j	jt|������|jr0|�d�||j����dS|�d�|����dS)Nr�z{} not triggered by {}z{} not triggered)r�rJr�r
rKr(r7�messagergr�r��warning�filename�linenor�r�r�r�)r"r�r�r�r��first_matching�m�ws        rrJz_AssertWarnsContext.__exit__+s�����&�&�x��B�?�?�?����F�	*��}�-�H�H���	*�	*�	*��4�=�)�)�H�H�H�	*��������
	�
	�A��	�A��a���/�/�
���%�!"���#�/��'�.�.�s�1�v�v�6�6�0���D�L��J�D�M��(�D�K��F�F��%����9�@�@��(�0�#�n�2E�2E� G� G�
H�
H�
H��=�	D����7�>�>�x�?C�}� N� N�
O�
O�
O�
O�
O�
���1�8�8��B�B�C�C�C�C�Cs�/�A�AN)	r
rrr�Warningr�r�rIrJrrrr�r�sG������L�L��J�?�N�	�	�	� D� D� D� D� Drr�c��eZdZd�ZdS)�_OrderedChainMapc#�~K�t��}|jD]$}|D]}||vr|�|��|V�� �%dSr0)�set�maps�add)r"�seen�mapping�ks    r�__iter__z_OrderedChainMap.__iter__Os`�����u�u���y�	�	�G��
�
���D�=�=��H�H�Q�K�K�K��G�G�G��
�	�	rN)r
rrr�rrrr�r�Ns#����������rr�c���eZdZdZeZdZdZdZ�fd�Z	dOd�Z
d�Zd	�Zd
�Z
ed���Zed���Zd
�Zd�Zed���Zed���Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zejefd���Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&dPd!�Z'd"�Z(ed#���Z)d$�Z*d%�Z+d&�Z,dPd'�Z-dPd(�Z.dPd)�Z/d*�Z0d+�Z1d,�Z2dQd-�Z3dQd.�Z4d/�Z5dPd0�Z6dPd1�Z7dPd2�Z8		dRd3�Z9		dRd4�Z:dQd5�Z;d6�Z<dPd7�Z=dPd8�Z>dPd9�Z?dPd:�Z@dPd;�ZAdPd<�ZBdPd=�ZCdPd>�ZDdPd?�ZEdPd@�ZFdPdA�ZGdPdB�ZHdPdC�ZIdPdD�ZJdPdE�ZKdPdF�ZLdPdG�ZMdPdH�ZNdPdI�ZOdJ�ZPdK�ZQdPdL�ZRdPdM�ZSdN�ZTeTe7��xZUZVeTe8��xZWZXeTe9��xZYZZeTe:��xZ[Z\eTe/��xZ]Z^eTe1��Z_eTe.��Z`eTeP��ZaeTeR��ZbeTeS��Zc�xZdS)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�ic�V��d|_g|_t��j|i|��dS)NF)�_classSetupFailed�_class_cleanups�super�__init_subclass__)rOrWrX�	__class__s   �rr�zTestCase.__init_subclass__�s5��� %��� ���!����!�4�2�6�2�2�2�2�2r�runTestc�:�||_d|_d|_	t||��}|j|_n0#t
$r#|dkrt
d|j�d|�����YnwxYwg|_d|_	i|_
|�td��|�td��|�td��|�td	��|�t d	��|�t"d
��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 �: �assertDictEqual�assertListEqual�assertTupleEqual�assertSetEqual�assertMultiLineEqual)�_testMethodName�_outcome�_testMethodDocr6rrK�
ValueErrorr��	_cleanups�_subtest�_type_equality_funcs�addTypeEqualityFunc�dictr�r�r��	frozensetr()r"�
methodName�
testMethods   rr#zTestCase.__init__�sA��
 *�����
�'���		5� ��z�2�2�J�#-�"4�D�����	4�	4�	4��Y�&�&�!�j��~�~�~�z�z�"3�4�4�4�'�&�	4���������
�
%'��!�� � ��'8�9�9�9�� � ��'8�9�9�9�� � ��(:�;�;�;�� � ��&6�7�7�7�� � ��,<�=�=�=�� � ��&<�=�=�=�=�=s�4�*A!� A!c��||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�)r"�typeobjrVs   rr�zTestCase.addTypeEqualityFunc�s��.6��!�'�*�*�*rc�@�|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).N)r�rU�r"rVrWrXs    r�
addCleanupzTestCase.addCleanup�s'��	
����x��v�6�7�7�7�7�7rc�,�t||j��S)z�Enters the supplied context manager.

        If successful, also adds its __exit__ method as a cleanup
        function and returns the result of the __enter__ method.
        )rRr�)r"rMs  r�enterContextzTestCase.enterContext�s���b�$�/�2�2�2rc�@�|j�|||f��dS)zpSame as addCleanup, except the cleanup items are called even if
        setUpClass fails (unlike tearDownClass).N)r�rU�rOrVrWrXs    r�addClassCleanupzTestCase.addClassCleanup�s(��	��"�"�H�d�F�#;�<�<�<�<�<rc�,�t||j��S)z%Same as enterContext, but class-wide.)rRr�)rOrMs  r�enterClassContextzTestCase.enterClassContext�s���b�#�"5�6�6�6rc��dS)zAHook method for setting up the test fixture before exercising it.Nrr�s r�setUpzTestCase.setUp�����rc��dS)zAHook method for deconstructing the test fixture after testing it.Nrr�s r�tearDownzTestCase.tearDown�r�rc��dS)zKHook method for setting up class fixture before running tests in the class.Nr�rOs r�
setUpClasszTestCase.setUpClass�����rc��dS)zVHook method for deconstructing the class fixture after running all tests in the class.Nrr�s r�
tearDownClasszTestCase.tearDownClass�rrc��dS)Nrrr�s r�countTestCaseszTestCase.countTestCases�s���qrc�(�tj��Sr0)r�
TestResultr�s r�defaultTestResultzTestCase.defaultTestResult�s��� �"�"�"rc��|j}|r?|����d��d���ndS)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"�docs  r�shortDescriptionzTestCase.shortDescription�sC���!��58�B�s�y�y�{�{� � ��&�&�q�)�/�/�1�1�1�d�Brc�>�t|j���d|j��S)NrG�rr�r�r�s r�idzTestCase.id�s#��"�4�>�2�2�2�2�D�4H�4H�I�Irc�l�t|��t|��urtS|j|jkSr0)rH�NotImplementedr��r"�others  r�__eq__zTestCase.__eq__�s0����:�:�T�%�[�[�(�(�!�!��#�u�'<�<�<rc�H�tt|��|jf��Sr0)�hashrHr�r�s r�__hash__zTestCase.__hash__�s���T�$�Z�Z��!5�6�7�7�7rc�P�|j�dt|j���d|j�d�S)N� (rG�))r�rr�r�s r�__str__zTestCase.__str__s1��#�3�3�3�X�d�n�5M�5M�5M�5M�t�Oc�Oc�Oc�d�drc�B�dt|j���d|j�d�S)N�<z testMethod=�>rr�s r�__repr__zTestCase.__repr__s.������(�(�(�(�$�*>�*>�*>�@�	@rc+��K�|j�|jjsdV�dS|j}|�t|��}n|j�|��}t
|||��|_	|j�|jd���5dV�ddd��n#1swxYwY|jjs|jj	}|�|j
rt�n|jjrt�||_dS#||_wxYw)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/r r�failfastrr!)r"r�r#�parent�
params_maprs      rr,zTestCase.subTestsI�����=� ��
�(N� ��E�E�E��F�����>�)�&�1�1�J�J���0�0��8�8�J� ��s�J�7�7��
�	#���/�/��
�t�/�L�L�
�
�����
�
�
�
�
�
�
�
�
�
�
����
�
�
�
��=�(�
"���-���%�&�/�%�%�%����.�
"�"�!�"�D�M�M�M��F�D�M�"�"�"�"s0�&!C(�B�C(�B�C(�B� ?C(�(	C1c��	|j}|||��dS#t$r.tjdt��|j|��YdSwxYw)Nz@TestResult has no addExpectedFailure method, reporting as passes)�addExpectedFailurerKr7r8r9r:)r"rr*r*s    r�_addExpectedFailurezTestCase._addExpectedFailure&s~��	/�!'�!:��
��t�X�.�.�.�.�.���	$�	$�	$��M�\�(�
*�
*�
*��F��d�#�#�#�#�#�#�	$���s��4A�Ac��	|j}||��dS#t$rXtjdt��	t
d�#t
$r'|j|tj����YYdSwxYwwxYw)NzCTestResult has no addUnexpectedSuccess method, reporting as failure)	�addUnexpectedSuccessrKr7r8r9rr?r)r*)r"rr-s   r�_addUnexpectedSuccesszTestCase._addUnexpectedSuccess0s���	'�#)�#>� �
!� ��&�&�&�&�&���	8�	8�	8��M�_�(�
*�
*�
*�
8�(�d�2��%�
8�
8�
8�!��!�$�����7�7�7�7�7�7�7�
8����	8���s&��$A8�A�,A4�/A8�3A4�4A8c�.�|���dSr0)r�r�s r�
_callSetUpzTestCase._callSetUp?s���
�
�����rc�^�|���"tjd|�d�td���dSdS)NzFIt is deprecated to return a value that is not None from a test case (r�)�
stacklevel)r7r8�DeprecationWarning)r"�methods  r�_callTestMethodzTestCase._callTestMethodBs\���6�8�8���M�2�(.�2�2�2�3E�RS�
U�
U�
U�
U�
U�
U� �rc�.�|���dSr0)r�r�s r�
_callTearDownzTestCase._callTearDownGs���
�
�����rc��||i|��dSr0rr�s    r�_callCleanupzTestCase._callCleanupJs����$�!�&�!�!�!�!�!rNc��|�C|���}t|dd��}t|dd��}|�
|��nd}|j|��	t||j��}t|jdd��st|dd��rWt|jdd��pt|dd��}t|||��||j|��|�|��SSt|dd��pt|dd��}t|��}	||_|�	|��5|�
��ddd��n#1swxYwY|jr�||_|�	|��5|�
|��ddd��n#1swxYwYd|_|�	|��5|���ddd��n#1swxYwY|���|jrK|r9|jr|�||j��n&|�|��n|j|��|d|_d}d|_|j|��|�|��SS#d|_d}d|_wxYw#|j|��|�|��wwxYw)N�startTestRun�stopTestRunrjFrkrnrz)rr6�	startTestr�r�r'�stopTestrr�r/r0r rr6r8�
doCleanupsr!r+r.r:)r"rr<r=r��skip_whyr�outcomes        r�runzTestCase.runMs����>��+�+�-�-�F�"�6�>�4�@�@�L�!�&�-��>�>�K��'��������K��������2	� ��t�';�<�<�J����(;�U�C�C�
��
�$7��?�?�
�$�D�N�4K�R�P�P�P�&�z�3J�B�O�O�����x�0�0�0��P
�F�O�D�!�!�!��&���
�
�
�
�'�M��>��F�F�M��
�$D�e�L�L�
��v�&�&�G�
%� '��
��-�-�d�3�3�&�&��O�O�%�%�%�&�&�&�&�&�&�&�&�&�&�&����&�&�&�&��?�-�0A�G�-� �1�1�$�7�7�9�9��,�,�Z�8�8�8�9�9�9�9�9�9�9�9�9�9�9����9�9�9�9�05�G�-� �1�1�$�7�7�-�-��*�*�,�,�,�-�-�-�-�-�-�-�-�-�-�-����-�-�-�-����!�!�!��?�0�(�0�"�2�?� �4�4�V�W�=T�U�U�U�U� �6�6�v�>�>�>�>�)��)�$�/�/�/��+/��'���!%��
�
�F�O�D�!�!�!��&���
�
�
�
�'��+/��'���!%��
�$�$�$�$��
�F�O�D�!�!�!��&���
�
�
�
�'���s��A5J(�,1J(�J�:E�J�E�J�"E�#&J�	F+�J�+F/�/J�2F/�3J�G3�'J�3G7�7J�:G7�;A*J�%J(�J%�%J(�(Kc��|jp
t��}|jrb|j���\}}}|�|��5|j|g|�Ri|��ddd��n#1swxYwY|j�b|jS)zNExecute all cleanup functions. Normally called for you after
        tearDown.N)r�rr�r]r/r:r )r"rBrVrWrXs     rr@zTestCase.doCleanups�s����-�-�8�:�:���n�	=�%)�^�%7�%7�%9�%9�"�H�d�F��)�)�$�/�/�
=�
=�!��!�(�<�T�<�<�<�V�<�<�<�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=����
=�
=�
=�
=��n�	=���s�A-�-A1�4A1c��g|_|jrk|j���\}}}	||i|��n;#t$r.|j�tj����YnwxYw|j�idSdS)zYExecute all class cleanup functions. Normally called for you after
        tearDownClass.N)�tearDown_exceptionsr�r]r^rUr)r*r�s    r�doClassCleanupszTestCase.doClassCleanups�s���#%����!�	?�%(�%8�%<�%<�%>�%>�"�H�d�F�
?���$�)�&�)�)�)�)���
?�
?�
?��'�.�.�s�|�~�~�>�>�>�>�>�
?����	�!�	?�	?�	?�	?�	?s�6�5A.�-A.c��|j|i|��Sr0)rC)r"rW�kwdss   r�__call__zTestCase.__call__�s���t�x��&��&�&�&rc���t||j��}t|jdd��st|dd��r6t|jdd��pt|dd��}t|���|���|�|��|���|jr7|j���\}}}|j	|g|�Ri|��|j�5dSdS)z6Run the test without collecting errors in a TestResultrjFrkrnN)
r6r�r�rr0r6r8r�r]r:)r"r�rArVrWrXs      r�debugzTestCase.debug�s���T�4�#7�8�8�
��D�N�$7��?�?�	%��J� 3�U�;�;�	%� ���0G��L�L�L�"�:�/F��K�K�
��8�$�$�$����������Z�(�(�(��������n�	9�%)�^�%7�%7�%9�%9�"�H�d�F��D��h�8��8�8�8��8�8�8��n�	9�	9�	9�	9�	9rc� �t|���)zSkip this test.re)r"r;s  r�skipTestzTestCase.skipTest�s���v���rc�,�|�|���)z)Fail immediately, with the given message.)r>)r"r�s  r�failz
TestCase.fail�s���#�#�C�(�(�(rc��|r;|�|dt|��z��}|�|���dS)z#Check that the expression is false.z%s is not falseN�r�rr>�r"�exprr�s   r�assertFalsezTestCase.assertFalse�sI���	-��%�%�c�+<�y����+N�O�O�C��'�'��,�,�,�	-�	-rc��|s;|�|dt|��z��}|�|���dS)z"Check that the expression is true.z%s is not trueNrRrSs   r�
assertTruezTestCase.assertTrue�sI���	-��%�%�c�+;�i��o�o�+M�N�N�C��'�'��,�,�,�	-�	-rc��|js|p|S|�|S	|�d|��S#t$r$t|���dt|����cYSwxYw)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 : )�longMessage�UnicodeDecodeErrorr)r"r�r�s   rr�zTestCase._formatMessage�s�����	&��%�+�%��;���	I�!,���S�S�1�1��!�	I�	I�	I�!*�;�!7�!7�!7�!7��3����H�H�H�H�	I���s��+A�Ac�d�t||��}	|�d||��d}S#d}wxYw)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_exceptionrWrX�contexts     rr\zTestCase.assertRaises�sB��4'�'9�4�@�@��	��>�>�.�$��?�?��G�G��d�G�N�N�N�Ns�+�/c�P�t||��}|�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�r�r�)r"�expected_warningrWrXr_s     rrazTestCase.assertWarnss*��8&�&6��=�=���~�~�m�T�6�:�:�:rc�,�ddlm}||||d���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��_AssertLogsContextF��no_logs��_logrf�r"�logger�levelrfs    r�
assertLogszTestCase.assertLogs"s0��*	-�,�,�,�,�,�!�!�$���u�E�E�E�Erc�,�ddlm}||||d���S)z� Fail unless no log messages of level *level* or higher are emitted
        on *logger_name* or its children.

        This method must be used as a context manager.
        rreTrgrirks    r�assertNoLogszTestCase.assertNoLogs:s0��	-�,�,�,�,�,�!�!�$���t�D�D�D�Drc���t|��t|��urP|j�t|����}|�'t|t��rt||��}|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.
        )rHr��getrgr(r6�_baseAssertEqual)r"�first�second�asserters    r�_getAssertEqualityFunczTestCase._getAssertEqualityFuncCsl��"��;�;�$�v�,�,�&�&��0�4�4�T�%�[�[�A�A�H��#��h��,�,�7�&�t�X�6�6�H����$�$rc��||ks>dt||��z}|�||��}|�|���dS)z:The default assertEqual implementation, not type specific.�%s != %sN)r	r�r>)r"rtrur�r�s     rrszTestCase._baseAssertEqual]sP������$�';�E�6�'J�'J�J�K��%�%�c�;�7�7�C��'�'��,�,�,��rc�N�|�||��}||||���dS)z[Fail if the two objects are unequal as determined by the '=='
           operator.
        )r�N)rw)r"rtrur��assertion_funcs     r�assertEqualzTestCase.assertEqualds6���4�4�U�F�C�C����u�f�#�.�.�.�.�.�.rc��||ksJ|�|t|���dt|������}|�|���dS)zYFail if the two objects are equal as determined by the '!='
           operator.
        � == NrR)r"rtrur�s    r�assertNotEqualzTestCase.assertNotEqualkse�������%�%�c��5�9I�9I�9I�9I�:C�F�:K�:K�:K�,M�N�N�C��'�'��,�,�,��rc	���||krdS|�|�td���t||z
��}|�K||krdSt|���dt|���dt|���dt|���d�}nO|�d}t||��dkrdSt|���dt|���d|�d	t|���d�}|�||��}|�|���)
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 != � within � delta (� difference)�rz	 places (�rL�absr�roundr�r>�r"rtru�placesr��delta�diffr�s        r�assertAlmostEqualzTestCase.assertAlmostEqualts,���F�?�?��F����!3��>�?�?�?��5�6�>�"�"�����u�}�}����%� � � � ��&�!�!�!�!��%� � � � ��$�����	!�K�K��~����T�6�"�"�a�'�'����%� � � � ��&�!�!�!�!�����$�����	!�K�
�!�!�#�{�3�3���#�#�C�(�(�(rc	���|�|�td���t||z
��}|�Q||ks||krdSt|���dt|���dt|���dt|���d�}nE|�d}||kst||��dkrdSt|���dt|���d|�d	�}|�||��}|�|���)
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.
        Nr�r~r�r�r�r�rz placesr�r�s        r�assertNotAlmostEqualzTestCase.assertNotAlmostEqual�s�����!3��>�?�?�?��5�6�>�"�"�����V�O�O��������%� � � � ��&�!�!�!�!��%� � � � ��$�����	!�K�K��~����V�O�O��t�V�)<�)<��)A�)A���9B�5�9I�9I�9I�9I�9B�6�9J�9J�9J�9J�9?���A�K��!�!�#�{�3�3���#�#�C�(�(�(rc	��|�x|j}t||��s(|�d|�dt|�������t||��s(|�d|�dt|�������nd}d}	t	|��}n#t
tf$rd|z}YnwxYw|�-	t	|��}n#t
tf$rd|z}YnwxYw|���||krdSd|���ft||��zz}tt||����D]�}		||	}
n(#t
ttf$r|d	|	|fzz
}Yn�wxYw	||	}n(#t
ttf$r|d
|	|fzz
}YnQwxYw|
|kr|d|	ft|
|��zzz
}n+��||kr$|�"t|��t|��krdS||krS|d|||z
fzz
}	|d
|t||��fzz
}n�#t
ttf$r
|d||fzz
}Yn]wxYw||krS|d|||z
fzz
}	|d
|t||��fzz
}n'#t
ttf$r
|d||fzz
}YnwxYw|}dd�
tjt!j|�����t!j|���������z}
|�||
��}|�||��}|�|��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 r�zSecond sequence is not a �sequencez(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
rgr>r�lenrL�NotImplementedError�
capitalizer	�range�min�
IndexErrorrH�join�difflib�ndiff�pprint�pformat�
splitlines�_truncateMessager�rP)r"�seq1�seq2r��seq_type�
seq_type_name�	differing�len1�len2�i�item1�item2r��diffMsgs              r�assertSequenceEqualzTestCase.assertSequenceEqual�s�����$�-�M��d�H�-�-�
L��+�+�+�+8�=�=�)�D�/�/�/�-K�L�L�L��d�H�-�-�
L��+�+�+�+8�=�=�)�D�/�/�/�-K�L�L�L�
L�'�M��	�	#��t�9�9�D�D���.�/�	#�	#�	#�B�!�#�I�I�I�	#������
'��4�y�y�����2�3�
'�
'�
'�G�%�'�	�	�	�
'�������t�|�|���0�"�-�-�/�/�1�(��t�4�4�5�6�I��3�t�T�?�?�+�+�
�
��� ��G�E�E��!�:�/B�C�����"N�"#�]�!3�#4�5�I��E�E�����
� ��G�E�E��!�:�/B�C�����"O�"#�]�!3�#4�5�I��E�E�����
�E�>�>��"K�#$�$�)=�e�U�)K�)K�"K�#M�N�I��E�"�
�D�L�L�X�%5���J�J�$�t�*�*�,�,��F��d�{�{��+�.;�T�D�[�-I�J�K�	�K��"A�#'��4��:�)>�)>�"?�#@�A�I�I��!�:�/B�C�K�K�K��#2�59�=�4I�#J�K�I�I�I�K���������+�.;�T�D�[�-I�J�K�	�L��"A�#'��4��:�)>�)>�"?�#@�A�I�I��!�:�/B�C�L�L�L��#3�6:�M�5J�#K�L�I�I�I�L���� �������M�&�.��.�.�9�9�;�;� �.��.�.�9�9�;�;�
=�
=�>�>�>���+�+�K��A�A���!�!�#�{�3�3���	�	�#�����sl�B�B)�(B)�/B?�?C�C�/D8�8!E�E�!E*�*!F�F�3H�!H5�4H5�I*�*!J�
Jc�x�|j}|�t|��|kr||zS|tt|��zzSr0)�maxDiffr��DIFF_OMITTED)r"r�r��max_diffs    rr�zTestCase._truncateMessage's?���<����s�4�y�y�H�4�4��T�>�!��,��T���2�3�3rc�B�|�|||t���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�)r"�list1�list2r�s    rr�zTestCase.assertListEqual-s'��	
� � ���s�T� �B�B�B�B�Brc�B�|�|||t���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.
        r�N)r�r�)r"�tuple1�tuple2r�s    rr�zTestCase.assertTupleEqual9s'��	
� � ����u� �E�E�E�E�Erc�J�	|�|��}nY#t$r"}|�d|z��Yd}~n2d}~wt$r"}|�d|z��Yd}~nd}~wwxYw	|�|��}nY#t$r"}|�d|z��Yd}~n2d}~wt$r"}|�d|z��Yd}~nd}~wwxYw|s|sdSg}|r<|�d��|D]$}|�t|�����%|r<|�d��|D]$}|�t|�����%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	)�
differencerLrPrKrU�reprr�r�)
r"�set1�set2r��difference1r.�difference2�lines�itemr�s
          rr�zTestCase.assertSetEqualDs&��	P��/�/�$�/�/�K�K���	M�	M�	M��I�I�G�!�K�L�L�L�L�L�L�L�L������	P�	P�	P��I�I�J�Q�N�O�O�O�O�O�O�O�O�����	P����	Q��/�/�$�/�/�K�K���	M�	M�	M��I�I�G�!�K�L�L�L�L�L�L�L�L������	Q�	Q�	Q��I�I�K�a�O�P�P�P�P�P�P�P�P�����	Q�����	�{�	��F����	)��L�L�E�F�F�F�#�
)�
)�����T�$�Z�Z�(�(�(�(��	)��L�L�E�F�F�F�#�
)�
)�����T�$�Z�Z�(�(�(�(��i�i��&�&���	�	�$�%�%�c�;�7�7�8�8�8�8�8sB��
A.�?�
A.�A)�)A.�2B�
C�B/�/
C�<C�Cc��||vrLt|���dt|����}|�|�||����dSdS)zDJust like self.assertTrue(a in b), but with a nicer default message.� not found in N�rrPr��r"�member�	containerr�r�s     r�assertInzTestCase.assertInosd����"�"�2;�F�2C�2C�2C�2C�2;�I�2F�2F�2F�H�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<�#�"rc��||vrLt|���dt|����}|�|�||����dSdS)zHJust like self.assertTrue(a not in b), but with a nicer default message.z unexpectedly found in Nr�r�s     r�assertNotInzTestCase.assertNotInvsd���Y���;D�V�;L�;L�;L�;L�8A�)�8L�8L�8L�N�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��rc��||urLt|���dt|����}|�|�||����dSdS)zDJust like self.assertTrue(a is b), but with a nicer default message.z is not Nr��r"�expr1�expr2r�r�s     r�assertIszTestCase.assertIs}sc������,5�e�,<�,<�,<�,<�-6�u�-=�-=�-=�?�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��rc��||ur=dt|����}|�|�||����dSdS)zHJust like self.assertTrue(a is not b), but with a nicer default message.zunexpectedly identical: Nr�r�s     r�assertIsNotzTestCase.assertIsNot�sO���E�>�>�>�:C�E�:J�:J�:J�L�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��>rc	��|�|td��|�|td��||kr�dt||��z}dd�t	jt
j|�����t
j|���������z}|�	||��}|�
|�||����dSdS)Nz"First argument is not a dictionaryz#Second argument is not a dictionaryryr	)�assertIsInstancer�r	r�r�r�r�r�r�r�rPr�)r"�d1�d2r�r�r�s      rr�zTestCase.assertDictEqual�s������b�$�(L�M�M�M����b�$�(M�N�N�N�
��8�8�$�';�B��'C�'C�C�K��4�9�9�W�]�!�>�"�-�-�8�8�:�:�!�>�"�-�-�8�8�:�:�&<�&<�=�=�=�D��/�/��T�B�B�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<�
�8rc�H�tjdt��g}g}|���D]u\}}||vr|�|���|||krJ|�t|���dt|���dt||�������v|s|sdSd}|r"dd�d�|D����z}|r"|r|d	z
}|d
d�|��zz
}|�|�||����dS)z2Checks whether dictionary is a superset of subset.z&assertDictContainsSubset is deprecatedz, expected: z
, actual: NrnzMissing: %s�,c3�4K�|]}t|��V��dSr0)r)r~r�s  rr�z4TestCase.assertDictContainsSubset.<locals>.<genexpr>�s8����3=�3=�A�9�Q�<�<�3=�3=�3=�3=�3=�3=rz; zMismatched values: %s)	r7r8r4�itemsrUrr�rPr�)	r"�subset�
dictionaryr��missing�
mismatched�key�valuer�s	         r�assertDictContainsSubsetz!TestCase.assertDictContainsSubset�sz���
�>�(�	*�	*�	*����
� �,�,�.�.�	@�	@�J�C���*�$�$����s�#�#�#�#��*�S�/�)�)��!�!�#,�S�>�>�>�>�9�U�3C�3C�3C�3C�#,�Z��_�#=�#=�#=�#?�@�@�@���	�:�	��F����	=�'�#�(�(�3=�3=�4;�3=�3=�3=�+=�+=�=�K��	J��
$��t�#���2�S�X�X�j�5I�5I�I�I�K��	�	�$�%�%�c�;�7�7�8�8�8�8�8rc���t|��t|��}}	tj|��}tj|��}||krdSt||��}n #t$rt||��}YnwxYw|rfd}d�|D��}d�|��}	|�||	��}|�||��}|�	|��dSdS)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:
c��g|]}d|z��S)z First has %d, Second has %d:  %rr)r~r�s  r�
<listcomp>z-TestCase.assertCountEqual.<locals>.<listcomp>�s��W�W�W�4�7�$�>�W�W�Wrr	)
r��collections�CounterrrLrr�r�r�rP)
r"rtrur��	first_seq�
second_seq�differencesr�r�r�s
          r�assertCountEqualzTestCase.assertCountEqual�s��!%�U���T�&�\�\�:�	�		F��'�	�2�2�E� �(��4�4�F�
������.�y�*�E�E�K�K��
�	I�	I�	I�1�)�Z�H�H�K�K�K�	I�����	�<�K�W�W�;�W�W�W�E��i�i��&�&�G��/�/��W�E�E�K��%�%�c�;�7�7�C��I�I�c�N�N�N�N�N�
	�	s�(A!�!A>�=A>c���|�|td��|�|td��||k�r*t|��|jkst|��|jkr|�|||��|�d���}|�d���}t|��dkr%|�d��|kr|dzg}|dzg}dt||��z}dd	�tj
||����z}|�||��}|�|�
||����d
Sd
S)z-Assert that two multi-line strings are equal.zFirst argument is not a stringzSecond argument is not a stringT)�keependsrz
r	ryrnN)r�r(r��_diffThresholdrsr�r
r	r�r�r�r�rPr�)r"rtrur��
firstlines�secondlinesr�r�s        rr�zTestCase.assertMultiLineEqual�sa�����e�S�*J�K�K�K����f�c�+L�M�M�M��F�?�?��E�
�
�T�0�0�0��F���d�1�1�1��%�%�e�V�S�9�9�9��)�)�4�)�8�8�J� �+�+�T�+�:�:�K��:���!�#�#����F�(;�(;�u�(D�(D�#�d�l�^�
�%��}�o��$�';�E�6�'J�'J�J�K��"�'�'�'�-�
�K�"H�"H�I�I�I�D��/�/��T�B�B�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��?rc��||ksLt|���dt|����}|�|�||����dSdS)zCJust like self.assertTrue(a < b), but with a nicer default message.z not less than Nr��r"�a�br�r�s     r�
assertLesszTestCase.assertLess�sV���1�u�u�3<�Q�<�<�<�<��1����N�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��urc��||ksLt|���dt|����}|�|�||����dSdS)zDJust like self.assertTrue(a <= b), but with a nicer default message.z not less than or equal to Nr�r�s     r�assertLessEqualzTestCase.assertLessEqual�sW���A�v�v�?H��|�|�|�|�Y�WX�\�\�\�Z�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��vrc��||ksLt|���dt|����}|�|�||����dSdS)zCJust like self.assertTrue(a > b), but with a nicer default message.z not greater than Nr�r�s     r�
assertGreaterzTestCase.assertGreater�sV���1�u�u�6?��l�l�l�l�I�a�L�L�L�Q�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��urc��||ksLt|���dt|����}|�|�||����dSdS)zDJust like self.assertTrue(a >= b), but with a nicer default message.z not greater than or equal to Nr�r�s     r�assertGreaterEqualzTestCase.assertGreaterEqual�s[���A�v�v�BK�A�,�,�,�,�PY�Z[�P\�P\�P\�]�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��vrc��|�=t|���d�}|�|�||����dSdS)zCSame as self.assertTrue(obj is None), with a nicer default message.Nz is not Noner��r"rCr�r�s    r�assertIsNonezTestCase.assertIsNone�sH���?�.7��n�n�n�n�>�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��?rc�d�|�-d}|�|�||����dSdS)z(Included for symmetry with assertIsNone.Nzunexpectedly None)rPr�r�s    r�assertIsNotNonezTestCase.assertIsNotNones;���;�-�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��;rc��t||��s?t|���d|��}|�|�||����dSdS)zTSame as self.assertTrue(isinstance(obj, cls)), with a nicer
        default message.z is not an instance of N�rgrrPr��r"rCrOr�r�s     rr�zTestCase.assertIsInstances^���#�s�#�#�	=�;D�S�>�>�>�>�3�3�O�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<�	=�	=rc��t||��r?t|���d|��}|�|�||����dSdS)z,Included for symmetry with assertIsInstance.z is an instance of Nr�r�s     r�assertNotIsInstancezTestCase.assertNotIsInstances\���c�3���	=�7@��~�~�~�~�s�s�K�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<�	=�	=rc�R�t|||��}|�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])r"r^r�rWrXr_s      rrzTestCase.assertRaisesRegexs-��'�'9�4��P�P���~�~�1�4��@�@�@rc�R�t|||��}|�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.
        �assertWarnsRegexrb)r"rcr�rWrXr_s      rrzTestCase.assertWarnsRegex(s-�� &�&6��n�M�M���~�~�0�$��?�?�?rc��t|ttf��rtj|��}|�|��s8d|j�d|��}|�||��}|�|���dS)z=Fail the test unless the text matches the regular expression.zRegex didn't match: r�N)	rgr(�bytesr�r�r�r�r�r>)r"�textr�r�r�s     r�assertRegexzTestCase.assertRegex;s����n�s�E�l�3�3�	8��Z��7�7�N��$�$�T�*�*�	-�	-��&�&�&���.�K��%�%�c�;�7�7�C��'�'��,�,�,�	-�	-rc�b�t|ttf��rtj|��}|�|��}|rgd||���|�����d|j�d|��}|�	||��}|�
|���dS)z9Fail the test if the text matches the regular expression.zRegex matched: z	 matches z in N)rgr(rr�r�r��start�endr�r�r>)r"r�unexpected_regexr��matchr�s      r�assertNotRegexzTestCase.assertNotRegexGs����&��e��5�5�	<�!�z�*:�;�;�� �'�'��-�-���	-�	-��U�[�[�]�]�U�Y�Y�[�[�0�1�1�1� �(�(�(����K�
�%�%�c�;�7�7�C��'�'��,�,�,�	-�	-rc����fd�}|S)Nc�z��tjd��j��td���|i|��S)NzPlease use {0} instead.r5)r7r8r�r
r4)rWrX�
original_funcs  �r�deprecated_funcz,TestCase._deprecate.<locals>.deprecated_funcWsG����M�)�0�0��1G�H�H�"�A�
'�
'�
'�!�=�$�1�&�1�1�1rr)rrs` r�
_deprecatezTestCase._deprecateVs$���	2�	2�	2�	2�	2�
�r)r�r0)NN�NNN)er
rrr�AssertionErrorr>rYr�r�r�r#r�r�r�r�r�r�r�r�r�rrrrrrrrr!r1r2�_subtest_msg_sentinelr,r+r.r0r6r8r:rCr@rGrJrLrNrPrUrWr�r\rarnrprwrsr|rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr�failUnlessEqual�assertEquals�failIfEqual�assertNotEquals�failUnlessAlmostEqual�assertAlmostEquals�failIfAlmostEqual�assertNotAlmostEquals�
failUnless�assert_�failUnlessRaises�failIf�assertRaisesRegexp�assertRegexpMatches�assertNotRegexpMatches�
__classcell__�r�s@rr�r�Xs����������@&���K��G��N�3�3�3�3�3�>�>�>�>�@
6�
6�
6�8�8�8�3�3�3��=�=��[�=�
�7�7��[�7�
�
�
�
�
�
��V�V��[�V��a�a��[�a����#�#�#�C�C�C�J�J�J�=�=�=�8�8�8�e�e�e�@�@�@���/�#�#�#���#�</�/�/�
'�
'�
'����U�U�U�
���"�"�"�=�=�=�=�~����	?�	?��[�	?�'�'�'�9�9�9�"���)�)�)�)�-�-�-�-�-�-�-�-�I�I�I�*���B;�;�;�>F�F�F�F�0E�E�E�E�%�%�%�4-�-�-�-�/�/�/�/�-�-�-�-�AE� $�+)�+)�+)�+)�ZDH�#'�!)�!)�!)�!)�Fa�a�a�a�F4�4�4�
C�
C�
C�
C�	F�	F�	F�	F�)9�)9�)9�)9�V=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�
=�
=�
=�
=�9�9�9�9�:����@=�=�=�=�(=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�A�A�A� @�@�@�&
-�
-�
-�
-�-�-�-�-����&0�Z��%<�%<�<�O�l�$.�J�~�$>�$>�>�K�/�1;��<M�1N�1N�N��.�0:�
�;O�0P�0P�P��-�%�:�j�1�1�1�J��!�z�,�/�/��
�Z��
$�
$�F�#��$5�6�6��$�*�[�1�1��'�Z��7�7�����rr�c�Z��eZdZdZd
�fd�	Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
�xZS)�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.
    Nc���tt|�����||_||_||_||_dSr0)r�r)r#�
_setUpFunc�
_tearDownFunc�	_testFunc�_description)r"�testFuncr�r��descriptionr�s     �rr#zFunctionTestCase.__init__usD���
���%�%�.�.�0�0�0����%���!���'����rc�@�|j�|���dSdSr0)r+r�s rr�zFunctionTestCase.setUp|s(���?�&��O�O������'�&rc�@�|j�|���dSdSr0)r,r�s rr�zFunctionTestCase.tearDown�s+����)���� � � � � �*�)rc�.�|���dSr0)r-r�s rr�zFunctionTestCase.runTest�s���������rc��|jjSr0)r-r
r�s rrzFunctionTestCase.id�s
���~�&�&rc��t||j��stS|j|jko/|j|jko|j|jko|j|jkSr0)rgr�rr+r,r-r.rs  rrzFunctionTestCase.__eq__�sg���%���0�0�	"�!�!���%�"2�2�7��!�U�%8�8�7��~���0�7�� �E�$6�6�	7rc�l�tt|��|j|j|j|jf��Sr0)rrHr+r,r-r.r�s rrzFunctionTestCase.__hash__�s4���T�$�Z�Z���$�2D��^�T�%6�8�9�9�	9rc�J�t|j���d|jj�d�S)Nrr)rr�r-r
r�s rrzFunctionTestCase.__str__�s-��$�T�^�4�4�4�4� �N�3�3�3�5�	5rc�B�dt|j���d|j�d�S)Nrz tec=r )rr�r-r�s rr!zFunctionTestCase.__repr__�s*��� (��� 8� 8� 8� 8�%)�^�^�^�5�	5rc��|j�|jS|jj}|r-|�d��d���pdS)Nr	r)r.r-rrr
rs  rrz!FunctionTestCase.shortDescription�sI����(��$�$��n�$���1�s�y�y����q�)�/�/�1�1�9�T�9rr)r
rrrr#r�r�r�rrrrr!rr&r's@rr)r)ls����������(�(�(�(�(�(����!�!�!����'�'�'�7�7�7�9�9�9�5�5�5�5�5�5�:�:�:�:�:�:�:rr)c�<��eZdZ�fd�Zd�Zd�Zd�Zd�Zd�Z�xZ	S)r%c���t�����||_||_||_|j|_dSr0)r�r#�_messager%r#r>)r"r%r�r#r�s    �rr#z_SubTest.__init__�s?���
����������
�"������ )� :����rc� �td���)Nzsubtests cannot be run directly)r�r�s rr�z_SubTest.runTest�s��!�"C�D�D�Drc�t�g}|jtur-|�d�|j����|jr^d�d�|j���D����}|�d�|����d�|��pdS)Nz[{}]z, c3�HK�|]\}}d�||��V��dS)z{}={!r}N)r�)r~r�r�s   rr�z+_SubTest._subDescription.<locals>.<genexpr>�sJ����$3�$3��Q��� � ��A�&�&�$3�$3�$3�$3�$3�$3rz({})� z(<subtest>))r<rrUr�r#r�r�)r"�parts�params_descs   r�_subDescriptionz_SubTest._subDescription�s������=� 5�5�5��L�L����t�}�5�5�6�6�6��;�	5��)�)�$3�$3�"�k�/�/�1�1�$3�$3�$3�3�3�K�
�L�L����{�3�3�4�4�4��x�x����/�-�/rc��d�|j���|�����S�Nz{} {})r�r%rrCr�s rrz_SubTest.id�s0���~�~�d�n�/�/�1�1�4�3G�3G�3I�3I�J�J�Jrc�4�|j���S)zlReturns a one-line description of the subtest, or None if no
        description has been provided.
        )r%rr�s rrz_SubTest.shortDescription�s���~�.�.�0�0�0rc�\�d�|j|�����SrE)r�r%rCr�s rrz_SubTest.__str__�s$���~�~�d�n�d�.B�.B�.D�.D�E�E�Er)
r
rrr#r�rCrrrr&r's@rr%r%�s��������;�;�;�;�;�E�E�E�	0�	0�	0�K�K�K�1�1�1�F�F�F�F�F�F�Frr%)2rr)rhr�r�r�r7r�r1r�rornr�utilrrrrr	�
__unittest�objectrr�r^rrrrr'r+rDrRrTrYr[rarqrvrxr!r}r�r�r�r��ChainMapr�r�r)r%rrr�<module>rLs�����
�
�
�
���������
�
�
�
�	�	�	�	���������������������������?�?�?�?�?�?�?�?�?�?�?�?�?�?��
������7�������y���������)����
���������&8�&8�&8�&8�&8�v�&8�&8�&8�R%�%�%�,�,�,���������6�6�6�
0�0�0�

�
�
� ���(���������I�I�I�
3�3�3�3�3�3�3�3�'�'�'�'�'�3�'�'�'�T$8�$8�$8�$8�$8�3�$8�$8�$8�N1D�1D�1D�1D�1D�2�1D�1D�1D�h�����{�+����P8�P8�P8�P8�P8�v�P8�P8�P8�h 7:�7:�7:�7:�7:�x�7:�7:�7:�t!F�!F�!F�!F�!F�x�!F�!F�!F�!F�!Fr__pycache__/signals.cpython-311.opt-2.pyc000064400000007471152401764000014066 0ustar00�

;/�R�|��~�ddlZddlZddlmZdZGd�de��Zej��Zd�Z	d�Z
dad�Zd
d	�Z
dS)�N)�wrapsTc��eZdZd�Zd�ZdS)�_InterruptHandlerc���d|_||_t|t��r@|tjkr
tj}n#|tjkrd�}ntd���||_	dS)NFc��dS�N�)�
unused_signum�unused_frames  �;/opt/alt/python-internal/lib/python3.11/unittest/signals.py�default_handlerz3_InterruptHandler.__init__.<locals>.default_handlers���D�zYexpected 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
)�selfr
s  r�__init__z_InterruptHandler.__init__
s������ /����o�s�+�+�	3��&�.�0�0�"(�"<��� �F�N�2�2����� �!2�3�3�3� /����rc��tjtj��}||ur|�||��|jr|�||��d|_t
���D]}|����dS)NT)r�	getsignal�SIGINTr
r�_results�keys�stop)r�signum�frame�installed_handler�results     r�__call__z_InterruptHandler.__call__s���"�,�V�]�;�;���D�(�(�
� � ���/�/�/��;�	0�� � ���/�/�/�����m�m�o�o�	�	�F��K�K�M�M�M�M�	�	rN)�__name__�
__module__�__qualname__rr$r	rrrr	s2������/�/�/�$����rrc��dt|<dS)N�)r�r#s r�registerResultr+*s���H�V���rc�R�tt�|d����Sr)�boolr�popr*s r�removeResultr/-s������V�T�*�*�+�+�+rc��t�Stjtj��}t	|��atjtjt��dSdSr)�_interrupt_handlerrrrr)r
s r�installHandlerr21sK���!� �*�6�=�9�9��.��?�?���
�f�m�%7�8�8�8�8�8�"�!rc�����t����fd���}|St�+tjtjtj��dSdS)Nc����tjtj��}t��	�|i|��tjtj|��S#tjtj|��wxYwr)rrr�
removeHandler)�args�kwargs�initial�methods   �r�innerzremoveHandler.<locals>.inner;sf����&�v�}�5�5�G��O�O�O�
6��v�t�.�v�.�.��
�f�m�W�5�5�5�5���
�f�m�W�5�5�5�5���s�A�!A7)rr1rrr)r9r:s` rr5r59sg���
��	�v���	6�	6�	6�	6�
��	6����%��
�f�m�%7�%H�I�I�I�I�I�&�%rr)r�weakref�	functoolsr�
__unittest�objectr�WeakKeyDictionaryrr+r/r1r2r5r	rr�<module>r@s���
�
�
�
�����������
�
����������@%�7�$�&�&�����,�,�,���9�9�9�J�J�J�J�J�Jr__pycache__/__init__.cpython-311.pyc000064400000010232152401764000013212 0ustar00�

N@�s�D����dZgd�Ze�gd���dZddlmZddlmZmZm	Z	m
Z
mZmZm
Z
mZmZmZddlmZmZddlmZmZdd	lmZmZdd
lmZmZddlmZmZmZm Z ddlm!Z!m"Z"m#Z#eZ$d
�Z%d�Z&d�Z'dS)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�doModuleCleanups�enterModuleContext)�getTestCaseNames�	makeSuite�
findTestCasesT�)r)
rrrrrr
rrrr)�
BaseTestSuiter)rr
)�TestProgramr	)rr)rrrr)rrrc�v�ddl}|j�t��}|�||���S)N�)�	start_dir�pattern)�os.path�path�dirname�__file__�discover)�loader�testsr!�os�this_dirs     �</opt/alt/python-internal/lib/python3.11/unittest/__init__.py�
load_testsr,Os4���N�N�N��w���x�(�(�H��?�?�X�w�?�?�?�?�c�J�t�����dhzS)Nr)�globals�keys�r-r+�__dir__r2Zs���9�9�>�>���8�9�9�9r-c�\�|dkr
ddlmatStdt�d|�����)Nrr)rzmodule z has no attribute )�
async_caser�AttributeError�__name__)�names r+�__getattr__r8]sE���(�(�(�7�7�7�7�7�7�&�&�
�I�8�I�I��I�I�
J�
J�Jr-N)(�__doc__�__all__�extend�
__unittest�resultr�caserrrrrr
rrrr�suiterrr'rr
r	r�runnerrr�signalsrrrrrrr�_TextTestResultr,r2r8r1r-r+�<module>rCs���,�,�\I�I�I�����A�A�A�B�B�B�
�
�������'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�,�+�+�+�+�+�+�+�1�1�1�1�1�1�1�1�#�#�#�#�#�#�#�#�2�2�2�2�2�2�2�2�P�P�P�P�P�P�P�P�P�P�P�P�>�>�>�>�>�>�>�>�>�>�!��@�@�@�:�:�:�K�K�K�K�Kr-__pycache__/main.cpython-311.opt-1.pyc000064400000032772152401764000013353 0ustar00�

�u�ʡ�����dZddlZddlZddlZddlZddlmZmZddlm	Z	dZ
dZdZd	�Z
d
�Zd�ZGd�d
e��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
c�V�tj�|���r|����d��r�tj�|��rstj�|tj����}tj�|��s|�tj	��r|S|}tj�
|��dd��dd���dd��S|S)Nz.py����\�.�/)�os�path�isfile�lower�endswith�isabs�relpath�getcwd�
startswith�pardir�normpath�replace)�name�rel_paths  �8/opt/alt/python-internal/lib/python3.11/unittest/main.py�
_convert_namers���

�w�~�~�d���P��
�
��� 5� 5�e� <� <�P�
�7�=�=����	��w���t�R�Y�[�[�9�9�H��w�}�}�X�&�&�
�(�*=�*=�b�i�*H�*H�
����D��w����%�%�c�r�c�*�2�2�4��=�=�E�E�c�3�O�O�O��K�c��d�|D��S)Nc�,�g|]}t|����S�)r)�.0rs  r�
<listcomp>z"_convert_names.<locals>.<listcomp>/s ��2�2�2�D�M�$���2�2�2rr)�namess r�_convert_namesr#.s��2�2�E�2�2�2�2rc��d|vrd|z}|S)N�*z*%s*r)�patterns r�_convert_select_patternr'2s���'�>�>��7�"���Nrc��eZdZdZdZdZdxZxZxZxZ	xZ
ZdZdddde
jddddddfdd�d�Zdd	�Zd
�Zd�Zdd�Zd
�Zd�Zd�Zd�Zdd�Zd�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�V�t|t��rOt|��|_|�d��dd�D]}
t|j|
��|_�n||_|�tj}||_||_	|	|_
||_|
|_||_
|�tjsd|_n||_||_||_||_t&j�|d��|_|�|��|���dS)Nr
r�defaultr)�
isinstance�str�
__import__�module�split�getattr�sys�argv�exit�failfast�
catchbreak�	verbosity�bufferr+�warnoptions�warnings�defaultTest�
testRunner�
testLoaderrr
�basename�progName�	parseArgs�runTests)�selfr1r=r5r>r?r6r9r7r8r:r<r+�parts              r�__init__zTestProgram.__init__Bs���f�c�"�"�	!�$�V�,�,�D�K����S�)�)�!�"�"�-�
9�
9��%�d�k�4�8�8����
9�!�D�K��<��8�D���	� ��
�$���"������"�����C�O��&�D�M�M�%�D�M�&���$���$�����(�(��a��1�1��
����t�����
�
�����rc���tjdt��|rt|��|j�|���|���tjd��dS)NzHTestProgram.usageExit() is deprecated and will be removed in Python 3.13�)	r<�warn�DeprecationWarning�print�_discovery_parser�_initArgParsers�_print_helpr4r6)rD�msgs  r�	usageExitzTestProgram.usageExithsr���
�0�1C�	E�	E�	E��	��#�J�J�J��!�)�� � �"�"�"��������������rc�Z�|j�_t|j�����ttd|jiz��|j���dSt|j�����ttd|jiz��dS)N�prog)	r1rK�_main_parser�format_help�
MAIN_EXAMPLESrArL�
print_help�MODULE_EXAMPLES)rD�args�kwargss   rrNzTestProgram._print_helprs����;���$�#�/�/�1�1�2�2�2��-�6�4�=�"9�9�:�:�:��"�-�-�/�/�/�/�/��$�#�/�/�1�1�2�2�2��/�V�T�]�$;�;�<�<�<�<�<rc���|���|j��t|��dkr=|d���dkr|�|dd���dS|j�|dd�|��|js|�g��dSn#|j�|dd�|��|jr,t|j��|_	tdkrd|_nP|j�d|_	nAt|jt��r|jf|_	nt|j��|_	|���dS)Nr�discoverrHr*)rMr1�lenr�
_do_discoveryrS�
parse_args�testsr#�	testNames�__name__r=r.r/�list�createTests)rDr5s  rrBzTestProgram.parseArgs{s^���������;���4�y�y�1�}�}��a������J�!>�!>��"�"�4����8�,�,�,�����(�(��a�b�b��4�8�8�8��:�
��"�"�2�&�&�&���	
�
��(�(��a�b�b��4�8�8�8��:�	4�+�D�J�7�7�D�N��:�%�%�"����
�
�
%�!�D�N�N�
��(�#�
.�
.�	4�"�.�0�D�N�N�!�$�"2�3�3�D�N��������rc�^�|jr|j|j_|r;|�|jn	|��}|j|j|j|j��|_dS|j�&|j�|j	��|_dS|j�
|j|j	��|_dS�N)�testNamePatternsr?r[�startr&�top�testr`�loadTestsFromModuler1�loadTestsFromNames)rD�from_discovery�Loaderrs    rrczTestProgram.createTests�s���� �	E�/3�/D�D�O�,��	H�(.��T�_�_�F�F�H�H�F�'����
�D�L�$�(�K�K�D�I�I�I�
�^�
#���;�;�D�K�H�H�D�I�I�I���:�:�4�>�;?�;�H�H�D�I�I�Irc��|���}|�|��|_|�|��|_dSre)�_getParentArgParser�_getMainArgParserrS�_getDiscoveryArgParserrL)rD�
parent_parsers  rrMzTestProgram._initArgParsers�sE���0�0�2�2�
� �2�2�=�A�A���!%�!<�!<�]�!K�!K����rc��tjd���}|�dddddd�	��|�d
ddddd
�	��|�dddd���|j�!|�ddddd���d|_|j�!|�ddddd���d|_|j�!|�ddddd���d|_|j�&|�dd d!td"�#��g|_|S)$NF)�add_helpz-vz	--verboser9�store_constrHzVerbose output)�dest�action�const�helpz-qz--quietrzQuiet outputz--localsr+�
store_truez"Show local variables in tracebacks)rvrwryz-fz
--failfastr7zStop on first fail or errorz-cz--catchr8z'Catch Ctrl-C and display results so farz-bz--bufferr:z%Buffer stdout and stderr during testsz-krf�appendz.Only run tests which match the given substring)rvrw�typery)�argparse�ArgumentParser�add_argumentr7r8r:rfr')rD�parsers  rrozTestProgram._getParentArgParser�s����(�%�8�8�8�����D�+�K�#0��!1�	�	3�	3�	3�	���D�)�+�#0��!/�	�	1�	1�	1�	���J�[�#/�!E�	�	G�	G�	G��=� �����l��'3�%B�
 �
D�
D�
D�"�D�M��?�"�����i�l�'3�%N�
 �
P�
P�
P�$�D�O��;������j�x�'3�%L�
 �
N�
N�
N� �D�K�� �(�����+=�'/�6M�%U�
 �
W�
W�
W�%'�D�!��
rc��tj|g���}|j|_|j|_|�ddd���|S)N��parentsr_r%z?a list of any number of test modules, classes and test methods.)�nargsry)r}r~rArRrNrVr)rD�parentr�s   rrpzTestProgram._getMainArgParser�sX���(�&��:�:�:���m��� �,������G�3�"8�	�	9�	9�	9��
rc�X�tj|g���}d|jz|_d|_|�dddd���|�d	d
dd���|�d
ddd���dD]/}|�|dtjtj����0|S)Nr�z%s discoverzcFor test discovery all test modules must be importable from the top level directory of the project.z-sz--start-directoryrgz*Directory to start discovery ('.' default))rvryz-pz	--patternr&z+Pattern to match tests ('test*.py' default)z-tz--top-level-directoryrhz<Top level directory of project (defaults to start directory))rgr&rh�?)r�r-ry)r}r~rArR�epilogr�SUPPRESS)rDr�r��args    rrqz"TestProgram._getDiscoveryArgParser�s����(�&��:�:�:��#�d�m�3���$��
�	���D�"5�G�!M�	�	O�	O�	O����D�+�I�!N�	�	P�	P�	P����D�"9��"4�	�	5�	5�	5�/�	8�	8�C�����3�(0�(9�%-�%6�
 �
8�
8�
8�
8��
rc���d|_d|_d|_|�6|j�|���|j�||��|�d|���dS)Nr
ztest*.pyT)rlrm)rgr&rhrLrMr^rc)rDr5rms   rr]zTestProgram._do_discovery�sp����
�!���������%�-��$�$�&�&�&��"�-�-�d�D�9�9�9�����V��<�<�<�<�<rc�z�|jrt��|j�tj|_t|jt��r�		|�|j|j|j	|j
|j���}n=#t$r0|�|j|j|j	|j
���}YnwxYwn+#t$r|���}YnwxYw|j}|�
|j��|_|jr.t#j|j�����dSdS)N)r9r7r:r<r+)r9r7r:r<)r8rr>r�TextTestRunnerr.r|r9r7r:r<r+�	TypeError�runri�resultr6r4�
wasSuccessful)rDr>s  rrCzTestProgram.runTests�sY���?�	������?�"�$�3�D�O��d�o�t�,�,�	)�
/�I�!%���4�>�:>�-�8<��:>�-�;?�>�	"1�"K�"K�J�J��
!�I�I�I�!%���4�>�:>�-�8<��:>�-�"1�"I�"I�J�J�J�I�������
/�
/�
/�!�_�_�.�.�
�
�
�
/����
��J� �n�n�T�Y�/�/����9�	6��H���2�2�4�4�4�5�5�5�5�5�	6�	6s0�
3A>�=B<�>7B8�5B<�7B8�8B<�<C�Cre)FN)ra�
__module__�__qualname__�__doc__r1r9r7r8r:rAr<rfrLr�defaultTestLoaderrFrPrNrBrcrMrorprqr]rCrrrr)r)8s>���������F��I�NR�R�H�R�z�R�F�R�X�R��;K���(�d��#��0H���T�d��$�$�>C�$�$�$�$�$�L����=�=�=����:
H�
H�
H�
H�L�L�L�
!�!�!�F	�	�	����*=�=�=�=�6�6�6�6�6rr))r�r4r}rr<�rr�signalsr�
__unittestrUrWrr#r'�objectr)�mainrrr�<module>r�s�����
�
�
�
�����	�	�	�	�������������#�#�#�#�#�#�
�
��
������ 3�3�3����\6�\6�\6�\6�\6�&�\6�\6�\6�|���r__pycache__/runner.cpython-311.opt-2.pyc000064400000037027152401764000013737 0ustar00�

����yWc���	ddlZddlZddlZddlmZddlmZddlmZdZ	Gd�de
��ZGd	�d
ej��Z
Gd�de
��ZdS)
�N�)�result)�_SubTest)�registerResultTc�$�eZdZ	d�Zd�Zdd�ZdS)�_WritelnDecoratorc��||_dS�N)�stream)�selfrs  �:/opt/alt/python-internal/lib/python3.11/unittest/runner.py�__init__z_WritelnDecorator.__init__s
�������c�R�|dvrt|���t|j|��S)N)r�__getstate__)�AttributeError�getattrr)r�attrs  r
�__getattr__z_WritelnDecorator.__getattr__s.���-�-�-� ��&�&�&��t�{�4�(�(�(rNc�^�|r|�|��|�d��dS�N�
)�write)r�args  r
�writelnz_WritelnDecorator.writelns1���	��J�J�s�O�O�O��
�
�4�����rr
)�__name__�
__module__�__qualname__rrr�rr
rrsI������J����)�)�)�
�����rrc���eZdZ	dZdZ�fd�Zd�Z�fd�Zd�Z�fd�Z	�fd�Z
�fd	�Z�fd
�Z�fd�Z
�fd�Z�fd
�Zd�Zd�Z�xZS)�TextTestResultzF======================================================================zF----------------------------------------------------------------------c���tt|���|||��||_|dk|_|dk|_||_d|_dS)NrT)�superr!rr�showAll�dots�descriptions�_newline)rrr&�	verbosity�	__class__s    �r
rzTextTestResult.__init__&sU���
�n�d�#�#�,�,�V�\�9�M�M�M���� �1�}�����N��	�(�����
�
�
rc��|���}|jr&|r$d�t|��|f��St|��Sr)�shortDescriptionr&�join�str)r�test�doc_first_lines   r
�getDescriptionzTextTestResult.getDescription.sN���.�.�0�0����	��	��9�9�c�$�i�i��8�9�9�9��t�9�9�rc�8��tt|���|��|jri|j�|�|����|j�d��|j���d|_dSdS)N� ... F)	r#r!�	startTestr$rrr0�flushr'�rr.r)s  �r
r3zTextTestResult.startTest5s����
�n�d�#�#�-�-�d�3�3�3��<�	"��K���d�1�1�$�7�7�8�8�8��K���g�&�&�&��K������!�D�M�M�M�		"�	"rc��t|t��}|s|jr�|js|j���|r|j�d��|j�|�|����|j�d��|j�|��|j���d|_dS)Nz  r2T)�
isinstancerr'rrrr0r4)rr.�status�
is_subtests    r
�
_write_statuszTextTestResult._write_status=s�����h�/�/�
��	'���	'��=�
&���#�#�%�%�%��
(���!�!�$�'�'�'��K���d�1�1�$�7�7�8�8�8��K���g�&�&�&�����F�#�#�#����������
�
�
rc����|��|jrIt|d|j��r|�|d��n�|�|d��np|jrit|d|j��r|j�d��n|j�d��|j���tt|���
|||��dS)Nr�FAIL�ERROR�F�E)r$�
issubclass�failureExceptionr:r%rrr4r#r!�
addSubTest)rr.�subtest�errr)s    �r
rBzTextTestResult.addSubTestJs�����?��|�

$��c�!�f�g�&>�?�?�9��&�&�w��7�7�7�7��&�&�w��8�8�8�8���
$��c�!�f�g�&>�?�?�+��K�%�%�c�*�*�*�*��K�%�%�c�*�*�*���!�!�#�#�#�
�n�d�#�#�.�.�t�W�c�B�B�B�B�Brc���tt|���|��|jr|�|d��dS|jr5|j�d��|j���dSdS)N�ok�.)	r#r!�
addSuccessr$r:r%rrr4r5s  �r
rHzTextTestResult.addSuccessYs����
�n�d�#�#�.�.�t�4�4�4��<�	 ����t�T�*�*�*�*�*�
�Y�	 ��K���c�"�"�"��K��������	 �	 rc���tt|���||��|jr|�|d��dS|jr5|j�d��|j���dSdS)Nr=r?)	r#r!�addErrorr$r:r%rrr4�rr.rDr)s   �r
rJzTextTestResult.addErroras����
�n�d�#�#�,�,�T�3�7�7�7��<�	 ����t�W�-�-�-�-�-�
�Y�	 ��K���c�"�"�"��K��������	 �	 rc���tt|���||��|jr|�|d��dS|jr5|j�d��|j���dSdS)Nr<r>)	r#r!�
addFailurer$r:r%rrr4rKs   �r
rMzTextTestResult.addFailureis����
�n�d�#�#�.�.�t�S�9�9�9��<�	 ����t�V�,�,�,�,�,�
�Y�	 ��K���c�"�"�"��K��������	 �	 rc�6��tt|���||��|jr+|�|d�|����dS|jr5|j�d��|j�	��dSdS)Nz
skipped {0!r}�s)
r#r!�addSkipr$r:�formatr%rrr4)rr.�reasonr)s   �r
rPzTextTestResult.addSkipqs����
�n�d�#�#�+�+�D�&�9�9�9��<�	 ����t�_�%;�%;�F�%C�%C�D�D�D�D�D�
�Y�	 ��K���c�"�"�"��K��������	 �	 rc�J��tt|���||��|jr5|j�d��|j���dS|jr5|j�d��|j���dSdS)Nzexpected failure�x)	r#r!�addExpectedFailurer$rrr4r%rrKs   �r
rUz!TextTestResult.addExpectedFailureys����
�n�d�#�#�6�6�t�S�A�A�A��<�	 ��K��� 2�3�3�3��K��������
�Y�	 ��K���c�"�"�"��K��������	 �	 rc�H��tt|���|��|jr5|j�d��|j���dS|jr5|j�d��|j���dSdS)Nzunexpected success�u)	r#r!�addUnexpectedSuccessr$rrr4r%rr5s  �r
rXz#TextTestResult.addUnexpectedSuccess�s����
�n�d�#�#�8�8��>�>�>��<�	 ��K��� 4�5�5�5��K��������
�Y�	 ��K���c�"�"�"��K��������	 �	 rc��|js|jr2|j���|j���|�d|j��|�d|j��t|dd��}|ro|j�|j	��|D]2}|j�d|�
|�������3|j���dSdS)Nr=r<�unexpectedSuccessesrzUNEXPECTED SUCCESS: )r%r$rrr4�printErrorList�errors�failuresr�
separator1r0)rrZr.s   r
�printErrorszTextTestResult.printErrors�s���9�	 ���	 ��K���!�!�!��K���������G�T�[�1�1�1����F�D�M�2�2�2�%�d�,A�2�F�F���	 ��K�����0�0�0�+�
X�
X����#�#�$V�4�;N�;N�t�;T�;T�$V�$V�W�W�W�W��K��������		 �	 rc�b�|D]�\}}|j�|j��|j�|�d|�|������|j�|j��|j�d|z��|j�����dS)Nz: z%s)rrr^r0�
separator2r4)r�flavourr\r.rDs     r
r[zTextTestResult.printErrorList�s����	 �	 �I�D�#��K�����0�0�0��K���G�G�G�D�4G�4G��4M�4M�4M� N�O�O�O��K�����0�0�0��K����s�
�+�+�+��K�������	 �	 r)rrrr^rarr0r3r:rBrHrJrMrPrUrXr_r[�
__classcell__)r)s@r
r!r!sR���������J��J���������"�"�"�"�"����
C�
C�
C�
C�
C� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � rr!c�2�eZdZ	eZ		d	dd�d�Zd�Zd�ZdS)
�TextTestRunnerNTrF)�	tb_localsc��	|�tj}t|��|_||_||_||_||_||_||_	|�	||_
dSdSr
)�sys�stderrrrr&r(�failfast�bufferrf�warnings�resultclass)	rrr&r(rjrkrmrlrfs	         r
rzTextTestRunner.__init__�sk��	�
�>��Z�F�'��/�/���(���"��� ��
����"��� ��
��"�*�D����#�"rc�N�|�|j|j|j��Sr
)rmrr&r()rs r
�_makeResultzTextTestRunner._makeResult�s!�������T�->���O�O�Orc���	|���}t|��|j|_|j|_|j|_tj��5|jr>tj|j��|jdvrtjdtd���tj��}t|dd��}|�
|��	||��t|dd��}|�
|��n##t|dd��}|�|��wwxYwtj��}ddd��n#1swxYwY||z
}|j
��t|d��r|j�|j��|j}|j�d||d	krd
pd|fz��|j���dx}	x}
}	t't(|j|j|jf��}|\}	}
}n#t0$rYnwxYwg}
|j��sw|j�d
��t)|j��t)|j��}}|r|
�d|z��|r|
�d|z��n|j�d��|r|
�d|z��|	r|
�d|	z��|
r|
�d|
z��|
r2|j�dd�|
���d���n|j�d��|j���|S)N)�default�always�modulezPlease use assert\w+ instead.)�category�message�startTestRun�stopTestRunrazRan %d test%s in %.3fsrrO�r�FAILEDzfailures=%dz	errors=%d�OKz
skipped=%dzexpected failures=%dzunexpected successes=%dz (z, �)r) rorrjrkrfrl�catch_warnings�simplefilter�filterwarnings�DeprecationWarning�time�perf_counterrr_�hasattrrrra�testsRun�map�len�expectedFailuresrZ�skippedr�
wasSuccessfulrr]r\�appendr,r4)rr.r�	startTimervrw�stopTime�	timeTaken�run�
expectedFailsrZr��results�infos�failed�erroreds                r
r�zTextTestRunner.run�s��0��!�!�#�#���v�����-������
��>���
�
$�
&�
&�	+�	+��}�
F��%�d�m�4�4�4��=�$9�9�9��+�H�%7�$D�F�F�F�F��)�+�+�I�"�6�>�4�@�@�L��'������
"���V����%�f�m�T�B�B���*��K�M�M�M���&�f�m�T�B�B���*��K�M�M�M�M�+�����(�*�*�H�/	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+�0�y�(�	��������6�<�(�(�	3��K���� 1�2�2�2��o������4� �#��(�"2�s�"8�b�)�D�E�	F�	F�	F��������89�9�
�9�+�g�	B��#�� 7� &� :� &�� 0�1�1�G�;B�7�M�.�����	�	�	��D�	����
��#�v�#�%�%�	$��K���h�'�'�'�!�&�/�2�2�C��
�4F�4F�G�F��
5����]�V�3�4�4�4��
4����[�7�2�3�3�3���K���d�#�#�#��	1��L�L���/�0�0�0��	A��L�L�/�-�?�@�@�@��	J��L�L�2�5H�H�I�I�I��	$��K����4�9�9�U�+;�+;�+;�+;� =�>�>�>�>��K���d�#�#�#���������
s=�A6D>�C<�D>�< D�D>�>E�E�'H	�	
H�H)NTrFFNN)rrrr!rmrror�rrr
rere�sm�������
!�K�AB�JN�+�#�+�+�+�+�+�(P�P�P�G�G�G�G�Grre)rhr�rlrxr�caser�signalsr�
__unittest�objectr�
TestResultr!rerrr
�<module>r�s����
�
�
�
���������������������#�#�#�#�#�#�
�
�
�
�
�
�
��
�
�
� @ �@ �@ �@ �@ �V�&�@ �@ �@ �Ff�f�f�f�f�V�f�f�f�f�fr__pycache__/main.cpython-311.pyc000064400000032772152401764000012414 0ustar00�

�u�ʡ�����dZddlZddlZddlZddlZddlmZmZddlm	Z	dZ
dZdZd	�Z
d
�Zd�ZGd�d
e��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
c�V�tj�|���r|����d��r�tj�|��rstj�|tj����}tj�|��s|�tj	��r|S|}tj�
|��dd��dd���dd��S|S)Nz.py����\�.�/)�os�path�isfile�lower�endswith�isabs�relpath�getcwd�
startswith�pardir�normpath�replace)�name�rel_paths  �8/opt/alt/python-internal/lib/python3.11/unittest/main.py�
_convert_namers���

�w�~�~�d���P��
�
��� 5� 5�e� <� <�P�
�7�=�=����	��w���t�R�Y�[�[�9�9�H��w�}�}�X�&�&�
�(�*=�*=�b�i�*H�*H�
����D��w����%�%�c�r�c�*�2�2�4��=�=�E�E�c�3�O�O�O��K�c��d�|D��S)Nc�,�g|]}t|����S�)r)�.0rs  r�
<listcomp>z"_convert_names.<locals>.<listcomp>/s ��2�2�2�D�M�$���2�2�2rr)�namess r�_convert_namesr#.s��2�2�E�2�2�2�2rc��d|vrd|z}|S)N�*z*%s*r)�patterns r�_convert_select_patternr'2s���'�>�>��7�"���Nrc��eZdZdZdZdZdxZxZxZxZ	xZ
ZdZdddde
jddddddfdd�d�Zdd	�Zd
�Zd�Zdd�Zd
�Zd�Zd�Zd�Zdd�Zd�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�V�t|t��rOt|��|_|�d��dd�D]}
t|j|
��|_�n||_|�tj}||_||_	|	|_
||_|
|_||_
|�tjsd|_n||_||_||_||_t&j�|d��|_|�|��|���dS)Nr
r�defaultr)�
isinstance�str�
__import__�module�split�getattr�sys�argv�exit�failfast�
catchbreak�	verbosity�bufferr+�warnoptions�warnings�defaultTest�
testRunner�
testLoaderrr
�basename�progName�	parseArgs�runTests)�selfr1r=r5r>r?r6r9r7r8r:r<r+�parts              r�__init__zTestProgram.__init__Bs���f�c�"�"�	!�$�V�,�,�D�K����S�)�)�!�"�"�-�
9�
9��%�d�k�4�8�8����
9�!�D�K��<��8�D���	� ��
�$���"������"�����C�O��&�D�M�M�%�D�M�&���$���$�����(�(��a��1�1��
����t�����
�
�����rc���tjdt��|rt|��|j�|���|���tjd��dS)NzHTestProgram.usageExit() is deprecated and will be removed in Python 3.13�)	r<�warn�DeprecationWarning�print�_discovery_parser�_initArgParsers�_print_helpr4r6)rD�msgs  r�	usageExitzTestProgram.usageExithsr���
�0�1C�	E�	E�	E��	��#�J�J�J��!�)�� � �"�"�"��������������rc�Z�|j�_t|j�����ttd|jiz��|j���dSt|j�����ttd|jiz��dS)N�prog)	r1rK�_main_parser�format_help�
MAIN_EXAMPLESrArL�
print_help�MODULE_EXAMPLES)rD�args�kwargss   rrNzTestProgram._print_helprs����;���$�#�/�/�1�1�2�2�2��-�6�4�=�"9�9�:�:�:��"�-�-�/�/�/�/�/��$�#�/�/�1�1�2�2�2��/�V�T�]�$;�;�<�<�<�<�<rc���|���|j��t|��dkr=|d���dkr|�|dd���dS|j�|dd�|��|js|�g��dSn#|j�|dd�|��|jr,t|j��|_	tdkrd|_nP|j�d|_	nAt|jt��r|jf|_	nt|j��|_	|���dS)Nr�discoverrHr*)rMr1�lenr�
_do_discoveryrS�
parse_args�testsr#�	testNames�__name__r=r.r/�list�createTests)rDr5s  rrBzTestProgram.parseArgs{s^���������;���4�y�y�1�}�}��a������J�!>�!>��"�"�4����8�,�,�,�����(�(��a�b�b��4�8�8�8��:�
��"�"�2�&�&�&���	
�
��(�(��a�b�b��4�8�8�8��:�	4�+�D�J�7�7�D�N��:�%�%�"����
�
�
%�!�D�N�N�
��(�#�
.�
.�	4�"�.�0�D�N�N�!�$�"2�3�3�D�N��������rc�^�|jr|j|j_|r;|�|jn	|��}|j|j|j|j��|_dS|j�&|j�|j	��|_dS|j�
|j|j	��|_dS�N)�testNamePatternsr?r[�startr&�top�testr`�loadTestsFromModuler1�loadTestsFromNames)rD�from_discovery�Loaderrs    rrczTestProgram.createTests�s���� �	E�/3�/D�D�O�,��	H�(.��T�_�_�F�F�H�H�F�'����
�D�L�$�(�K�K�D�I�I�I�
�^�
#���;�;�D�K�H�H�D�I�I�I���:�:�4�>�;?�;�H�H�D�I�I�Irc��|���}|�|��|_|�|��|_dSre)�_getParentArgParser�_getMainArgParserrS�_getDiscoveryArgParserrL)rD�
parent_parsers  rrMzTestProgram._initArgParsers�sE���0�0�2�2�
� �2�2�=�A�A���!%�!<�!<�]�!K�!K����rc��tjd���}|�dddddd�	��|�d
ddddd
�	��|�dddd���|j�!|�ddddd���d|_|j�!|�ddddd���d|_|j�!|�ddddd���d|_|j�&|�dd d!td"�#��g|_|S)$NF)�add_helpz-vz	--verboser9�store_constrHzVerbose output)�dest�action�const�helpz-qz--quietrzQuiet outputz--localsr+�
store_truez"Show local variables in tracebacks)rvrwryz-fz
--failfastr7zStop on first fail or errorz-cz--catchr8z'Catch Ctrl-C and display results so farz-bz--bufferr:z%Buffer stdout and stderr during testsz-krf�appendz.Only run tests which match the given substring)rvrw�typery)�argparse�ArgumentParser�add_argumentr7r8r:rfr')rD�parsers  rrozTestProgram._getParentArgParser�s����(�%�8�8�8�����D�+�K�#0��!1�	�	3�	3�	3�	���D�)�+�#0��!/�	�	1�	1�	1�	���J�[�#/�!E�	�	G�	G�	G��=� �����l��'3�%B�
 �
D�
D�
D�"�D�M��?�"�����i�l�'3�%N�
 �
P�
P�
P�$�D�O��;������j�x�'3�%L�
 �
N�
N�
N� �D�K�� �(�����+=�'/�6M�%U�
 �
W�
W�
W�%'�D�!��
rc��tj|g���}|j|_|j|_|�ddd���|S)N��parentsr_r%z?a list of any number of test modules, classes and test methods.)�nargsry)r}r~rArRrNrVr)rD�parentr�s   rrpzTestProgram._getMainArgParser�sX���(�&��:�:�:���m��� �,������G�3�"8�	�	9�	9�	9��
rc�X�tj|g���}d|jz|_d|_|�dddd���|�d	d
dd���|�d
ddd���dD]/}|�|dtjtj����0|S)Nr�z%s discoverzcFor test discovery all test modules must be importable from the top level directory of the project.z-sz--start-directoryrgz*Directory to start discovery ('.' default))rvryz-pz	--patternr&z+Pattern to match tests ('test*.py' default)z-tz--top-level-directoryrhz<Top level directory of project (defaults to start directory))rgr&rh�?)r�r-ry)r}r~rArR�epilogr�SUPPRESS)rDr�r��args    rrqz"TestProgram._getDiscoveryArgParser�s����(�&��:�:�:��#�d�m�3���$��
�	���D�"5�G�!M�	�	O�	O�	O����D�+�I�!N�	�	P�	P�	P����D�"9��"4�	�	5�	5�	5�/�	8�	8�C�����3�(0�(9�%-�%6�
 �
8�
8�
8�
8��
rc���d|_d|_d|_|�6|j�|���|j�||��|�d|���dS)Nr
ztest*.pyT)rlrm)rgr&rhrLrMr^rc)rDr5rms   rr]zTestProgram._do_discovery�sp����
�!���������%�-��$�$�&�&�&��"�-�-�d�D�9�9�9�����V��<�<�<�<�<rc�z�|jrt��|j�tj|_t|jt��r�		|�|j|j|j	|j
|j���}n=#t$r0|�|j|j|j	|j
���}YnwxYwn+#t$r|���}YnwxYw|j}|�
|j��|_|jr.t#j|j�����dSdS)N)r9r7r:r<r+)r9r7r:r<)r8rr>r�TextTestRunnerr.r|r9r7r:r<r+�	TypeError�runri�resultr6r4�
wasSuccessful)rDr>s  rrCzTestProgram.runTests�sY���?�	������?�"�$�3�D�O��d�o�t�,�,�	)�
/�I�!%���4�>�:>�-�8<��:>�-�;?�>�	"1�"K�"K�J�J��
!�I�I�I�!%���4�>�:>�-�8<��:>�-�"1�"I�"I�J�J�J�I�������
/�
/�
/�!�_�_�.�.�
�
�
�
/����
��J� �n�n�T�Y�/�/����9�	6��H���2�2�4�4�4�5�5�5�5�5�	6�	6s0�
3A>�=B<�>7B8�5B<�7B8�8B<�<C�Cre)FN)ra�
__module__�__qualname__�__doc__r1r9r7r8r:rAr<rfrLr�defaultTestLoaderrFrPrNrBrcrMrorprqr]rCrrrr)r)8s>���������F��I�NR�R�H�R�z�R�F�R�X�R��;K���(�d��#��0H���T�d��$�$�>C�$�$�$�$�$�L����=�=�=����:
H�
H�
H�
H�L�L�L�
!�!�!�F	�	�	����*=�=�=�=�6�6�6�6�6rr))r�r4r}rr<�rr�signalsr�
__unittestrUrWrr#r'�objectr)�mainrrr�<module>r�s�����
�
�
�
�����	�	�	�	�������������#�#�#�#�#�#�
�
��
������ 3�3�3����\6�\6�\6�\6�\6�&�\6�\6�\6�|���r__pycache__/_log.cpython-311.pyc000064400000011335152401764000012400 0ustar00�

0���L�{���ddlZddlZddlmZejdddg��ZGd�dej��ZGd	�d
e��ZdS)�N�)�_BaseTestCaseContext�_LoggingWatcher�records�outputc�$�eZdZdZd�Zd�Zd�ZdS)�_CapturingHandlerzM
    A logging handler capturing all (raw and formatted) logging output.
    c�n�tj�|��tgg��|_dS�N)�logging�Handler�__init__r�watcher��selfs �8/opt/alt/python-internal/lib/python3.11/unittest/_log.pyrz_CapturingHandler.__init__s-���� � ��&�&�&�&�r�2�.�.�����c��dSr�rs r�flushz_CapturingHandler.flushs���rc��|jj�|��|�|��}|jj�|��dSr)rr�append�formatr)r�record�msgs   r�emitz_CapturingHandler.emitsK�����#�#�F�+�+�+��k�k�&�!�!�����"�"�3�'�'�'�'�'rN)�__name__�
__module__�__qualname__�__doc__rrrrrrr	r	
sK��������/�/�/�
�
�
�(�(�(�(�(rr	c�(�eZdZdZdZd�Zd�Zd�ZdS)�_AssertLogsContextz6A context manager for assertLogs() and assertNoLogs() z"%(levelname)s:%(name)s:%(message)sc���tj||��||_|r&tj�||��|_ntj|_d|_||_	dSr)
rr�logger_namer�_nameToLevel�get�level�INFOr�no_logs)r�	test_caser$r'r)s     rrz_AssertLogsContext.__init__!s\���%�d�I�6�6�6�&����	&� �-�1�1�%��?�?�D�J�J� ��D�J��������rc�,�t|jtj��r|jx}|_n tj|j��x}|_tj|j��}t��}|�	|j
��|�|��|j|_|j
dd�|_|j
|_|j|_|g|_
|�	|j
��d|_|jrdS|jS)NF)�
isinstancer$r�Logger�logger�	getLogger�	Formatter�LOGGING_FORMATr	�setLevelr'�setFormatterr�handlers�old_handlers�	old_level�	propagate�
old_propagater))rr.�	formatter�handlers    r�	__enter__z_AssertLogsContext.__enter__+s����d�&���7�7�	G�#'�#3�3�F�T�[�[�#*�#4�T�5E�#F�#F�F�F�T�[��%�d�&9�:�:�	�#�%�%�������$�$�$����Y�'�'�'�����"�O�A�A�A�.�������#�-���"�)�������
�#�#�#� ����<�	��F���rc��|j|j_|j|j_|j�|j��|�dS|jrSt|j	j
��dkr4|�d�|j	j
����dSdSt|j	j
��dkrL|�d�tj|j��|jj����dSdS)NFrzUnexpected logs found: {!r}z-no logs of level {} or higher triggered on {})r5r.r4r8r7r2r6r)�lenrr�
_raiseFailurerrr�getLevelNamer'�name)r�exc_type�	exc_value�tbs    r�__exit__z_AssertLogsContext.__exit__?s��#�0���� $� 2��������T�^�,�,�,����5��<�	Q��4�<�'�(�(�1�,�,��"�"�1�8�8���+��������-�,��4�<�'�(�(�A�-�-��"�"�C��V�G�0���<�<�d�k�>N�O�O�Q�Q�Q�Q�Q�.�-rN)rrrr r1rr;rDrrrr"r"sQ������@�@�9�N�������(Q�Q�Q�Q�Qrr")	r�collections�caser�
namedtuplerr
r	r"rrr�<module>rHs�����������&�&�&�&�&�&�)�+�(�):�*3�X�)>�@�@��(�(�(�(�(���(�(�(�$:Q�:Q�:Q�:Q�:Q�-�:Q�:Q�:Q�:Q�:Qr__pycache__/util.cpython-311.pyc000064400000020310152401764000012426 0ustar00�

���B�����dZddlmZmZddlmZdZdZdZdZ	dZ
dZee	ezezeze
zz
ZedksJ�d�Z
d	�Zdd�Zd�Zd
�Zd�Zd�Zedd��Zd�Zd�ZdS)zVarious utility functions.�)�
namedtuple�Counter)�commonprefixT�P��c��t|��|z
|z
}|tkr(d|d|�||t|��|z
d�fz}|S)Nz%s[%d chars]%s)�len�_PLACEHOLDER_LEN)�s�	prefixlen�	suffixlen�skips    �8/opt/alt/python-internal/lib/python3.11/unittest/util.py�_shortenrsW���q�6�6�I��	�)�D�������*�9�*�
�t�Q�s�1�v�v�	�7I�7J�7J�5K�L�L���H�c�V���ttt|����}ttt|����}|t
kr|St
|���t	����t
|�z
tztzz
}|tkrZttztz|�z
zt
ksJ�t�t|���t��fd�|D����St�tt���t��fd�|D����S)Nc3�2�K�|]}�|�d�zV��dS�N���.0r�prefixr
s  ��r�	<genexpr>z'_common_shorten_repr.<locals>.<genexpr>'s0�����:�:��V�a�	�
�
�m�+�:�:�:�:�:�:rc3�d�K�|]*}�t|�d�tt��zV��+dSr)r�
_MIN_DIFF_LEN�_MIN_END_LENrs  ��rrz'_common_shorten_repr.<locals>.<genexpr>*sP����� � ���(�1�Y�Z�Z�=�-��N�N�N� � � � � � r)�tuple�map�	safe_repr�maxr
�_MAX_LENGTHr�_MIN_BEGIN_LENr�_MIN_COMMON_LENr)�args�maxlen�
common_lenrr
s   @@r�_common_shorten_reprr(s8������Y��%�%�&�&�D�
��S�$���
 �
 �F�
������
�$�
�
�F��F���I���9�$�~�5�8H�H�J�J��O�#�#�� 0�0�?�B���"�$�&1�2�2�2�2��&�.�*�=�=���:�:�:�:�:�T�:�:�:�:�:�:�
�f�n�o�
>�
>�F�� � � � � �� � � � � � rFc���	t|��}n*#t$rt�|��}YnwxYw|rt	|��t
kr|S|dt
�dzS)Nz [truncated]...)�repr�	Exception�object�__repr__r
r")�obj�short�results   rr r -sv��&��c�������&�&�&�����%�%����&������C��K�K�+�-�-��
��,�;�,��"3�3�3s��$9�9c�$�|j�d|j��S)N�.)�
__module__�__qualname__)�clss r�strclassr66s���n�n�n�c�&6�&6�7�7rc��dx}}g}g}		||}||}||kr8|�|��|dz
}|||kr|dz
}|||k�n�||kr8|�|��|dz
}|||kr|dz
}|||k�nm|dz
}	|||kr|dz
}|||k�|dz
}|||kr|dz
}|||k�n'#|dz
}|||kr|dz
}|||k�wxYwnJ#t$r=|�||d���|�||d���YnwxYw��G||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.
    rT�N)�append�
IndexError�extend)�expected�actual�i�j�missing�
unexpected�e�as        r�sorted_list_differencerD9s���
�I�A���G��J��	����A��q�	�A��1�u�u����q�!�!�!��Q����q�k�Q�&�&���F�A��q�k�Q�&�&���Q����!�!�!�$�$�$��Q����Q�i�1�n�n���F�A��Q�i�1�n�n���Q����"�1�+��*�*��Q���#�1�+��*�*���F�A� ��)�q�.�.��Q���!��)�q�.�.�����F�A� ��)�q�.�.��Q���!��)�q�.�.�.�.�.�.����	�	�	��N�N�8�A�B�B�<�(�(�(����f�Q�R�R�j�)�)�)��E�	����/�6�J��s+�BD�C�:#D�$D�D�AE�Ec��g}|rR|���}	|�|��n%#t$r|�|��YnwxYw|�R||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�
ValueErrorr9)r<r=r@�items    r�unorderable_list_differencerJbs����G�
�!��|�|�~�~��	!��M�M�$�������	!�	!�	!��N�N�4� � � � � �	!����	�!��F�?�s�0�A�Ac��||k||kz
S)z.Return -1 if x < y, 0 if x == y and 1 if x > yr)�x�ys  r�
three_way_cmprNss��
��E�a�!�e��r�Mismatchzactual expected valuec��t|��t|��}}t|��t|��}}t��}g}t|��D]�\}}	|	|ur�
dx}
}t	||��D]}|||	kr
|
dz
}
|||<�t|��D]\}}
|
|	kr
|dz
}|||<�|
|kr&t|
||	��}|�|����t|��D][\}}	|	|ur�
d}t	||��D]}|||	kr
|dz
}|||<�td||	��}|�|���\|S)�HReturns list of (cnt_act, cnt_exp, elem) triples where the counts differrr8)�listr
r,�	enumerate�range�	_Mismatchr9)r=r<r�t�m�n�NULLr0r>�elem�cnt_s�cnt_tr?�
other_elem�diffs               r�_count_diff_all_purposer_ys�����<�<��h���q�A��q�6�6�3�q�6�6�q�A��8�8�D�
�F��Q�<�<� � ���4��4�<�<�������q�!���	�	�A���t�t�|�|���
����!���&�q�\�\�	�	�M�A�z��T�!�!���
����!����E�>�>��U�E�4�0�0�D��M�M�$������Q�<�<�	�	���4��4�<�<�����q�!���	�	�A���t�t�|�|���
����!�����E�4�(�(���
�
�d������Mrc��t|��t|��}}g}|���D]G\}}|�|d��}||kr&t|||��}|�|���H|���D]/\}}||vr&td||��}|�|���0|S)rQr)r�items�getrUr9)	r=r<rrVr0rZr[r\r^s	         r�_count_diff_hashablerc�s����6�?�?�G�H�-�-�q�A�
�F��w�w�y�y� � ���e����d�A�����E�>�>��U�E�4�0�0�D��M�M�$������w�w�y�y� � ���e��q�=�=��Q��t�,�,�D��M�M�$������MrN)F)�__doc__�collectionsrr�os.pathr�
__unittestr"rr#rr$rrr(r r6rDrJrNrUr_rcrrr�<module>rhs;�� � �+�+�+�+�+�+�+�+� � � � � � �
�
�������������!1�1�O�C� �!�#/�0�1�
�������
�
�
� � � �*4�4�4�4�8�8�8�&�&�&�R���"���
�J�z�#:�;�;�	�!�!�!�F����r__pycache__/async_case.cpython-311.opt-2.pyc000064400000014451152401764000014532 0ustar00�

��Hx�N�ddlZddlZddlZddlZddlmZGd�de��ZdS)�N�)�TestCasec���eZdZd�fd�	Zd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�fd�	Z�fd�Zd�Z�xZS)�IsolatedAsyncioTestCase�runTestc���t���|��d|_tj��|_dS�N)�super�__init__�_asyncioRunner�contextvars�copy_context�_asyncioTestContext)�self�
methodName�	__class__s  ��>/opt/alt/python-internal/lib/python3.11/unittest/async_case.pyrz IsolatedAsyncioTestCase.__init__#s:���
������$�$�$�"���#.�#;�#=�#=�� � � �c��
K�dSr	��rs r�
asyncSetUpz"IsolatedAsyncioTestCase.asyncSetUp(������rc��
K�dSr	rrs r�
asyncTearDownz%IsolatedAsyncioTestCase.asyncTearDown+rrc�(�|j|g|�Ri|��dSr	)�
addCleanup�r�func�args�kwargss    r�addAsyncCleanupz'IsolatedAsyncioTestCase.addAsyncCleanup.s)��	���$�����1�&�1�1�1�1�1rc��K�	t|��}	|j}|j}n/#t$r"t	d|j�d|j�d���d�wxYw||���d{V��}|�||ddd��|S)N�'�.zC' object does not support the asynchronous context manager protocol)�type�
__aenter__�	__aexit__�AttributeError�	TypeError�
__module__�__qualname__r")r�cm�cls�enter�exit�results      r�enterAsyncContextz)IsolatedAsyncioTestCase.enterAsyncContext=s�����	��2�h�h��	'��N�E��=�D�D���	'�	'�	'��U���U�U��1A�U�U�U���"&�
'�	'�����u�R�y�y�����������T�2�t�T�4�8�8�8��
s	�#�,Ac��|j���|j�|j��|�|j��dSr	)r�get_loopr�run�setUp�
_callAsyncrrs r�
_callSetUpz"IsolatedAsyncioTestCase._callSetUpQsL��	
��$�$�&�&�&�� �$�$�T�Z�0�0�0������(�(�(�(�(rc�t�|�|���"tjd|�d�td���dSdS)NzFIt is deprecated to return a value that is not None from a test case (�)�)�
stacklevel)�_callMaybeAsync�warnings�warn�DeprecationWarning)r�methods  r�_callTestMethodz'IsolatedAsyncioTestCase._callTestMethodYsd������'�'�3��M�2�(.�2�2�2�3E�RS�
U�
U�
U�
U�
U�
U�4�3rc�x�|�|j��|j�|j��dSr	)r7rrr5�tearDownrs r�
_callTearDownz%IsolatedAsyncioTestCase._callTearDown^s6������*�+�+�+�� �$�$�T�]�3�3�3�3�3rc�(�|j|g|�Ri|��dSr	)r=)r�functionr r!s    r�_callCleanupz$IsolatedAsyncioTestCase._callCleanupbs+�����X�7��7�7�7��7�7�7�7�7rc�P�|j�||i|��|j���S�N)�context)rr5rrs    rr7z"IsolatedAsyncioTestCase._callAsynces<���"�&�&��D�$�!�&�!�!��,�'�
�
�	
rc��tj|��r'|j�||i|��|j���S|jj|g|�Ri|��SrJ)�inspect�iscoroutinefunctionrr5rrs    rr=z'IsolatedAsyncioTestCase._callMaybeAsyncmsv���&�t�,�,�	G��&�*�*���d�%�f�%�%��0�+���
�
0�4�+�/��F�t�F�F�F�v�F�F�Frc�>�tjd���}||_dS)NT)�debug)�asyncio�Runnerr�r�runners  r�_setupAsyncioRunnerz+IsolatedAsyncioTestCase._setupAsyncioRunnerws"����d�+�+�+��$����rc�<�|j}|���dSr	)r�closerSs  r�_tearDownAsyncioRunnerz.IsolatedAsyncioTestCase._tearDownAsyncioRunner|s���$���������rNc����|���	t���|��|���S#|���wxYwr	)rUr
r5rX)rr1rs  �rr5zIsolatedAsyncioTestCase.run�sZ���� � �"�"�"�	*��7�7�;�;�v�&�&��'�'�)�)�)�)��D�'�'�)�)�)�)���s� A�A"c���|���t�����|���dSr	)rUr
rPrX)rrs �rrPzIsolatedAsyncioTestCase.debug�s>���� � �"�"�"�
���
�
�����#�#�%�%�%�%�%rc�@�|j�|���dSdSr	)rrXrs r�__del__zIsolatedAsyncioTestCase.__del__�s+����*��'�'�)�)�)�)�)�+�*r)rr	)�__name__r+r,rrrr"r2r8rBrErHr7r=rUrXr5rPr\�
__classcell__)rs@rrr	s=�������4>�>�>�>�>�>�

�
�
�
�
�
�
2�
2�
2����()�)�)�U�U�U�
4�4�4�8�8�8�
�
�
�G�G�G�%�%�%�
���*�*�*�*�*�*�&�&�&�&�&�
*�*�*�*�*�*�*rr)rQr
rMr>�caserrrrr�<module>r`s|������������������������E*�E*�E*�E*�E*�h�E*�E*�E*�E*�E*r__pycache__/__init__.cpython-311.opt-2.pyc000064400000004670152401764000014163 0ustar00�

N@�s�D����	gd�Ze�gd���dZddlmZddlmZmZmZm	Z	m
Z
mZmZm
Z
mZmZddlmZmZddlmZmZddlmZmZdd	lmZmZdd
lmZmZmZmZddlm Z m!Z!m"Z"eZ#d�Z$d
�Z%d�Z&dS))�
TestResult�TestCase�IsolatedAsyncioTestCase�	TestSuite�TextTestRunner�
TestLoader�FunctionTestCase�main�defaultTestLoader�SkipTest�skip�skipIf�
skipUnless�expectedFailure�TextTestResult�installHandler�registerResult�removeResult�
removeHandler�addModuleCleanup�doModuleCleanups�enterModuleContext)�getTestCaseNames�	makeSuite�
findTestCasesT�)r)
rrrrrr
rrrr)�
BaseTestSuiter)rr
)�TestProgramr	)rr)rrrr)rrrc�v�ddl}|j�t��}|�||���S)N�)�	start_dir�pattern)�os.path�path�dirname�__file__�discover)�loader�testsr!�os�this_dirs     �</opt/alt/python-internal/lib/python3.11/unittest/__init__.py�
load_testsr,Os4���N�N�N��w���x�(�(�H��?�?�X�w�?�?�?�?�c�J�t�����dhzS)Nr)�globals�keys�r-r+�__dir__r2Zs���9�9�>�>���8�9�9�9r-c�\�|dkr
ddlmatStdt�d|�����)Nrr)rzmodule z has no attribute )�
async_caser�AttributeError�__name__)�names r+�__getattr__r8]sE���(�(�(�7�7�7�7�7�7�&�&�
�I�8�I�I��I�I�
J�
J�Jr-N)'�__all__�extend�
__unittest�resultr�caserrrrrr
rrrr�suiterrr'rr
r	r�runnerrr�signalsrrrrrrr�_TextTestResultr,r2r8r1r-r+�<module>rBs���,�\I�I�I�����A�A�A�B�B�B�
�
�������'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�,�+�+�+�+�+�+�+�1�1�1�1�1�1�1�1�#�#�#�#�#�#�#�#�2�2�2�2�2�2�2�2�P�P�P�P�P�P�P�P�P�P�P�P�>�>�>�>�>�>�>�>�>�>�!��@�@�@�:�:�:�K�K�K�K�Kr-__pycache__/_log.cpython-311.opt-1.pyc000064400000011335152401764000013337 0ustar00�

0���L�{���ddlZddlZddlmZejdddg��ZGd�dej��ZGd	�d
e��ZdS)�N�)�_BaseTestCaseContext�_LoggingWatcher�records�outputc�$�eZdZdZd�Zd�Zd�ZdS)�_CapturingHandlerzM
    A logging handler capturing all (raw and formatted) logging output.
    c�n�tj�|��tgg��|_dS�N)�logging�Handler�__init__r�watcher��selfs �8/opt/alt/python-internal/lib/python3.11/unittest/_log.pyrz_CapturingHandler.__init__s-���� � ��&�&�&�&�r�2�.�.�����c��dSr�rs r�flushz_CapturingHandler.flushs���rc��|jj�|��|�|��}|jj�|��dSr)rr�append�formatr)r�record�msgs   r�emitz_CapturingHandler.emitsK�����#�#�F�+�+�+��k�k�&�!�!�����"�"�3�'�'�'�'�'rN)�__name__�
__module__�__qualname__�__doc__rrrrrrr	r	
sK��������/�/�/�
�
�
�(�(�(�(�(rr	c�(�eZdZdZdZd�Zd�Zd�ZdS)�_AssertLogsContextz6A context manager for assertLogs() and assertNoLogs() z"%(levelname)s:%(name)s:%(message)sc���tj||��||_|r&tj�||��|_ntj|_d|_||_	dSr)
rr�logger_namer�_nameToLevel�get�level�INFOr�no_logs)r�	test_caser$r'r)s     rrz_AssertLogsContext.__init__!s\���%�d�I�6�6�6�&����	&� �-�1�1�%��?�?�D�J�J� ��D�J��������rc�,�t|jtj��r|jx}|_n tj|j��x}|_tj|j��}t��}|�	|j
��|�|��|j|_|j
dd�|_|j
|_|j|_|g|_
|�	|j
��d|_|jrdS|jS)NF)�
isinstancer$r�Logger�logger�	getLogger�	Formatter�LOGGING_FORMATr	�setLevelr'�setFormatterr�handlers�old_handlers�	old_level�	propagate�
old_propagater))rr.�	formatter�handlers    r�	__enter__z_AssertLogsContext.__enter__+s����d�&���7�7�	G�#'�#3�3�F�T�[�[�#*�#4�T�5E�#F�#F�F�F�T�[��%�d�&9�:�:�	�#�%�%�������$�$�$����Y�'�'�'�����"�O�A�A�A�.�������#�-���"�)�������
�#�#�#� ����<�	��F���rc��|j|j_|j|j_|j�|j��|�dS|jrSt|j	j
��dkr4|�d�|j	j
����dSdSt|j	j
��dkrL|�d�tj|j��|jj����dSdS)NFrzUnexpected logs found: {!r}z-no logs of level {} or higher triggered on {})r5r.r4r8r7r2r6r)�lenrr�
_raiseFailurerrr�getLevelNamer'�name)r�exc_type�	exc_value�tbs    r�__exit__z_AssertLogsContext.__exit__?s��#�0���� $� 2��������T�^�,�,�,����5��<�	Q��4�<�'�(�(�1�,�,��"�"�1�8�8���+��������-�,��4�<�'�(�(�A�-�-��"�"�C��V�G�0���<�<�d�k�>N�O�O�Q�Q�Q�Q�Q�.�-rN)rrrr r1rr;rDrrrr"r"sQ������@�@�9�N�������(Q�Q�Q�Q�Qrr")	r�collections�caser�
namedtuplerr
r	r"rrr�<module>rHs�����������&�&�&�&�&�&�)�+�(�):�*3�X�)>�@�@��(�(�(�(�(���(�(�(�$:Q�:Q�:Q�:Q�:Q�-�:Q�:Q�:Q�:Q�:Qr__pycache__/loader.cpython-311.pyc000064400000065424152401764000012736 0ustar00�

��(�DNO���l�dZddlZddlZddlZddlZddlZddlZddlZddlmZm	Z	ddl
mZmZm
Z
dZejdej��ZGd�d	ej��Zd
�Zd�Zd�Zd
�Zd�ZGd�de��Ze��Zdd�Ze
jdfd�Zde
jejfd�Z de
jejfd�Z!dS)zLoading unittests.�N)�fnmatch�fnmatchcase�)�case�suite�utilTz[_a-z]\w*\.py$c�,��eZdZdZ�fd�Z�fd�Z�xZS)�_FailedTestNc�f��||_tt|���|��dS�N)�
_exception�superr
�__init__)�self�method_name�	exception�	__class__s   ��:/opt/alt/python-internal/lib/python3.11/unittest/loader.pyrz_FailedTest.__init__s.���#���
�k�4� � �)�)�+�6�6�6�6�6�c�z���|�jkr(tt����|��S�fd�}|S)Nc����j�r)r
�rs�r�testFailurez,_FailedTest.__getattr__.<locals>.testFailure!s����/�!r)�_testMethodNamerr
�__getattr__)r�namerrs`  �rrz_FailedTest.__getattr__sO�����4�'�'�'���d�+�+�7�7��=�=�=�	"�	"�	"�	"�	"��r)�__name__�
__module__�__qualname__rrr�
__classcell__�rs@rr
r
sV��������O�7�7�7�7�7���������rr
c�r�d|�dtj����}t|t|��||��S)NzFailed to import test module: �
)�	traceback�
format_exc�_make_failed_test�ImportError)r�
suiteClass�messages   r�_make_failed_import_testr*&s<������i�"�$�$�$�&�G��T�;�w�#7�#7��W�M�M�Mrc�R�dtj����}t||||��S)NzFailed to call load_tests:
)r$r%r&)rrr(r)s    r�_make_failed_load_testsr,+s3���2;�2F�2H�2H�2H�J�G���i��W�.�.�.rc�>�t||��}||f��|fSr)r
)�
methodnamerr(r)�tests     rr&r&0s(���z�9�-�-�D��:�t�g����'�'rc��tjt|����d���}||i}tdtjf|��}|||��f��S)Nc��dSr�rs r�testSkippedz'_make_skipped_test.<locals>.testSkipped5s���r�
ModuleSkipped)r�skip�str�type�TestCase)r.rr(r3�attrs�	TestClasss      r�_make_skipped_testr;4si��	�Y�s�9�~�~���
�
���
�
��%�E��_�t�}�&6��>�>�I��:�y�y��,�,�.�/�/�/rc��|����d��r
|dd�Stj�|��dS)Nz	$py.classi����r)�lower�endswith�os�path�splitext)r@s r�_jython_aware_splitextrB<sI���z�z�|�|���[�)�)���C�R�C�y��
�7���D�!�!�!�$�$rc���eZdZdZdZeej��ZdZ	e
jZdZ
�fd�Zd�Zdd�d�Zdd�Zdd	�Zd
�Zdd�Zd
�Zd�Zd�Zd�Zd�Zd�Z�xZS)�
TestLoaderz�
    This class is responsible for loading tests according to various criteria
    and returning them wrapped in a TestSuite
    r/Nc���tt|�����g|_t	��|_dSr)rrDr�errors�set�_loading_packages)rrs �rrzTestLoader.__init__Ms:���
�j�$���(�(�*�*�*����"%������rc�,�t|tj��rtd���|tjtjfvrg}n*|�|��}|st|d��rdg}|�	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?�runTest)�
issubclassr�	TestSuite�	TypeErrorrr8�FunctionTestCase�getTestCaseNames�hasattrr(�map)r�
testCaseClass�
testCaseNames�loaded_suites    r�loadTestsFromTestCasez TestLoader.loadTestsFromTestCaseTs����m�U�_�5�5�	)��(�)�)�
)��T�]�D�,A�B�B�B��M�M� �1�1�-�@�@�M� �
,�W�]�I�%F�%F�
,�!*��
����s�=�-�'H�'H�I�I���r��patternc���t|��dksd|vr0tjdt��|�dd��t|��dkr4t|��dz}td�|�����t|��dkr7t|��d}td�|�����g}t|��D]�}t||��}t|t��r\t|tj��rB|tjtjfvr(|�|�|������t|dd��}	|�|��}|	�_	|	|||��S#t&$rD}
t)|j|
|j��\}}|j�|��|cYd}
~
Sd}
~
wwxYw|S)	z>Return a suite of all test cases contained in the given moduler�use_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�poprM�format�sorted�dir�getattr�
isinstancer7rKrr8rN�appendrUr(�	Exceptionr,rrF)
r�modulerW�args�kws�	complaint�testsr�objrZ�e�
error_case�
error_messages
             r�loadTestsFromModulezTestLoader.loadTestsFromModulefs���t�9�9�q�=�=�,��3�3��M�D�,�
.�
.�
.��G�G�$�d�+�+�+��t�9�9�q�=�=��D�	�	�A�
�I��a�h�h�ir�s�s�t�t�t��s�8�8�q�=�=�
�s���A��I��[�b�b�cl�m�m�n�n�n�����K�K�	>�	>�D��&�$�'�'�C��3��%�%�
>��s�D�M�2�2�
>���
�t�/D�E�E�E����T�7�7��<�<�=�=�=���V�\�4�8�8�
�����&�&���!�
"�!�z�$��w�7�7�7���
"�
"�
"�,C��O�Q���-9�-9�)�
�M���"�"�=�1�1�1�!�!�!�!�!�!�!�����	
"����
�s�F$�$
G2�.9G-�'G2�-G2c
�v�|�d��}d\}}|��|dd�}|r�	d�|��}t|��}n^#t$rO|���}t||j��\}}|s|j�|��|cYSYnwxYw|��|dd�}|}	|D]�}
	|	t|	|
��}	}�#t$r�}t|	dd���%|�#|j�|��|cYd}~cSt|
||jdtj
������\}}|j�|��|cYd}~cSd}~wwxYwt|	tj��r|�|	��St|	t$��rIt'|	t(j��r/|	t(jt(jfvr|�|	��St|	tj��r�t|t$��rlt'|t(j��rR|d}||��}
tt|
|��tj��s|�|
g��Snt|	t2j��r|	St7|	��rl|	��}t|t2j��r|St|t(j��r|�|g��St9d|	�d	|�d
����t9d|	z���)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:
���zcalling z
 returned z, not a testz$don't know how to make test from: %s)�split�join�
__import__r'r_r*r(rFrerc�AttributeErrorr&r$r%rd�types�
ModuleTyperpr7rKrr8rNrU�FunctionTyperrL�callablerM)rrrg�partsrnro�
parts_copy�module_name�next_attributerl�part�parentrm�instr/s               r�loadTestsFromNamezTestLoader.loadTestsFromName�s����
�
�3����$.�!�
�M��>��q�q�q��J��

*�*�"%�(�(�:�"6�"6�K�'��4�4�F���"�*�*�*�%/�^�^�%5�%5�N�0H�&���19�19�-�J�
�%�*���*�*�=�9�9�9�)�)�)�)�*�*�*�����

*��!�"�"�I�E����	&�	&�D�
&�!�7�3��#5�#5�����!�
&�
&�
&��C��T�2�2�>�"�.��K�&�&�}�5�5�5�%�%�%�%�%�%�%�%�%�1B��a����%�0�2�2�2�5�16�16�-�J�
��K�&�&�}�5�5�5�%�%�%�%�%�%�%�%�%�����%
&����(�c�5�+�,�,�	��+�+�C�0�0�0��s�D�!�!�	��3��
�.�.�	��D�M�4�+@�A�A�A��-�-�c�2�2�2���e�0�1�1�		����&�&�		�����/�/�		���9�D��6�$�<�<�D��g�d�D�1�1�5�3E�F�F�
/�����v�.�.�.�
/�
��U�_�
-�
-�	��J��C�=�=�
	J��3�5�5�D��$���0�0�
-����D�$�-�0�0�
-�����v�.�.�.��i�!$���d�d�d�!,�-�-�-��B�S�H�I�I�Is=�$A�AB(�'B(�>C�
E'�.E"�	E'�A	E"�E'�"E'c�N�����fd�|D��}��|��S)z�Return a suite of all test cases found using the given sequence
        of string specifiers. See 'loadTestsFromName()'.
        c�<��g|]}��|�����Sr2)r�)�.0rrgrs  ��r�
<listcomp>z1TestLoader.loadTestsFromNames.<locals>.<listcomp>�s)���I�I�I�4�$�(�(��v�6�6�I�I�Ir)r()r�namesrg�suitess` ` r�loadTestsFromNameszTestLoader.loadTestsFromNames�s5����J�I�I�I�I�5�I�I�I�����v�&�&�&rc�������fd�}tt|t�������}�jr-|�tj�j�����|S)zLReturn a sorted sequence of method names found within testCaseClass
        c����|��j��sdSt�|��}t|��sdSd�j�j|fz��jdupt�fd��jD����S)NFz%s.%s.%sc3�8�K�|]}t�|��V��dSr)r)r�rW�fullNames  �r�	<genexpr>zKTestLoader.getTestCaseNames.<locals>.shouldIncludeMethod.<locals>.<genexpr>�s-�����X�X�w�K��'�2�2�X�X�X�X�X�Xr)�
startswith�testMethodPrefixrcr}rr�testNamePatterns�any)�attrname�testFuncr�rrRs  @��r�shouldIncludeMethodz8TestLoader.getTestCaseNames.<locals>.shouldIncludeMethod�s������&�&�t�'<�=�=�
��u��}�h�7�7�H��H�%�%�
��u�"��(�-�*D�h�&��H��(�D�0�Y��X�X�X�X�$�BW�X�X�X�X�X�
Yr)�key)�list�filterrb�sortTestMethodsUsing�sort�	functools�
cmp_to_key)rrRr��testFnNamess``  rrOzTestLoader.getTestCaseNames�s�����
	Y�
	Y�
	Y�
	Y�
	Y�
	Y��6�"5�s�=�7I�7I�J�J�K�K���$�	R�����!5�d�6O�!P�!P��Q�Q�Q��r�test*.pyc���d}|�|j�|j}n|�d}|}tj�|��}|tjvr tj�d|��||_d}tj�tj�|����retj�|��}||kr>tj�tj�|d����}�n	t|��tj
|}|�d��d}	tj�tj�|j
����}nD#t$r7|jtjvrt#d��d�t#d|����d�wxYw|r9|�|��|_tj�|��n#t($rd}YnwxYw|rt)d	|z���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__.pyrrz2Can not use builtin modules as dotted module namesz don't know how to discover from z%Start directory is not importable: %r)�_top_level_dirr?r@�abspath�sys�insert�isdir�isfilerwrx�modulesrv�dirname�__file__ryr�builtin_module_namesrM� _get_directory_containing_module�remover'r��_find_testsr()	r�	start_dirrW�
top_level_dir�set_implicit_top�is_not_importable�
the_module�top_partrks	         r�discoverzTestLoader.discover�se��8!��� �T�%8�%D� �/�M�M�
�
"�#��%�M�����
�6�6�
����(�(�

�H�O�O�A�}�-�-�-�+���!��
�7�=�=������3�3�4�4�	3�����	�2�2�I��M�)�)�(*����r�w�|�|�I�}�7]�7]�(^�(^�$^�!��
3��9�%�%�%�!�[��3�
�$�?�?�3�/�/��2��(� "���������)<�>�>�!@�!@�I�I��%�(�(�(�!�*�c�.F�F�F�'�)A�B�B�GK�L�(�M�z�M�M���#'�(�
(����$�3�*.�*O�*O�PX�*Y�*Y�D�'��H�O�O�M�2�2�2���)�
)�
)�
)�$(�!�!�!�
)����,�	S��E�	�Q�R�R�R��T�%�%�i��9�9�:�:�����u�%�%�%s �H�AF�AG�H �H c��tj|}tj�|j��}tj�|������d��r<tj�	tj�	|����Stj�	|��S)Nr�)
r�r�r?r@r�r��basenamer=r�r�)rr�rg�	full_paths    rr�z+TestLoader._get_directory_containing_moduleQs�����[�)���G�O�O�F�O�4�4�	�
�7���I�&�&�,�,�.�.�9�9�-�H�H�	.��7�?�?�2�7�?�?�9�#=�#=�>�>�>�
�7�?�?�9�-�-�-rc��||jkrdSttj�|����}tj�||j��}tj�|��r
Jd���|�d��r
Jd���|�tjj	d��}|S)NrrzPath must be within the projectz..)
r�rBr?r@�normpath�relpath�isabsr��replace�sep)rr@�_relpathrs    r�_get_name_from_pathzTestLoader._get_name_from_path]s����4�&�&�&��3�%�b�g�&6�&6�t�&<�&<�=�=���7�?�?�4��)<�=�=���7�=�=��*�*�M�M�,M�M�M�*��&�&�t�,�,�O�O�.O�O�O�,�������S�1�1���rc�D�t|��tj|Sr)rxr�r�)rrs  r�_get_module_from_namez TestLoader._get_module_from_nameis���4�����{�4� � rc�"�t||��Sr)r)rr@r�rWs    r�_match_pathzTestLoader._match_pathms���t�W�%�%�%rc#�rK�|�|��}|dkr,||jvr#|�||��\}}|�|V�|sdStt	j|����}|D]�}tj�||��}|�||��\}}|�|V�|r�|�|��}|j�|��	|�	||��Ed{V��|j�
|����#|j�
|��wxYw��dS)z/Used by discovery. Yields test suites it loads.rrN)r�rH�_find_test_pathrar?�listdirr@rw�addr��discard)	rr�rWrrk�should_recurse�pathsr@r�s	         rr�zTestLoader._find_testsqsv�����'�'�	�2�2���3�;�;�4�t�'=�=�=�%)�$8�$8��G�$L�$L�!�E�>�� �����!�
����r�z�)�,�,�-�-���	9�	9�D�����Y��5�5�I�$(�$8�$8��G�$L�$L�!�E�>�� ������
9��/�/�	�:�:���&�*�*�4�0�0�0�9�#�/�/�	�7�C�C�C�C�C�C�C�C�C��*�2�2�4�8�8�8�8��D�*�2�2�4�8�8�8�8����
9�	9�	9s� D�D3c���tj�|��}tj�|���rt�|��sdS|�|||��sdS|�|��}	|�|��}tj�	t|d|����}ttj�|����}ttj�|����}|�
��|�
��kr�tj�|��}	ttj�|����}
tj�|��}d}t||
|	|fz���|�||���dfS#t"j$r"}
t'||
|j��dfcYd}
~
Sd}
~
wt+||j��\}}|j�|��|dfcYSxYwtj�|���rztj�tj�|d����sdSd}d}|�|��}	|�|��}t|dd��}|j�|��	|�||���}|�|df|j�|��S|d	f|j�|��S#|j�|��wxYw#t"j$r"}
t'||
|j��dfcYd}
~
Sd}
~
wt+||j��\}}|j�|��|dfcYSxYwdS)
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?rVFNr�rZT)r?r@r�r��VALID_MODULE_NAME�matchr�r�r�r�rcrB�realpathr=r�r'rpr�SkipTestr;r(r*rFrer�rwrHr�r�)rr�rWr�rrg�mod_filer��fullpath_noext�
module_dir�mod_name�expected_dir�msgrmrnrorZrk�packages                   rr�zTestLoader._find_test_path�s����7�#�#�I�.�.��
�7�>�>�)�$�$�?	�$�*�*�8�4�4�
#�"�{��#�#�H�i��A�A�
#�"�{��+�+�I�6�6�D�
P��3�3�D�9�9���7�?�?��F�J�	�:�:�<�<��1��G�$�$�X�.�.�0�0��!7��G�$�$�Y�/�/�"1�"1���>�>�#�#�~�';�';�'=�'=�=�=�!#�����!:�!:�J�5���(�(��3�3� 5� 5�H�#%�7�?�?�9�#=�#=�L�D�C�%��x��\�B�B�D�D�D��/�/���/�H�H�%�O�O��/�=�
K�
K�
K�)�$��4�?�C�C�U�J�J�J�J�J�J�J�����
)�,�T�4�?�C�C�*�
�M���"�"�=�1�1�1�!�5�(�(�(�(����$�W�]�]�9�
%�
%�	��7�>�>�"�'�,�,�y�-�"H�"H�I�I�
#�"�{��J��E��+�+�I�6�6�D�
9��4�4�T�:�:��%�W�l�D�A�A�
��&�*�*�4�0�0�0�9� �4�4�W�g�4�N�N�E�!�-�$�e�|��*�2�2�4�8�8�8�8�!�$�;��*�2�2�4�8�8�8�8��D�*�2�2�4�8�8�8�8�����%�=�
K�
K�
K�)�$��4�?�C�C�U�J�J�J�J�J�J�J�����
)�,�T�4�?�C�C�*�
�M���"�"�=�1�1�1�!�5�(�(�(�(�����;sN�G*�*I�9H�I�;I�N�M%�M%�%N�O-�N0�*O-�0;O-r)r�N)rrr�__doc__r��staticmethodr�
three_way_cmpr�r�rrLr(r�rrUrpr�r�rOr�r�r�r�r�r�r�r r!s@rrDrDBsX�����������'�<��(:�;�;������J��N�'�'�'�'�'����$:>�*�*�*�*�*�XPJ�PJ�PJ�PJ�d'�'�'�'����&Q&�Q&�Q&�Q&�f
.�
.�
.�
�
�
�!�!�!�&�&�&�9�9�9�@H�H�H�H�H�H�HrrDc�^�t��}||_||_||_|r||_|Sr)rDr�r�r�r()�prefix�	sortUsingr(r��loaders     r�_makeLoaderr��s8��
�\�\�F�"+�F��$�F��.�F���'�&����Mrc��ddl}|jdtd���t|||����|��S)Nrz�unittest.getTestCaseNames() is deprecated and will be removed in Python 3.13. Please use unittest.TestLoader.getTestCaseNames() instead.���
stacklevel)r�)r\r]r^r�rO)rRr�r�r�r\s     rrOrO�sX���O�O�O��H�M�	E��q�����
�v�y�;K�L�L�L�]�]�^k�l�l�lrr/c��ddl}|jdtd���t|||���|��S)Nrz�unittest.makeSuite() is deprecated and will be removed in Python 3.13. Please use unittest.TestLoader.loadTestsFromTestCase() instead.r�r�)r\r]r^r�rU)rRr�r�r(r\s     r�	makeSuiter��sZ���O�O�O��H�M�	J��q�����
�v�y�*�5�5�K�K����rc��ddl}|jdtd���t|||���|��S)Nrz�unittest.findTestCases() is deprecated and will be removed in Python 3.13. Please use unittest.TestLoader.loadTestsFromModule() instead.r�r�)r\r]r^r�rp)rgr�r�r(r\s     r�
findTestCasesr��sZ���O�O�O��H�M�	H��q�����
�v�y�*�5�5�I�I����rrs)"r�r?�rer�r$rzr�r\rr�rrr�
__unittest�compile�
IGNORECASEr�r8r
r*r,r&r;rB�objectrD�defaultTestLoaderr�r�rOrLr�r�r2rr�<module>r�s�����	�	�	�	�	�	�	�	�
�
�
�
�����������������(�(�(�(�(�(�(�(�����������
�
�
�B�J�0�"�-�@�@�������$�-����N�N�N�
.�.�.�
(�(�(�0�0�0�%�%�%�W�W�W�W�W��W�W�W�t�J�L�L������7;�6H�[_�m�m�m�m�%+�d�6H���	�	�	�	�"(�4�3E�"�_�	�	�	�	�	�	r__pycache__/util.cpython-311.opt-2.pyc000064400000016567152401764000013411 0ustar00�

���B�����	ddlmZmZddlmZdZdZdZdZdZ	dZ
eeeze
zeze	zz
Zd�Zd�Z
dd
�Zd�Zd�Zd
�Zd�Zedd��Zd�Zd�ZdS)�)�
namedtuple�Counter)�commonprefixT�P��c��t|��|z
|z
}|tkr(d|d|�||t|��|z
d�fz}|S)Nz%s[%d chars]%s)�len�_PLACEHOLDER_LEN)�s�	prefixlen�	suffixlen�skips    �8/opt/alt/python-internal/lib/python3.11/unittest/util.py�_shortenrsW���q�6�6�I��	�)�D�������*�9�*�
�t�Q�s�1�v�v�	�7I�7J�7J�5K�L�L���H�c����ttt|����}ttt|����}|t
kr|St
|���t	����t
|�z
tztzz
}|tkr2t�t|���t��fd�|D����St�tt���t��fd�|D����S)Nc3�2�K�|]}�|�d�zV��dS�N���.0r�prefixr
s  ��r�	<genexpr>z'_common_shorten_repr.<locals>.<genexpr>'s0�����:�:��V�a�	�
�
�m�+�:�:�:�:�:�:rc3�d�K�|]*}�t|�d�tt��zV��+dSr)r�
_MIN_DIFF_LEN�_MIN_END_LENrs  ��rrz'_common_shorten_repr.<locals>.<genexpr>*sP����� � ���(�1�Y�Z�Z�=�-��N�N�N� � � � � � r)�tuple�map�	safe_repr�maxr
�_MAX_LENGTHr�_MIN_BEGIN_LENr�_MIN_COMMON_LENr)�args�maxlen�
common_lenrr
s   @@r�_common_shorten_reprr(s������Y��%�%�&�&�D�
��S�$���
 �
 �F�
������
�$�
�
�F��F���I���9�$�~�5�8H�H�J�J��O�#�#��&�.�*�=�=���:�:�:�:�:�T�:�:�:�:�:�:�
�f�n�o�
>�
>�F�� � � � � �� � � � � � rFc���	t|��}n*#t$rt�|��}YnwxYw|rt	|��t
kr|S|dt
�dzS)Nz [truncated]...)�repr�	Exception�object�__repr__r
r")�obj�short�results   rr r -sv��&��c�������&�&�&�����%�%����&������C��K�K�+�-�-��
��,�;�,��"3�3�3s��$9�9c�$�|j�d|j��S)N�.)�
__module__�__qualname__)�clss r�strclassr66s���n�n�n�c�&6�&6�7�7rc��	dx}}g}g}		||}||}||kr8|�|��|dz
}|||kr|dz
}|||k�n�||kr8|�|��|dz
}|||kr|dz
}|||k�nm|dz
}	|||kr|dz
}|||k�|dz
}|||kr|dz
}|||k�n'#|dz
}|||kr|dz
}|||k�wxYwnJ#t$r=|�||d���|�||d���YnwxYw��G||fS)NrT�)�append�
IndexError�extend)�expected�actual�i�j�missing�
unexpected�e�as        r�sorted_list_differencerD9s����
�I�A���G��J��	����A��q�	�A��1�u�u����q�!�!�!��Q����q�k�Q�&�&���F�A��q�k�Q�&�&���Q����!�!�!�$�$�$��Q����Q�i�1�n�n���F�A��Q�i�1�n�n���Q����"�1�+��*�*��Q���#�1�+��*�*���F�A� ��)�q�.�.��Q���!��)�q�.�.�����F�A� ��)�q�.�.��Q���!��)�q�.�.�.�.�.�.����	�	�	��N�N�8�A�B�B�<�(�(�(����f�Q�R�R�j�)�)�)��E�	����/�6�J��s+�BD�C�;#D�$D�D�AE
�E
c��	g}|rR|���}	|�|��n%#t$r|�|��YnwxYw|�R||fSr)�pop�remove�
ValueErrorr9)r<r=r@�items    r�unorderable_list_differencerJbs����
�G�
�!��|�|�~�~��	!��M�M�$�������	!�	!�	!��N�N�4� � � � � �	!����	�!��F�?�s�1�A�Ac��	||k||kz
Srr)�x�ys  r�
three_way_cmprNss��8�
��E�a�!�e��r�Mismatchzactual expected valuec��	t|��t|��}}t|��t|��}}t��}g}t|��D]�\}}	|	|ur�
dx}
}t	||��D]}|||	kr
|
dz
}
|||<�t|��D]\}}
|
|	kr
|dz
}|||<�|
|kr&t|
||	��}|�|����t|��D][\}}	|	|ur�
d}t	||��D]}|||	kr
|dz
}|||<�td||	��}|�|���\|S)Nrr8)�listr
r,�	enumerate�range�	_Mismatchr9)r=r<r�t�m�n�NULLr0r>�elem�cnt_s�cnt_tr?�
other_elem�diffs               r�_count_diff_all_purposer^ys���N���<�<��h���q�A��q�6�6�3�q�6�6�q�A��8�8�D�
�F��Q�<�<� � ���4��4�<�<�������q�!���	�	�A���t�t�|�|���
����!���&�q�\�\�	�	�M�A�z��T�!�!���
����!����E�>�>��U�E�4�0�0�D��M�M�$������Q�<�<�	�	���4��4�<�<�����q�!���	�	�A���t�t�|�|���
����!�����E�4�(�(���
�
�d������Mrc��	t|��t|��}}g}|���D]G\}}|�|d��}||kr&t|||��}|�|���H|���D]/\}}||vr&td||��}|�|���0|S)Nr)r�items�getrTr9)	r=r<rrUr0rYrZr[r]s	         r�_count_diff_hashablerb�s���N��6�?�?�G�H�-�-�q�A�
�F��w�w�y�y� � ���e����d�A�����E�>�>��U�E�4�0�0�D��M�M�$������w�w�y�y� � ���e��q�=�=��Q��t�,�,�D��M�M�$������MrN)F)�collectionsrr�os.pathr�
__unittestr"rr#rr$rrr(r r6rDrJrNrTr^rbrrr�<module>rfs%�� �+�+�+�+�+�+�+�+� � � � � � �
�
�������������!1�1�O�C� �!�#/�0�1�
�

�
�
� � � �*4�4�4�4�8�8�8�&�&�&�R���"���
�J�z�#:�;�;�	�!�!�!�F����r__pycache__/loader.cpython-311.opt-2.pyc000064400000057702152401764000013676 0ustar00�

��(�DNO���j�	ddlZddlZddlZddlZddlZddlZddlZddlmZmZddl	m
Z
mZmZdZ
ejdej��ZGd�de
j��Zd	�Zd
�Zd�Zd�Zd
�ZGd�de��Ze��Zdd�Zejdfd�Zdejejfd�Zdejejfd�Z dS)�N)�fnmatch�fnmatchcase�)�case�suite�utilTz[_a-z]\w*\.py$c�,��eZdZdZ�fd�Z�fd�Z�xZS)�_FailedTestNc�f��||_tt|���|��dS�N)�
_exception�superr
�__init__)�self�method_name�	exception�	__class__s   ��:/opt/alt/python-internal/lib/python3.11/unittest/loader.pyrz_FailedTest.__init__s.���#���
�k�4� � �)�)�+�6�6�6�6�6�c�z���|�jkr(tt����|��S�fd�}|S)Nc����j�r)r
�rs�r�testFailurez,_FailedTest.__getattr__.<locals>.testFailure!s����/�!r)�_testMethodNamerr
�__getattr__)r�namerrs`  �rrz_FailedTest.__getattr__sO�����4�'�'�'���d�+�+�7�7��=�=�=�	"�	"�	"�	"�	"��r)�__name__�
__module__�__qualname__rrr�
__classcell__�rs@rr
r
sV��������O�7�7�7�7�7���������rr
c�r�d|�dtj����}t|t|��||��S)NzFailed to import test module: �
)�	traceback�
format_exc�_make_failed_test�ImportError)r�
suiteClass�messages   r�_make_failed_import_testr*&s<������i�"�$�$�$�&�G��T�;�w�#7�#7��W�M�M�Mrc�R�dtj����}t||||��S)NzFailed to call load_tests:
)r$r%r&)rrr(r)s    r�_make_failed_load_testsr,+s3���2;�2F�2H�2H�2H�J�G���i��W�.�.�.rc�>�t||��}||f��|fSr)r
)�
methodnamerr(r)�tests     rr&r&0s(���z�9�-�-�D��:�t�g����'�'rc��tjt|����d���}||i}tdtjf|��}|||��f��S)Nc��dSr�rs r�testSkippedz'_make_skipped_test.<locals>.testSkipped5s���r�
ModuleSkipped)r�skip�str�type�TestCase)r.rr(r3�attrs�	TestClasss      r�_make_skipped_testr;4si��	�Y�s�9�~�~���
�
���
�
��%�E��_�t�}�&6��>�>�I��:�y�y��,�,�.�/�/�/rc��|����d��r
|dd�Stj�|��dS)Nz	$py.classi����r)�lower�endswith�os�path�splitext)r@s r�_jython_aware_splitextrB<sI���z�z�|�|���[�)�)���C�R�C�y��
�7���D�!�!�!�$�$rc���eZdZ	dZeej��ZdZe	j
ZdZ�fd�Z
d�Zdd�d�Zdd�Zdd�Zd	�Zdd�Zd�Zd
�Zd�Zd�Zd�Zd�Z�xZS)�
TestLoaderr/Nc���tt|�����g|_t	��|_dSr)rrDr�errors�set�_loading_packages)rrs �rrzTestLoader.__init__Ms:���
�j�$���(�(�*�*�*����"%������rc�.�	t|tj��rtd���|tjtjfvrg}n*|�|��}|st|d��rdg}|�	t||����}|S)NzYTest cases should not be derived from TestSuite. Maybe you meant to derive from TestCase?�runTest)�
issubclassr�	TestSuite�	TypeErrorrr8�FunctionTestCase�getTestCaseNames�hasattrr(�map)r�
testCaseClass�
testCaseNames�loaded_suites    r�loadTestsFromTestCasez TestLoader.loadTestsFromTestCaseTs���I��m�U�_�5�5�	)��(�)�)�
)��T�]�D�,A�B�B�B��M�M� �1�1�-�@�@�M� �
,�W�]�I�%F�%F�
,�!*��
����s�=�-�'H�'H�I�I���r��patternc���	t|��dksd|vr0tjdt��|�dd��t|��dkr4t|��dz}td�|�����t|��dkr7t|��d}td�|�����g}t|��D]�}t||��}t|t��r\t|tj��rB|tjtjfvr(|�|�|������t|dd��}	|�|��}|	�_	|	|||��S#t&$rD}
t)|j|
|j��\}}|j�|��|cYd}
~
Sd}
~
wwxYw|S)Nr�use_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�poprM�format�sorted�dir�getattr�
isinstancer7rKrr8rN�appendrUr(�	Exceptionr,rrF)
r�modulerW�args�kws�	complaint�testsr�objrZ�e�
error_case�
error_messages
             r�loadTestsFromModulezTestLoader.loadTestsFromModulefs��L�
�t�9�9�q�=�=�,��3�3��M�D�,�
.�
.�
.��G�G�$�d�+�+�+��t�9�9�q�=�=��D�	�	�A�
�I��a�h�h�ir�s�s�t�t�t��s�8�8�q�=�=�
�s���A��I��[�b�b�cl�m�m�n�n�n�����K�K�	>�	>�D��&�$�'�'�C��3��%�%�
>��s�D�M�2�2�
>���
�t�/D�E�E�E����T�7�7��<�<�=�=�=���V�\�4�8�8�
�����&�&���!�
"�!�z�$��w�7�7�7���
"�
"�
"�,C��O�Q���-9�-9�)�
�M���"�"�=�1�1�1�!�!�!�!�!�!�!�����	
"����
�s�F%�%
G3�/9G.�(G3�.G3c
�x�	|�d��}d\}}|��|dd�}|r�	d�|��}t|��}n^#t$rO|���}t||j��\}}|s|j�|��|cYSYnwxYw|��|dd�}|}	|D]�}
	|	t|	|
��}	}�#t$r�}t|	dd���%|�#|j�|��|cYd}~cSt|
||jdtj
������\}}|j�|��|cYd}~cSd}~wwxYwt|	tj��r|�|	��St|	t$��rIt'|	t(j��r/|	t(jt(jfvr|�|	��St|	tj��r�t|t$��rlt'|t(j��rR|d}||��}
tt|
|��tj��s|�|
g��Snt|	t2j��r|	St7|	��rl|	��}t|t2j��r|St|t(j��r|�|g��St9d|	�d|�d	����t9d
|	z���)N�.�NNr�__path__zFailed to access attribute:
���zcalling z
 returned z, not a testz$don't know how to make test from: %s)�split�join�
__import__r'r_r*r(rFrerc�AttributeErrorr&r$r%rd�types�
ModuleTyperpr7rKrr8rNrU�FunctionTyperrL�callablerM)rrrg�partsrnro�
parts_copy�module_name�next_attributerl�part�parentrm�instr/s               r�loadTestsFromNamezTestLoader.loadTestsFromName�s���	��
�
�3����$.�!�
�M��>��q�q�q��J��

*�*�"%�(�(�:�"6�"6�K�'��4�4�F���"�*�*�*�%/�^�^�%5�%5�N�0H�&���19�19�-�J�
�%�*���*�*�=�9�9�9�)�)�)�)�*�*�*�����

*��!�"�"�I�E����	&�	&�D�
&�!�7�3��#5�#5�����!�
&�
&�
&��C��T�2�2�>�"�.��K�&�&�}�5�5�5�%�%�%�%�%�%�%�%�%�1B��a����%�0�2�2�2�5�16�16�-�J�
��K�&�&�}�5�5�5�%�%�%�%�%�%�%�%�%�����%
&����(�c�5�+�,�,�	��+�+�C�0�0�0��s�D�!�!�	��3��
�.�.�	��D�M�4�+@�A�A�A��-�-�c�2�2�2���e�0�1�1�		����&�&�		�����/�/�		���9�D��6�$�<�<�D��g�d�D�1�1�5�3E�F�F�
/�����v�.�.�.�
/�
��U�_�
-�
-�	��J��C�=�=�
	J��3�5�5�D��$���0�0�
-����D�$�-�0�0�
-�����v�.�.�.��i�!$���d�d�d�!,�-�-�-��B�S�H�I�I�Is=�$A�AB)�(B)�?C�
E(�.E#�
E(�A	E#�E(�#E(c�P���	��fd�|D��}��|��S)Nc�<��g|]}��|�����Sr2)r�)�.0rrgrs  ��r�
<listcomp>z1TestLoader.loadTestsFromNames.<locals>.<listcomp>�s)���I�I�I�4�$�(�(��v�6�6�I�I�Ir)r()r�namesrg�suitess` ` r�loadTestsFromNameszTestLoader.loadTestsFromNames�s:����	�J�I�I�I�I�5�I�I�I�����v�&�&�&rc�����	��fd�}tt|t�������}�jr-|�tj�j�����|S)Nc����|��j��sdSt�|��}t|��sdSd�j�j|fz��jdupt�fd��jD����S)NFz%s.%s.%sc3�8�K�|]}t�|��V��dSr)r)r�rW�fullNames  �r�	<genexpr>zKTestLoader.getTestCaseNames.<locals>.shouldIncludeMethod.<locals>.<genexpr>�s-�����X�X�w�K��'�2�2�X�X�X�X�X�Xr)�
startswith�testMethodPrefixrcr}rr�testNamePatterns�any)�attrname�testFuncr�rrRs  @��r�shouldIncludeMethodz8TestLoader.getTestCaseNames.<locals>.shouldIncludeMethod�s������&�&�t�'<�=�=�
��u��}�h�7�7�H��H�%�%�
��u�"��(�-�*D�h�&��H��(�D�0�Y��X�X�X�X�$�BW�X�X�X�X�X�
Yr)�key)�list�filterrb�sortTestMethodsUsing�sort�	functools�
cmp_to_key)rrRr��testFnNamess``  rrOzTestLoader.getTestCaseNames�s�����	�
	Y�
	Y�
	Y�
	Y�
	Y�
	Y��6�"5�s�=�7I�7I�J�J�K�K���$�	R�����!5�d�6O�!P�!P��Q�Q�Q��r�test*.pyc���	d}|�|j�|j}n|�d}|}tj�|��}|tjvr tj�d|��||_d}tj�tj�|����retj�|��}||kr>tj�tj�|d����}�n	t|��tj
|}|�d��d}	tj�tj�|j
����}nD#t$r7|jtjvrt#d��d�t#d|����d�wxYw|r9|�|��|_tj�|��n#t($rd}YnwxYw|rt)d|z���t+|�||����}|�|��S)	NFTr�__init__.pyrrz2Can not use builtin modules as dotted module namesz don't know how to discover from z%Start directory is not importable: %r)�_top_level_dirr?r@�abspath�sys�insert�isdir�isfilerwrx�modulesrv�dirname�__file__ryr�builtin_module_namesrM� _get_directory_containing_module�remover'r��_find_testsr()	r�	start_dirrW�
top_level_dir�set_implicit_top�is_not_importable�
the_module�top_partrks	         r�discoverzTestLoader.discover�sj��	�6!��� �T�%8�%D� �/�M�M�
�
"�#��%�M�����
�6�6�
����(�(�

�H�O�O�A�}�-�-�-�+���!��
�7�=�=������3�3�4�4�	3�����	�2�2�I��M�)�)�(*����r�w�|�|�I�}�7]�7]�(^�(^�$^�!��
3��9�%�%�%�!�[��3�
�$�?�?�3�/�/��2��(� "���������)<�>�>�!@�!@�I�I��%�(�(�(�!�*�c�.F�F�F�'�)A�B�B�GK�L�(�M�z�M�M���#'�(�
(����$�3�*.�*O�*O�PX�*Y�*Y�D�'��H�O�O�M�2�2�2���)�
)�
)�
)�$(�!�!�!�
)����,�	S��E�	�Q�R�R�R��T�%�%�i��9�9�:�:�����u�%�%�%s �H�AF�AG�H!� H!c��tj|}tj�|j��}tj�|������d��r<tj�	tj�	|����Stj�	|��S)Nr�)
r�r�r?r@r�r��basenamer=r�r�)rr�rg�	full_paths    rr�z+TestLoader._get_directory_containing_moduleQs�����[�)���G�O�O�F�O�4�4�	�
�7���I�&�&�,�,�.�.�9�9�-�H�H�	.��7�?�?�2�7�?�?�9�#=�#=�>�>�>�
�7�?�?�9�-�-�-rc��||jkrdSttj�|����}tj�||j��}|�tjjd��}|S�Nrr)r�rBr?r@�normpath�relpath�replace�sep)rr@�_relpathrs    r�_get_name_from_pathzTestLoader._get_name_from_path]sj���4�&�&�&��3�%�b�g�&6�&6�t�&<�&<�=�=���7�?�?�4��)<�=�=��������S�1�1���rc�D�t|��tj|Sr)rxr�r�)rrs  r�_get_module_from_namez TestLoader._get_module_from_nameis���4�����{�4� � rc�"�t||��Sr)r)rr@r�rWs    r�_match_pathzTestLoader._match_pathms���t�W�%�%�%rc#�tK�	|�|��}|dkr,||jvr#|�||��\}}|�|V�|sdStt	j|����}|D]�}tj�||��}|�||��\}}|�|V�|r�|�|��}|j�|��	|�	||��Ed{V��|j�
|����#|j�
|��wxYw��dSr�)r�rH�_find_test_pathrar?�listdirr@rw�addr��discard)	rr�rWrrk�should_recurse�pathsr@r�s	         rr�zTestLoader._find_testsqsw����=��'�'�	�2�2���3�;�;�4�t�'=�=�=�%)�$8�$8��G�$L�$L�!�E�>�� �����!�
����r�z�)�,�,�-�-���	9�	9�D�����Y��5�5�I�$(�$8�$8��G�$L�$L�!�E�>�� ������
9��/�/�	�:�:���&�*�*�4�0�0�0�9�#�/�/�	�7�C�C�C�C�C�C�C�C�C��*�2�2�4�8�8�8�8��D�*�2�2�4�8�8�8�8����
9�	9�	9s�!D�D4c���	tj�|��}tj�|���rt�|��sdS|�|||��sdS|�|��}	|�|��}tj�	t|d|����}ttj�|����}ttj�|����}|�
��|�
��kr�tj�|��}	ttj�|����}
tj�|��}d}t||
|	|fz���|�||���dfS#t"j$r"}
t'||
|j��dfcYd}
~
Sd}
~
wt+||j��\}}|j�|��|dfcYSxYwtj�|���rztj�tj�|d����sdSd}d}|�|��}	|�|��}t|dd��}|j�|��	|�||���}|�|df|j�|��S|df|j�|��S#|j�|��wxYw#t"j$r"}
t'||
|j��dfcYd}
~
Sd}
~
wt+||j��\}}|j�|��|dfcYSxYwdS)	N)NFr�zW%r module incorrectly imported from %r. Expected %r. Is this module globally installed?rVFr�rZT)r?r@r�r��VALID_MODULE_NAME�matchr�r�r�r�rcrB�realpathr=r�r'rpr�SkipTestr;r(r*rFrer�rwrHr�r�)rr�rWr�rrg�mod_filer��fullpath_noext�
module_dir�mod_name�expected_dir�msgrmrnrorZrk�packages                   rr�zTestLoader._find_test_path�s��	��7�#�#�I�.�.��
�7�>�>�)�$�$�?	�$�*�*�8�4�4�
#�"�{��#�#�H�i��A�A�
#�"�{��+�+�I�6�6�D�
P��3�3�D�9�9���7�?�?��F�J�	�:�:�<�<��1��G�$�$�X�.�.�0�0��!7��G�$�$�Y�/�/�"1�"1���>�>�#�#�~�';�';�'=�'=�=�=�!#�����!:�!:�J�5���(�(��3�3� 5� 5�H�#%�7�?�?�9�#=�#=�L�D�C�%��x��\�B�B�D�D�D��/�/���/�H�H�%�O�O��/�=�
K�
K�
K�)�$��4�?�C�C�U�J�J�J�J�J�J�J�����
)�,�T�4�?�C�C�*�
�M���"�"�=�1�1�1�!�5�(�(�(�(����$�W�]�]�9�
%�
%�	��7�>�>�"�'�,�,�y�-�"H�"H�I�I�
#�"�{��J��E��+�+�I�6�6�D�
9��4�4�T�:�:��%�W�l�D�A�A�
��&�*�*�4�0�0�0�9� �4�4�W�g�4�N�N�E�!�-�$�e�|��*�2�2�4�8�8�8�8�!�$�;��*�2�2�4�8�8�8�8��D�*�2�2�4�8�8�8�8�����%�=�
K�
K�
K�)�$��4�?�C�C�U�J�J�J�J�J�J�J�����
)�,�T�4�?�C�C�*�
�M���"�"�=�1�1�1�!�5�(�(�(�(�����;sN�G+�+I�:H�I�;I�N�M&�M&�&N�O.�N1�+O.�1;O.r)r�N)rrrr��staticmethodr�
three_way_cmpr�r�rrLr(r�rrUrpr�r�rOr�r�r�r�r�r�r�r r!s@rrDrDBsS����������'�<��(:�;�;������J��N�'�'�'�'�'����$:>�*�*�*�*�*�XPJ�PJ�PJ�PJ�d'�'�'�'����&Q&�Q&�Q&�Q&�f
.�
.�
.�
�
�
�!�!�!�&�&�&�9�9�9�@H�H�H�H�H�H�HrrDc�^�t��}||_||_||_|r||_|Sr)rDr�r�r�r()�prefix�	sortUsingr(r��loaders     r�_makeLoaderr��s8��
�\�\�F�"+�F��$�F��.�F���'�&����Mrc��ddl}|jdtd���t|||����|��S)Nrz�unittest.getTestCaseNames() is deprecated and will be removed in Python 3.13. Please use unittest.TestLoader.getTestCaseNames() instead.���
stacklevel)r�)r\r]r^r�rO)rRr�r�r�r\s     rrOrO�sX���O�O�O��H�M�	E��q�����
�v�y�;K�L�L�L�]�]�^k�l�l�lrr/c��ddl}|jdtd���t|||���|��S)Nrz�unittest.makeSuite() is deprecated and will be removed in Python 3.13. Please use unittest.TestLoader.loadTestsFromTestCase() instead.r�r�)r\r]r^r�rU)rRr�r�r(r\s     r�	makeSuiter��sZ���O�O�O��H�M�	J��q�����
�v�y�*�5�5�K�K����rc��ddl}|jdtd���t|||���|��S)Nrz�unittest.findTestCases() is deprecated and will be removed in Python 3.13. Please use unittest.TestLoader.loadTestsFromModule() instead.r�r�)r\r]r^r�rp)rgr�r�r(r\s     r�
findTestCasesr��sZ���O�O�O��H�M�	H��q�����
�v�y�*�5�5�I�I����rrs)!r?�rer�r$rzr�r\rr�rrr�
__unittest�compile�
IGNORECASEr�r8r
r*r,r&r;rB�objectrD�defaultTestLoaderr�r�rOrLr�r�r2rr�<module>r�s����	�	�	�	�	�	�	�	�
�
�
�
�����������������(�(�(�(�(�(�(�(�����������
�
�
�B�J�0�"�-�@�@�������$�-����N�N�N�
.�.�.�
(�(�(�0�0�0�%�%�%�W�W�W�W�W��W�W�W�t�J�L�L������7;�6H�[_�m�m�m�m�%+�d�6H���	�	�	�	�"(�4�3E�"�_�	�	�	�	�	�	r__pycache__/__main__.cpython-311.pyc000064400000001244152401764000013176 0ustar00�

���xc������dZddlZejd�d��r1ddlZej�ej��Zedzejd<[dZ	ddl
m
Z
e
d���dS)	zMain entry point�Nz__main__.pyz -m unittestT�)�main)�module)�__doc__�sys�argv�endswith�os.path�os�path�basename�
executable�
__unittestr���</opt/alt/python-internal/lib/python3.11/unittest/__main__.py�<module>rs�����
�
�
�
��8�A�;���
�&�&���N�N�N�
��!�!�#�.�1�1�J��~�-�C�H�Q�K�
�
�
���������D������r__pycache__/suite.cpython-311.opt-2.pyc000064400000040772152401764000013560 0ustar00�

!�#�%,
���	ddlZddlmZddlmZdZd�ZGd�de��ZGd	�d
e��ZGd�de��Z	d
�Z
Gd�de��ZdS)�N�)�case)�utilTc�>�t||d���}|��dS)Nc��dS�N�r	��9/opt/alt/python-internal/lib/python3.11/unittest/suite.py�<lambda>z!_call_if_exists.<locals>.<lambda>s���r
)�getattr)�parent�attr�funcs   r�_call_if_existsrs$���6�4���.�.�D��D�F�F�F�F�Fr
c�X�eZdZ	dZdd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�ZdS)�
BaseTestSuiteTr	c�L�g|_d|_|�|��dS�Nr)�_tests�_removed_tests�addTests)�self�testss  r�__init__zBaseTestSuite.__init__s)���������
�
�e�����r
c�\�dtj|j���dt|���d�S)N�<z tests=�>)r�strclass�	__class__�list�rs r�__repr__zBaseTestSuite.__repr__s+���"&�-���"?�"?�"?�"?��d�����L�Lr
c�z�t||j��stSt|��t|��kSr)�
isinstancer �NotImplementedr!)r�others  r�__eq__zBaseTestSuite.__eq__s3���%���0�0�	"�!�!��D�z�z�T�%�[�[�(�(r
c�*�t|j��Sr)�iterrr"s r�__iter__zBaseTestSuite.__iter__"s���D�K� � � r
c�P�|j}|D]}|r||���z
}�|Sr)r�countTestCases)r�cases�tests   rr-zBaseTestSuite.countTestCases%s=���#���	/�	/�D��
/���,�,�.�.�.����r
c�@�t|��s/td�t|�������t	|t
��r0t
|tjtf��rtd���|j
�|��dS)Nz{} is not callablezNTestCases and TestSuites must be instantiated before passing them to addTest())�callable�	TypeError�format�reprr%�type�
issubclassr�TestCase�	TestSuiter�append�rr/s  r�addTestzBaseTestSuite.addTest,s�����~�~�	E��0�7�7��T�
�
�C�C�D�D�D��d�D�!�!�	@�j��26�-��1K�'M�'M�	@��?�@�@�
@�����4� � � � � r
c��t|t��rtd���|D]}|�|���dS)Nz0tests must be an iterable of tests, not a string)r%�strr2r;)rrr/s   rrzBaseTestSuite.addTests6sR���e�S�!�!�	P��N�O�O�O��	�	�D��L�L������	�	r
c��t|��D]5\}}|jrn(||��|jr|�|���6|Sr)�	enumerate�
shouldStop�_cleanup�_removeTestAtIndex)r�result�indexr/s    r�runzBaseTestSuite.run<s\��$�T�?�?�	/�	/�K�E�4�� �
����D��L�L�L��}�
/��'�'��.�.�.���
r
c��		|j|}t|d��r"|xj|���z
c_d|j|<dS#t$rYdSwxYw)Nr-)r�hasattrrr-r2)rrDr/s   rrBz BaseTestSuite._removeTestAtIndexEs���@�
	&��;�u�%�D��t�-�.�.�
=��#�#�t�':�':�'<�'<�<�#�#�!%�D�K�������	�	�	��D�D�	���s�
A�
A�Ac��|j|i|��Sr�rE)r�args�kwdss   r�__call__zBaseTestSuite.__call__Ss���t�x��&��&�&�&r
c�:�	|D]}|����dSr)�debugr:s  rrNzBaseTestSuite.debugVs-��E��	�	�D��J�J�L�L�L�L�	�	r
N)r	)�__name__�
__module__�__qualname__rArr#r(r+r-r;rrErBrLrNr	r
rrrs���������H�����
M�M�M�)�)�)�
!�!�!����!�!�!�������&�&�&�'�'�'�����r
rc�P�eZdZ	dd�Zd�Zd�Zd�Zd�Z	d
d�Z	d
d	�Z	d
�Z
d�ZdS)r8Fc�l�d}t|dd��dur	dx|_}t|��D]�\}}|jrn�t	|��rv|�||��|�||��|�||��|j|_	t|jdd��st|dd��r��|s||��n|�
��|jr|�|����|r2|�d|��|�
|��d|_|S)NF�_testRunEnteredT�_classSetupFailed�_moduleSetUpFailed)r
rTr?r@�_isnotsuite�_tearDownPreviousClass�_handleModuleFixture�_handleClassSetUpr �_previousTestClassrNrArB�_handleModuleTearDown)rrCrN�topLevelrDr/s      rrEz
TestSuite.runfsb�����6�,�e�4�4��=�=�04�4�F�"�X�$�T�?�?�	/�	/�K�E�4�� �
����4� � �
��+�+�D�&�9�9�9��)�)�$��7�7�7��&�&�t�V�4�4�4�,0�N��)��D�N�,?��G�G���F�$8�%�@�@����
���V������
�
�����}�
/��'�'��.�.�.���	+��'�'��f�5�5�5��&�&�v�.�.�.�%*�F�"��
r
c�P�	t��}|�|d��dS)NT)�_DebugResultrE)rrNs  rrNzTestSuite.debug�s(��E��������������r
c���t|dd��}|j}||krdS|jrdSt|dd��rdSd}	d|_n#t$rYnwxYwt|dd��}t|dd��}|��t|d��		|��nt#t$rg}t|t��r�d}	d|_n#t$rYnwxYwtj
|��}	|�||d|	��Yd}~nd}~wwxYw|r6|�4|��|jD]"}
|�||
dd|	|
�	���#t|d
��dS#t|d
��wxYwdS)Nr[�__unittest_skip__F�
setUpClass�doClassCleanups�_setupStdoutTr��info�_restoreStdout)
r
r rVrUr2r�	Exceptionr%r_rr�"_createClassOrModuleLevelException�tearDown_exceptions)rr/rC�
previousClass�currentClass�failedrbrc�e�	className�exc_infos           rrZzTestSuite._handleClassSetUp�s8����(<�d�C�C�
��~���=�(�(��F��$�	��F��<�!4�e�<�<�	��F���	�-2�L�*�*���	�	�	�
�D�	����
�\�<��>�>�
�!�,�0A�4�H�H���!��F�N�3�3�3�
:�
G��J�L�L�L�L�� �G�G�G�!�&�,�7�7���!�F��9=��6�6��$���������� $�
�l� ;� ;�I��;�;�F�A�<H�<E�G�G�G�G�G�G�G�G�����G�����/�o�9�#�O�%�%�%�$0�$D�/�/���?�?� &����\�9�%-�@�/�/�/�/� ��(8�9�9�9�9�9����(8�9�9�9�9����1"�!sf�A�
A�A�
B�E�
D
�#D�<C�D�
C�D�C�/D�E�D
�
;E�E)c�>�d}t|dd��}|�|j}|S)Nr[)r
rP)rrC�previousModulerks    r�_get_previous_modulezTestSuite._get_previous_module�s-������(<�d�C�C�
��$�*�5�N��r
c��|�|��}|jj}||krdS|�|��d|_	t
j|}n#t$rYdSwxYwt|dd��}|��t|d��		|��nL#t$r?}t|t��r�d|_|�
||d|��Yd}~nd}~wwxYw|jrD	tj��n/#t$r"}|�
||d|��Yd}~nd}~wwxYwt|d��dS#t|d��wxYwdS)NF�setUpModulerdTrg)rsr rPr\rV�sys�modules�KeyErrorr
rrhr%r_rir�doModuleCleanups)rr/rCrr�
currentModule�modulerurns        rrYzTestSuite._handleModuleFixture�s���2�2�6�:�:����1�
��N�*�*��F��"�"�6�*�*�*�%*��!�	��[��/�F�F���	�	�	��F�F�	�����f�m�T�:�:���"��F�N�3�3�3�
:�K��K�M�M�M�M�� �K�K�K�!�&�,�7�7���04�F�-��;�;�F�A�<I�<I�K�K�K�K�K�K�K�K�����	K�����,�O�O��-�/�/�/�/��$�O�O�O��?�?���@M�@M�O�O�O�O�O�O�O�O�����O����
 ��(8�9�9�9�9�9����(8�9�9�9�9����)#�"sl�A�
A(�'A(�
B�E�
C$�%5C�E�C$�$
E�/D�E�
D/�
D*�%E�*D/�/E�ENc�F�|�d|�d�}|�||||��dS)Nz (�))�_addClassOrModuleLevelException)rrC�exc�method_namerrf�	errorNames       rriz,TestSuite._createClassOrModuleLevelException�s8��"�/�/�f�/�/�/�	��,�,�V�S�)�T�J�J�J�J�Jr
c�6�t|��}t|dd��}|�5t|tj��r||t|����dS|s)|�|tj����dS|�||��dS)N�addSkip)	�_ErrorHolderr
r%r�SkipTestr=�addErrorrvrp)rrC�	exceptionr�rf�errorr�s       rr~z)TestSuite._addClassOrModuleLevelException�s����Y�'�'���&�)�T�2�2����:�i���#G�#G���G�E�3�y�>�>�*�*�*�*�*��
-�����s�|�~�~�6�6�6�6�6�����t�,�,�,�,�,r
c�|�|�|��}|�dS|jrdS	tj|}n#t$rYdSwxYwt|d��	t
|dd��}|�Q	|��nE#t$r8}t|t��r�|�
||d|��Yd}~nd}~wwxYw	tj��nE#t$r8}t|t��r�|�
||d|��Yd}~nd}~wwxYwt|d��dS#t|d��wxYw)Nrd�tearDownModulerg)
rsrVrvrwrxrr
rhr%r_rirry)rrCrrr{r�rns      rr\zTestSuite._handleModuleTearDown�s����2�2�6�:�:���!��F��$�	��F�	��[��0�F�F���	�	�	��F�F�	����	���/�/�/�	6�$�V�-=�t�D�D�N��)�L�"�N�$�$�$�$�� �L�L�L�!�&�,�7�7����;�;�F�A�<L�<J�L�L�L�L�L�L�L�L�����L����
H��%�'�'�'�'���
H�
H�
H��f�l�3�3����7�7���8H�8F�H�H�H�H�H�H�H�H�����
H����
�F�$4�5�5�5�5�5��O�F�$4�5�5�5�5���so�7�
A�A�D)�-
A8�7D)�8
B:�.B5�0D)�5B:�:D)�>C�D)�
D�.D�
D)�D�D)�)D;c��t|dd��}|j}||ks|�dSt|dd��rdSt|dd��rdSt|dd��rdSt|dd��}t|dd��}|�|�dSt|d��	|�e	|��nY#t$rL}t	|t
��r�t
j|��}|�||d|��Yd}~nd}~wwxYw|�e|��|j	D]S}	t	|t
��r|	d	�t
j|��}|�||	d	d||	�
���Tt|d��dS#t|d��wxYw)Nr[rUFrVra�
tearDownClassrcrdrrerg)
r
r rrhr%r_rrrirj)
rr/rCrkrlr�rcrnrorps
          rrXz TestSuite._tearDownPreviousClasss%����(<�d�C�C�
��~���=�(�(�M�,A��F��=�"5�u�=�=�	��F��6�/��7�7�	��F��=�"5�u�=�=�	��F��
���E�E�
�!�-�1B�D�I�I��� �_�%<��F����/�/�/�	6��(�G�!�M�O�O�O�O�� �G�G�G�!�&�,�7�7��� $�
�m� <� <�I��;�;�F�A�<K�<E�G�G�G�G�G�G�G�G�����	G�����*���!�!�!� -� A�K�K�H�!�&�,�7�7�*�&�q�k�)� $�
�m� <� <�I��;�;�F�H�Q�K�<K�<E�AI�<�K�K�K�K�

�F�$4�5�5�5�5�5��O�F�$4�5�5�5�5���s8�E5�
B#�"E5�#
C9�-AC4�/E5�4C9�9A*E5�5F)Fr)rOrPrQrErNrZrsrYrir~r\rXr	r
rr8r8\s������������B���,:�,:�,:�\���#:�#:�#:�L9=�K�K�K�K�.2�
-�
-�
-�
-�!6�!6�!6�F(6�(6�(6�(6�(6r
r8c�D�eZdZ	dZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�ZdS)
r�Nc��||_dSr��description)rr�s  rrz_ErrorHolder.__init__Ts��&����r
c��|jSrr�r"s r�idz_ErrorHolder.idWs����r
c��dSrr	r"s r�shortDescriptionz_ErrorHolder.shortDescriptionZs���tr
c��d|j�d�S)Nz<ErrorHolder description=rr�r"s rr#z_ErrorHolder.__repr__]s���15�1A�1A�1A�C�Cr
c�*�|���Sr)r�r"s r�__str__z_ErrorHolder.__str__`s���w�w�y�y�r
c��dSrr	�rrCs  rrEz_ErrorHolder.runcs	��	
�r
c�,�|�|��SrrIr�s  rrLz_ErrorHolder.__call__hs���x�x����r
c��dSrr	r"s rr-z_ErrorHolder.countTestCasesks���qr
)rOrPrQ�failureExceptionrr�r�r#r�rErLr-r	r
rr�r�Hs����������'�'�'� � � ����D�D�D����
�
�
�
 � � �����r
r�c�L�		t|��n#t$rYdSwxYwdS)NTF)r*r2)r/s rrWrWns>��E���T�
�
�
�
�������t�t������5s��
!�!c��eZdZ	dZdZdZdS)r_NF)rOrPrQr[rVr@r	r
rr_r_ws"������I������J�J�Jr
r_)rv�rr�
__unittestr�objectrr8r�rWr_r	r
r�<module>r�s���
�
�
�
�������������
�
����
I�I�I�I�I�F�I�I�I�Xi6�i6�i6�i6�i6�
�i6�i6�i6�X$�$�$�$�$�6�$�$�$�L��������6�����r
__pycache__/mock.cpython-311.pyc000064400000374270152401764000012423 0ustar00�

|@���pA���`�dZddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
ddlmZddlmZmZddlmZGd�d	e��Zd
�ee��D��ZdZeZd�Zd
�Zd�Zd�Zd�Z d�Z!dyd�Z"d�Z#d�Z$d�Z%d�Z&dyd�Z'd�Z(d�Z)d�Z*Gd�de+��Z,Gd�de+��Z-e-��Z.e.j/Z/e.j0Z1e.j2Z3hd �Z4d!�Z5Gd"�d#e6��Z7d$�Z8Gd%�d&e+��Z9Gd'�d(e+��Z:Gd)�d*e:��Z;ej<e;j=��Z>Gd+�d,e6��Z?d-�Z@Gd.�d/e:��ZAGd0�d1eAe;��ZBd2�ZCGd3�d4e+��ZDd5�ZEe/dddddfdd6�d7�ZF		dzd8�ZGe/dddddfdd6�d9�ZHGd:�d;e+��ZId<�ZJd=�ZKeFeH_+eIeH_LeGeH_MeKeH_Nd>eH_Od?ZPd@ZQdA�RdB�eQ�S��D����ZTdA�RdC�eQ�S��D����ZUhdD�ZVdE�ZWdF�dA�RePeQeTeUg���S��D��ZXhdG�ZYdHhZZeYeZzZ[eXeVzZ\e\e[zZ]hdI�Z^dJ�dK�dL�dM�dN�Z_e`e`e`e`dOddddPdQddOddR�
ZadS�ZbdT�ZcdU�ZddV�ZeebecedeedW�ZfdX�ZgGdY�dZe:��ZhGd[�d\ehe;��ZiGd]�d^eh��ZjGd_�d`eheB��ZkGda�dbe:��ZlGdc�dde:��ZmGde�dfemejeB��ZnGdg�dhe+��Zoeo��Zpdi�ZqGdj�dker��Zsesd�l��Zt		d{dd6�dm�Zudn�ZvGdo�dpe+��Zwexeu��exepjy��fZzda{da|dq�Z}d|ds�Z~Gdt�dueB��Zdv�Z�Gdw�dx��Z�dS)})�Mock�	MagicMock�patch�sentinel�DEFAULT�ANY�call�create_autospec�	AsyncMock�
FILTER_DIR�NonCallableMock�NonCallableMagicMock�	mock_open�PropertyMock�seal�N)�iscoroutinefunction)�CodeType�
ModuleType�
MethodType)�	safe_repr)�wraps�partial)�RLockc��eZdZdZdS)�InvalidSpecErrorz8Indicates that an invalid value was used as a mock spec.N��__name__�
__module__�__qualname__�__doc__���8/opt/alt/python-internal/lib/python3.11/unittest/mock.pyrr)s������B�B�B�Br"rc�<�h|]}|�d���|��S��_��
startswith)�.0�names  r#�	<setcomp>r+-s)��H�H�H�d�4�?�?�3�3G�3G�H�T�H�H�Hr"Tc���t|��rt|t��sdSt|d��rt	|d��}t|��pt
j|��S)NF�__func__)�_is_instance_mock�
isinstancer
�hasattr�getattrr�inspect�isawaitable��objs r#�
_is_async_objr65sg�������j��i�&@�&@���u��s�J���'��c�:�&�&���s�#�#�?�w�':�3�'?�'?�?r"c�F�t|dd��rt|��SdS)N�__code__F)r1r)�funcs r#�_is_async_funcr:=s)���t�Z��&�&��"�4�(�(�(��ur"c�F�tt|��t��S�N)�
issubclass�typerr4s r#r.r.Ds���d�3�i�i��1�1�1r"c��t|t��p)t|t��ot|t��Sr<)r/�
BaseExceptionr>r=r4s r#�
_is_exceptionrAJs6���3�
�&�&�	A��3����@�*�S�-�"@�"@�r"c�^�t|t��rt|d��r|jS|S�N�mock)r/�
FunctionTypesr0rDr4s r#�
_extract_mockrFQs3���#�}�%�%��'�#�v�*>�*>���x���
r"c��t|t��r|s
|j}d}njt|ttf��rt|t��rd}|j}n/t|t��s	|j}n#t$rYdSwxYw|rt|d��}n|}	|tj|��fS#t$rYdSwxYw)z�
    Given an arbitrary, possibly callable object, try to create a suitable
    signature object.
    Return a (reduced func, signature) tuple, or None.
    TN)
r/r>�__init__�classmethod�staticmethodr-rE�__call__�AttributeErrorrr2�	signature�
ValueError)r9�as_instance�eat_self�sig_funcs    r#�_get_signature_objectrRZs����$�����k���}�����	�D�;��5�	6�	6���d�K�(�(�	��H��}���
��m�
,�
,��	��=�D�D���	�	�	��4�4�	�������4��&�&�������W�&�x�0�0�0�0�������t�t����s$�3A;�;
B	�B	�"B8�8
C�CFc���t|||�����dS�\}��fd�}t||��|t|��_�t|��_dS)Nc�"���j|i|��dSr<��bind)�self�args�kwargs�sigs   �r#�checksigz"_check_signature.<locals>.checksig�� ������$�!�&�!�!�!�!�!r")rR�_copy_func_detailsr>�_mock_check_sig�
__signature__)r9rD�	skipfirst�instancer[rZs     @r#�_check_signaturerb}sr���
��h�	�
:�
:�C�
�{����I�D�#�"�"�"�"�"��t�X�&�&�&�!)�D��J�J��"�D��J�J���r"c	�p�dD]2}	t||t||�����##t$rY�/wxYwdS)N)rr �__text_signature__r�__defaults__�__kwdefaults__)�setattrr1rL)r9�funcopy�	attributes   r#r]r]�sa�����	�	��G�Y���i�(@�(@�A�A�A�A���	�	�	��D�	����
�s�&�
3�3c���t|t��rdSt|tttf��rt|j��St|dd���dSdS)NTrKF)r/r>rJrIr�	_callabler-r1r4s r#rkrk�s^���#�t�����t��#��k�:�>�?�?�'����&�&�&��s�J��%�%�1��t��5r"c�<�t|��ttfvSr<)r>�list�tupler4s r#�_is_listro�s����9�9��u�
�%�%r"c��t|t��st|dd��duS|f|jzD]}|j�d���dS� dS)ztGiven an object, return True if the object is callable.
    For classes, return True if instances would be callable.rKNTF)r/r>r1�__mro__�__dict__�get)r5�bases  r#�_instance_callableru�sn���c�4� � �:��s�J��-�-�T�9�9�����$�����=���Z�(�(�4��4�4�5��5r"c�0��t|t��}t|||��}|�|S|\}��fd�}t||��|j}|���sd}||d�}d|z}	t
|	|��||}
t|
|���|
S)Nc�"���j|i|��dSr<rU)rXrYrZs  �r#r[z _set_signature.<locals>.checksig�r\r"rh)�
_checksig_rDzYdef %s(*args, **kwargs):
    _checksig_(*args, **kwargs)
    return mock(*args, **kwargs))r/r>rRr]r�isidentifier�exec�_setup_func)rD�originalrar`�resultr9r[r*�context�srcrhrZs           @r#�_set_signaturer��s����
�8�T�*�*�I�
"�8�X�y�
A�
A�F�
�~����I�D�#�"�"�"�"�"��t�X�&�&�&���D���������%�t�4�4�G�$�&*�+�C�	�#�w�����d�m�G����s�#�#�#��Nr"c�������_�fd�}�fd�}�fd�}�fd�}�fd�}�fd�}�fd�}	��fd�}
d	�_d
�_d�_t	���_t	���_t	���_�j�_�j	�_	�j
�_
|�_|�_|�_
|	�_|
�_|�_|�_|�_|�_��_dS)Nc����j|i|��Sr<)�assert_called_with�rXrYrDs  �r#r�z'_setup_func.<locals>.assert_called_with�����&�t�&��7��7�7�7r"c����j|i|��Sr<)�
assert_calledr�s  �r#r�z"_setup_func.<locals>.assert_called�s���!�t�!�4�2�6�2�2�2r"c����j|i|��Sr<)�assert_not_calledr�s  �r#r�z&_setup_func.<locals>.assert_not_called�s���%�t�%�t�6�v�6�6�6r"c����j|i|��Sr<)�assert_called_oncer�s  �r#r�z'_setup_func.<locals>.assert_called_once�r�r"c����j|i|��Sr<)�assert_called_once_withr�s  �r#r�z,_setup_func.<locals>.assert_called_once_with�s���+�t�+�T�<�V�<�<�<r"c����j|i|��Sr<)�assert_has_callsr�s  �r#r�z%_setup_func.<locals>.assert_has_calls�s���$�t�$�d�5�f�5�5�5r"c����j|i|��Sr<)�assert_any_callr�s  �r#r�z$_setup_func.<locals>.assert_any_call�s���#�t�#�T�4�V�4�4�4r"c����t���_t���_�����j}t|��r|�ur|���dSdSdSr<)�	_CallList�method_calls�
mock_calls�
reset_mock�return_valuer.)�retrhrDs ��r#r�z_setup_func.<locals>.reset_mock�so���(�{�{���&�[�[����������"���S�!�!�	�#��+�+��N�N������	�	�+�+r"Fr)rD�called�
call_count�	call_argsr��call_args_listr�r�r��side_effect�_mock_childrenr�r�r�r�r�r�r�r�r_�_mock_delegate)rhrDrZr�r�r�r�r�r�r�r�s``         r#r{r{�s������G�L�8�8�8�8�8�3�3�3�3�3�7�7�7�7�7�8�8�8�8�8�=�=�=�=�=�6�6�6�6�6�5�5�5�5�5��������G�N��G���G��&�[�[�G��$�;�;�G��"���G���,�G���*�G��!�0�G��!3�G��&=�G�#�/�G��-�G��#�G��)�G�� 1�G��!3�G���G��!�D���r"c	����tjj�_d�_d�_t���_�fd�}dD]!}t�|t||�����"dS)Nrc�:��t�j|��|i|��Sr<)r1rD)�attrrXrYrDs   �r#�wrapperz"_setup_async_mock.<locals>.wrapper
s$���'�w�t�y�$�'�'��8��8�8�8r")�assert_awaited�assert_awaited_once�assert_awaited_with�assert_awaited_once_with�assert_any_await�assert_has_awaits�assert_not_awaited)	�asyncio�
coroutines�
_is_coroutine�await_count�
await_argsr��await_args_listrgr)rDr�ris`  r#�_setup_async_mockr�s���� �+�9�D���D���D�O�$�;�;�D��
9�9�9�9�9�,�>�>�	�	��i���)�!<�!<�=�=�=�=�>�>r"c�$�d|dd�z|kS)N�__%s__����r!�r*s r#�	_is_magicr�s���d�1�R�4�j� �D�(�(r"c�$�eZdZdZd�Zd�Zd�ZdS)�_SentinelObjectz!A unique, named, sentinel object.c��||_dSr<r��rWr*s  r#rHz_SentinelObject.__init__"s
����	�	�	r"c��d|jzS�Nzsentinel.%sr��rWs r#�__repr__z_SentinelObject.__repr__%����t�y�(�(r"c��d|jzSr�r�r�s r#�
__reduce__z_SentinelObject.__reduce__(r�r"N)rrrr rHr�r�r!r"r#r�r� sG������'�'����)�)�)�)�)�)�)�)r"r�c�$�eZdZdZd�Zd�Zd�ZdS)�	_SentinelzAAccess attributes to return a named object, usable as a sentinel.c��i|_dSr<)�
_sentinelsr�s r#rHz_Sentinel.__init__.s
������r"c�l�|dkrt�|j�|t|����S)N�	__bases__)rLr��
setdefaultr�r�s  r#�__getattr__z_Sentinel.__getattr__1s3���;��� � ���)�)�$���0E�0E�F�F�Fr"c��dS)Nrr!r�s r#r�z_Sentinel.__reduce__7s���zr"N)rrrr rHr�r�r!r"r#r�r�,sJ������K�K����G�G�G�����r"r�>�
_mock_namer��_mock_parentr��_mock_new_name�_mock_new_parent�_mock_side_effect�_mock_return_valuec�x�t�|��d|z}||fd�}||fd�}t||��S)N�_mock_c�T�|j}|�t||��St||��Sr<)r�r1)rWr*�	_the_namerZs    r#�_getz"_delegating_property.<locals>._getLs/���!���;��4��+�+�+��s�D�!�!�!r"c�R�|j}|�||j|<dSt|||��dSr<)r�rrrg)rW�valuer*r�rZs     r#�_setz"_delegating_property.<locals>._setQs9���!���;�',�D�M�)�$�$�$��C��u�%�%�%�%�%r")�_allowed_names�add�property)r*r�r�r�s    r#�_delegating_propertyr�Ise�����t�����4��I��	�"�"�"�"�
 $�y�&�&�&�&��D�$���r"c��eZdZd�Zd�ZdS)r�c��t|t��st�||��St|��}t|��}||krdSt	d||z
dz��D]}||||z�}||krdS�dS)NFr�T)r/rm�__contains__�len�range)rWr��	len_value�len_self�i�sub_lists      r#r�z_CallList.__contains__^s����%��&�&�	2��$�$�T�5�1�1�1���J�J�	��t�9�9���x����5��q�(�Y�.��2�3�3�	�	�A��A�a�	�k�M�*�H��5� � ��t�t�!��ur"c�D�tjt|����Sr<)�pprint�pformatrmr�s r#r�z_CallList.__repr__ls���~�d�4�j�j�)�)�)r"N)rrrr�r�r!r"r#r�r�\s2���������*�*�*�*�*r"r�c���t|��}t|��sdS|js|js|j�|j�dS|}|�||urdS|j}|�|r||_||_|r||_||_dS)NFT)rFr.r�r�r�r�)�parentr�r*�new_name�_parents     r#�_check_and_set_parentr�ps����%� � �E��U�#�#���u�	�	��U�1��	�	�	'�	�	�	+��u��G�
�
��e����5��*���
��(�!'���'���� �#�������4r"c��eZdZd�Zd�ZdS)�	_MockIterc�.�t|��|_dSr<)�iterr5)rWr5s  r#rHz_MockIter.__init__�s����9�9����r"c�*�t|j��Sr<)�nextr5r�s r#�__next__z_MockIter.__next__�s���D�H�~�~�r"N)rrrrHr�r!r"r#r�r��s2�������������r"r�c��eZdZeZdZd�ZdS)�BaseNc��dSr<r!�rWrXrYs   r#rHz
Base.__init__�s���r")rrrrr�r�rHr!r"r#r�r��s/������ ����
�
�
�
�
r"r�c��eZdZdZe��Zd�Z			d-d�Zd�Zd.d�Z			d/d	�Z
d
�Zd�ZdZ
eeee
��Zed
���Zed��Zed��Zed��Zed��Zed��Zd�Zd�Zeee��Zd0ddd�d�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d1d �Z#d!�Z$d"�Z%d#�Z&d$�Z'd%�Z(d&�Z)d'�Z*d.d(�Z+d)�Z,d*�Z-d2d,�Z.dS)3rz A non-callable version of `Mock`c�z�|f}t|t��s]tj|g|�Ri|��j}|�d|�d����}|�t
|��r	t|f}t|j|d|j	i��}tt|���|��}|S)N�spec_set�specr )
r=�AsyncMockMixin�	_MOCK_SIG�bind_partial�	argumentsrsr6r>rr �_safe_superr�__new__)�clsrX�kw�bases�
bound_args�spec_arg�newras        r#rzNonCallableMock.__new__�s�������#�~�.�.�	.�"�/��A�d�A�A�A�b�A�A�K�J�!�~�~�j�*�.�.��2H�2H�I�I�H��#�
�h�(?�(?�#�'��-���3�<���C�K�(@�A�A�����4�4�<�<�S�A�A���r"N�Fc��|�|}|j}
||
d<||
d<||
d<||
d<d|
d<|�|}d}|
�|du}
|�|||	|
��i|
d<||
d	<d|
d
<d|
d<d|
d<d
|
d<t��|
d<t��|
d<t��|
d<||
d<|r
|jdi|��t	t
|���||||||��dS)Nr�r�r�r�F�_mock_sealedTr��_mock_wrapsr��_mock_called�_mock_call_argsr�_mock_call_count�_mock_call_args_list�_mock_mock_callsr��_mock_unsafer!)rr�_mock_add_specr��configure_mockrrrH)rWr�rr*r�r��_spec_state�	_new_name�_new_parent�_spec_as_instance�	_eat_self�unsaferYrrs              r#rHzNonCallableMock.__init__�sV��
�� �K��=��#)��� �!%����%.��!�"�'2��#�$�#(��� ����D��H����d�*�I����D�(�,=�y�I�I�I�%'��!�"�"'����%)��!�"�#(��� �&*��"�#�'(��#�$�+4�;�;��'�(�'0�{�{��#�$�#,�;�;��� �#)��� ��	*��D��)�)�&�)�)�)��O�T�*�*�3�3��%��x���	
�	
�	
�	
�	
r"c�~�t|��}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)rFr�r�r�r�rg)rWrDri�
inner_mocks    r#�attach_mockzNonCallableMock.attach_mock�sI��
#�4�(�(�
�"&�
��&*�
�#� "�
��$(�
�!���i��&�&�&�&�&r"c�2�|�||��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�rWr�r�s   r#�
mock_add_speczNonCallableMock.mock_add_spec�s ��	
���D�(�+�+�+�+�+r"c���t|��rtd|�d����d}d}g}t|��D]5}tt	||d����r|�|���6|�`t
|��sQt|t��r|}nt|��}t|||��}	|	o|	d}t|��}|j
}
||
d<||
d<||
d<||
d<||
d<dS)	Nz#Cannot spec a Mock object. [object=�]r��_spec_class�	_spec_set�_spec_signature�
_mock_methods�_spec_asyncs)r.r�dirrr1�appendror/r>rRrr)rWr�r�rrr&r(r*r��resrrs           r#rzNonCallableMock._mock_add_spec�s'���T�"�"�	T�"�#R��#R�#R�#R�S�S�S���������I�I�	*�	*�D�"�7�4��t�#<�#<�=�=�
*��#�#�D�)�)�)����H�T�N�N���$��%�%�
)�"���"�4�j�j��'��(9�9�F�F�C�!�n�c�!�f�O��t�9�9�D��=��"-���� (����&5��"�#�$(���!�#/��� � � r"c��|j}|j�|jj}|tur%|j�|�|d���}||_|S)N�()�rr)r�r�r�rr�_get_child_mock)rWr�s  r#�__get_return_valuez"NonCallableMock.__get_return_values]���%����*��%�2�C��'�>�>�d�.�6��&�&� �D�'���C�!$�D���
r"c�b�|j�||j_dS||_t||dd��dS)Nr/)r�r�r�r�)rWr�s  r#�__set_return_valuez"NonCallableMock.__set_return_value%s>����*�/4�D��,�,�,�&+�D�#�!�$��t�T�:�:�:�:�:r"z1The value to be returned when the mock is called.c�<�|j�t|��S|jSr<)r&r>r�s r#�	__class__zNonCallableMock.__class__1s ����#���:�:����r"r�r�r�r�r�c���|j}|�|jS|j}|�It|��s:t	|t
��s%t
|��st|��}||_|Sr<)r�r�r��callabler/r�rA)rW�	delegated�sfs   r#�__get_side_effectz!NonCallableMock.__get_side_effect>sj���'�	����)�)�
�
"���N�8�B�<�<�N�"�2�y�1�1�
�:G��:K�:K�
��2���B�$&�I�!��	r"c�V�t|��}|j}|�	||_dS||_dSr<)�	_try_iterr�r�r�)rWr�r9s   r#�__set_side_effectz!NonCallableMock.__set_side_effectIs9���%� � ���'�	���%*�D�"�"�"�$)�I�!�!�!r"�r�r�c�N�|�g}t|��|vrdS|�t|����d|_d|_d|_t��|_t��|_t��|_|rt|_
|rd|_|j�
��D]9}t|t��s	|t ur�!|�|||����:|j
}t%|��r||ur|�|��dSdSdS)z-Restore the mock object to its initial state.NFrr?)�idr,r�r�r�r�r�r�r�rr�r�r��valuesr/�
_SpecState�_deletedr�r.)rW�visitedr�r��childr�s      r#r�zNonCallableMock.reset_mockTs5���?��G�
�d�8�8�w����F����r�$�x�x� � � ����������#�+�+���'�k�k���%�K�K����	.�&-�D�#��	*�%)�D�"��(�/�/�1�1�	Z�	Z�E��%��,�,�
���0A�0A�����W�<�[��Y�Y�Y�Y��%���S�!�!�	$�c��o�o��N�N�7�#�#�#�#�#�	$�	$�o�or"c��t|���d����D]V\}}|�d��}|���}|}|D]}t	||��}�t|||���WdS)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)c�8�|d�d��S)Nr�.)�count)�entrys r#�<lambda>z0NonCallableMock.configure_mock.<locals>.<lambda>s���q�����1D�1D�r")�keyrIN)�sorted�items�split�popr1rg)rWrY�arg�valrX�finalr5rKs        r#rzNonCallableMock.configure_mockrs����v�|�|�~�~�$E�#D�	F�F�F�
	%�
	%�H�C��
�9�9�S�>�>�D��H�H�J�J�E��C��
*�
*���c�5�)�)����C���$�$�$�$�
	%�
	%r"c
��|dvrt|���|j�%||jvs	|tvrtd|z���nt|��rt|���|js:|jr	||jvr*|�d��rt|�d|�d����tj5|j�	|��}|turt|���|�Cd}|j�t|j|��}|�
|||||���}||j|<n�t|t��rv	t!|j|j|j|j|j��}n>#t,$r1|jdp|}t-d|�d	|�d
|�d|j�d�	���wxYw||j|<ddd��n#1swxYwY|S)
N>rr)zMock object has no attribute %r)�assert�assret�asert�aseert�assrtz6 is not a valid assertion. Use a spec for the mock if z is meant to be an attribute.)r�r*rrrr��Cannot autospec attr �
 from target �, as it has already been mocked out. [target=�, attr=r%)rLr)�_all_magicsr�rr(r�_lockr�rsrDrr1r1r/rCr	r�r�rar�r*rrr)rWr*r}r�target_names     r#r�zNonCallableMock.__getattr__�s����4�4�4� ��&�&�&�
�
�
+��4�-�-�-���1D�1D�$�%F��%M�N�N�N�2E�
�t�_�_�	'� ��&�&�&�� �	N�$�*<�	N��D�L^�@^�@^����O�P�P�
N�$��M�M�'+�M�M�M�N�N�N��
"�	4�	4��(�,�,�T�2�2�F���!�!�$�T�*�*�*������#�/�$�D�$4�d�;�;�E��-�-��d�%�4� $�.����.4��#�D�)�)��F�J�/�/�
4�
D�,���V�_�f�o��
�v�{���F�F��(�D�D�D�"&�-��"=�"E��K�*�C��C�C�&�C�C�#'�C�C�28�+�C�C�C�D�D�D�D����.4��#�D�)�;	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4����	4�	4�	4�	4�>�
s+�+B
F:�9,E&�%F:�&;F!�!
F:�:F>�F>c�n�|jg}|j}|}d}|dgkrd}|�7|}|�|j|z��d}|jdkrd}|j}|�7tt	|����}|jpd}t
|��dkr|ddvr|dz
}||d<d�|��S)NrIr/rrDr�)r/z().r)r�r�r,rm�reversedr�r��join)rW�
_name_listr��last�dot�_firsts      r#�_extract_mock_namez"NonCallableMock._extract_mock_name�s����)�*�
��'�������$�����C��!��D����g�4�s�:�;�;�;��C��%��-�-����.�G��!��(�:�.�.�/�/�
���*�F���z�?�?�Q����!�}�M�1�1��#�
���
�1�
��w�w�z�"�"�"r"c���|���}d}|dvrd|z}d}|j�d}|jrd}||jjz}dt	|��j�|�|�dt|���d�S)	Nr)rDzmock.z name=%rz spec=%rz spec_set=%r�<z id='z'>)rir&r'rr>rA)rWr*�name_string�spec_strings    r#r�zNonCallableMock.__repr__�s����&�&�(�(�����(�(�(�$�t�+�K�����'�$�K��~�
-�,��%��(8�(A�A�K����J�J����K��K�K��t�H�H�H�H�	
�	
r"c�v�tst�|��S|jpg}t	t|����}t
|j��}d�|j�	��D��}d�|D��}d�|D��}tt||z|z|z����S)z8Filter the output of `dir(mock)` to only useful members.c�*�g|]\}}|tu�|��Sr!)rD)r)�m_name�m_values   r#�
<listcomp>z+NonCallableMock.__dir__.<locals>.<listcomp>�s1��(�(�(�&�v�w��h�&�&�
�&�&�&r"c�<�g|]}|�d���|��Sr%r'�r)�es  r#rrz+NonCallableMock.__dir__.<locals>.<listcomp>�s)��C�C�C�1����c�1B�1B�C�Q�C�C�Cr"c�Z�g|](}|�d��rt|���&|��)Sr%)r(r�rts  r#rrz+NonCallableMock.__dir__.<locals>.<listcomp>�sE��#�#�#�1����c�1B�1B�#��q�\�\�#�Q�#�#�#r")r�object�__dir__r)r+r>rmrrr�rOrN�set)rW�extras�	from_type�	from_dict�from_child_mockss     r#rxzNonCallableMock.__dir__�s����	(��>�>�$�'�'�'��#�)�r����T�
�
�O�O�	����'�'�	�(�(�*.�*=�*C�*C�*E�*E�(�(�(��D�C�	�C�C�C�	�#�#�	�#�#�#�	��c�&�9�,�y�8�;K�K�L�L�M�M�Mr"c�T���|tvrt��||��S�jr+�j�$|�jvr|�jvrt
d|z���|tvrd|z}t
|���|tvr��j�|�jvrt
d|z���t|��s5tt���|t||����|���fd�}nft�|d|��tt���||��|�j|<n+|dkr	|�_dSt�|||��r
|�j|<�jr;t#�|��s+�����d|��}t
d|�����t��||��S)Nz!Mock object has no attribute '%s'z.Attempting to set unsupported magic method %r.c�����g|�Ri|��Sr<r!)rXrr|rWs  ��r#rLz-NonCallableMock.__setattr__.<locals>.<lambda>s!���H�H�T�,G�D�,G�,G�,G�B�,G�,G�r"r6rIzCannot set )r�rw�__setattr__r'r)rrrL�_unsupported_magicsr_r.rgr>�_get_methodr�r�r&r
r0ri)rWr*r��msg�	mock_namer|s`    @r#r�zNonCallableMock.__setattr__�s������>�!�!��%�%�d�D�%�8�8�8��n�	2��!3�!?���*�*�*���
�%�%� �!D�t�!K�L�L�L�
�(�
(�
(�B�T�I�C� ��%�%�%�
�[�
 �
 ��!�-�$�d�>P�2P�2P�$�%H�4�%O�P�P�P�$�U�+�+�	
2���T�
�
�D�+�d�E�*B�*B�C�C�C� ��G�G�G�G�G���&�d�E�4��>�>�>���T�
�
�D�%�0�0�0�,1��#�D�)�)�
�[�
 �
 �$�D���F�$�T�5�$��=�=�
2�,1��#�D�)���	<�W�T�4�%8�%8�	<��2�2�4�4�=�=�t�=�=�I� �!:�y�!:�!:�;�;�;��!�!�$��e�4�4�4r"c��|tvr>|t|��jvr(tt|��|��||jvrdS|j�|t��}||jvr)tt|���	|��n|turt|���|tur|j|=t|j|<dSr<)r_r>rr�delattrr�rs�_missingrr�__delattr__rDrL)rWr*r5s   r#r�zNonCallableMock.__delattr__!s����;���4�4��:�:�+>�#>�#>��D��J�J��%�%�%��4�=�(�(����!�%�%�d�H�5�5���4�=� � ����.�.�:�:�4�@�@�@�@�
�H�_�_� ��&�&�&��h����#�D�)�$,���D�!�!�!r"c�6�|jpd}t|||��SrC)r��_format_call_signature�rWrXrYr*s    r#�_format_mock_call_signaturez+NonCallableMock._format_mock_call_signature3s ����(�&��%�d�D�&�9�9�9r"rc�d�d}|�||��}|j}|j|�}||||fzS)Nz0expected %s not found.
Expected: %s
  Actual: %s)r�r�)rWrXrY�action�message�expected_stringr��
actual_strings        r#�_format_mock_failure_messagez,NonCallableMock._format_mock_failure_message8sD��F���:�:�4��H�H���N�	�8��8�)�D�
��&�/�=�A�A�Ar"c��|s|jSd}|�dd���d��}|j}|D]M}|�|��}|�t|t��rnt|��}|j}|j}�N|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/rrI)r(�replacerPr�rsr/rCrF)rWr*rZ�names�childrenrFs      r#�_get_call_signature_from_namez-NonCallableMock._get_call_signature_from_name@s����	(��'�'������T�2�&�&�,�,�S�1�1���&���
	,�
	,�D��L�L��&�&�E��}�
�5�*� =� =�}���
&�e�,�,�� �/���+����
r"c��t|t��r/t|��dkr|�|d��}n|j}|�vt|��dkrd}|\}}n|\}}}	|j|i|��}t
||j|j��S#t$r}|�
d��cYd}~Sd}~wwxYw|S)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/rnr�r�r(rVrrXrY�	TypeError�with_traceback)rW�_callrZr*rXrY�
bound_callrus        r#�
_call_matcherzNonCallableMock._call_matcheras����e�U�#�#�	'��E�
�
�Q����4�4�U�1�X�>�>�C�C��&�C��?��5�z�z�Q�����$���f�f�%*�"��d�F�
.�%�S�X�t�6�v�6�6�
��D�*�/�:�3D�E�E�E���
.�
.�
.��'�'��-�-�-�-�-�-�-�-�����
.�����Ls�0'B�
C�"B<�6C�<Cc��|jdkr8d|jpd�d|j�d|�����}t|���dS)z/assert that the mock was never called.
        r�
Expected 'rDz"' to not have been called. Called � times.N�r�r��_calls_repr�AssertionError�rWr�s  r#r�z!NonCallableMock.assert_not_called|s^���?�a�����o�/��/�/��o�o�o��&�&�(�(�(�*�C�!��%�%�%� �r"c�R�|jdkrd|jpdz}t|���dS)z6assert that the mock was called at least once
        rz"Expected '%s' to have been called.rDN)r�r�r�r�s  r#r�zNonCallableMock.assert_called�s;���?�a���7��O�-�v�/�C� ��%�%�%� �r"c��|jdks8d|jpd�d|j�d|�����}t|���dS)z3assert that the mock was called only once.
        r�r�rDz#' to have been called once. Called r�Nr�r�s  r#r�z"NonCallableMock.assert_called_once�s^����!�#�#�#��o�/��/�/��o�o�o��&�&�(�(�(�*�C�!��%�%�%�$�#r"c�t�����j�/������}d}d|�d|��}t|������fd�}��t	��fd�����}���j��}||kr1t|t��r|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.z#expected call not found.
Expected: z
  Actual: c�4��������}|Sr<�r��r�rXrYrWs ���r#�_error_messagez:NonCallableMock.assert_called_with.<locals>._error_message�s����3�3�D�&�A�A�C��Jr"T��two)r�r�r�r��_Callr/�	Exception)rWrXrY�expected�actual�
error_messager��causes```     r#r�z"NonCallableMock.assert_called_with�s������
�>�!��7�7��f�E�E�H�"�F�F��x�x���)�M� ��/�/�/�	�	�	�	�	�	�	��%�%�e�T�6�N��&E�&E�&E�F�F���#�#�D�N�3�3���X��� *�8�Y� ?� ?�I�H�H�T�E� ���!1�!1�2�2��=��r"c��|jdks8d|jpd�d|j�d|�����}t|���|j|i|��S)ziassert that the mock was called exactly once and that that call was
        with the specified arguments.r�r�rDz' to be called once. Called r�)r�r�r�r�r��rWrXrYr�s    r#r�z'NonCallableMock.assert_called_once_with�sn����!�#�#�#��o�/��/�/��o�o�o��&�&�(�(�(�*�C�!��%�%�%�&�t�&��7��7�7�7r"c����fd�|D��}td�|D��d��}t�fd��jD����}|su||vro|�d}nd�d�|D����}t	|�dt|�����d	�
���d������|�dSt|��}g}|D]=}	|�|���#t$r|�
|��Y�:wxYw|r-t	�jpd�d
t|���d|�d���|�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`.c�:��g|]}��|����Sr!�r��r)�crWs  �r#rrz4NonCallableMock.assert_has_calls.<locals>.<listcomp>��'���9�9�9�a�D�&�&�q�)�)�9�9�9r"c3�DK�|]}t|t���|V��dSr<�r/r�rts  r#�	<genexpr>z3NonCallableMock.assert_has_calls.<locals>.<genexpr>��1����F�F�A�Z��9�-E�-E�F�a�F�F�F�F�F�Fr"Nc3�B�K�|]}��|��V��dSr<r�r�s  �r#r�z3NonCallableMock.assert_has_calls.<locals>.<genexpr>�s1�����M�M��d�0�0��3�3�M�M�M�M�M�Mr"zCalls not found.z+Error processing expected calls.
Errors: {}c�@�g|]}t|t��r|nd��Sr<r�rts  r#rrz4NonCallableMock.assert_has_calls.<locals>.<listcomp>��;��$7�$7�$7�()�*4�A�y�)A�)A�$K�A�A�t�$7�$7�$7r"�
Expected: z  Actual)�prefixrIrDz does not contain all of z in its call list, found z instead)
r�r�r��formatr�r��rstriprm�removerNr,r�rn)	rW�calls�	any_orderr�r��	all_calls�problem�	not_found�kalls	`        r#r�z NonCallableMock.assert_has_calls�s����:�9�9�9�5�9�9�9���F�F��F�F�F��M�M���M�M�M�M�T�_�M�M�M�M�M�	��	��y�(�(��=�0�G�G� ,�-3�V�$7�$7�-5�$7�$7�$7�.8�.8��%��I�I�!*�5�!1�!1�I��'�'�z�'�:�:�A�A�#�F�F�I�I����	�

�F���O�O�	��	��	'�	'�D�
'�� � ��&�&�&�&���
'�
'�
'�� � ��&�&�&�&�&�
'�����	� �&*�o�&?��&?�&?�&+�I�&6�&6�&6�&6�	�	�	�C����	
�	�	s�C-�-D�Dc�$����t||fd�����}t|t��r|nd}�fd��jD��}|s|t|��vr)��||��}td|z��|�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.Tr�Nc�:��g|]}��|����Sr!r�r�s  �r#rrz3NonCallableMock.assert_any_call.<locals>.<listcomp>�s'���E�E�E�A�$�$�$�Q�'�'�E�E�Er"z%s call not found)r�r�r/r�r��_AnyComparerr�r��rWrXrYr�r�r�r�s`      r#r�zNonCallableMock.assert_any_call�s�����%�%�e�T�6�N��&E�&E�&E�F�F��&�x��;�;�E�����E�E�E�E��1D�E�E�E���	�H�L��$8�$8�8�8�"�>�>�t�V�L�L�O� �#�o�5����
�9�8r"c��|jr7d|vrd|d��nd}|���|z}t|���|�d��}||jdvrtdi|��St
|��}t|t��r|tvrt
}n�t|t��r)|tvs|jr||jvrt}ndt
}n\t|t��s:t|t��rt}n*t|t��rt }n
|jd}|di|��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*rIr/rr*r�r!)r
rirLrsrrr
r>r=r�_async_method_magicsr��_all_sync_magicsr)�
CallableMixinr
rrrq)rWrrir�r�_type�klasss       r#r1zNonCallableMock._get_child_mock�s[����	,�,2�b�L�L�(�B�v�J�(�(�(�d�I��/�/�1�1�I�=�I� ��+�+�+��F�F�;�'�'�	���
�n�5�5�5��?�?�r�?�?�"��T�
�
���e�Y�'�'�	%�I�9M�,M�,M��E�E�
��~�
.�
.�
	%��-�-�-��&�.�+4��8J�+J�+J�!���!����E�=�1�1�	%��%�!5�6�6�
�!����E�?�3�3�
�����M�!�$�E��u�{�{�r�{�{�r"�Callsc�J�|jsdSd|�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: rI)r�r)rWr�s  r#r�zNonCallableMock._calls_reprs6����	��2�;�F�;�;�i���8�8�;�;�;�;r")NNNNNNrNFNF�F)FFr<)r)r�)/rrrr rr`rrHrr#r�"_NonCallableMock__get_return_value�"_NonCallableMock__set_return_value�"_NonCallableMock__return_value_docr�r�r6r�r�r�r�r�r��!_NonCallableMock__get_side_effect�!_NonCallableMock__set_side_effectr�r�rr�rir�rxr�r�r�r�r�r�r�r�r�r�r�r�r�r1r�r!r"r#rr�s�������*�*�
�E�G�G�E�
�
�
�">B�EI�<A�*
�*
�*
�*
�Z'�'�'�,�,�,�,�@E�!&�0�0�0�0�>
�
�
�;�;�;�M���8�.�0B�.�0�0�L�� � ��X� �
"�
!�(�
+�
+�F�%�%�l�3�3�J�$�$�[�1�1�I�)�)�*:�;�;�N�%�%�l�3�3�J�	�	�	�*�*�*��(�,�.?�@�@�K�$�u�%�$�$�$�$�$�<%�%�%�,-�-�-�`#�#�#�6
�
�
�*N�N�N�$$5�$5�$5�N-�-�-�$:�:�:�
B�B�B�B����B���6&�&�&�&�&�&�&�&�&�>�>�>�,	8�	8�	8�*�*�*�*�Z
�
�
� #�#�#�L
<�
<�
<�
<�
<�
<r"rc��eZdZdZd�ZdS)r�z�A list which checks if it contains a call which may have an
    argument of ANY, flipping the components of item and self from
    their traditional locations so that ANY is guaranteed to be on
    the left.c��|D]N}t|��t|��ksJ�td�t||��D����rdS�OdS)Nc� �g|]\}}||k��Sr!r!)r)r�r�s   r#rrz-_AnyComparer.__contains__.<locals>.<listcomp>5s1�����$�H�f��F�"���r"TF)r��all�zip)rW�itemr�s   r#r�z_AnyComparer.__contains__2s{���	�	�E��t�9�9��E�
�
�*�*�*�*����(+�D�%�(8�(8������
��t�t�	
�
�ur"N)rrrr r�r!r"r#r�r�-s-������������r"r�c��|�|St|��r|St|��r|S	t|��S#t$r|cYSwxYwr<)rArkr�r�r4s r#r=r==sk��
�{��
��S�����
���~�~���
���C�y�y��������
�
�
����s�7�A�Ac
�H�eZdZddedddddddf
d�Zd�Zd�Zd�Zd�Zd�Z	dS)	r�Nrc
�x�||jd<tt|��j|||||||	|
fi|��||_dS)Nr�)rrrr�rHr�)rWr�r�r�rr*r�r�rrrrYs            r#rHzCallableMixin.__init__Nsa��/;��
�*�+�1��M�4�(�(�1��%��x����K�	
�	
�39�	
�	
�	
�
'����r"c��dSr<r!r�s   r#r^zCallableMixin._mock_check_sigZs���r"c�P�|j|i|��|j|i|��|j|i|��Sr<)r^�_increment_mock_call�
_mock_callr�s   r#rKzCallableMixin.__call___sK��	���d�-�f�-�-�-�!��!�4�2�6�2�2�2��t���/��/�/�/r"c��|j|i|��Sr<)�_execute_mock_callr�s   r#r�zCallableMixin._mock_callgs��&�t�&��7��7�7�7r"c�~�d|_|xjdz
c_t||fd���}||_|j�|��|jdu}|j}|j}|dk}|j	�td||f����|j
}|��|rB|j�t|||f����|jdu}|r
|jdz|z}t|||f��}	|j	�|	��|jr|rd}
nd}
|jdk}|j|
z|z}|j
}|��dSdS)NTr�r�r/rrI)r�r�r�r�r�r,r�r�r�r�r�r�)rWrXrYr��do_method_calls�method_call_name�mock_call_name�	is_a_callr�this_mock_callrgs           r#r�z"CallableMixin._increment_mock_calljs���������1����
�t�V�n�$�/�/�/�������"�"�5�)�)�)��+�4�7���?���,��"�d�*�	�����u�b�$��%7�8�8�9�9�9��+���%��
W��(�/�/��7G��v�6V�0W�0W�X�X�X�"-�":�$�"F��"�W�'2�'=��'C�FV�'V�$�#�N�D�&�#A�B�B�N��"�)�)�.�9�9�9��)�
S����C�C��C�'�6�$�>�	�!,�!;�c�!A�N�!R��&�6�K�-�%�%�%�%�%r"c�^�|j}|�Tt|��r|�t|��s!t|��}t|��r|�n||i|��}|tur|S|jtur|jS|jr|jjtur|jS|j�
|j|i|��S|jSr<)	r�rArkr�rr�r�r�r)rWrXrY�effectr}s     r#r�z CallableMixin._execute_mock_call�s����!�����V�$�$�
1����v�&�&�
1��f���� ��(�(�!� �L�!� ���0��0�0���W�$�$��
��"�'�1�1��$�$���	%�4�#6�#C�7�#R�#R��$�$���'�#�4�#�T�4�V�4�4�4�� � r")
rrrrrHr^rKr�r�r�r!r"r#r�r�Ls������� �d���$��d�!�R�T�	'�	'�	'�	'�
�
�
�
0�0�0�8�8�8�,7�,7�,7�\!�!�!�!�!r"r�c��eZdZdZdS)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.

    * `unsafe`: By default, accessing any attribute whose name starts with
      *assert*, *assret*, *asert*, *aseert* or *assrt* will raise an
       AttributeError. Passing `unsafe=True` will allow access to
      these attributes.

    * `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.
    Nrr!r"r#rr�s������5�5�5�5r"rc�@�d}|D]}||vrt|�d�����dS)N)�	autospect�	auto_spec�set_specz5 might be a typo; use unsafe=True if this is intended)�RuntimeError)�kwargs_to_check�typos�typos   r#�_check_spec_arg_typosr�sN��2�E������?�"�"���P�P�P���
�#��r"c�~�eZdZdZgZdd�d�Zd�Zd�Zd�Ze	j
d���Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�ZdS)�_patchNF�rc
��|�)|turtd���|�td���|
st|	��t|��rt	d|�d|�d����t|��rt	d|�d|�d����||_||_||_||_||_	||_
d|_||_||_
|	|_g|_dS)Nz,Cannot use 'new' and 'new_callable' togetherz1Cannot use 'autospec' and 'new_callable' togetherzCannot spec attr z0 as the spec has already been mocked out. [spec=r%z? as the spec_set target has already been mocked out. [spec_set=F)rrNrr.r�getterrir
�new_callabler��create�	has_localr��autospecrY�additional_patchers)rWrrir
r�rr�r
rrYrs           r#rHz_patch.__init__sV���#��'�!�!� �B�����#� �G�����	*�!�&�)�)�)��T�"�"�	A�"�@�I�@�@�6:�@�@�@�A�A�
A��X�&�&�	P�"�O�I�O�O�AI�O�O�O�P�P�
P����"������(�����	������� ��
� ��
����#%�� � � r"c���t|j|j|j|j|j|j|j|j|j	�	�	}|j
|_
d�|jD��|_|S)Nc�6�g|]}|�����Sr!)�copy)r)�ps  r#rrz_patch.copy.<locals>.<listcomp>,s-��'
�'
�'
��A�F�F�H�H�'
�'
�'
r")rrrir
r�rr�r
rrY�attribute_namer)rW�patchers  r#rz_patch.copy%sq����K�����4�9��K����M�4�,�d�k�
�
��
"&�!4���'
�'
�"�6�'
�'
�'
��#��r"c���t|t��r|�|��Stj|��r|�|��S|�|��Sr<�r/r>�decorate_classr2r�decorate_async_callable�decorate_callable)rWr9s  r#rKz_patch.__call__2sc���d�D�!�!�	-��&�&�t�,�,�,��&�t�,�,�	6��/�/��5�5�5��%�%�d�+�+�+r"c��t|��D]q}|�tj��s�"t	||��}t|d��s�C|���}t||||�����r|S�NrK)r+r(r�TEST_PREFIXr1r0rrg)rWr�r��
attr_valuers     r#rz_patch.decorate_class:s�����J�J�		6�		6�D��?�?�5�#4�5�5�
�� ���-�-�J��:�z�2�2�
���i�i�k�k�G��E�4����!4�!4�5�5�5�5��r"c#�TK�g}tj��5}|jD]W}|�|��}|j�|�|���4|jtur|�|���X|t|��z
}||fV�ddd��dS#1swxYwYdSr<)
�
contextlib�	ExitStack�	patchings�
enter_contextr�updater
rr,rn)rW�patchedrX�keywargs�
extra_args�
exit_stack�patchingrRs        r#�decoration_helperz_patch.decoration_helperHs�����
�
�
!�
#�
#�		#�z�#�-�
+�
+�� �.�.�x�8�8���*�6��O�O�C�(�(�(�(��\�W�,�,��%�%�c�*�*�*���E�*�%�%�%�D���"�"�"�"�		#�		#�		#�		#�		#�		#�		#�		#�		#�		#�		#�		#����		#�		#�		#�		#�		#�		#s�A8B�B!�$B!c�����t�d��r�j�����St������fd�����g�_�S)Nrc�|�����||��5\}}�|i|��cddd��S#1swxYwYdSr<�r&�rXr"�newargs�newkeywargsr9r!rWs    ���r#r!z)_patch.decorate_callable.<locals>.patched]s�����'�'��(,�(0�2�2�
5�5K�g�{��t�W�4��4�4�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5����
5�
5�
5�
5�
5�
5s�1�5�5�r0rr,r�rWr9r!s``@r#rz_patch.decorate_callableWsv������4��%�%�	��N�!�!�$�'�'�'��K�	�t���	5�	5�	5�	5�	5�	5�
��	5�"�F����r"c�����t�d��r�j�����St������fd�����g�_�S)Nrc���K����||��5\}}�|i|���d{V��cddd��S#1swxYwYdSr<r)r*s    ���r#r!z/_patch.decorate_async_callable.<locals>.patchedns�������'�'��(,�(0�2�2�
;�5K�g�{�!�T�7�:�k�:�:�:�:�:�:�:�:�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;����
;�
;�
;�
;�
;�
;s
�9�=�=r-r.s``@r#rz_patch.decorate_async_callablehsv������4��%�%�	��N�!�!�$�'�'�'��K�	�t���	;�	;�	;�	;�	;�	;�
��	;�"�F����r"c�`�|���}|j}t}d}	|j|}d}n-#tt
f$rt
||t��}YnwxYw|tvrt|t��rd|_
|j
s|turt	|�d|�����||fS)NFTz does not have the attribute )rrirrrrL�KeyErrorr1�	_builtinsr/rr)rW�targetr*r|�locals     r#�get_originalz_patch.get_originalys����������~������	���t�,�H��E�E����)�	6�	6�	6��v�t�W�5�5�H�H�H�	6����
�9����F�J�!?�!?���D�K��{�	�x�7�2�2� �7=�v�v�t�t�D���
����s�
6�'A �A c��|j|j|j}}}|j|j}}|j}|���|_|durd}|durd}|durd}|�|�td���|�|�|dvrtd���|�	��\}}|tu�r�|���d}	|dur|}|dur|}d}n|�	|dur|}d}n|dur|}|�|�/|turtd���t|t��rd}	|�t|��rt}
nt}
i}|�|}
nN|�|�J|}|�|}t!|��rd|v}
nt#|��}
t|��rt}
n	|
rt$}
|�||d	<|�||d
<t|
t��r&t'|
t(��r|jr
|j|d<|�|��|
di|��}|	r_t/|��rP|}|�|}t!|��st1|��st$}
|�d��|
d|dd
�|��|_n�|��|turtd���|turtd���t7|��}|dur|}t/|j��r#t9d|j�d|j�d|�d����t/|��rAt;|jd|j��}t9d|j�d|�d|j�d|�d�	���t=|f||jd�|��}n|rtd���|}||_||_ tCj"��|_#	tI|j|j|��|j%�ci}|jtur
|||j%<|j&D]?}|j#�'|��}|jtur|�|���@|S|S#|j(tSj*���s�YdSxYw)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=TruerKr�r�r*r/r0zBautospec creates the mock for you. Can't specify autospec and new.z%Can't use 'autospec' with create=Truer[z: as the patch target has already been mocked out. [target=r^r%rr\r])r��_namez.Can't pass kwargs to a mock we aren't creatingr!)+r
r�r�r
rYrrr4r�r6rr/r>r6r
rror8r
r=rrir r.rurQr��boolrr1r	�
temp_original�is_localrr�_exit_stackrgrrr�__exit__�sys�exc_info)rWr
r�r�r
rYrr|r5�inherit�Klass�_kwargs�	this_spec�not_callablera�new_attrr#r%rRs                   r#�	__enter__z_patch.__enter__�s���"�h��	�4�=�8�T���=�$�+�&���(���k�k�m�m����5�=�=��D��u����H��u����H���� 4��=�>�>�>�
�
��!5��L�(�(��T�U�U�U��+�+�-�-���%��'�>�>�h�.��G��t�|�|����t�#�#�'�H��D���!��t�#�#�#�H��D���T�!�!�#����8�#7��w�&�&�#�$G�H�H�H��h��-�-�#�"�G��|�
�h� 7� 7�|�!���!���G��'�$����!�X�%9� �	��'� (�I��I�&�&�;�#-�Y�#>�L�L�'/�	�':�':�#:�L� ��+�+�1�%�E�E�!�1�0�E���"&�����#�&.��
�#��5�$�'�'�
1��5�/�2�2�
1�7;�~�
1�"&�.�����N�N�6�"�"�"��%�"�"�'�"�"�C��
4�,�S�1�1�
4�!�	��'� (�I� ��+�+�1�&�y�1�1�1�0�E����F�#�#�#�#(�5�$4�S�D�$4�$4�+2�$4�$4�� ��
�
!��'�!�!��(�����7�"�"�� G�H�H�H��H�~�~�H��4���#�� ���-�-�
D�&�C�D�N�C�C�#�{�C�C�5=�C�C�C�D�D�D�!��*�*�
D�%�d�k�:�t�{�K�K��&�C�D�N�C�C�"�C�C�#�{�C�C�5=�C�C�C�D�D�D�
"�(�B�X�(,��B�B�:@�B�B�C�C�
�	N��L�M�M�M���%�����
�%�/�1�1���	��D�K����:�:�:��"�.��
��8�w�&�&�7:�J�t�2�3� $� 8�/�/�H��*�8�8��B�B�C��|�w�.�.�"�)�)�#�.�.�.��!�!��J��	� �4�=�#�,�.�.�1�
��
�
�
���s�BO�O�O<c�h�|jr/|jtur!t|j|j|j��ndt
|j|j��|jsCt|j|j��r	|jdvr t|j|j|j��|`|`|`|j	}|`	|j
|�S)zUndo the patch.)r rre�__annotations__rf)r;r:rrgr4rir�rr0r<r=)rWr?r$s   r#r=z_patch.__exit__#s����=�		I�T�/�w�>�>��D�K����1C�D�D�D�D��D�K���0�0�0��;�
I����T�^�(L�(L�
I���+=�=�=����T�^�T�5G�H�H�H����M��K��%�
���"�z�"�H�-�-r"c�b�|���}|j�|��|S�z-Activate a patch, returning any created mock.)rF�_active_patchesr,�rWr}s  r#�startz_patch.start8s-�����!�!����#�#�D�)�)�)��
r"c��	|j�|��n#t$rYdSwxYw|�ddd��S�zStop an active patch.N)rKr�rNr=r�s r#�stopz_patch.stop?s[��	�� �'�'��-�-�-�-���	�	�	��4�4�	�����}�}�T�4��.�.�.s��
+�+)rrrrrKrHrrKrr�contextmanagerr&rrr6rFr=rMrPr!r"r#rr�s��������N��O�AF�"&�"&�"&�"&�"&�J
�
�
�,�,�,������#�#���#����"���"���0P�P�P�d.�.�.�*���/�/�/�/�/r"rc���	|�dd��\}}n-#tttf$rtd|�����wxYwt	t
j|��|fS)NrIr�z,Need a valid target to patch. You supplied: )�rsplitr�rNrLr�pkgutil�resolve_name)r4ris  r#�_get_targetrVKs���G�"�M�M�#�q�1�1���	�	���z�>�2�G�G�G��E�6�E�E�G�G�	G�G�����7�'��0�0�)�;�;s	��*Arc���t���turt��d�����fd�}
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 strc����Sr<r!�r4s�r#rLz_patch_object.<locals>.<lambda>js���V�r"r)r>�strr�r)r4rir
r�rr�r
rrrYrs`          r#�
_patch_objectr[Tsn���$�F�|�|�s�����L�L�L�
�
�	
��^�^�^�F���	�3��f��(�L�&�����r"c���t���turttj���}n�fd�}|std���t
|�����}|d\}	}
t||	|
|||||i�	�	}|	|_	|dd�D]=\}	}
t||	|
|||||i�	�	}|	|_	|j
�|���>|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.
    c����Sr<r!rYs�r#rLz!_patch_multiple.<locals>.<lambda>�s����r"z=Must supply at least one keyword argument with patch.multiplerr�N)r>rZrrTrUrNrmrOrrrr,)
r4r�rr�r
rrYrrOrir
r�this_patchers
`            r#�_patch_multipler_qs
���,�F�|�|�s�����-�v�6�6���������
��K�
�
�	
�
������ � �E��1�X�N�I�s���	�3��f�h��,����G�'�G������)�9�9��	�3���I�s�D�&�(��l�B�
�
��'0��#��#�*�*�<�8�8�8�8��Nr"c�X�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 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 will raise a `RuntimeError` if passed some common misspellings of
    the arguments autospec and spec_set. Pass the argument `unsafe` with the
    value True to disable that check.

    `patch` takes arbitrary keyword arguments. These will be passed to
    `AsyncMock` if the patched object is asynchronous, to `MagicMock`
    otherwise or to `new_callable` if specified.

    `patch.dict(...)`, `patch.multiple(...)` and `patch.object(...)` are
    available for alternate use-cases.
    r)rVr)r4r
r�rr�r
rrrYrris           r#rr�sD��V$�F�+�+��F�I���	�3��f��(�L�&�����r"c�V�eZdZdZdd�Zd�Zd�Zd�Zd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
d�ZdS)�_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.
    r!Fc��||_t|��|_|j�|��||_d|_dSr<)�in_dict�dictrBr �clear�	_original)rWrdrBrfrYs     r#rHz_patch_dict.__init__s>������6�l�l�������6�"�"�"���
�����r"c���t|t��r|�|��Stj|��r|�|��S|�|��Sr<r)rW�fs  r#rKz_patch_dict.__call__sc���a����	*��&�&�q�)�)�)��&�q�)�)�	3��/�/��2�2�2��%�%�a�(�(�(r"c�@���t�����fd���}|S)Nc�������	�|i|������S#����wxYwr<�rb�
_unpatch_dict�rXrrirWs  ��r#�_innerz-_patch_dict.decorate_callable.<locals>._inner#sV���������
%��q�$�~�"�~�~��"�"�$�$�$�$���"�"�$�$�$�$���s	�3�A	�r�rWriros`` r#rz_patch_dict.decorate_callable"�9����	�q���	%�	%�	%�	%�	%�
��	%��
r"c�@���t�����fd���}|S)Nc���K�����	�|i|���d{V��	����S#����wxYwr<rlrns  ��r#roz3_patch_dict.decorate_async_callable.<locals>._inner/so�����������
%��Q��^��^�^�+�+�+�+�+�+�+��"�"�$�$�$�$���"�"�$�$�$�$���s	�
<�Arprqs`` r#rz#_patch_dict.decorate_async_callable.rrr"c� �t|��D]}}t||��}|�tj��rLt|d��r<t
|j|j|j	��}||��}t|||���~|Sr)r+r1r(rrr0rbrdrBrfrg)rWr�r�r�	decorator�	decorateds      r#rz_patch_dict.decorate_class:s�����J�J�	0�	0�D� ���-�-�J����� 1�2�2�
0���Z�0�0�
0�'���d�k�4�:�N�N�	�%�I�j�1�1�	���t�Y�/�/�/���r"c�8�|���|jS)zPatch the dict.)rbrdr�s r#rFz_patch_dict.__enter__Es���������|�r"c��|j}t|jt��rt	j|j��|_|j}|j}	|���}n"#t$ri}|D]
}||||<�YnwxYw||_	|rt|��	|�|��dS#t$r|D]
}||||<�YdSwxYwr<)rBr/rdrZrTrUrfrrLrg�_clear_dictr )rWrBrdrfr|rMs      r#rbz_patch_dict._patch_dictKs!������d�l�C�(�(�	>�"�/���=�=�D�L��,���
��	-��|�|�~�~�H�H���	-�	-�	-��H��
-�
-�� '�����
�
�
-�
-�		-����"����	!��� � � �	+��N�N�6�"�"�"�"�"���	+�	+�	+��
+�
+��%�c�{�����
+�
+�
+�	+���s$�A$�$B�B�B6�6C�Cc��|j}|j}t|��	|�|��dS#t$r|D]
}||||<�YdSwxYwr<)rdrgrzr rL)rWrdr|rMs    r#rmz_patch_dict._unpatch_dictgs����,���>���G����	-��N�N�8�$�$�$�$�$���	-�	-�	-��
-�
-��'��}�����
-�
-�
-�	-���s�6�A�Ac�<�|j�|���dS)zUnpatch the dict.NF)rgrm)rWrXs  r#r=z_patch_dict.__exit__ts!���>�%���� � � ��ur"c�l�|���}tj�|��|SrJ)rFrrKr,rLs  r#rMz_patch_dict.start{s-�����!�!����%�%�d�+�+�+��
r"c��	tj�|��n#t$rYdSwxYw|�ddd��SrO)rrKr�rNr=r�s r#rPz_patch_dict.stop�s[��	��"�)�)�$�/�/�/�/���	�	�	��4�4�	�����}�}�T�4��.�.�.s�"�
0�0N)r!F)rrrr rHrKrrrrFrbrmr=rMrPr!r"r#rbrb�s���������8����)�)�)�	�	�	�	�	�	�������+�+�+�8
-�
-�
-�������/�/�/�/�/r"rbc��	|���dS#t$rt|��}|D]}||=�YdSwxYwr<)rfrLrm)rd�keysrMs   r#rzrz�se����
�
������������G�}�}���	�	�C�����	�	�	����s��!=�=c�f�ttj��D]}|����dS)z7Stop all active patches. LIFO to unroll nested patches.N)rcrrKrP)rs r#�_patch_stopallr��s5���&�0�1�1����
�
�
������r"�testz�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 zDadd sub mul matmul truediv floordiv mod lshift rshift and xor or pow� c#� K�|]	}d|zV��
dS)zi%sNr!�r)�ns  r#r�r��s&����7�7��5�1�9�7�7�7�7�7�7r"c#� K�|]	}d|zV��
dS)zr%sNr!r�s  r#r�r��s&����5�5�q����5�5�5�5�5�5r">rx�__get__�__set__r��
__delete__�
__format__r��__missing__�__getstate__�__reversed__�__setstate__�
__getformat__�
__reduce_ex__�__getnewargs__�__subclasses__�__getinitargs__�__getnewargs_ex__c� ���fd�}||_|S)z:Turns a callable object (like a mock) into a real functionc����|g|�Ri|��Sr<r!)rWrXrr9s   �r#�methodz_get_method.<locals>.method�s#����t�D�&�4�&�&�&�2�&�&�&r")r)r*r9r�s ` r#r�r��s(���'�'�'�'�'��F�O��Mr"c��h|]}d|z��S)r�r!)r)r�s  r#r+r+�s*����� �H�v����r">�	__aexit__�	__anext__�
__aenter__�	__aiter__>�__del__rrHr��__prepare__r��__instancecheck__�__subclasscheck__c�6�t�|��Sr<)rw�__hash__r�s r#rLrL�s��V�_�_�T�2�2�r"c�6�t�|��Sr<)rw�__str__r�s r#rLrL�s��F�N�N�4�0�0�r"c�6�t�|��Sr<)rw�
__sizeof__r�s r#rLrL�s��v�0�0��6�6�r"c�x�t|��j�d|����dt|����S)N�/)r>rrirAr�s r#rLrL�s;��$�t�*�*�"5�^�^��8O�8O�8Q�8Q�^�^�TV�W[�T\�T\�^�^�r")r�r�r��
__fspath__r�y�?g�?)
�__lt__�__gt__�__le__�__ge__�__int__r��__len__r=�__complex__�	__float__�__bool__�	__index__r�c����fd�}|S)Nc�L���jj}|tur|S�|urdStS�NT)�__eq__r�r�NotImplemented)�other�ret_valrWs  �r#r�z_get_eq.<locals>.__eq__�s1����+�0���'�!�!��N��5�=�=��4��r"r!)rWr�s` r#�_get_eqr��s#���������Mr"c����fd�}|S)Nc�R���jjturtS�|urdStS�NF)�__ne__r�rr�)r�rWs �r#r�z_get_ne.<locals>.__ne__s,����;�)��8�8��N��5�=�=��5��r"r!)rWr�s` r#�_get_ner�s#���������Mr"c����fd�}|S)Nc�j���jj}|turtg��St|��Sr<)�__iter__r�rr��r�rWs �r#r�z_get_iter.<locals>.__iter__s1����-�2���g�����8�8�O��G�}�}�r"r!)rWr�s` r#�	_get_iterr�
s#���������Or"c����fd�}|S)Nc����jj}|turtt	g����Stt	|����Sr<)r�r�r�_AsyncIteratorr�r�s �r#r�z"_get_async_iter.<locals>.__aiter__s@����.�3���g���!�$�r�(�(�+�+�+��d�7�m�m�,�,�,r"r!)rWr�s` r#�_get_async_iterr�s$���-�-�-�-�-�
�r")r�r�r�r�c�&�t�|t��}|tur	||_dSt�|��}|�||��}||_dSt
�|��}|�||��|_dSdSr<)�_return_valuesrsrr��_calculate_return_value�_side_effect_methodsr�)rDr�r*�fixed�return_calculatorr��
side_effectors       r#�_set_return_valuer�(s������t�W�-�-�E��G���#�����/�3�3�D�9�9���$�(�(��.�.��*�����(�,�,�T�2�2�M�� �*�]�4�0�0�����!� r"c��eZdZd�Zd�ZdS)�
MagicMixinc��|���tt|��j|i|��|���dSr<)�_mock_set_magicsrr�rH�rWrXrs   r#rHzMagicMixin.__init__;sN��������.��J��%�%�.��;��;�;�;��������r"c	��ttz}|}t|dd���X|�|j��}t��}||z
}|D](}|t
|��jvrt||���)|tt
|��j��z
}t
|��}|D]!}t||t||�����"dS)Nr))�_magicsr�r1�intersectionr)ryr>rrr�rg�
MagicProxy)rW�orig_magics�these_magics�
remove_magicsrKr�s      r#r�zMagicMixin._mock_set_magicsAs���� 4�4��"���4��$�/�/�;�&�3�3�D�4F�G�G�L��E�E�M�'�,�6�M�&�
)�
)���D��J�J�/�/�/��D�%�(�(�(��$�c�$�t�*�*�*=�&>�&>�>���T�
�
��!�	;�	;�E��E�5�*�U�D�"9�"9�:�:�:�:�	;�	;r"N)rrrrHr�r!r"r#r�r�:s2������ � � �;�;�;�;�;r"r�c��eZdZdZdd�ZdS)r
z-A version of `MagicMock` that isn't callable.Fc�Z�|�||��|���dSr!�rr�r"s   r#r#z"NonCallableMagicMock.mock_add_spec[�2��	
���D�(�+�+�+��������r"Nr��rrrr r#r!r"r#r
r
Ys.������7�7� � � � � � r"r
c��eZdZd�ZdS)�AsyncMagicMixinc��|���tt|��j|i|��|���dSr<)r�rr�rHr�s   r#rHzAsyncMagicMixin.__init__fsN��������3��O�T�*�*�3�T�@�R�@�@�@��������r"N�rrrrHr!r"r#r�r�es#������ � � � � r"r�c��eZdZdZdd�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`.
    Fc�Z�|�||��|���dSr!r�r"s   r#r#zMagicMock.mock_add_specvr�r"Nr�r�r!r"r#rrks2������	�	� � � � � � r"rc�"�eZdZd�Zd�Zdd�ZdS)r�c�"�||_||_dSr<�r*r�)rWr*r�s   r#rHzMagicProxy.__init__�s����	�����r"c��|j}|j}|�|||���}t|||��t	|||��|S)N)r*rr)r*r�r1rgr�)rWrKr��ms    r#�create_mockzMagicProxy.create_mock�sZ���	������"�"���/5�
#�
7�
7�����q�!�!�!��&�!�U�+�+�+��r"Nc�*�|���Sr<)r�)rWr5r�s   r#r�zMagicProxy.__get__�s�����!�!�!r"r<)rrrrHr�r�r!r"r#r�r��sF������������"�"�"�"�"�"r"r�c���eZdZed��Zed��Zed��Z�fd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
dd�Zd
�Z�fd�Z�xZS)r�r�r�r�c����t��j|i|��tjj|jd<d|jd<d|jd<t
��|jd<tt���}tj
tjztjz|_
d|_d|_d|_d|_||jd<d	|jd
<t%��|jd<i|jd<d|jd
<dS)Nr�r�_mock_await_count�_mock_await_args�_mock_await_args_list�r�)rXrYr8r
rrerfrH)�superrHr�r�r�rrr�rrr2�CO_COROUTINE�
CO_VARARGS�CO_VARKEYWORDS�co_flags�co_argcount�co_varnames�co_posonlyargcount�co_kwonlyargcountrn)rWrXrY�	code_mockr6s    �r#rHzAsyncMockMixin.__init__�s���������$�)�&�)�)�)�*1�);�)I��
�o�&�-.��
�)�*�,0��
�(�)�1:����
�-�.�#�X�6�6�6�	�� �� �
!��$�
%�	��
!"�	�� 2�	��'(�	�$�&'�	�#�$-��
�j�!�$/��
�j�!�(-����
�n�%�*,��
�&�'�+/��
�'�(�(�(r"c��`K�t||fd���}|xjdz
c_||_|j�|��|j}|��t
|��r|�t|��s8	t|��}n#t$rt�wxYwt
|��r|�n&t|��r||i|���d{V��}n||i|��}|tur|S|j
tur|jS|j�4t|j��r|j|i|���d{V��S|j|i|��S|jS)NTr�r�)r�r�r�r�r,r�rArkr��
StopIteration�StopAsyncIterationrrr�r�r)rWrXrYr�r�r}s      r#r�z!AsyncMockMixin._execute_mock_call�s������t�V�n�$�/�/�/�����A���������#�#�E�*�*�*��!�����V�$�$�
1����v�&�&�
1�-�!�&�\�\�F�F��$�-�-�-�-�,�-����!��(�(�!� �L�!�$�V�,�,�
1�%�v�t�6�v�6�6�6�6�6�6�6�6������0��0�0���W�$�$��
��"�'�1�1��$�$���'�"�4�#3�4�4�
?�-�T�-�t�>�v�>�>�>�>�>�>�>�>�>�#�4�#�T�4�V�4�4�4�� � s�1B�Bc�T�|jdkrd|jpd�d�}t|���dS)zA
        Assert that the mock was awaited at least once.
        r�	Expected rDz to have been awaited.N�r�r�r�r�s  r#r�zAsyncMockMixin.assert_awaited�s?����q� � �O�d�o�7��O�O�O�C� ��%�%�%�!� r"c�d�|jdks$d|jpd�d|j�d�}t|���dS)z@
        Assert that the mock was awaited exactly once.
        r�rrD�$ to have been awaited once. Awaited r�Nrr�s  r#r�z"AsyncMockMixin.assert_awaited_once�sW����1�$�$�9�t��8�&�9�9�#�/�9�9�9�C� ��%�%�%�%�$r"c�h�����j�)������}td|�d�������fd�}��t	��fd�����}���j��}||kr1t|t��r|nd}t|����|�dS)zN
        Assert that the last await was with the specified arguments.
        NzExpected await: z
Not awaitedc�8������d���}|S)N�await)r�r�r�s ���r#r�z:AsyncMockMixin.assert_awaited_with.<locals>._error_message�s"����3�3�D�&��3�Q�Q�C��Jr"Tr�)r�r�r�r�r�r/r�)rWrXrYr�r�r�r�s```    r#r�z"AsyncMockMixin.assert_awaited_with�s�������?�"��7�7��f�E�E�H� �!K�H�!K�!K�!K�L�L�L�	�	�	�	�	�	�	��%�%�e�T�6�N��&E�&E�&E�F�F���#�#�D�O�4�4���X��� *�8�Y� ?� ?�I�H�H�T�E� ���!1�!1�2�2��=��r"c�z�|jdks$d|jpd�d|j�d�}t|���|j|i|��S)zi
        Assert that the mock was awaited exactly once and with the specified
        arguments.
        r�rrDr	r�)r�r�r�r�r�s    r#r�z'AsyncMockMixin.assert_awaited_once_with�sg��
��1�$�$�9�t��8�&�9�9�#�/�9�9�9�C� ��%�%�%�'�t�'��8��8�8�8r"c�$����t||fd�����}t|t��r|nd}�fd��jD��}|s|t|��vr)��||��}td|z��|�dS)zU
        Assert the mock has ever been awaited with the specified arguments.
        Tr�Nc�:��g|]}��|����Sr!r�r�s  �r#rrz3AsyncMockMixin.assert_any_await.<locals>.<listcomp>	s'���F�F�F�A�$�$�$�Q�'�'�F�F�Fr"z%s await not found)r�r�r/r�r�r�r�r�r�s`      r#r�zAsyncMockMixin.assert_any_await
	s�����%�%�e�T�6�N��&E�&E�&E�F�F��&�x��;�;�E�����F�F�F�F��1E�F�F�F���	�H�L��$8�$8�8�8�"�>�>�t�V�L�L�O� �$��6����
�9�8r"Fc�*���fd�|D��}td�|D��d��}t�fd��jD����}|sT||vrN|�d}nd�d�|D����}t	|�dt|���d	�j����|�dSt|��}g}|D]=}	|�|���#t$r|�|��Y�:wxYw|r t	t|���d
���|�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`.
        c�:��g|]}��|����Sr!r�r�s  �r#rrz4AsyncMockMixin.assert_has_awaits.<locals>.<listcomp>#	r�r"c3�DK�|]}t|t���|V��dSr<r�rts  r#r�z3AsyncMockMixin.assert_has_awaits.<locals>.<genexpr>$	r�r"Nc3�B�K�|]}��|��V��dSr<r�r�s  �r#r�z3AsyncMockMixin.assert_has_awaits.<locals>.<genexpr>%	s1�����S�S��t�1�1�!�4�4�S�S�S�S�S�Sr"zAwaits not found.z,Error processing expected awaits.
Errors: {}c�@�g|]}t|t��r|nd��Sr<r�rts  r#rrz4AsyncMockMixin.assert_has_awaits.<locals>.<listcomp>-	r�r"r�z	
Actual: z not all found in await list)
r�r�r�r�r�rmr�rNr,rn)	rWr�r�r�r��
all_awaitsr�r�r�s	`        r#r�z AsyncMockMixin.assert_has_awaits	s����:�9�9�9�5�9�9�9���F�F��F�F�F��M�M���S�S�S�S�d�>R�S�S�S�S�S�
��	��z�)�)��=�1�G�G� ,�-3�V�$7�$7�-5�$7�$7�$7�.8�.8��%��6�6�!*�5�!1�!1�6�6�#�3�6�6����	�

�F��*�%�%�
��	��	'�	'�D�
'��!�!�$�'�'�'�'���
'�
'�
'�� � ��&�&�&�&�&�
'�����	� �49�)�4D�4D�4D�4D�F����
�	�	s�6C�C.�-C.c�d�|jdkr$d|jpd�d|j�d�}t|���dS)z9
        Assert that the mock was never awaited.
        rrrDz# to not have been awaited. Awaited r�Nrr�s  r#r�z!AsyncMockMixin.assert_not_awaitedC	sW����q� � �9�t��8�&�9�9�#�/�9�9�9�C� ��%�%�%�!� r"c�|��t��j|i|��d|_d|_t	��|_dS)z0
        See :func:`.Mock.reset_mock()`
        rN)r�r�r�r�r�r�)rWrXrYr6s   �r#r�zAsyncMockMixin.reset_mockL	sB���	�����D�+�F�+�+�+�������(�{�{����r"r�)rrrr�r�r�r�rHr�r�r�r�r�r�r�r�r��
__classcell__)r6s@r#r�r��s�������&�&�}�5�5�K�%�%�l�3�3�J�*�*�+<�=�=�O�0�0�0�0�0�8&!�&!�&!�P&�&�&�&�&�&�>�>�>�$	9�	9�	9����*�*�*�*�X&�&�&�+�+�+�+�+�+�+�+�+r"r�c��eZdZdZdS)r
aY
    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()
    >>> 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.
    Nrr!r"r#r
r
V	s������'�'�'�'r"r
c�$�eZdZdZd�Zd�Zd�ZdS)�_ANYz2A helper object that compares equal to everything.c��dSr�r!�rWr�s  r#r�z_ANY.__eq__�	s���tr"c��dSr�r!rs  r#r�z_ANY.__ne__�	s���ur"c��dS)Nz<ANY>r!r�s r#r�z
_ANY.__repr__�	s���wr"N)rrrr r�r�r�r!r"r#rr�	sG������8�8�����������r"rc���d|z}d}d�d�|D����}d�d�|���D����}|r|}|r|r|dz
}||z
}||zS)Nz%s(%%s)rz, c�,�g|]}t|����Sr!)�repr)r)rRs  r#rrz*_format_call_signature.<locals>.<listcomp>�	s��7�7�7�3�T�#�Y�Y�7�7�7r"c�"�g|]\}}|�d|����
S)�=r!)r)rMr�s   r#rrz*_format_call_signature.<locals>.<listcomp>�	s4�����#-�3��3�3�3������r")rdrO)r*rXrYr��formatted_args�args_string�
kwargs_strings       r#r�r��	s����$��G��N��)�)�7�7�$�7�7�7�8�8�K��I�I���17����������M��%�$���(��	#��d�"�N��-�'���^�#�#r"c��eZdZdZ		dd�Z		dd�Zd	�ZejZd
�Z	d�Z
d�Zd
�Ze
d���Ze
d���Zd�Zd�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!rNFTc��d}i}t|��}|dkr|\}}}n~|dkr<|\}	}
t|	t��r|	}t|
t��r|
}nD|
}nA|	|
}}n<|dkr6|\}t|t��r|}nt|t��r|}n|}|rt�|||f��St�||||f��S)Nr!�r�r�)r�r/rZrnr)rr�r*r�r��	from_kallrXrY�_len�first�seconds           r#rz
_Call.__new__�	s�������5�z�z���1�9�9�!&��D�$���
�Q�Y�Y�!�M�E�6��%��%�%�
-����f�e�,�,�$�!�D�D�#�F�F�$�f�f���
�Q�Y�Y��F�E��%��%�%�
�����E�5�)�)�
�������	6��=�=��t�V�n�5�5�5��}�}�S�4��v�"6�7�7�7r"c�0�||_||_||_dSr<)r�r��_mock_from_kall)rWr�r*r�r�r+s      r#rHz_Call.__init__�	s�����"���(����r"c�r�	t|��}n#t$r
tcYSwxYwd}t|��dkr|\}}n|\}}}t|dd��r#t|dd��r|j|jkrdSd}|dkrdi}}n�|dkr|\}}}n�|dkr?|\}	t|	t��r|	}i}nit|	t��r|	}di}}nMd}|	}nH|dkr@|\}
}t|
t��r!|
}t|t��r|i}}nd|}}n|
|}}ndS|r||krdS||f||fkS)	Nrr�r�Frr!r*r�)r�r�r�r1r�r/rnrZ)rWr��	len_other�	self_name�	self_args�self_kwargs�
other_name�
other_args�other_kwargsr�r-r.s            r#r�z_Call.__eq__�	s���	"��E�
�
�I�I���	"�	"�	"�!�!�!�!�	"�����	��t�9�9��>�>�%)�"�I�{�{�04�-�I�y�+��D�.�$�/�/�	�G�E�>�SW�4X�4X�	��%��);�;�;��5��
���>�>�')�2��J�J�
�!�^�^�38�0�J�
�L�L�
�!�^�^��F�E��%��'�'�
%�"�
�!����E�3�'�'�
%�"�
�+-�r�L�
�
��
�$���
�!�^�^�!�M�E�6��%��%�%�
9�"�
��f�e�,�,�:�/5�r��J�J�/1�6��J�J�+0�&�L�
�
��5��	��y�0�0��5��L�)�i��-E�E�Es��&�&c��|j�td||fd���S|jdz}t|j||f||���S)Nrr/r�r��r�r�r�s    r#rKz_Call.__call__
sN���?�"��"�d�F�+�$�7�7�7�7����%���d�o�t�V�4�4��M�M�M�Mr"c�n�|j�t|d���S|j�d|��}t||d���S)NF)r*r+rI)r*r�r+r:)rWr�r*s   r#r�z_Call.__getattr__
sD���?�"��d�e�4�4�4�4��/�/�/�4�4�0���$�t�u�=�=�=�=r"c�b�|tjvrt�t�||��Sr<)rnrrrL�__getattribute__)rWr�s  r#r=z_Call.__getattribute__$
s+���5�>�!�!� � ��%�%�d�D�1�1�1r"c�H�t|��dkr|\}}n|\}}}||fS)Nr�)r�r�s    r#�_get_call_argumentsz_Call._get_call_arguments*
s2���t�9�9��>�>��L�D�&�&�!%��D�$���V�|�r"c�6�|���dS�Nr�r?r�s r#rXz
_Call.args2
����'�'�)�)�!�,�,r"c�6�|���dS)Nr�rBr�s r#rYz_Call.kwargs6
rCr"c��|js%|jpd}|�d��rd|z}|St|��dkrd}|\}}n+|\}}}|sd}n |�d��sd|z}nd|z}t	|||��S)Nrr/zcall%sr�zcall.%s)r0r�r(r�r�)rWr*rXrYs    r#r�z_Call.__repr__:
s����#�	��?�,�f�D����t�$�$�
'��$����K��t�9�9��>�>��D��L�D�&�&�!%��D�$���
'�����_�_�T�*�*�
'� �4�'����$���%�d�D�&�9�9�9r"c��g}|}|�%|jr|�|��|j}|�%tt	|����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.)r0r,r�r�rc)rW�vals�things   r#�	call_listz_Call.call_listO
sW���������$�
#����E�"�"�"��&�E�����$���(�(�(r")r!rNFT)r!NNFT)rrrr rrHr�rwr�rKr�r=r?r�rXrYr�rIr!r"r#r�r��	s��������$:?��8�8�8�8�@>C��)�)�)�)�2F�2F�2F�j�]�F�N�N�N�>�>�>�2�2�2�����-�-��X�-��-�-��X�-�:�:�:�*
)�
)�
)�
)�
)r"r�)r+c	�$�t|��rt|��}t|t��}t|��rt	d|�d����t|��}d|i}	|rd|i}	n|�i}	|	r|rd|	d<|st
|��|	�|��t}
tj
|��ri}	nL|r|rtd���t}
n1t|��st}
n|r|rt|��st}
|	�d	|��}|}|�d
}|
d||||d�|	��}t|t"��r"t%||��}|rt'|��nt)||||��|�|s
||j|<|�d��}
|r |sd
|vrt/||dd||
���|_t3|��D�];}t5|��r�	t7||��}n#t8$rY�1wxYwd|i}|
r&t;|
|��r|�|���|rd|i}t|t"��st=|||||��}||j|<n{|}t|t"��r|j}tA|||��}||d<tC|��rt}nt}|d||||d�|��}||j|<t)|||���t|t"��rtE|||����=|S)aCreate 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` will raise a `RuntimeError` if passed some common
    misspellings of the arguments autospec and spec_set. Pass the argument
    `unsafe` with the value True to disable that check.

    `create_autospec` also takes arbitrary keyword arguments that are passed to
    the constructor of the created mock.z'Cannot autospec a Mock object. [object=r%r�r�NTrzJInstance can not be True when create_autospec is mocking an async functionr*r)r�rrr*rr�r/)rar8r�rrpr)r�r*rr)r`r!)#ror>r/r.rr:rr rr2�isdatadescriptorr�r
rkr
rurQrEr�r�rbr�rsr	r�r+r�r1rLr0rCrD�
_must_skiprrg)r�r�rar�r8rrY�is_type�
is_async_funcrBrArrD�wrappedrKr|r
r�r`�child_klasss                    r#r	r	_
s��.��~�~���D�z�z����t�$�$�G�����5�� 4�*.� 4� 4� 4�5�5�	5�"�4�(�(�M��t�n�G����t�$���	
�����,�8�,�'+��#�$��&��f�%�%�%��N�N�6�����E����%�%�%����	�%��	?�� >�?�?�
?����
�t�_�_�%�$���	�%�X�%�&8��&>�&>�%�$���K�K���&�&�E��I����	��5�(��W�	��(�(�&�(�(�D��$�
�&�&�8��d�D�)�)���	$��d�#�#�#����t�W�h�7�7�7���8��(,���u�%��j�j��!�!�G��;�x�;�N�&�$@�$@�+�D�(�T�26��29�;�;�;����T���3&�3&���U���	��	��t�U�+�+�H�H���	�	�	��H�	�����(�#���	*�w�w��.�.�	*��M�M��M�)�)�)��	,� �(�+�F��(�M�2�2�	A��X�x��u�h�G�G�C�),�D���&�&��F��$�
�.�.�
#����"�4���8�8�I�"+�F�;��"�8�,�,�
(�'���'���+�(�V�%�5�*0�(�(� &�(�(�C�*-�D���&��X�s�i�@�@�@�@��c�=�)�)�	&��D�%��%�%�%���Ks�'G8�8
H�Hc�D�t|t��s|t|di��vrdS|j}|jD]f}|j�|t��}|tur�,t|ttf��rdSt|t��r|cSdS|S)z[
    Return whether we should skip the first argument on spec's `entry`
    attribute.
    rrF)r/r>r1r6rqrrrsrrJrIrE)r�rKrMr�r}s     r#rLrL�
s���
�d�D�!�!���G�D�*�b�1�1�1�1��5��~���������#�#�E�7�3�3���W�����f�|�[�9�:�:�	��5�5�
��
�
.�
.�	��N�N�N��5�5��Nr"c��eZdZ		dd�ZdS)rCFNc�Z�||_||_||_||_||_||_dSr<)r��idsr�r�rar*)rWr�r�r�r*rTras       r#rHz_SpecState.__init__s0����	���� ��
���� ��
���	�	�	r")FNNNFr�r!r"r#rCrC
s.������48�/4������r"rCc�|�t|t��rtj|��Stj|��Sr<)r/�bytes�io�BytesIO�StringIO)�	read_datas r#�
_to_streamr[%s4���)�U�#�#�&��z�)�$�$�$��{�9�%�%�%r"rc	�V���	�
��t���}|dg�
�
�fd�}�
�fd�}��
fd��	�
�fd���
�fd�}t�dddl}tt	t|j�����t	t|j��������at�2ddl}tt	t|j
������a	|�tdt�	��}tt�
�����j_
d�j_
d�j_
d�j_
d�j_
|�j_�	���
d<�
d�j_|�j_��j_|�j_�	�
��fd�}||_�|_
|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.
    Nc�Z���jj��jjS�dj|i|��SrA)�	readlinesr��rXrY�_state�handles  ��r#�_readlines_side_effectz)mock_open.<locals>._readlines_side_effect;s7�����(�4��#�0�0�"�v�a�y�"�D�3�F�3�3�3r"c�Z���jj��jjS�dj|i|��SrA)�readr�r_s  ��r#�_read_side_effectz$mock_open.<locals>._read_side_effect@s4����;�#�/��;�+�+��v�a�y�~�t�.�v�.�.�.r"c?�V�K����Ed{V��	�dj|i|��V���NTr)�readline)rXrY�_iter_side_effectr`s  ��r#�_readline_side_effectz(mock_open.<locals>._readline_side_effectEsT�����$�$�&�&�&�&�&�&�&�&�&�	6�$�&��)�$�d�5�f�5�5�5�5�5�	6r"c3�b�K��jj�	�jjV���dD]}|V��dSrg)rhr�)�liner`ras ��r#riz$mock_open.<locals>._iter_side_effectJsU������?�'�3�
3��o�2�2�2�2�
3��1�I�	�	�D��J�J�J�J�	�	r"c�^���jj��jjSt�d��SrA)rhr�r�)r`ras��r#�_next_side_effectz$mock_open.<locals>._next_side_effectQs)����?�'�3��?�/�/��F�1�I���r"r�open)r*r�)r�r�c���t����d<�jj�dkr����d<�d�j_tS)Nrr�)r[rhr�r)rXrYrjr`rarZs  ����r#�
reset_datazmock_open.<locals>.reset_dataqsM����y�)�)��q�	��?�&�&��)�3�3�-�-�/�/�F�1�I�*0��)�F�O�'��r")r[�	file_spec�_iormryr+�
TextIOWrapper�unionrX�	open_specrorrFr��writerdrhr^r�r�r�)rDrZ�
_read_datarbrernrsrqrirjr`ras `      @@@@r#rr,s��������I�&�&�J��$�
�F�4�4�4�4�4�4�
/�/�/�/�/�/�
6�6�6�6�6�6�
���������������
�
�
���S��!2�3�3�4�4�:�:�3�s�3�;�?O�?O�;P�;P�Q�Q�R�R�	����
�
�
���S���]�]�+�+�,�,�	��|��f�9�5�5�5��
�I�
&�
&�
&�F�$*�F��!� $�F�L��#�F�K��#'�F�O� �$(�F��!�/�F�K��%�%�'�'�F�1�I�"(��)�F�O��#9�F�� �"3�F�O��"3�F�O����������"�D���D���Kr"c�&�eZdZdZd�Zdd�Zd�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.
    c��tdi|��S)Nr!)r)rWrYs  r#r1zPropertyMock._get_child_mock�s���"�"�6�"�"�"r"Nc��|��Sr<r!)rWr5�obj_types   r#r�zPropertyMock.__get__�s
���t�v�v�
r"c��||��dSr<r!)rWr5rSs   r#r�zPropertyMock.__set__�s����S�	�	�	�	�	r"r<)rrrr r1r�r�r!r"r#rr~sP��������#�#�#���������r"rc�4�d|_t|��D]�}	t||��}n#t$rY� wxYwt	|t
��s�:t	|j�|��t��r�h|j	|urt|����dS)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+r1rLr/rr�rsrCr�r)rDr�r�s   r#rr�s����D���D�	�	�
�
��	���d�#�#�A�A���	�	�	��H�	�����!�_�-�-�	���a�&�*�*�4�0�0�*�=�=�	�����%�%���G�G�G��
�
s�+�
8�8c��eZdZdZd�Zd�ZdS)r�z8
    Wraps an iterator in an asynchronous iterator.
    c�t�||_tt���}tj|_||jd<dS)Nr�r8)�iteratorrrr2�CO_ITERABLE_COROUTINEr�rr)rWr�rs   r#rHz_AsyncIterator.__init__�s6�� ��
�#�X�6�6�6�	�$�:�	��$-��
�j�!�!�!r"c��^K�	t|j��S#t$rYnwxYwt�r<)r�r�rrr�s r#r�z_AsyncIterator.__anext__�sA����	���
�&�&�&���	�	�	��D�	���� � s��
%�%N)rrrr rHr�r!r"r#r�r��s<��������.�.�.�!�!�!�!�!r"r�r�)NFNNN)FFNN)Nr)��__all__r�rrWr2r�r>�builtinsrTr�typesrrr�
unittest.utilr�	functoolsrr�	threadingrr�rr+r3rr�rr6r:r.rArFrRrbr]rkrorur�r{r�r�rwr�r�rr�MISSINGr��DELETEDrDr�r�rmr�r�r�r�rrMrHrr�r=r�rrrrVr[r_rrbrzr�re�multiple�stopallr�
magic_methods�numericsrdrP�inplace�right�
_non_defaultsr�r�r��_sync_async_magics�
_async_magicsr�r_r�r�r�r�r�r�r�r�r�r�r�r
r�rr�r�r
rrr�rnr�rr	rLrCr>r�rErrrvr[rrrr�r!r"r#�<module>r�s5
����&��������	�	�	�	�����
�
�
�
�
�
�
�
���������'�'�'�'�'�'�2�2�2�2�2�2�2�2�2�2�#�#�#�#�#�#�$�$�$�$�$�$�$�$�������C�C�C�C�C�y�C�C�C�
I�H�c�c�(�m�m�H�H�H�	�
�
���@�@�@����2�2�2������� � � �F	#�	#�	#�	#�
�
�
����&�&�&��������6."�."�."�b>�>�>�6)�)�)�	)�	)�	)�	)�	)�f�	)�	)�	)�����������9�;�;��
�
������������ � � �&*�*�*�*�*��*�*�*�(���6���������
�
�
�
�
�6�
�
�
�N
<�N
<�N
<�N
<�N
<�d�N
<�N
<�N
<�b
�G��o�6�7�7�	�
�
�
�
�
�4�
�
�
� ���g!�g!�g!�g!�g!�D�g!�g!�g!�V6�6�6�6�6�=�/�6�6�6�v���L/�L/�L/�L/�L/�V�L/�L/�L/�`
<�<�<� '�T��t�d���&+������:?C�04�.�.�.�.�d�$�u���4�O�CH�O�O�O�O�O�dV/�V/�V/�V/�V/�&�V/�V/�V/�r���������
��
� �����
����
��"K�	��(�(�7�7�h�n�n�&6�&6�7�7�7�
7�
7�����5�5�H�N�N�$4�$4�5�5�5�5�5�����
�������H�H�m�X�w��
6�7�7�=�=�?�?�����@�?�?��!�]��$�'9�9�
��]�*����.������3�2�0�0�6�6�^�^�	�������������������"��������������� �	���1�1�1�$;�;�;�;�;��;�;�;�>	 �	 �	 �	 �	 �:��	 �	 �	 � � � � � �j� � � � � � � � �
�D� � � �,"�"�"�"�"��"�"�"�$@+�@+�@+�@+�@+�T�@+�@+�@+�F(�(�(�(�(����(�(�(�V
�
�
�
�
�6�
�
�
��d�f�f��$�$�$�$v)�v)�v)�v)�v)�E�v)�v)�v)�r
�u�u�����CG��O�*/�O�O�O�O�O�d���8	�	�	�	�	��	�	�	�	�D�����D�����	�
�
�	��	�&�&�&�O�O�O�O�d�����4����$���0!�!�!�!�!�!�!�!�!�!r"__pycache__/case.cpython-311.opt-2.pyc000064400000175612152401764000013344 0ustar00�

�K��4b���@�	ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
mZmZmZmZdZe��ZdZGd�de��ZGd	�d
e��ZGd�de��ZGd
�de��Zd�Zd�Zd�Zd�ZgZd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'Gd�d��Z(Gd�de(��Z)Gd�d e)��Z*Gd!�d"e)��Z+Gd#�d$ej,��Z-Gd%�d&e��Z.Gd'�d(e.��Z/Gd)�d*e.��Z0dS)+�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��eZdZdS)�SkipTestN��__name__�
__module__�__qualname__���8/opt/alt/python-internal/lib/python3.11/unittest/case.pyrrs�������rrc��eZdZdS)�_ShouldStopNrrrrrr!��������rrc��eZdZdS)�_UnexpectedSuccessNrrrrrr&rrrc�8�eZdZdd�Zejdd���ZdS)�_OutcomeNc�h�d|_||_t|d��|_d|_d|_dS)NF�
addSubTestT)�expecting_failurer�hasattr�result_supports_subtests�success�expectedFailure)�selfrs  r�__init__z_Outcome.__init__-s8��!&������(/���(E�(E��%����#����rFc#�BK�|j}d|_	dV�|r(|jr!|j�|j|d��n�#t$r�t
$r4}d|_t
|j|t|����Yd}~nzd}~wt$rYnktj
��}|jr||_nAd|_|r"|j�|j||��nt|j||��d}YnxYw|jo||_dS#|jo||_wxYw)NTF)rrr�	test_case�KeyboardInterruptr�_addSkip�strr�sys�exc_inforr �	_addError)r!r$�subTest�old_success�er)s      r�testPartExecutorz_Outcome.testPartExecutor4sq�����l�����	8��E�E�E�,�
M�4�<�
M���&�&�y�':�I�t�L�L�L���-!�	�	�	���	5�	5�	5� �D�L��T�[�)�S��V�V�4�4�4�4�4�4�4�4������	�	�	��D�	��|�~�~�H��%�
@�'/��$�$�$����@��K�*�*�9�+>�	�8�T�T�T�T��d�k�9�h�?�?�?��H�H�H����
 �<�7�K�D�L�L�L��4�<�7�K�D�L�7�7�7�7s;�A�+D�C;�*B�?D�
C;�D�A&C;�9D�D�N)F)r
rrr"�
contextlib�contextmanagerr.rrrrr,sL������$�$�$�$���8�8�8���8�8�8rrc��t|dd��}|�|||��dStjdtd��|j|��dS)N�addSkipz4TestResult has no addSkip method, skips not reported�)�getattr�warnings�warn�RuntimeWarning�
addSuccess)rr$�reasonr3s    rr&r&Usf���f�i��.�.�G�����	�6�"�"�"�"�"��
�L�$�a�	)�	)�	)����)�$�$�$�$�$rc��|�C|�Ct|d|j��r|j||��dS|j||��dSdSdS�Nr)�
issubclass�failureException�
addFailure�addError)r�testr)s   rr*r*^si��
��h�2��h�q�k�4�#8�9�9�	,��F��d�H�-�-�-�-�-��F�O�D�(�+�+�+�+�+�	��2�2rc��|Sr/r)�objs r�_idrDes���Jrc���t|��}	|j}|j}n/#t$r"t	d|j�d|j�d���d�wxYw||��}|||ddd��|S)N�'�.z6' object does not support the context manager protocol)�type�	__enter__�__exit__�AttributeError�	TypeErrorrr)�cm�
addcleanup�cls�enter�exitrs      r�_enter_contextrRis����r�(�(�C�O��
���|�����O�O�O��D�C�N�D�D�S�-=�D�D�D�E�E�JN�	O�O�����U�2�Y�Y�F��J�t�R��t�T�*�*�*��Ms	� �,Ac�B�	t�|||f��dSr/)�_module_cleanups�append)�function�args�kwargss   r�addModuleCleanuprYys(��2����X�t�V�4�5�5�5�5�5rc�.�	t|t��Sr/)rRrY)rMs r�enterModuleContextr[~s��0��"�.�/�/�/rc���	g}trZt���\}}}	||i|��n,#t$r}|�|��Yd}~nd}~wwxYwt�Z|r|d�dSr<)rT�pop�	ExceptionrU)�
exceptionsrVrWrX�excs     r�doModuleCleanupsra�s�����J�
�#�!1�!5�!5�!7�!7���$��	#��H�d�%�f�%�%�%�%���	#�	#�	#����c�"�"�"�"�"�"�"�"�����	#����	�#�����m���s�2�
A�A�Ac�f��	�fd�}t�tj��r�}d�||��S|S)Nc���t|t��s!tj|���fd���}|}d|_�|_|S)Nc�"��t����r/�r)rWrXr:s  �r�skip_wrapperz-skip.<locals>.decorator.<locals>.skip_wrapper�s����v�&�&�&rT)�
isinstancerH�	functools�wraps�__unittest_skip__�__unittest_skip_why__)�	test_itemrfr:s  �r�	decoratorzskip.<locals>.decorator�s^����)�T�*�*�	%�
�_�Y�
'�
'�
'�
'�
'�
'�(�
'�
'�$�I�&*�	�#�*0�	�'��r�)rg�types�FunctionType)r:rmrls`  r�skiprq�sX����	�	�	�	�	��&�%�,�-�-�$��	����y��#�#�#��rc�4�	|rt|��StSr/�rqrD��	conditionr:s  r�skipIfrv�s"������F�|�|���Jrc�4�	|st|��StSr/rsrts  r�
skipUnlessrx�s"������F�|�|���Jrc��d|_|S)NT)�__unittest_expecting_failure__)rls rr r �s��/3�I�,��rc���t|t��rt�fd�|D����St|t��ot	|���S)Nc3�8�K�|]}t|���V��dSr/)�_is_subtype)�.0r-�basetypes  �r�	<genexpr>z_is_subtype.<locals>.<genexpr>�s-�����>�>��;�q�(�+�+�>�>�>�>�>�>r)rg�tuple�allrHr=)�expectedrs `rr}r}�sW����(�E�"�"�?��>�>�>�>�X�>�>�>�>�>�>��h��%�%�H�*�X�x�*H�*H�Hrc��eZdZd�Zd�ZdS)�_BaseTestCaseContextc��||_dSr/)r$)r!r$s  rr"z_BaseTestCaseContext.__init__�s
��"����rc�v�|j�|j|��}|j�|���r/)r$�_formatMessage�msgr>)r!�standardMsgr�s   r�
_raiseFailurez"_BaseTestCaseContext._raiseFailure�s1���n�+�+�D�H�k�B�B���n�-�-�c�2�2�2rN)r
rrr"r�rrrr�r��s2������#�#�#�3�3�3�3�3rr�c��eZdZdd�Zd�ZdS)�_AssertRaisesBaseContextNc��t�||��||_||_|�t	j|��}||_d|_d|_dSr/)	r�r"r�r$�re�compile�expected_regex�obj_namer�)r!r�r$r�s    rr"z!_AssertRaisesBaseContext.__init__�sU���%�%�d�I�6�6�6� ��
�"����%��Z��7�7�N�,�����
�����rc���		t|j|j��st|�d|j�����|sM|�dd��|_|r,ttt|�����d����|d}S|^}}	|j	|_
n$#t$rt|��|_
YnwxYw|5||i|��ddd��n#1swxYwYd}dS#d}wxYw)Nz() arg 1 must be r�z1 is an invalid keyword argument for this function)
r}r��
_base_typerL�_base_type_strr]r��next�iterr
r�rKr')r!�namerWrX�callable_objs     r�handlez_AssertRaisesBaseContext.handle�s��	�	��t�}�d�o�>�>�
=��!%���t�':�':�!<�=�=�=��
�!�:�:�e�T�2�2����M�#�7;�D��L�L�7I�7I�7I�7I�%L�M�M�M���D�D�#'��L�4�
2� ,� 5��
�
��!�
2�
2�
2� #�L� 1� 1��
�
�
�
2�����
.�
.���d�-�f�-�-�-�
.�
.�
.�
.�
.�
.�
.�
.�
.�
.�
.����
.�
.�
.�
.��D�D�D��4�D�K�K�K�KsZ�A?C!�C!�
B�C!�B8�5C!�7B8�8C!�=	C�C!�C�C!�C�C!�!C%r/)r
rrr"r�rrrr�r��s7��������������rr�c�D�eZdZ	eZdZd�Zd�Zee	j
��ZdS)�_AssertRaisesContextz-an exception type or tuple of exception typesc��|Sr/r�r!s rrIz_AssertRaisesContext.__enter__�s���rc��|��	|jj}n$#t$rt|j��}YnwxYw|jr/|�d�||j����n=|�d�|����ntj|��t||j��sdS|�
d��|_|j�dS|j}|�
t|����s;|�d�|jt|������dS)Nz{} not raised by {}z
{} not raisedFT�"{}" does not match "{}")r�r
rKr'r�r��format�	traceback�clear_framesr=�with_traceback�	exceptionr��search�pattern)r!�exc_type�	exc_value�tb�exc_namer�s      rrJz_AssertRaisesContext.__exit__�se����
.��=�1����!�
.�
.�
.��t�}�-�-����
.�����}�
E��"�"�#8�#?�#?��@D�
�$O�$O�P�P�P�P��"�"�?�#9�#9�(�#C�#C�D�D�D�D��"�2�&�&�&��(�D�M�2�2�	��5�"�1�1�$�7�7�����&��4��,���$�$�S��^�^�4�4�	>����9�@�@�#�+�S��^�^� =� =�
>�
>�
>��ts��2�2N)r
rr�
BaseExceptionr�r�rIrJ�classmethodro�GenericAlias�__class_getitem__rrrr�r��sP������M��J�D�N�������6$��E�$6�7�7���rr�c�$�eZdZ	eZdZd�Zd�ZdS)�_AssertWarnsContextz(a warning type or tuple of warning typesc�6�ttj�����D]}t	|dd��ri|_�t
jd���|_|j�	��|_t
j
d|j��|S)N�__warningregistry__T)�record�always)�listr(�modules�valuesr5r�r6�catch_warnings�warnings_managerrI�simplefilterr�)r!�vs  rrIz_AssertWarnsContext.__enter__ s����c�k�(�(�*�*�+�+�	+�	+�A��q�/��6�6�
+�(*��%�� (� 7�t� D� D� D����-�7�7�9�9��
���h��
�6�6�6��rc���|j�|||��|�dS	|jj}n$#t$rt|j��}YnwxYwd}|jD]s}|j}t||j��s�|�|}|j	�(|j	�
t|����s�R||_|j|_|j
|_
dS|�@|�d�|j	jt|������|jr0|�d�||j����dS|�d�|����dS)Nr�z{} not triggered by {}z{} not triggered)r�rJr�r
rKr'r6�messagergr�r��warning�filename�linenor�r�r�r�)r!r�r�r�r��first_matching�m�ws        rrJz_AssertWarnsContext.__exit__+s�����&�&�x��B�?�?�?����F�	*��}�-�H�H���	*�	*�	*��4�=�)�)�H�H�H�	*��������
	�
	�A��	�A��a���/�/�
���%�!"���#�/��'�.�.�s�1�v�v�6�6�0���D�L��J�D�M��(�D�K��F�F��%����9�@�@��(�0�#�n�2E�2E� G� G�
H�
H�
H��=�	D����7�>�>�x�?C�}� N� N�
O�
O�
O�
O�
O�
���1�8�8��B�B�C�C�C�C�Cs�/�A�AN)r
rr�Warningr�r�rIrJrrrr�r�sD������L��J�?�N�	�	�	� D� D� D� D� Drr�c��eZdZd�ZdS)�_OrderedChainMapc#�~K�t��}|jD]$}|D]}||vr|�|��|V�� �%dSr/)�set�maps�add)r!�seen�mapping�ks    r�__iter__z_OrderedChainMap.__iter__Os`�����u�u���y�	�	�G��
�
���D�=�=��H�H�Q�K�K�K��G�G�G��
�	�	rN)r
rrr�rrrr�r�Ns#����������rr�c���eZdZ	eZdZdZdZ�fd�ZdNd�Z	d�Z
d�Zd	�Ze
d
���Ze
d���Zd�Zd
�Ze
d���Ze
d���Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zejefd���Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%dOd �Z&d!�Z'e
d"���Z(d#�Z)d$�Z*d%�Z+dOd&�Z,dOd'�Z-dOd(�Z.d)�Z/d*�Z0d+�Z1dPd,�Z2dPd-�Z3d.�Z4dOd/�Z5dOd0�Z6dOd1�Z7		dQd2�Z8		dQd3�Z9dPd4�Z:d5�Z;dOd6�Z<dOd7�Z=dOd8�Z>dOd9�Z?dOd:�Z@dOd;�ZAdOd<�ZBdOd=�ZCdOd>�ZDdOd?�ZEdOd@�ZFdOdA�ZGdOdB�ZHdOdC�ZIdOdD�ZJdOdE�ZKdOdF�ZLdOdG�ZMdOdH�ZNdI�ZOdJ�ZPdOdK�ZQdOdL�ZRdM�ZSeSe6��xZTZUeSe7��xZVZWeSe8��xZXZYeSe9��xZZZ[eSe.��xZ\Z]eSe0��Z^eSe-��Z_eSeO��Z`eSeQ��ZaeSeR��Zb�xZcS)R�TestCaseTi�ic�V��d|_g|_t��j|i|��dS)NF)�_classSetupFailed�_class_cleanups�super�__init_subclass__)rOrWrX�	__class__s   �rr�zTestCase.__init_subclass__�s5��� %��� ���!����!�4�2�6�2�2�2�2�2r�runTestc�<�	||_d|_d|_	t||��}|j|_n0#t
$r#|dkrt
d|j�d|�����YnwxYwg|_d|_	i|_
|�td��|�td��|�td��|�td��|�t d��|�t"d	��dS)
NzNo testr�zno such test method in �: �assertDictEqual�assertListEqual�assertTupleEqual�assertSetEqual�assertMultiLineEqual)�_testMethodName�_outcome�_testMethodDocr5�__doc__rK�
ValueErrorr��	_cleanups�_subtest�_type_equality_funcs�addTypeEqualityFunc�dictr�r�r��	frozensetr')r!�
methodName�
testMethods   rr"zTestCase.__init__�sF��	� *�����
�'���		5� ��z�2�2�J�#-�"4�D�����	4�	4�	4��Y�&�&�!�j��~�~�~�z�z�"3�4�4�4�'�&�	4���������
�
%'��!�� � ��'8�9�9�9�� � ��'8�9�9�9�� � ��(:�;�;�;�� � ��&6�7�7�7�� � ��,<�=�=�=�� � ��&<�=�=�=�=�=s�5�*A"�!A"c��	||j|<dSr/)r�)r!�typeobjrVs   rr�zTestCase.addTypeEqualityFunc�s��	�.6��!�'�*�*�*rc�B�	|j�|||f��dSr/)r�rU�r!rVrWrXs    r�
addCleanupzTestCase.addCleanup�s-��	K�
	
����x��v�6�7�7�7�7�7rc�.�	t||j��Sr/)rRr�)r!rMs  r�enterContextzTestCase.enterContext�s��	�
�b�$�/�2�2�2rc�B�	|j�|||f��dSr/)r�rU�rOrVrWrXs    r�addClassCleanupzTestCase.addClassCleanup�s+��	4���"�"�H�d�F�#;�<�<�<�<�<rc�.�	t||j��Sr/)rRr�)rOrMs  r�enterClassContextzTestCase.enterClassContext�s��3��b�#�"5�6�6�6rc��	dSr/rr�s r�setUpzTestCase.setUp��
��K��rc��	dSr/rr�s r�tearDownzTestCase.tearDown�r�rc��dSr/r�rOs r�
setUpClasszTestCase.setUpClass�s��U�Urc��dSr/rr�s r�
tearDownClasszTestCase.tearDownClass�s��`�`rc��dS)Nrrr�s r�countTestCaseszTestCase.countTestCases�s���qrc�(�tj��Sr/)r�
TestResultr�s r�defaultTestResultzTestCase.defaultTestResult�s��� �"�"�"rc��	|j}|r?|����d��d���ndS�N�
r)r��strip�split�r!�docs  r�shortDescriptionzTestCase.shortDescription�sH��	��!��58�B�s�y�y�{�{� � ��&�&�q�)�/�/�1�1�1�d�Brc�>�t|j���d|j��S)NrG�rr�r�r�s r�idzTestCase.id�s#��"�4�>�2�2�2�2�D�4H�4H�I�Irc�l�t|��t|��urtS|j|jkSr/)rH�NotImplementedr��r!�others  r�__eq__zTestCase.__eq__�s0����:�:�T�%�[�[�(�(�!�!��#�u�'<�<�<rc�H�tt|��|jf��Sr/)�hashrHr�r�s r�__hash__zTestCase.__hash__�s���T�$�Z�Z��!5�6�7�7�7rc�P�|j�dt|j���d|j�d�S)N� (rG�))r�rr�r�s r�__str__zTestCase.__str__s1��#�3�3�3�X�d�n�5M�5M�5M�5M�t�Oc�Oc�Oc�d�drc�B�dt|j���d|j�d�S)N�<z testMethod=�>rr�s r�__repr__zTestCase.__repr__s.������(�(�(�(�$�*>�*>�*>�@�	@rc+��K�	|j�|jjsdV�dS|j}|�t|��}n|j�|��}t
|||��|_	|j�|jd���5dV�ddd��n#1swxYwY|jjs|jj	}|�|j
rt�n|jjrt�||_dS#||_wxYw)NT)r+)
r�rr�r��params�	new_child�_SubTestr.rr�failfastrr )r!r�r$�parent�
params_maprs      rr+zTestCase.subTestsN����	��=� ��
�(N� ��E�E�E��F�����>�)�&�1�1�J�J���0�0��8�8�J� ��s�J�7�7��
�	#���/�/��
�t�/�L�L�
�
�����
�
�
�
�
�
�
�
�
�
�
����
�
�
�
��=�(�
"���-���%�&�/�%�%�%����.�
"�"�!�"�D�M�M�M��F�D�M�"�"�"�"s0�'!C)�B�
C)�B�C)� B�!?C)�)	C2c��	|j}|||��dS#t$r.tjdt��|j|��YdSwxYw)Nz@TestResult has no addExpectedFailure method, reporting as passes)�addExpectedFailurerKr6r7r8r9)r!rr)r+s    r�_addExpectedFailurezTestCase._addExpectedFailure&s~��	/�!'�!:��
��t�X�.�.�.�.�.���	$�	$�	$��M�\�(�
*�
*�
*��F��d�#�#�#�#�#�#�	$���s��4A�Ac��	|j}||��dS#t$rXtjdt��	t
d�#t
$r'|j|tj����YYdSwxYwwxYw)NzCTestResult has no addUnexpectedSuccess method, reporting as failure)	�addUnexpectedSuccessrKr6r7r8rr?r(r))r!rr.s   r�_addUnexpectedSuccesszTestCase._addUnexpectedSuccess0s���	'�#)�#>� �
!� ��&�&�&�&�&���	8�	8�	8��M�_�(�
*�
*�
*�
8�(�d�2��%�
8�
8�
8�!��!�$�����7�7�7�7�7�7�7�
8����	8���s&��$A8�A�,A4�/A8�3A4�4A8c�.�|���dSr/)r�r�s r�
_callSetUpzTestCase._callSetUp?s���
�
�����rc�^�|���"tjd|�d�td���dSdS)NzFIt is deprecated to return a value that is not None from a test case (r�)�
stacklevel)r6r7�DeprecationWarning)r!�methods  r�_callTestMethodzTestCase._callTestMethodBs\���6�8�8���M�2�(.�2�2�2�3E�RS�
U�
U�
U�
U�
U�
U� �rc�.�|���dSr/)r�r�s r�
_callTearDownzTestCase._callTearDownGs���
�
�����rc��||i|��dSr/rr�s    r�_callCleanupzTestCase._callCleanupJs����$�!�&�!�!�!�!�!rNc��|�C|���}t|dd��}t|dd��}|�
|��nd}|j|��	t||j��}t|jdd��st|dd��rWt|jdd��pt|dd��}t|||��||j|��|�|��SSt|dd��pt|dd��}t|��}	||_|�	|��5|�
��ddd��n#1swxYwY|jr�||_|�	|��5|�
|��ddd��n#1swxYwYd|_|�	|��5|���ddd��n#1swxYwY|���|jrK|r9|jr|�||j��n&|�|��n|j|��|d|_d}d|_|j|��|�|��SS#d|_d}d|_wxYw#|j|��|�|��wwxYw)N�startTestRun�stopTestRunrjFrkrnrz)rr5�	startTestr�r�r&�stopTestrr�r.r1rrr7r9�
doCleanupsr r,r/r9)r!rr=r>r��skip_whyr�outcomes        r�runzTestCase.runMs����>��+�+�-�-�F�"�6�>�4�@�@�L�!�&�-��>�>�K��'��������K��������2	� ��t�';�<�<�J����(;�U�C�C�
��
�$7��?�?�
�$�D�N�4K�R�P�P�P�&�z�3J�B�O�O�����x�0�0�0��P
�F�O�D�!�!�!��&���
�
�
�
�'�M��>��F�F�M��
�$D�e�L�L�
��v�&�&�G�
%� '��
��-�-�d�3�3�&�&��O�O�%�%�%�&�&�&�&�&�&�&�&�&�&�&����&�&�&�&��?�-�0A�G�-� �1�1�$�7�7�9�9��,�,�Z�8�8�8�9�9�9�9�9�9�9�9�9�9�9����9�9�9�9�05�G�-� �1�1�$�7�7�-�-��*�*�,�,�,�-�-�-�-�-�-�-�-�-�-�-����-�-�-�-����!�!�!��?�0�(�0�"�2�?� �4�4�V�W�=T�U�U�U�U� �6�6�v�>�>�>�>�)��)�$�/�/�/��+/��'���!%��
�
�F�O�D�!�!�!��&���
�
�
�
�'��+/��'���!%��
�$�$�$�$��
�F�O�D�!�!�!��&���
�
�
�
�'���s��A5J(�,1J(�J�:E�J�E�J�"E�#&J�	F+�J�+F/�/J�2F/�3J�G3�'J�3G7�7J�:G7�;A*J�%J(�J%�%J(�(Kc��	|jp
t��}|jrb|j���\}}}|�|��5|j|g|�Ri|��ddd��n#1swxYwY|j�b|jSr/)r�rr�r]r.r;r)r!rCrVrWrXs     rrAzTestCase.doCleanups�s���	��-�-�8�:�:���n�	=�%)�^�%7�%7�%9�%9�"�H�d�F��)�)�$�/�/�
=�
=�!��!�(�<�T�<�<�<�V�<�<�<�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=����
=�
=�
=�
=��n�	=���s�A.�.A2�5A2c��	g|_|jrk|j���\}}}	||i|��n;#t$r.|j�tj����YnwxYw|j�idSdSr/)�tearDown_exceptionsr�r]r^rUr(r)r�s    r�doClassCleanupszTestCase.doClassCleanups�s���	�"$����!�	?�%(�%8�%<�%<�%>�%>�"�H�d�F�
?���$�)�&�)�)�)�)���
?�
?�
?��'�.�.�s�|�~�~�>�>�>�>�>�
?����	�!�	?�	?�	?�	?�	?s�7�5A/�.A/c��|j|i|��Sr/)rD)r!rW�kwdss   r�__call__zTestCase.__call__�s���t�x��&��&�&�&rc���	t||j��}t|jdd��st|dd��r6t|jdd��pt|dd��}t|���|���|�|��|���|jr7|j���\}}}|j	|g|�Ri|��|j�5dSdS)NrjFrkrn)
r5r�r�rr1r7r9r�r]r;)r!r�rBrVrWrXs      r�debugzTestCase.debug�s��D��T�4�#7�8�8�
��D�N�$7��?�?�	%��J� 3�U�;�;�	%� ���0G��L�L�L�"�:�/F��K�K�
��8�$�$�$����������Z�(�(�(��������n�	9�%)�^�%7�%7�%9�%9�"�H�d�F��D��h�8��8�8�8��8�8�8��n�	9�	9�	9�	9�	9rc�"�	t|���r/re)r!r:s  r�skipTestzTestCase.skipTest�s����v���rc�.�	|�|���r/)r>)r!r�s  r�failz
TestCase.fail�s��7��#�#�C�(�(�(rc��	|r;|�|dt|��z��}|�|���dS)Nz%s is not false�r�rr>�r!�exprr�s   r�assertFalsezTestCase.assertFalse�sL��1��	-��%�%�c�+<�y����+N�O�O�C��'�'��,�,�,�	-�	-rc��	|s;|�|dt|��z��}|�|���dS)Nz%s is not truerSrTs   r�
assertTruezTestCase.assertTrue�sL��0��	-��%�%�c�+;�i��o�o�+M�N�N�C��'�'��,�,�,�	-�	-rc��	|js|p|S|�|S	|�d|��S#t$r$t|���dt|����cYSwxYw)Nz : )�longMessage�UnicodeDecodeErrorr)r!r�r�s   rr�zTestCase._formatMessage�s���	���	&��%�+�%��;���	I�!,���S�S�1�1��!�	I�	I�	I�!*�;�!7�!7�!7�!7��3����H�H�H�H�	I���s��+A�Ac�f�	t||��}	|�d||��d}S#d}wxYw)N�assertRaises�r�r�)r!�expected_exceptionrWrX�contexts     rr]zTestCase.assertRaises�sG��	�2'�'9�4�@�@��	��>�>�.�$��?�?��G�G��d�G�N�N�N�Ns�,�0c�R�	t||��}|�d||��S)N�assertWarns�r�r�)r!�expected_warningrWrXr`s     rrbzTestCase.assertWarnss/��	�6&�&6��=�=���~�~�m�T�6�:�:�:rc�.�	ddlm}||||d���S)Nr��_AssertLogsContextF��no_logs��_logrg�r!�logger�levelrgs    r�
assertLogszTestCase.assertLogs"s5��	�(	-�,�,�,�,�,�!�!�$���u�E�E�E�Erc�.�	ddlm}||||d���S)NrrfTrhrjrls    r�assertNoLogszTestCase.assertNoLogs:s5��	�
	-�,�,�,�,�,�!�!�$���t�D�D�D�Drc���	t|��t|��urP|j�t|����}|�'t|t��rt||��}|S|jSr/)rHr��getrgr'r5�_baseAssertEqual)r!�first�second�asserters    r�_getAssertEqualityFunczTestCase._getAssertEqualityFuncCsq��	� ��;�;�$�v�,�,�&�&��0�4�4�T�%�[�[�A�A�H��#��h��,�,�7�&�t�X�6�6�H����$�$rc��	||ks>dt||��z}|�||��}|�|���dS)N�%s != %s)r	r�r>)r!rurvr�r�s     rrtzTestCase._baseAssertEqual]sS��H�����$�';�E�6�'J�'J�J�K��%�%�c�;�7�7�C��'�'��,�,�,��rc�P�	|�||��}||||���dS)N)r�)rx)r!rurvr��assertion_funcs     r�assertEqualzTestCase.assertEqualds;��	��4�4�U�F�C�C����u�f�#�.�.�.�.�.�.rc��	||ksJ|�|t|���dt|������}|�|���dS)N� == rS)r!rurvr�s    r�assertNotEqualzTestCase.assertNotEqualksj��	������%�%�c��5�9I�9I�9I�9I�:C�F�:K�:K�:K�,M�N�N�C��'�'��,�,�,��rc	���	||krdS|�|�td���t||z
��}|�K||krdSt|���dt|���dt|���dt|���d�}nO|�d}t||��dkrdSt|���dt|���d|�dt|���d�}|�||��}|�|���)	N� specify delta or places not bothz != � within � delta (� difference)�rz	 places (�rL�absr�roundr�r>�r!rurv�placesr��delta�diffr�s        r�assertAlmostEqualzTestCase.assertAlmostEqualts1��	��F�?�?��F����!3��>�?�?�?��5�6�>�"�"�����u�}�}����%� � � � ��&�!�!�!�!��%� � � � ��$�����	!�K�K��~����T�6�"�"�a�'�'����%� � � � ��&�!�!�!�!�����$�����	!�K�
�!�!�#�{�3�3���#�#�C�(�(�(rc	���	|�|�td���t||z
��}|�Q||ks||krdSt|���dt|���dt|���dt|���d�}nE|�d}||kst||��dkrdSt|���dt|���d|�d�}|�||��}|�|���)	Nr�rr�r�r�r�rz placesr�r�s        r�assertNotAlmostEqualzTestCase.assertNotAlmostEqual�s#��		����!3��>�?�?�?��5�6�>�"�"�����V�O�O��������%� � � � ��&�!�!�!�!��%� � � � ��$�����	!�K�K��~����V�O�O��t�V�)<�)<��)A�)A���9B�5�9I�9I�9I�9I�9B�6�9J�9J�9J�9J�9?���A�K��!�!�#�{�3�3���#�#�C�(�(�(rc	��	|�x|j}t||��s(|�d|�dt|�������t||��s(|�d|�dt|�������nd}d}	t	|��}n#t
tf$rd|z}YnwxYw|�-	t	|��}n#t
tf$rd|z}YnwxYw|���||krdSd|���ft||��zz}tt||����D]�}		||	}
n(#t
ttf$r|d|	|fzz
}Yn�wxYw	||	}n(#t
ttf$r|d	|	|fzz
}YnQwxYw|
|kr|d
|	ft|
|��zzz
}n+��||kr$|�"t|��t|��krdS||krS|d|||z
fzz
}	|d|t||��fzz
}n�#t
ttf$r
|d
||fzz
}Yn]wxYw||krS|d|||z
fzz
}	|d|t||��fzz
}n'#t
ttf$r
|d||fzz
}YnwxYw|}dd�
tjt!j|�����t!j|���������z}
|�||
��}|�||��}|�|��dS)NzFirst sequence is not a r�zSecond sequence is not a �sequencez(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
rgr>r�lenrL�NotImplementedError�
capitalizer	�range�min�
IndexErrorrH�join�difflib�ndiff�pprint�pformat�
splitlines�_truncateMessager�rQ)r!�seq1�seq2r��seq_type�
seq_type_name�	differing�len1�len2�i�item1�item2r��diffMsgs              r�assertSequenceEqualzTestCase.assertSequenceEqual�s���	���$�-�M��d�H�-�-�
L��+�+�+�+8�=�=�)�D�/�/�/�-K�L�L�L��d�H�-�-�
L��+�+�+�+8�=�=�)�D�/�/�/�-K�L�L�L�
L�'�M��	�	#��t�9�9�D�D���.�/�	#�	#�	#�B�!�#�I�I�I�	#������
'��4�y�y�����2�3�
'�
'�
'�G�%�'�	�	�	�
'�������t�|�|���0�"�-�-�/�/�1�(��t�4�4�5�6�I��3�t�T�?�?�+�+�
�
��� ��G�E�E��!�:�/B�C�����"N�"#�]�!3�#4�5�I��E�E�����
� ��G�E�E��!�:�/B�C�����"O�"#�]�!3�#4�5�I��E�E�����
�E�>�>��"K�#$�$�)=�e�U�)K�)K�"K�#M�N�I��E�"�
�D�L�L�X�%5���J�J�$�t�*�*�,�,��F��d�{�{��+�.;�T�D�[�-I�J�K�	�K��"A�#'��4��:�)>�)>�"?�#@�A�I�I��!�:�/B�C�K�K�K��#2�59�=�4I�#J�K�I�I�I�K���������+�.;�T�D�[�-I�J�K�	�L��"A�#'��4��:�)>�)>�"?�#@�A�I�I��!�:�/B�C�L�L�L��#3�6:�M�5J�#K�L�I�I�I�L���� �������M�&�.��.�.�9�9�;�;� �.��.�.�9�9�;�;�
=�
=�>�>�>���+�+�K��A�A���!�!�#�{�3�3���	�	�#�����sl�B�B*�)B*�0C�C�C�0D9�9!E�E�"E+�+!F�F�4H�!H6�5H6�
I+�+!J�Jc�x�|j}|�t|��|kr||zS|tt|��zzSr/)�maxDiffr��DIFF_OMITTED)r!r�r��max_diffs    rr�zTestCase._truncateMessage's?���<����s�4�y�y�H�4�4��T�>�!��,��T���2�3�3rc�D�	|�|||t���dS�N)r�)r�r�)r!�list1�list2r�s    rr�zTestCase.assertListEqual-s,��	�	
� � ���s�T� �B�B�B�B�Brc�D�	|�|||t���dSr�)r�r�)r!�tuple1�tuple2r�s    rr�zTestCase.assertTupleEqual9s,��	�	
� � ����u� �E�E�E�E�Erc�L�		|�|��}nY#t$r"}|�d|z��Yd}~n2d}~wt$r"}|�d|z��Yd}~nd}~wwxYw	|�|��}nY#t$r"}|�d|z��Yd}~n2d}~wt$r"}|�d|z��Yd}~nd}~wwxYw|s|sdSg}|r<|�d��|D]$}|�t|�����%|r<|�d��|D]$}|�t|�����%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
)�
differencerLrQrKrU�reprr�r�)
r!�set1�set2r��difference1r-�difference2�lines�itemr�s
          rr�zTestCase.assertSetEqualDs+��	�	P��/�/�$�/�/�K�K���	M�	M�	M��I�I�G�!�K�L�L�L�L�L�L�L�L������	P�	P�	P��I�I�J�Q�N�O�O�O�O�O�O�O�O�����	P����	Q��/�/�$�/�/�K�K���	M�	M�	M��I�I�G�!�K�L�L�L�L�L�L�L�L������	Q�	Q�	Q��I�I�K�a�O�P�P�P�P�P�P�P�P�����	Q�����	�{�	��F����	)��L�L�E�F�F�F�#�
)�
)�����T�$�Z�Z�(�(�(�(��	)��L�L�E�F�F�F�#�
)�
)�����T�$�Z�Z�(�(�(�(��i�i��&�&���	�	�$�%�%�c�;�7�7�8�8�8�8�8sD��
A/�A�
A/�
A*�*A/�3B	�	
C�B0�0
C�=C�Cc��	||vrLt|���dt|����}|�|�||����dSdS)N� not found in �rrQr��r!�member�	containerr�r�s     r�assertInzTestCase.assertInosg��R���"�"�2;�F�2C�2C�2C�2C�2;�I�2F�2F�2F�H�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<�#�"rc��	||vrLt|���dt|����}|�|�||����dSdS)Nz unexpectedly found in r�r�s     r�assertNotInzTestCase.assertNotInvsg��V��Y���;D�V�;L�;L�;L�;L�8A�)�8L�8L�8L�N�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��rc��	||urLt|���dt|����}|�|�||����dSdS)Nz is not r��r!�expr1�expr2r�r�s     r�assertIszTestCase.assertIs}sf��R�����,5�e�,<�,<�,<�,<�-6�u�-=�-=�-=�?�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��rc��	||ur=dt|����}|�|�||����dSdS)Nzunexpectedly identical: r�r�s     r�assertIsNotzTestCase.assertIsNot�sR��V��E�>�>�>�:C�E�:J�:J�:J�L�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��>rc	��|�|td��|�|td��||kr�dt||��z}dd�t	jt
j|�����t
j|���������z}|�	||��}|�
|�||����dSdS)Nz"First argument is not a dictionaryz#Second argument is not a dictionaryrzr
)�assertIsInstancer�r	r�r�r�r�r�r�r�rQr�)r!�d1�d2r�r�r�s      rr�zTestCase.assertDictEqual�s������b�$�(L�M�M�M����b�$�(M�N�N�N�
��8�8�$�';�B��'C�'C�C�K��4�9�9�W�]�!�>�"�-�-�8�8�:�:�!�>�"�-�-�8�8�:�:�&<�&<�=�=�=�D��/�/��T�B�B�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<�
�8rc�J�	tjdt��g}g}|���D]u\}}||vr|�|���|||krJ|�t|���dt|���dt||�������v|s|sdSd}|r"dd�d�|D����z}|r"|r|dz
}|d	d�|��zz
}|�|�||����dS)
Nz&assertDictContainsSubset is deprecatedz, expected: z
, actual: rnzMissing: %s�,c3�4K�|]}t|��V��dSr/)r)r~r�s  rr�z4TestCase.assertDictContainsSubset.<locals>.<genexpr>�s8����3=�3=�A�9�Q�<�<�3=�3=�3=�3=�3=�3=rz; zMismatched values: %s)	r6r7r5�itemsrUrr�rQr�)	r!�subset�
dictionaryr��missing�
mismatched�key�valuer�s	         r�assertDictContainsSubsetz!TestCase.assertDictContainsSubset�s}��@��
�>�(�	*�	*�	*����
� �,�,�.�.�	@�	@�J�C���*�$�$����s�#�#�#�#��*�S�/�)�)��!�!�#,�S�>�>�>�>�9�U�3C�3C�3C�3C�#,�Z��_�#=�#=�#=�#?�@�@�@���	�:�	��F����	=�'�#�(�(�3=�3=�4;�3=�3=�3=�+=�+=�=�K��	J��
$��t�#���2�S�X�X�j�5I�5I�I�I�K��	�	�$�%�%�c�;�7�7�8�8�8�8�8rc���	t|��t|��}}	tj|��}tj|��}||krdSt||��}n #t$rt||��}YnwxYw|rfd}d�|D��}d�|��}	|�||	��}|�||��}|�	|��dSdS)NzElement counts were not equal:
c��g|]}d|z��S)z First has %d, Second has %d:  %rr)r~r�s  r�
<listcomp>z-TestCase.assertCountEqual.<locals>.<listcomp>�s��W�W�W�4�7�$�>�W�W�Wrr
)
r��collections�CounterrrLrr�r�r�rQ)
r!rurvr��	first_seq�
second_seq�differencesr�r�r�s
          r�assertCountEqualzTestCase.assertCountEqual�s��
	�!%�U���T�&�\�\�:�	�		F��'�	�2�2�E� �(��4�4�F�
������.�y�*�E�E�K�K��
�	I�	I�	I�1�)�Z�H�H�K�K�K�	I�����	�<�K�W�W�;�W�W�W�E��i�i��&�&�G��/�/��W�E�E�K��%�%�c�;�7�7�C��I�I�c�N�N�N�N�N�
	�	s�(A"�"A?�>A?c���	|�|td��|�|td��||k�r*t|��|jkst|��|jkr|�|||��|�d���}|�d���}t|��dkr%|�d��|kr|dzg}|dzg}dt||��z}dd	�tj
||����z}|�||��}|�|�
||����dSdS)
NzFirst argument is not a stringzSecond argument is not a stringT)�keependsrz
r
rzrn)r�r'r��_diffThresholdrtr�rr	r�r�r�r�rQr�)r!rurvr��
firstlines�secondlinesr�r�s        rr�zTestCase.assertMultiLineEqual�sd��;����e�S�*J�K�K�K����f�c�+L�M�M�M��F�?�?��E�
�
�T�0�0�0��F���d�1�1�1��%�%�e�V�S�9�9�9��)�)�4�)�8�8�J� �+�+�T�+�:�:�K��:���!�#�#����F�(;�(;�u�(D�(D�#�d�l�^�
�%��}�o��$�';�E�6�'J�'J�J�K��"�'�'�'�-�
�K�"H�"H�I�I�I�D��/�/��T�B�B�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��?rc��	||ksLt|���dt|����}|�|�||����dSdS)Nz not less than r��r!�a�br�r�s     r�
assertLesszTestCase.assertLess�sY��Q��1�u�u�3<�Q�<�<�<�<��1����N�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��urc��	||ksLt|���dt|����}|�|�||����dSdS)Nz not less than or equal to r�r�s     r�assertLessEqualzTestCase.assertLessEqual�sZ��R��A�v�v�?H��|�|�|�|�Y�WX�\�\�\�Z�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��vrc��	||ksLt|���dt|����}|�|�||����dSdS)Nz not greater than r�r�s     r�
assertGreaterzTestCase.assertGreater�sY��Q��1�u�u�6?��l�l�l�l�I�a�L�L�L�Q�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��urc��	||ksLt|���dt|����}|�|�||����dSdS)Nz not greater than or equal to r�r�s     r�assertGreaterEqualzTestCase.assertGreaterEqual�s^��R��A�v�v�BK�A�,�,�,�,�PY�Z[�P\�P\�P\�]�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��vrc��	|�=t|���d�}|�|�||����dSdS)Nz is not Noner��r!rCr�r�s    r�assertIsNonezTestCase.assertIsNone�sK��Q��?�.7��n�n�n�n�>�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��?rc�f�	|�-d}|�|�||����dSdS)Nzunexpectedly None)rQr�r�s    r�assertIsNotNonezTestCase.assertIsNotNones>��6��;�-�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<��;rc��	t||��s?t|���d|��}|�|�||����dSdS)Nz is not an instance of �rgrrQr��r!rCrOr�r�s     rr�zTestCase.assertIsInstancesa��	��#�s�#�#�	=�;D�S�>�>�>�>�3�3�O�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<�	=�	=rc��	t||��r?t|���d|��}|�|�||����dSdS)Nz is an instance of r�r�s     r�assertNotIsInstancezTestCase.assertNotIsInstances_��:��c�3���	=�7@��~�~�~�~�s�s�K�K��I�I�d�)�)�#�{�;�;�<�<�<�<�<�	=�	=rc�T�	t|||��}|�d||��S)N�assertRaisesRegexr^)r!r_r�rWrXr`s      rrzTestCase.assertRaisesRegexs2��
	�'�'9�4��P�P���~�~�1�4��@�@�@rc�T�	t|||��}|�d||��S)N�assertWarnsRegexrc)r!rdr�rWrXr`s      rrzTestCase.assertWarnsRegex(s2��
	�&�&6��n�M�M���~�~�0�$��?�?�?rc��	t|ttf��rtj|��}|�|��s8d|j�d|��}|�||��}|�|���dS)NzRegex didn't match: r�)	rgr'�bytesr�r�r�r�r�r>)r!�textr�r�r�s     r�assertRegexzTestCase.assertRegex;s���K��n�s�E�l�3�3�	8��Z��7�7�N��$�$�T�*�*�	-�	-��&�&�&���.�K��%�%�c�;�7�7�C��'�'��,�,�,�	-�	-rc�d�	t|ttf��rtj|��}|�|��}|rgd||���|�����d|j�d|��}|�	||��}|�
|���dS)NzRegex matched: z	 matches z in )rgr'rr�r�r��start�endr�r�r>)r!r�unexpected_regexr��matchr�s      r�assertNotRegexzTestCase.assertNotRegexGs���G��&��e��5�5�	<�!�z�*:�;�;�� �'�'��-�-���	-�	-��U�[�[�]�]�U�Y�Y�[�[�0�1�1�1� �(�(�(����K�
�%�%�c�;�7�7�C��'�'��,�,�,�	-�	-rc����fd�}|S)Nc�z��tjd��j��td���|i|��S)NzPlease use {0} instead.r4)r6r7r�r
r5)rWrX�
original_funcs  �r�deprecated_funcz,TestCase._deprecate.<locals>.deprecated_funcWsG����M�)�0�0��1G�H�H�"�A�
'�
'�
'�!�=�$�1�&�1�1�1rr)rrs` r�
_deprecatezTestCase._deprecateVs$���	2�	2�	2�	2�	2�
�r)r�r/)NN�NNN)dr
rr�AssertionErrorr>rZr�r�r�r"r�r�r�r�r�r�r�r�rrrrrrrrrr"r0r1�_subtest_msg_sentinelr+r,r/r1r7r9r;rDrArHrKrMrOrQrVrXr�r]rbrorqrxrtr}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr	rr�failUnlessEqual�assertEquals�failIfEqual�assertNotEquals�failUnlessAlmostEqual�assertAlmostEquals�failIfAlmostEqual�assertNotAlmostEquals�
failUnless�assert_�failUnlessRaises�failIf�assertRaisesRegexp�assertRegexpMatches�assertNotRegexpMatches�
__classcell__�r�s@rr�r�Xs���������@&���K��G��N�3�3�3�3�3�>�>�>�>�@
6�
6�
6�8�8�8�3�3�3��=�=��[�=�
�7�7��[�7�
�
�
�
�
�
��V�V��[�V��a�a��[�a����#�#�#�C�C�C�J�J�J�=�=�=�8�8�8�e�e�e�@�@�@���/�#�#�#���#�</�/�/�
'�
'�
'����U�U�U�
���"�"�"�=�=�=�=�~����	?�	?��[�	?�'�'�'�9�9�9�"���)�)�)�)�-�-�-�-�-�-�-�-�I�I�I�*���B;�;�;�>F�F�F�F�0E�E�E�E�%�%�%�4-�-�-�-�/�/�/�/�-�-�-�-�AE� $�+)�+)�+)�+)�ZDH�#'�!)�!)�!)�!)�Fa�a�a�a�F4�4�4�
C�
C�
C�
C�	F�	F�	F�	F�)9�)9�)9�)9�V=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�
=�
=�
=�
=�9�9�9�9�:����@=�=�=�=�(=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�A�A�A� @�@�@�&
-�
-�
-�
-�-�-�-�-����&0�Z��%<�%<�<�O�l�$.�J�~�$>�$>�>�K�/�1;��<M�1N�1N�N��.�0:�
�;O�0P�0P�P��-�%�:�j�1�1�1�J��!�z�,�/�/��
�Z��
$�
$�F�#��$5�6�6��$�*�[�1�1��'�Z��7�7�����rr�c�X��eZdZ	d�fd�	Zd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Z�xZ
S)
�FunctionTestCaseNc���tt|�����||_||_||_||_dSr/)r�r*r"�
_setUpFunc�
_tearDownFunc�	_testFunc�_description)r!�testFuncr�r��descriptionr�s     �rr"zFunctionTestCase.__init__usD���
���%�%�.�.�0�0�0����%���!���'����rc�@�|j�|���dSdSr/)r,r�s rr�zFunctionTestCase.setUp|s(���?�&��O�O������'�&rc�@�|j�|���dSdSr/)r-r�s rr�zFunctionTestCase.tearDown�s+����)���� � � � � �*�)rc�.�|���dSr/)r.r�s rr�zFunctionTestCase.runTest�s���������rc��|jjSr/)r.r
r�s rrzFunctionTestCase.id�s
���~�&�&rc��t||j��stS|j|jko/|j|jko|j|jko|j|jkSr/)rgr�rr,r-r.r/rs  rrzFunctionTestCase.__eq__�sg���%���0�0�	"�!�!���%�"2�2�7��!�U�%8�8�7��~���0�7�� �E�$6�6�	7rc�l�tt|��|j|j|j|jf��Sr/)rrHr,r-r.r/r�s rrzFunctionTestCase.__hash__�s4���T�$�Z�Z���$�2D��^�T�%6�8�9�9�	9rc�J�t|j���d|jj�d�S)Nrr)rr�r.r
r�s rrzFunctionTestCase.__str__�s-��$�T�^�4�4�4�4� �N�3�3�3�5�	5rc�B�dt|j���d|j�d�S)Nr z tec=r!)rr�r.r�s rr"zFunctionTestCase.__repr__�s*��� (��� 8� 8� 8� 8�%)�^�^�^�5�	5rc��|j�|jS|jj}|r-|�d��d���pdSr	)r/r.r�rrr
s  rrz!FunctionTestCase.shortDescription�sI����(��$�$��n�$���1�s�y�y����q�)�/�/�1�1�9�T�9rr)r
rrr"r�r�r�rrrrr"rr'r(s@rr*r*ls���������(�(�(�(�(�(����!�!�!����'�'�'�7�7�7�9�9�9�5�5�5�5�5�5�:�:�:�:�:�:�:rr*c�<��eZdZ�fd�Zd�Zd�Zd�Zd�Zd�Z�xZ	S)r&c���t�����||_||_||_|j|_dSr/)r�r"�_messager$r$r>)r!r$r�r$r�s    �rr"z_SubTest.__init__�s?���
����������
�"������ )� :����rc� �td���)Nzsubtests cannot be run directly)r�r�s rr�z_SubTest.runTest�s��!�"C�D�D�Drc�t�g}|jtur-|�d�|j����|jr^d�d�|j���D����}|�d�|����d�|��pdS)Nz[{}]z, c3�HK�|]\}}d�||��V��dS)z{}={!r}N)r�)r~r�r�s   rr�z+_SubTest._subDescription.<locals>.<genexpr>�sJ����$3�$3��Q��� � ��A�&�&�$3�$3�$3�$3�$3�$3rz({})� z(<subtest>))r=rrUr�r$r�r�)r!�parts�params_descs   r�_subDescriptionz_SubTest._subDescription�s������=� 5�5�5��L�L����t�}�5�5�6�6�6��;�	5��)�)�$3�$3�"�k�/�/�1�1�$3�$3�$3�3�3�K�
�L�L����{�3�3�4�4�4��x�x����/�-�/rc��d�|j���|�����S�Nz{} {})r�r$rrDr�s rrz_SubTest.id�s0���~�~�d�n�/�/�1�1�4�3G�3G�3I�3I�J�J�Jrc�6�	|j���Sr/)r$rr�s rrz_SubTest.shortDescription�s��	��~�.�.�0�0�0rc�\�d�|j|�����SrF)r�r$rDr�s rrz_SubTest.__str__�s$���~�~�d�n�d�.B�.B�.D�.D�E�E�Er)
r
rrr"r�rDrrrr'r(s@rr&r&�s��������;�;�;�;�;�E�E�E�	0�	0�	0�K�K�K�1�1�1�F�F�F�F�F�F�Frr&)1r(rhr�r�r�r6r�r0r�rornr�utilrrrrr	�
__unittest�objectrr�r^rrrrr&r*rDrRrTrYr[rarqrvrxr r}r�r�r�r��ChainMapr�r�r*r&rrr�<module>rMs����
�
�
�
���������
�
�
�
�	�	�	�	���������������������������?�?�?�?�?�?�?�?�?�?�?�?�?�?��
������7�������y���������)����
���������&8�&8�&8�&8�&8�v�&8�&8�&8�R%�%�%�,�,�,���������6�6�6�
0�0�0�

�
�
� ���(���������I�I�I�
3�3�3�3�3�3�3�3�'�'�'�'�'�3�'�'�'�T$8�$8�$8�$8�$8�3�$8�$8�$8�N1D�1D�1D�1D�1D�2�1D�1D�1D�h�����{�+����P8�P8�P8�P8�P8�v�P8�P8�P8�h 7:�7:�7:�7:�7:�x�7:�7:�7:�t!F�!F�!F�!F�!F�x�!F�!F�!F�!F�!Fr__pycache__/async_case.cpython-311.opt-1.pyc000064400000014744152401764000014536 0ustar00�

��Hx�N�ddlZddlZddlZddlZddlmZGd�de��ZdS)�N�)�TestCasec���eZdZd�fd�	Zd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�fd�	Z�fd�Zd�Z�xZS)�IsolatedAsyncioTestCase�runTestc���t���|��d|_tj��|_dS�N)�super�__init__�_asyncioRunner�contextvars�copy_context�_asyncioTestContext)�self�
methodName�	__class__s  ��>/opt/alt/python-internal/lib/python3.11/unittest/async_case.pyrz IsolatedAsyncioTestCase.__init__#s:���
������$�$�$�"���#.�#;�#=�#=�� � � �c��
K�dSr	��rs r�
asyncSetUpz"IsolatedAsyncioTestCase.asyncSetUp(������rc��
K�dSr	rrs r�
asyncTearDownz%IsolatedAsyncioTestCase.asyncTearDown+rrc�(�|j|g|�Ri|��dSr	)�
addCleanup�r�func�args�kwargss    r�addAsyncCleanupz'IsolatedAsyncioTestCase.addAsyncCleanup.s)��	���$�����1�&�1�1�1�1�1rc��K�t|��}	|j}|j}n/#t$r"t	d|j�d|j�d���d�wxYw||���d{V��}|�||ddd��|S)z�Enters the supplied asynchronous context manager.

        If successful, also adds its __aexit__ method as a cleanup
        function and returns the result of the __aenter__ method.
        �'�.zC' object does not support the asynchronous context manager protocolN)�type�
__aenter__�	__aexit__�AttributeError�	TypeError�
__module__�__qualname__r")r�cm�cls�enter�exit�results      r�enterAsyncContextz)IsolatedAsyncioTestCase.enterAsyncContext=s������2�h�h��	'��N�E��=�D�D���	'�	'�	'��U���U�U��1A�U�U�U���"&�
'�	'�����u�R�y�y�����������T�2�t�T�4�8�8�8��
s	�"�,Ac��|j���|j�|j��|�|j��dSr	)r�get_loopr�run�setUp�
_callAsyncrrs r�
_callSetUpz"IsolatedAsyncioTestCase._callSetUpQsL��	
��$�$�&�&�&�� �$�$�T�Z�0�0�0������(�(�(�(�(rc�t�|�|���"tjd|�d�td���dSdS)NzFIt is deprecated to return a value that is not None from a test case (�)�)�
stacklevel)�_callMaybeAsync�warnings�warn�DeprecationWarning)r�methods  r�_callTestMethodz'IsolatedAsyncioTestCase._callTestMethodYsd������'�'�3��M�2�(.�2�2�2�3E�RS�
U�
U�
U�
U�
U�
U�4�3rc�x�|�|j��|j�|j��dSr	)r7rrr5�tearDownrs r�
_callTearDownz%IsolatedAsyncioTestCase._callTearDown^s6������*�+�+�+�� �$�$�T�]�3�3�3�3�3rc�(�|j|g|�Ri|��dSr	)r=)r�functionr r!s    r�_callCleanupz$IsolatedAsyncioTestCase._callCleanupbs+�����X�7��7�7�7��7�7�7�7�7rc�P�|j�||i|��|j���S�N)�context)rr5rrs    rr7z"IsolatedAsyncioTestCase._callAsynces<���"�&�&��D�$�!�&�!�!��,�'�
�
�	
rc��tj|��r'|j�||i|��|j���S|jj|g|�Ri|��SrJ)�inspect�iscoroutinefunctionrr5rrs    rr=z'IsolatedAsyncioTestCase._callMaybeAsyncmsv���&�t�,�,�	G��&�*�*���d�%�f�%�%��0�+���
�
0�4�+�/��F�t�F�F�F�v�F�F�Frc�>�tjd���}||_dS)NT)�debug)�asyncio�Runnerr�r�runners  r�_setupAsyncioRunnerz+IsolatedAsyncioTestCase._setupAsyncioRunnerws"����d�+�+�+��$����rc�<�|j}|���dSr	)r�closerSs  r�_tearDownAsyncioRunnerz.IsolatedAsyncioTestCase._tearDownAsyncioRunner|s���$���������rNc����|���	t���|��|���S#|���wxYwr	)rUr
r5rX)rr1rs  �rr5zIsolatedAsyncioTestCase.run�sZ���� � �"�"�"�	*��7�7�;�;�v�&�&��'�'�)�)�)�)��D�'�'�)�)�)�)���s� A�A"c���|���t�����|���dSr	)rUr
rPrX)rrs �rrPzIsolatedAsyncioTestCase.debug�s>���� � �"�"�"�
���
�
�����#�#�%�%�%�%�%rc�@�|j�|���dSdSr	)rrXrs r�__del__zIsolatedAsyncioTestCase.__del__�s+����*��'�'�)�)�)�)�)�+�*r)rr	)�__name__r+r,rrrr"r2r8rBrErHr7r=rUrXr5rPr\�
__classcell__)rs@rrr	s=�������4>�>�>�>�>�>�

�
�
�
�
�
�
2�
2�
2����()�)�)�U�U�U�
4�4�4�8�8�8�
�
�
�G�G�G�%�%�%�
���*�*�*�*�*�*�&�&�&�&�&�
*�*�*�*�*�*�*rr)rQr
rMr>�caserrrrr�<module>r`s|������������������������E*�E*�E*�E*�E*�h�E*�E*�E*�E*�E*r__pycache__/loader.cpython-311.opt-1.pyc000064400000065017152401764000013673 0ustar00�

��(�DNO���l�dZddlZddlZddlZddlZddlZddlZddlZddlmZm	Z	ddl
mZmZm
Z
dZejdej��ZGd�d	ej��Zd
�Zd�Zd�Zd
�Zd�ZGd�de��Ze��Zdd�Ze
jdfd�Zde
jejfd�Z de
jejfd�Z!dS)zLoading unittests.�N)�fnmatch�fnmatchcase�)�case�suite�utilTz[_a-z]\w*\.py$c�,��eZdZdZ�fd�Z�fd�Z�xZS)�_FailedTestNc�f��||_tt|���|��dS�N)�
_exception�superr
�__init__)�self�method_name�	exception�	__class__s   ��:/opt/alt/python-internal/lib/python3.11/unittest/loader.pyrz_FailedTest.__init__s.���#���
�k�4� � �)�)�+�6�6�6�6�6�c�z���|�jkr(tt����|��S�fd�}|S)Nc����j�r)r
�rs�r�testFailurez,_FailedTest.__getattr__.<locals>.testFailure!s����/�!r)�_testMethodNamerr
�__getattr__)r�namerrs`  �rrz_FailedTest.__getattr__sO�����4�'�'�'���d�+�+�7�7��=�=�=�	"�	"�	"�	"�	"��r)�__name__�
__module__�__qualname__rrr�
__classcell__�rs@rr
r
sV��������O�7�7�7�7�7���������rr
c�r�d|�dtj����}t|t|��||��S)NzFailed to import test module: �
)�	traceback�
format_exc�_make_failed_test�ImportError)r�
suiteClass�messages   r�_make_failed_import_testr*&s<������i�"�$�$�$�&�G��T�;�w�#7�#7��W�M�M�Mrc�R�dtj����}t||||��S)NzFailed to call load_tests:
)r$r%r&)rrr(r)s    r�_make_failed_load_testsr,+s3���2;�2F�2H�2H�2H�J�G���i��W�.�.�.rc�>�t||��}||f��|fSr)r
)�
methodnamerr(r)�tests     rr&r&0s(���z�9�-�-�D��:�t�g����'�'rc��tjt|����d���}||i}tdtjf|��}|||��f��S)Nc��dSr�rs r�testSkippedz'_make_skipped_test.<locals>.testSkipped5s���r�
ModuleSkipped)r�skip�str�type�TestCase)r.rr(r3�attrs�	TestClasss      r�_make_skipped_testr;4si��	�Y�s�9�~�~���
�
���
�
��%�E��_�t�}�&6��>�>�I��:�y�y��,�,�.�/�/�/rc��|����d��r
|dd�Stj�|��dS)Nz	$py.classi����r)�lower�endswith�os�path�splitext)r@s r�_jython_aware_splitextrB<sI���z�z�|�|���[�)�)���C�R�C�y��
�7���D�!�!�!�$�$rc���eZdZdZdZeej��ZdZ	e
jZdZ
�fd�Zd�Zdd�d�Zdd�Zdd	�Zd
�Zdd�Zd
�Zd�Zd�Zd�Zd�Zd�Z�xZS)�
TestLoaderz�
    This class is responsible for loading tests according to various criteria
    and returning them wrapped in a TestSuite
    r/Nc���tt|�����g|_t	��|_dSr)rrDr�errors�set�_loading_packages)rrs �rrzTestLoader.__init__Ms:���
�j�$���(�(�*�*�*����"%������rc�,�t|tj��rtd���|tjtjfvrg}n*|�|��}|st|d��rdg}|�	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?�runTest)�
issubclassr�	TestSuite�	TypeErrorrr8�FunctionTestCase�getTestCaseNames�hasattrr(�map)r�
testCaseClass�
testCaseNames�loaded_suites    r�loadTestsFromTestCasez TestLoader.loadTestsFromTestCaseTs����m�U�_�5�5�	)��(�)�)�
)��T�]�D�,A�B�B�B��M�M� �1�1�-�@�@�M� �
,�W�]�I�%F�%F�
,�!*��
����s�=�-�'H�'H�I�I���r��patternc���t|��dksd|vr0tjdt��|�dd��t|��dkr4t|��dz}td�|�����t|��dkr7t|��d}td�|�����g}t|��D]�}t||��}t|t��r\t|tj��rB|tjtjfvr(|�|�|������t|dd��}	|�|��}|	�_	|	|||��S#t&$rD}
t)|j|
|j��\}}|j�|��|cYd}
~
Sd}
~
wwxYw|S)	z>Return a suite of all test cases contained in the given moduler�use_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�poprM�format�sorted�dir�getattr�
isinstancer7rKrr8rN�appendrUr(�	Exceptionr,rrF)
r�modulerW�args�kws�	complaint�testsr�objrZ�e�
error_case�
error_messages
             r�loadTestsFromModulezTestLoader.loadTestsFromModulefs���t�9�9�q�=�=�,��3�3��M�D�,�
.�
.�
.��G�G�$�d�+�+�+��t�9�9�q�=�=��D�	�	�A�
�I��a�h�h�ir�s�s�t�t�t��s�8�8�q�=�=�
�s���A��I��[�b�b�cl�m�m�n�n�n�����K�K�	>�	>�D��&�$�'�'�C��3��%�%�
>��s�D�M�2�2�
>���
�t�/D�E�E�E����T�7�7��<�<�=�=�=���V�\�4�8�8�
�����&�&���!�
"�!�z�$��w�7�7�7���
"�
"�
"�,C��O�Q���-9�-9�)�
�M���"�"�=�1�1�1�!�!�!�!�!�!�!�����	
"����
�s�F$�$
G2�.9G-�'G2�-G2c
�v�|�d��}d\}}|��|dd�}|r�	d�|��}t|��}n^#t$rO|���}t||j��\}}|s|j�|��|cYSYnwxYw|��|dd�}|}	|D]�}
	|	t|	|
��}	}�#t$r�}t|	dd���%|�#|j�|��|cYd}~cSt|
||jdtj
������\}}|j�|��|cYd}~cSd}~wwxYwt|	tj��r|�|	��St|	t$��rIt'|	t(j��r/|	t(jt(jfvr|�|	��St|	tj��r�t|t$��rlt'|t(j��rR|d}||��}
tt|
|��tj��s|�|
g��Snt|	t2j��r|	St7|	��rl|	��}t|t2j��r|St|t(j��r|�|g��St9d|	�d	|�d
����t9d|	z���)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:
���zcalling z
 returned z, not a testz$don't know how to make test from: %s)�split�join�
__import__r'r_r*r(rFrerc�AttributeErrorr&r$r%rd�types�
ModuleTyperpr7rKrr8rNrU�FunctionTyperrL�callablerM)rrrg�partsrnro�
parts_copy�module_name�next_attributerl�part�parentrm�instr/s               r�loadTestsFromNamezTestLoader.loadTestsFromName�s����
�
�3����$.�!�
�M��>��q�q�q��J��

*�*�"%�(�(�:�"6�"6�K�'��4�4�F���"�*�*�*�%/�^�^�%5�%5�N�0H�&���19�19�-�J�
�%�*���*�*�=�9�9�9�)�)�)�)�*�*�*�����

*��!�"�"�I�E����	&�	&�D�
&�!�7�3��#5�#5�����!�
&�
&�
&��C��T�2�2�>�"�.��K�&�&�}�5�5�5�%�%�%�%�%�%�%�%�%�1B��a����%�0�2�2�2�5�16�16�-�J�
��K�&�&�}�5�5�5�%�%�%�%�%�%�%�%�%�����%
&����(�c�5�+�,�,�	��+�+�C�0�0�0��s�D�!�!�	��3��
�.�.�	��D�M�4�+@�A�A�A��-�-�c�2�2�2���e�0�1�1�		����&�&�		�����/�/�		���9�D��6�$�<�<�D��g�d�D�1�1�5�3E�F�F�
/�����v�.�.�.�
/�
��U�_�
-�
-�	��J��C�=�=�
	J��3�5�5�D��$���0�0�
-����D�$�-�0�0�
-�����v�.�.�.��i�!$���d�d�d�!,�-�-�-��B�S�H�I�I�Is=�$A�AB(�'B(�>C�
E'�.E"�	E'�A	E"�E'�"E'c�N�����fd�|D��}��|��S)z�Return a suite of all test cases found using the given sequence
        of string specifiers. See 'loadTestsFromName()'.
        c�<��g|]}��|�����Sr2)r�)�.0rrgrs  ��r�
<listcomp>z1TestLoader.loadTestsFromNames.<locals>.<listcomp>�s)���I�I�I�4�$�(�(��v�6�6�I�I�Ir)r()r�namesrg�suitess` ` r�loadTestsFromNameszTestLoader.loadTestsFromNames�s5����J�I�I�I�I�5�I�I�I�����v�&�&�&rc�������fd�}tt|t�������}�jr-|�tj�j�����|S)zLReturn a sorted sequence of method names found within testCaseClass
        c����|��j��sdSt�|��}t|��sdSd�j�j|fz��jdupt�fd��jD����S)NFz%s.%s.%sc3�8�K�|]}t�|��V��dSr)r)r�rW�fullNames  �r�	<genexpr>zKTestLoader.getTestCaseNames.<locals>.shouldIncludeMethod.<locals>.<genexpr>�s-�����X�X�w�K��'�2�2�X�X�X�X�X�Xr)�
startswith�testMethodPrefixrcr}rr�testNamePatterns�any)�attrname�testFuncr�rrRs  @��r�shouldIncludeMethodz8TestLoader.getTestCaseNames.<locals>.shouldIncludeMethod�s������&�&�t�'<�=�=�
��u��}�h�7�7�H��H�%�%�
��u�"��(�-�*D�h�&��H��(�D�0�Y��X�X�X�X�$�BW�X�X�X�X�X�
Yr)�key)�list�filterrb�sortTestMethodsUsing�sort�	functools�
cmp_to_key)rrRr��testFnNamess``  rrOzTestLoader.getTestCaseNames�s�����
	Y�
	Y�
	Y�
	Y�
	Y�
	Y��6�"5�s�=�7I�7I�J�J�K�K���$�	R�����!5�d�6O�!P�!P��Q�Q�Q��r�test*.pyc���d}|�|j�|j}n|�d}|}tj�|��}|tjvr tj�d|��||_d}tj�tj�|����retj�|��}||kr>tj�tj�|d����}�n	t|��tj
|}|�d��d}	tj�tj�|j
����}nD#t$r7|jtjvrt#d��d�t#d|����d�wxYw|r9|�|��|_tj�|��n#t($rd}YnwxYw|rt)d	|z���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__.pyrrz2Can not use builtin modules as dotted module namesz don't know how to discover from z%Start directory is not importable: %r)�_top_level_dirr?r@�abspath�sys�insert�isdir�isfilerwrx�modulesrv�dirname�__file__ryr�builtin_module_namesrM� _get_directory_containing_module�remover'r��_find_testsr()	r�	start_dirrW�
top_level_dir�set_implicit_top�is_not_importable�
the_module�top_partrks	         r�discoverzTestLoader.discover�se��8!��� �T�%8�%D� �/�M�M�
�
"�#��%�M�����
�6�6�
����(�(�

�H�O�O�A�}�-�-�-�+���!��
�7�=�=������3�3�4�4�	3�����	�2�2�I��M�)�)�(*����r�w�|�|�I�}�7]�7]�(^�(^�$^�!��
3��9�%�%�%�!�[��3�
�$�?�?�3�/�/��2��(� "���������)<�>�>�!@�!@�I�I��%�(�(�(�!�*�c�.F�F�F�'�)A�B�B�GK�L�(�M�z�M�M���#'�(�
(����$�3�*.�*O�*O�PX�*Y�*Y�D�'��H�O�O�M�2�2�2���)�
)�
)�
)�$(�!�!�!�
)����,�	S��E�	�Q�R�R�R��T�%�%�i��9�9�:�:�����u�%�%�%s �H�AF�AG�H �H c��tj|}tj�|j��}tj�|������d��r<tj�	tj�	|����Stj�	|��S)Nr�)
r�r�r?r@r�r��basenamer=r�r�)rr�rg�	full_paths    rr�z+TestLoader._get_directory_containing_moduleQs�����[�)���G�O�O�F�O�4�4�	�
�7���I�&�&�,�,�.�.�9�9�-�H�H�	.��7�?�?�2�7�?�?�9�#=�#=�>�>�>�
�7�?�?�9�-�-�-rc��||jkrdSttj�|����}tj�||j��}|�tjjd��}|S)Nrr)r�rBr?r@�normpath�relpath�replace�sep)rr@�_relpathrs    r�_get_name_from_pathzTestLoader._get_name_from_path]sj���4�&�&�&��3�%�b�g�&6�&6�t�&<�&<�=�=���7�?�?�4��)<�=�=��������S�1�1���rc�D�t|��tj|Sr)rxr�r�)rrs  r�_get_module_from_namez TestLoader._get_module_from_nameis���4�����{�4� � rc�"�t||��Sr)r)rr@r�rWs    r�_match_pathzTestLoader._match_pathms���t�W�%�%�%rc#�rK�|�|��}|dkr,||jvr#|�||��\}}|�|V�|sdStt	j|����}|D]�}tj�||��}|�||��\}}|�|V�|r�|�|��}|j�|��	|�	||��Ed{V��|j�
|����#|j�
|��wxYw��dS)z/Used by discovery. Yields test suites it loads.rrN)r�rH�_find_test_pathrar?�listdirr@rw�addr��discard)	rr�rWrrk�should_recurse�pathsr@r�s	         rr�zTestLoader._find_testsqsv�����'�'�	�2�2���3�;�;�4�t�'=�=�=�%)�$8�$8��G�$L�$L�!�E�>�� �����!�
����r�z�)�,�,�-�-���	9�	9�D�����Y��5�5�I�$(�$8�$8��G�$L�$L�!�E�>�� ������
9��/�/�	�:�:���&�*�*�4�0�0�0�9�#�/�/�	�7�C�C�C�C�C�C�C�C�C��*�2�2�4�8�8�8�8��D�*�2�2�4�8�8�8�8����
9�	9�	9s� D�D3c���tj�|��}tj�|���rt�|��sdS|�|||��sdS|�|��}	|�|��}tj�	t|d|����}ttj�|����}ttj�|����}|�
��|�
��kr�tj�|��}	ttj�|����}
tj�|��}d}t||
|	|fz���|�||���dfS#t"j$r"}
t'||
|j��dfcYd}
~
Sd}
~
wt+||j��\}}|j�|��|dfcYSxYwtj�|���rztj�tj�|d����sdSd}d}|�|��}	|�|��}t|dd��}|j�|��	|�||���}|�|df|j�|��S|d	f|j�|��S#|j�|��wxYw#t"j$r"}
t'||
|j��dfcYd}
~
Sd}
~
wt+||j��\}}|j�|��|dfcYSxYwdS)
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?rVFNr�rZT)r?r@r�r��VALID_MODULE_NAME�matchr�r�r�r�rcrB�realpathr=r�r'rpr�SkipTestr;r(r*rFrer�rwrHr�r�)rr�rWr�rrg�mod_filer��fullpath_noext�
module_dir�mod_name�expected_dir�msgrmrnrorZrk�packages                   rr�zTestLoader._find_test_path�s����7�#�#�I�.�.��
�7�>�>�)�$�$�?	�$�*�*�8�4�4�
#�"�{��#�#�H�i��A�A�
#�"�{��+�+�I�6�6�D�
P��3�3�D�9�9���7�?�?��F�J�	�:�:�<�<��1��G�$�$�X�.�.�0�0��!7��G�$�$�Y�/�/�"1�"1���>�>�#�#�~�';�';�'=�'=�=�=�!#�����!:�!:�J�5���(�(��3�3� 5� 5�H�#%�7�?�?�9�#=�#=�L�D�C�%��x��\�B�B�D�D�D��/�/���/�H�H�%�O�O��/�=�
K�
K�
K�)�$��4�?�C�C�U�J�J�J�J�J�J�J�����
)�,�T�4�?�C�C�*�
�M���"�"�=�1�1�1�!�5�(�(�(�(����$�W�]�]�9�
%�
%�	��7�>�>�"�'�,�,�y�-�"H�"H�I�I�
#�"�{��J��E��+�+�I�6�6�D�
9��4�4�T�:�:��%�W�l�D�A�A�
��&�*�*�4�0�0�0�9� �4�4�W�g�4�N�N�E�!�-�$�e�|��*�2�2�4�8�8�8�8�!�$�;��*�2�2�4�8�8�8�8��D�*�2�2�4�8�8�8�8�����%�=�
K�
K�
K�)�$��4�?�C�C�U�J�J�J�J�J�J�J�����
)�,�T�4�?�C�C�*�
�M���"�"�=�1�1�1�!�5�(�(�(�(�����;sN�G*�*I�9H�I�;I�N�M%�M%�%N�O-�N0�*O-�0;O-r)r�N)rrr�__doc__r��staticmethodr�
three_way_cmpr�r�rrLr(r�rrUrpr�r�rOr�r�r�r�r�r�r�r r!s@rrDrDBsX�����������'�<��(:�;�;������J��N�'�'�'�'�'����$:>�*�*�*�*�*�XPJ�PJ�PJ�PJ�d'�'�'�'����&Q&�Q&�Q&�Q&�f
.�
.�
.�
�
�
�!�!�!�&�&�&�9�9�9�@H�H�H�H�H�H�HrrDc�^�t��}||_||_||_|r||_|Sr)rDr�r�r�r()�prefix�	sortUsingr(r��loaders     r�_makeLoaderr��s8��
�\�\�F�"+�F��$�F��.�F���'�&����Mrc��ddl}|jdtd���t|||����|��S)Nrz�unittest.getTestCaseNames() is deprecated and will be removed in Python 3.13. Please use unittest.TestLoader.getTestCaseNames() instead.���
stacklevel)r�)r\r]r^r�rO)rRr�r�r�r\s     rrOrO�sX���O�O�O��H�M�	E��q�����
�v�y�;K�L�L�L�]�]�^k�l�l�lrr/c��ddl}|jdtd���t|||���|��S)Nrz�unittest.makeSuite() is deprecated and will be removed in Python 3.13. Please use unittest.TestLoader.loadTestsFromTestCase() instead.r�r�)r\r]r^r�rU)rRr�r�r(r\s     r�	makeSuiter��sZ���O�O�O��H�M�	J��q�����
�v�y�*�5�5�K�K����rc��ddl}|jdtd���t|||���|��S)Nrz�unittest.findTestCases() is deprecated and will be removed in Python 3.13. Please use unittest.TestLoader.loadTestsFromModule() instead.r�r�)r\r]r^r�rp)rgr�r�r(r\s     r�
findTestCasesr��sZ���O�O�O��H�M�	H��q�����
�v�y�*�5�5�I�I����rrs)"r�r?�rer�r$rzr�r\rr�rrr�
__unittest�compile�
IGNORECASEr�r8r
r*r,r&r;rB�objectrD�defaultTestLoaderr�r�rOrLr�r�r2rr�<module>r�s�����	�	�	�	�	�	�	�	�
�
�
�
�����������������(�(�(�(�(�(�(�(�����������
�
�
�B�J�0�"�-�@�@�������$�-����N�N�N�
.�.�.�
(�(�(�0�0�0�%�%�%�W�W�W�W�W��W�W�W�t�J�L�L������7;�6H�[_�m�m�m�m�%+�d�6H���	�	�	�	�"(�4�3E�"�_�	�	�	�	�	�	r__pycache__/runner.cpython-311.opt-1.pyc000064400000040162152401764000013730 0ustar00�

����yWc���dZddlZddlZddlZddlmZddlmZddlm	Z	dZ
Gd�d	e��ZGd
�dej
��ZGd�d
e��ZdS)z
Running tests�N�)�result)�_SubTest)�registerResultTc�&�eZdZdZd�Zd�Zdd�ZdS)�_WritelnDecoratorz@Used to decorate file-like objects with a handy 'writeln' methodc��||_dS�N)�stream)�selfrs  �:/opt/alt/python-internal/lib/python3.11/unittest/runner.py�__init__z_WritelnDecorator.__init__s
�������c�R�|dvrt|���t|j|��S)N)r�__getstate__)�AttributeError�getattrr)r�attrs  r
�__getattr__z_WritelnDecorator.__getattr__s.���-�-�-� ��&�&�&��t�{�4�(�(�(rNc�^�|r|�|��|�d��dS�N�
)�write)r�args  r
�writelnz_WritelnDecorator.writelns1���	��J�J�s�O�O�O��
�
�4�����rr
)�__name__�
__module__�__qualname__�__doc__rrr�rr
rrsL������J�J����)�)�)�
�����rrc���eZdZdZdZdZ�fd�Zd�Z�fd�Zd�Z	�fd�Z
�fd	�Z�fd
�Z�fd�Z
�fd�Z�fd
�Z�fd�Zd�Zd�Z�xZS)�TextTestResultzhA test result class that can print formatted text results to a stream.

    Used by TextTestRunner.
    zF======================================================================zF----------------------------------------------------------------------c���tt|���|||��||_|dk|_|dk|_||_d|_dS)NrT)�superr"rr�showAll�dots�descriptions�_newline)rrr'�	verbosity�	__class__s    �r
rzTextTestResult.__init__&sU���
�n�d�#�#�,�,�V�\�9�M�M�M���� �1�}�����N��	�(�����
�
�
rc��|���}|jr&|r$d�t|��|f��St|��Sr)�shortDescriptionr'�join�str)r�test�doc_first_lines   r
�getDescriptionzTextTestResult.getDescription.sN���.�.�0�0����	��	��9�9�c�$�i�i��8�9�9�9��t�9�9�rc�8��tt|���|��|jri|j�|�|����|j�d��|j���d|_dSdS)N� ... F)	r$r"�	startTestr%rrr1�flushr(�rr/r*s  �r
r4zTextTestResult.startTest5s����
�n�d�#�#�-�-�d�3�3�3��<�	"��K���d�1�1�$�7�7�8�8�8��K���g�&�&�&��K������!�D�M�M�M�		"�	"rc��t|t��}|s|jr�|js|j���|r|j�d��|j�|�|����|j�d��|j�|��|j���d|_dS)Nz  r3T)�
isinstancerr(rrrr1r5)rr/�status�
is_subtests    r
�
_write_statuszTextTestResult._write_status=s�����h�/�/�
��	'���	'��=�
&���#�#�%�%�%��
(���!�!�$�'�'�'��K���d�1�1�$�7�7�8�8�8��K���g�&�&�&�����F�#�#�#����������
�
�
rc����|��|jrIt|d|j��r|�|d��n�|�|d��np|jrit|d|j��r|j�d��n|j�d��|j���tt|���
|||��dS)Nr�FAIL�ERROR�F�E)r%�
issubclass�failureExceptionr;r&rrr5r$r"�
addSubTest)rr/�subtest�errr*s    �r
rCzTextTestResult.addSubTestJs�����?��|�

$��c�!�f�g�&>�?�?�9��&�&�w��7�7�7�7��&�&�w��8�8�8�8���
$��c�!�f�g�&>�?�?�+��K�%�%�c�*�*�*�*��K�%�%�c�*�*�*���!�!�#�#�#�
�n�d�#�#�.�.�t�W�c�B�B�B�B�Brc���tt|���|��|jr|�|d��dS|jr5|j�d��|j���dSdS)N�ok�.)	r$r"�
addSuccessr%r;r&rrr5r6s  �r
rIzTextTestResult.addSuccessYs����
�n�d�#�#�.�.�t�4�4�4��<�	 ����t�T�*�*�*�*�*�
�Y�	 ��K���c�"�"�"��K��������	 �	 rc���tt|���||��|jr|�|d��dS|jr5|j�d��|j���dSdS)Nr>r@)	r$r"�addErrorr%r;r&rrr5�rr/rEr*s   �r
rKzTextTestResult.addErroras����
�n�d�#�#�,�,�T�3�7�7�7��<�	 ����t�W�-�-�-�-�-�
�Y�	 ��K���c�"�"�"��K��������	 �	 rc���tt|���||��|jr|�|d��dS|jr5|j�d��|j���dSdS)Nr=r?)	r$r"�
addFailurer%r;r&rrr5rLs   �r
rNzTextTestResult.addFailureis����
�n�d�#�#�.�.�t�S�9�9�9��<�	 ����t�V�,�,�,�,�,�
�Y�	 ��K���c�"�"�"��K��������	 �	 rc�6��tt|���||��|jr+|�|d�|����dS|jr5|j�d��|j�	��dSdS)Nz
skipped {0!r}�s)
r$r"�addSkipr%r;�formatr&rrr5)rr/�reasonr*s   �r
rQzTextTestResult.addSkipqs����
�n�d�#�#�+�+�D�&�9�9�9��<�	 ����t�_�%;�%;�F�%C�%C�D�D�D�D�D�
�Y�	 ��K���c�"�"�"��K��������	 �	 rc�J��tt|���||��|jr5|j�d��|j���dS|jr5|j�d��|j���dSdS)Nzexpected failure�x)	r$r"�addExpectedFailurer%rrr5r&rrLs   �r
rVz!TextTestResult.addExpectedFailureys����
�n�d�#�#�6�6�t�S�A�A�A��<�	 ��K��� 2�3�3�3��K��������
�Y�	 ��K���c�"�"�"��K��������	 �	 rc�H��tt|���|��|jr5|j�d��|j���dS|jr5|j�d��|j���dSdS)Nzunexpected success�u)	r$r"�addUnexpectedSuccessr%rrr5r&rr6s  �r
rYz#TextTestResult.addUnexpectedSuccess�s����
�n�d�#�#�8�8��>�>�>��<�	 ��K��� 4�5�5�5��K��������
�Y�	 ��K���c�"�"�"��K��������	 �	 rc��|js|jr2|j���|j���|�d|j��|�d|j��t|dd��}|ro|j�|j	��|D]2}|j�d|�
|�������3|j���dSdS)Nr>r=�unexpectedSuccessesr zUNEXPECTED SUCCESS: )r&r%rrr5�printErrorList�errors�failuresr�
separator1r1)rr[r/s   r
�printErrorszTextTestResult.printErrors�s���9�	 ���	 ��K���!�!�!��K���������G�T�[�1�1�1����F�D�M�2�2�2�%�d�,A�2�F�F���	 ��K�����0�0�0�+�
X�
X����#�#�$V�4�;N�;N�t�;T�;T�$V�$V�W�W�W�W��K��������		 �	 rc�b�|D]�\}}|j�|j��|j�|�d|�|������|j�|j��|j�d|z��|j�����dS)Nz: z%s)rrr_r1�
separator2r5)r�flavourr]r/rEs     r
r\zTextTestResult.printErrorList�s����	 �	 �I�D�#��K�����0�0�0��K���G�G�G�D�4G�4G��4M�4M�4M� N�O�O�O��K�����0�0�0��K����s�
�+�+�+��K�������	 �	 r)rrrrr_rbrr1r4r;rCrIrKrNrQrVrYr`r\�
__classcell__)r*s@r
r"r"sW����������J��J���������"�"�"�"�"����
C�
C�
C�
C�
C� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � rr"c�4�eZdZdZeZ		d
dd�d�Zd�Zd	�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��|�tj}t|��|_||_||_||_||_||_||_	|�	||_
dSdS)z�Construct a TextTestRunner.

        Subclasses should accept **kwargs to ensure compatibility as the
        interface changes.
        N)�sys�stderrrrr'r)�failfast�bufferrg�warnings�resultclass)	rrr'r)rkrlrnrmrgs	         r
rzTextTestRunner.__init__�sf���>��Z�F�'��/�/���(���"��� ��
����"��� ��
��"�*�D����#�"rc�N�|�|j|j|j��Sr
)rnrr'r))rs r
�_makeResultzTextTestRunner._makeResult�s!�������T�->���O�O�Orc���|���}t|��|j|_|j|_|j|_tj��5|jr>tj|j��|jdvrtjdtd���tj��}t|dd��}|�
|��	||��t|dd��}|�
|��n##t|dd��}|�|��wwxYwtj��}ddd��n#1swxYwY||z
}|j
��t|d��r|j�|j��|j}|j�d	||d
krdpd|fz��|j���d
x}	x}
}	t't(|j|j|jf��}|\}	}
}n#t0$rYnwxYwg}
|j��sw|j�d��t)|j��t)|j��}}|r|
�d|z��|r|
�d|z��n|j�d��|r|
�d|z��|	r|
�d|	z��|
r|
�d|
z��|
r2|j�dd�|
���d���n|j�d��|j���|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 %.3fsrrP�r�FAILEDzfailures=%dz	errors=%d�OKz
skipped=%dzexpected failures=%dzunexpected successes=%dz (z, �)r) rprrkrlrgrm�catch_warnings�simplefilter�filterwarnings�DeprecationWarning�time�perf_counterrr`�hasattrrrrb�testsRun�map�len�expectedFailuresr[�skippedr�
wasSuccessfulrr^r]�appendr-r5)rr/r�	startTimerwrx�stopTime�	timeTaken�run�
expectedFailsr[r��results�infos�failed�erroreds                r
r�zTextTestRunner.run�s���!�!�#�#���v�����-������
��>���
�
$�
&�
&�	+�	+��}�
F��%�d�m�4�4�4��=�$9�9�9��+�H�%7�$D�F�F�F�F��)�+�+�I�"�6�>�4�@�@�L��'������
"���V����%�f�m�T�B�B���*��K�M�M�M���&�f�m�T�B�B���*��K�M�M�M�M�+�����(�*�*�H�/	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+�0�y�(�	��������6�<�(�(�	3��K���� 1�2�2�2��o������4� �#��(�"2�s�"8�b�)�D�E�	F�	F�	F��������89�9�
�9�+�g�	B��#�� 7� &� :� &�� 0�1�1�G�;B�7�M�.�����	�	�	��D�	����
��#�v�#�%�%�	$��K���h�'�'�'�!�&�/�2�2�C��
�4F�4F�G�F��
5����]�V�3�4�4�4��
4����[�7�2�3�3�3���K���d�#�#�#��	1��L�L���/�0�0�0��	A��L�L�/�-�?�@�@�@��	J��L�L�2�5H�H�I�I�I��	$��K����4�9�9�U�+;�+;�+;�+;� =�>�>�>�>��K���d�#�#�#���������
s=�A6D=�C;�D=�; D�D=�=E�E�'H�
H�H)NTrFFNN)	rrrrr"rnrrpr�r rr
rfrf�sr��������
!�K�AB�JN�+�#�+�+�+�+�+�(P�P�P�G�G�G�G�Grrf)rrir�rmryr�caser�signalsr�
__unittest�objectr�
TestResultr"rfr rr
�<module>r�s�����
�
�
�
���������������������#�#�#�#�#�#�
�
�
�
�
�
�
��
�
�
� @ �@ �@ �@ �@ �V�&�@ �@ �@ �Ff�f�f�f�f�V�f�f�f�f�fr__pycache__/suite.cpython-311.opt-1.pyc000064400000042736152401764000013561 0ustar00�

!�#�%,
���dZddlZddlmZddlmZdZd�ZGd�d	e��ZGd
�de��Z	Gd�de��Z
d
�ZGd�de��ZdS)�	TestSuite�N�)�case)�utilTc�>�t||d���}|��dS)Nc��dS�N�r
��9/opt/alt/python-internal/lib/python3.11/unittest/suite.py�<lambda>z!_call_if_exists.<locals>.<lambda>s���r)�getattr)�parent�attr�funcs   r�_call_if_existsrs$���6�4���.�.�D��D�F�F�F�F�Frc�Z�eZdZdZdZdd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�ZdS)�
BaseTestSuitezNA simple test suite that doesn't provide class or module shared fixtures.
    Tr
c�L�g|_d|_|�|��dS�Nr)�_tests�_removed_tests�addTests)�self�testss  r�__init__zBaseTestSuite.__init__s)���������
�
�e�����rc�\�dtj|j���dt|���d�S)N�<z tests=�>)r�strclass�	__class__�list�rs r�__repr__zBaseTestSuite.__repr__s+���"&�-���"?�"?�"?�"?��d�����L�Lrc�z�t||j��stSt|��t|��kSr	)�
isinstancer!�NotImplementedr")r�others  r�__eq__zBaseTestSuite.__eq__s3���%���0�0�	"�!�!��D�z�z�T�%�[�[�(�(rc�*�t|j��Sr	)�iterrr#s r�__iter__zBaseTestSuite.__iter__"s���D�K� � � rc�P�|j}|D]}|r||���z
}�|Sr	)r�countTestCases)r�cases�tests   rr.zBaseTestSuite.countTestCases%s=���#���	/�	/�D��
/���,�,�.�.�.����rc�@�t|��s/td�t|�������t	|t
��r0t
|tjtf��rtd���|j
�|��dS)Nz{} is not callablezNTestCases and TestSuites must be instantiated before passing them to addTest())�callable�	TypeError�format�reprr&�type�
issubclassr�TestCaserr�append�rr0s  r�addTestzBaseTestSuite.addTest,s�����~�~�	E��0�7�7��T�
�
�C�C�D�D�D��d�D�!�!�	@�j��26�-��1K�'M�'M�	@��?�@�@�
@�����4� � � � � rc��t|t��rtd���|D]}|�|���dS)Nz0tests must be an iterable of tests, not a string)r&�strr3r;)rrr0s   rrzBaseTestSuite.addTests6sR���e�S�!�!�	P��N�O�O�O��	�	�D��L�L������	�	rc��t|��D]5\}}|jrn(||��|jr|�|���6|Sr	)�	enumerate�
shouldStop�_cleanup�_removeTestAtIndex)r�result�indexr0s    r�runzBaseTestSuite.run<s\��$�T�?�?�	/�	/�K�E�4�� �
����D��L�L�L��}�
/��'�'��.�.�.���
rc��	|j|}t|d��r"|xj|���z
c_d|j|<dS#t$rYdSwxYw)z2Stop holding a reference to the TestCase at index.r.N)r�hasattrrr.r3)rrDr0s   rrBz BaseTestSuite._removeTestAtIndexEs~��
	&��;�u�%�D��t�-�.�.�
=��#�#�t�':�':�'<�'<�<�#�#�!%�D�K�������	�	�	��D�D�	���s�
A
�
A�Ac��|j|i|��Sr	�rE)r�args�kwdss   r�__call__zBaseTestSuite.__call__Ss���t�x��&��&�&�&rc�8�|D]}|����dS)�7Run the tests without collecting errors in a TestResultN)�debugr:s  rrOzBaseTestSuite.debugVs*���	�	�D��J�J�L�L�L�L�	�	rN)r
)�__name__�
__module__�__qualname__�__doc__rArr$r)r,r.r;rrErBrLrOr
rrrrs����������H�����
M�M�M�)�)�)�
!�!�!����!�!�!�������&�&�&�'�'�'�����rrc�R�eZdZdZd
d�Zd�Zd�Zd�Zd�Z	dd	�Z		dd
�Z
d�Zd�ZdS)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.
    Fc�l�d}t|dd��dur	dx|_}t|��D]�\}}|jrn�t	|��rv|�||��|�||��|�||��|j|_	t|jdd��st|dd��r��|s||��n|�
��|jr|�|����|r2|�d|��|�
|��d|_|S)NF�_testRunEnteredT�_classSetupFailed�_moduleSetUpFailed)rrVr?r@�_isnotsuite�_tearDownPreviousClass�_handleModuleFixture�_handleClassSetUpr!�_previousTestClassrOrArB�_handleModuleTearDown)rrCrO�topLevelrDr0s      rrEz
TestSuite.runfsb�����6�,�e�4�4��=�=�04�4�F�"�X�$�T�?�?�	/�	/�K�E�4�� �
����4� � �
��+�+�D�&�9�9�9��)�)�$��7�7�7��&�&�t�V�4�4�4�,0�N��)��D�N�,?��G�G���F�$8�%�@�@����
���V������
�
�����}�
/��'�'��.�.�.���	+��'�'��f�5�5�5��&�&�v�.�.�.�%*�F�"��
rc�N�t��}|�|d��dS)rNTN)�_DebugResultrE)rrOs  rrOzTestSuite.debug�s%���������������rc���t|dd��}|j}||krdS|jrdSt|dd��rdSd}	d|_n#t$rYnwxYwt|dd��}t|dd��}|��t|d��		|��nt#t$rg}t|t��r�d}	d|_n#t$rYnwxYwtj
|��}	|�||d|	��Yd}~nd}~wwxYw|r6|�4|��|jD]"}
|�||
dd|	|
�	���#t|d
��dS#t|d
��wxYwdS)Nr]�__unittest_skip__F�
setUpClass�doClassCleanups�_setupStdoutTr��info�_restoreStdout)
rr!rXrWr3r�	Exceptionr&rarr �"_createClassOrModuleLevelException�tearDown_exceptions)rr0rC�
previousClass�currentClass�failedrdre�e�	className�exc_infos           rr\zTestSuite._handleClassSetUp�s8����(<�d�C�C�
��~���=�(�(��F��$�	��F��<�!4�e�<�<�	��F���	�-2�L�*�*���	�	�	�
�D�	����
�\�<��>�>�
�!�,�0A�4�H�H���!��F�N�3�3�3�
:�
G��J�L�L�L�L�� �G�G�G�!�&�,�7�7���!�F��9=��6�6��$���������� $�
�l� ;� ;�I��;�;�F�A�<H�<E�G�G�G�G�G�G�G�G�����G�����/�o�9�#�O�%�%�%�$0�$D�/�/���?�?� &����\�9�%-�@�/�/�/�/� ��(8�9�9�9�9�9����(8�9�9�9�9����1"�!sf�A�
A�A�
B�E�
D
�#D�<C�D�
C�D�C�/D�E�D
�
;E�E)c�>�d}t|dd��}|�|j}|S)Nr])rrQ)rrC�previousModulerms    r�_get_previous_modulezTestSuite._get_previous_module�s-������(<�d�C�C�
��$�*�5�N��rc��|�|��}|jj}||krdS|�|��d|_	t
j|}n#t$rYdSwxYwt|dd��}|��t|d��		|��nL#t$r?}t|t��r�d|_|�
||d|��Yd}~nd}~wwxYw|jrD	tj��n/#t$r"}|�
||d|��Yd}~nd}~wwxYwt|d��dS#t|d��wxYwdS)NF�setUpModulerfTri)rur!rQr^rX�sys�modules�KeyErrorrrrjr&rarkr�doModuleCleanups)rr0rCrt�
currentModule�modulerwrps        rr[zTestSuite._handleModuleFixture�s���2�2�6�:�:����1�
��N�*�*��F��"�"�6�*�*�*�%*��!�	��[��/�F�F���	�	�	��F�F�	�����f�m�T�:�:���"��F�N�3�3�3�
:�K��K�M�M�M�M�� �K�K�K�!�&�,�7�7���04�F�-��;�;�F�A�<I�<I�K�K�K�K�K�K�K�K�����	K�����,�O�O��-�/�/�/�/��$�O�O�O��?�?���@M�@M�O�O�O�O�O�O�O�O�����O����
 ��(8�9�9�9�9�9����(8�9�9�9�9����)#�"sl�A�
A(�'A(�
B�E�
C$�%5C�E�C$�$
E�/D�E�
D/�
D*�%E�*D/�/E�ENc�F�|�d|�d�}|�||||��dS)Nz (�))�_addClassOrModuleLevelException)rrC�exc�method_namerrh�	errorNames       rrkz,TestSuite._createClassOrModuleLevelException�s8��"�/�/�f�/�/�/�	��,�,�V�S�)�T�J�J�J�J�Jrc�6�t|��}t|dd��}|�5t|tj��r||t|����dS|s)|�|tj����dS|�||��dS)N�addSkip)	�_ErrorHolderrr&r�SkipTestr=�addErrorrxrr)rrC�	exceptionr�rh�errorr�s       rr�z)TestSuite._addClassOrModuleLevelException�s����Y�'�'���&�)�T�2�2����:�i���#G�#G���G�E�3�y�>�>�*�*�*�*�*��
-�����s�|�~�~�6�6�6�6�6�����t�,�,�,�,�,rc�|�|�|��}|�dS|jrdS	tj|}n#t$rYdSwxYwt|d��	t
|dd��}|�Q	|��nE#t$r8}t|t��r�|�
||d|��Yd}~nd}~wwxYw	tj��nE#t$r8}t|t��r�|�
||d|��Yd}~nd}~wwxYwt|d��dS#t|d��wxYw)Nrf�tearDownModuleri)
rurXrxryrzrrrjr&rarkrr{)rrCrtr}r�rps      rr^zTestSuite._handleModuleTearDown�s����2�2�6�:�:���!��F��$�	��F�	��[��0�F�F���	�	�	��F�F�	����	���/�/�/�	6�$�V�-=�t�D�D�N��)�L�"�N�$�$�$�$�� �L�L�L�!�&�,�7�7����;�;�F�A�<L�<J�L�L�L�L�L�L�L�L�����L����
H��%�'�'�'�'���
H�
H�
H��f�l�3�3����7�7���8H�8F�H�H�H�H�H�H�H�H�����
H����
�F�$4�5�5�5�5�5��O�F�$4�5�5�5�5���so�7�
A�A�D)�-
A8�7D)�8
B:�.B5�0D)�5B:�:D)�>C�D)�
D�.D�
D)�D�D)�)D;c��t|dd��}|j}||ks|�dSt|dd��rdSt|dd��rdSt|dd��rdSt|dd��}t|dd��}|�|�dSt|d��	|�e	|��nY#t$rL}t	|t
��r�t
j|��}|�||d|��Yd}~nd}~wwxYw|�e|��|j	D]S}	t	|t
��r|	d	�t
j|��}|�||	d	d||	�
���Tt|d��dS#t|d��wxYw)Nr]rWFrXrc�
tearDownClassrerfrrgri)
rr!rrjr&rarr rkrl)
rr0rCrmrnr�rerprqrrs
          rrZz TestSuite._tearDownPreviousClasss%����(<�d�C�C�
��~���=�(�(�M�,A��F��=�"5�u�=�=�	��F��6�/��7�7�	��F��=�"5�u�=�=�	��F��
���E�E�
�!�-�1B�D�I�I��� �_�%<��F����/�/�/�	6��(�G�!�M�O�O�O�O�� �G�G�G�!�&�,�7�7��� $�
�m� <� <�I��;�;�F�A�<K�<E�G�G�G�G�G�G�G�G�����	G�����*���!�!�!� -� A�K�K�H�!�&�,�7�7�*�&�q�k�)� $�
�m� <� <�I��;�;�F�H�Q�K�<K�<E�AI�<�K�K�K�K�

�F�$4�5�5�5�5�5��O�F�$4�5�5�5�5���s8�E5�
B#�"E5�#
C9�-AC4�/E5�4C9�9A*E5�5F)Fr	)
rPrQrRrSrErOr\rur[rkr�r^rZr
rrrr\s�������������B���,:�,:�,:�\���#:�#:�#:�L9=�K�K�K�K�.2�
-�
-�
-�
-�!6�!6�!6�F(6�(6�(6�(6�(6rc�F�eZdZdZdZd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�ZdS)r�z�
    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.
    Nc��||_dSr	��description)rr�s  rrz_ErrorHolder.__init__Ts��&����rc��|jSr	r�r#s r�idz_ErrorHolder.idWs����rc��dSr	r
r#s r�shortDescriptionz_ErrorHolder.shortDescriptionZs���trc��d|j�d�S)Nz<ErrorHolder description=rr�r#s rr$z_ErrorHolder.__repr__]s���15�1A�1A�1A�C�Crc�*�|���Sr	)r�r#s r�__str__z_ErrorHolder.__str__`s���w�w�y�y�rc��dSr	r
�rrCs  rrEz_ErrorHolder.runcs	��	
�rc�,�|�|��Sr	rIr�s  rrLz_ErrorHolder.__call__hs���x�x����rc��dSrr
r#s rr.z_ErrorHolder.countTestCasesks���qr)
rPrQrRrS�failureExceptionrr�r�r$r�rErLr.r
rrr�r�Hs�����������'�'�'� � � ����D�D�D����
�
�
�
 � � �����rr�c�J�	t|��n#t$rYdSwxYwdS)z?A crude way to tell apart testcases and suites with duck-typingTF)r+r3)r0s rrYrYns;����T�
�
�
�
�������t�t������5s��
 � c��eZdZdZdZdZdZdS)razCUsed by the TestSuite to hold previous class when running in debug.NF)rPrQrRrSr]rXr@r
rrraraws%������I�I������J�J�Jrra)
rSrx�rr�
__unittestr�objectrrr�rYrar
rr�<module>r�s����
�
�
�
�������������
�
����
I�I�I�I�I�F�I�I�I�Xi6�i6�i6�i6�i6�
�i6�i6�i6�X$�$�$�$�$�6�$�$�$�L��������6�����r__pycache__/main.cpython-311.opt-2.pyc000064400000032510152401764000013342 0ustar00�

�u�ʡ�����	ddlZddlZddlZddlZddlmZmZddlmZdZ	dZ
dZd�Zd	�Z
d
�ZGd�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
c�V�tj�|���r|����d��r�tj�|��rstj�|tj����}tj�|��s|�tj	��r|S|}tj�
|��dd��dd���dd��S|S)Nz.py����\�.�/)�os�path�isfile�lower�endswith�isabs�relpath�getcwd�
startswith�pardir�normpath�replace)�name�rel_paths  �8/opt/alt/python-internal/lib/python3.11/unittest/main.py�
_convert_namers���

�w�~�~�d���P��
�
��� 5� 5�e� <� <�P�
�7�=�=����	��w���t�R�Y�[�[�9�9�H��w�}�}�X�&�&�
�(�*=�*=�b�i�*H�*H�
����D��w����%�%�c�r�c�*�2�2�4��=�=�E�E�c�3�O�O�O��K�c��d�|D��S)Nc�,�g|]}t|����S�)r)�.0rs  r�
<listcomp>z"_convert_names.<locals>.<listcomp>/s ��2�2�2�D�M�$���2�2�2rr)�namess r�_convert_namesr#.s��2�2�E�2�2�2�2rc��d|vrd|z}|S)N�*z*%s*r)�patterns r�_convert_select_patternr'2s���'�>�>��7�"���Nrc��eZdZ	dZdZdxZxZxZxZxZ	Z
dZddddej
ddddddfdd�d�Zdd�Zd	�Zd
�Zdd�Zd�Zd
�Zd�Zd�Zdd�Zd�ZdS)�TestProgramNr�__main__TF)�	tb_localsc�V�t|t��rOt|��|_|�d��dd�D]}
t|j|
��|_�n||_|�tj}||_||_	|	|_
||_|
|_||_
|�tjsd|_n||_||_||_||_t&j�|d��|_|�|��|���dS)Nr
r�defaultr)�
isinstance�str�
__import__�module�split�getattr�sys�argv�exit�failfast�
catchbreak�	verbosity�bufferr+�warnoptions�warnings�defaultTest�
testRunner�
testLoaderrr
�basename�progName�	parseArgs�runTests)�selfr1r=r5r>r?r6r9r7r8r:r<r+�parts              r�__init__zTestProgram.__init__Bs���f�c�"�"�	!�$�V�,�,�D�K����S�)�)�!�"�"�-�
9�
9��%�d�k�4�8�8����
9�!�D�K��<��8�D���	� ��
�$���"������"�����C�O��&�D�M�M�%�D�M�&���$���$�����(�(��a��1�1��
����t�����
�
�����rc���tjdt��|rt|��|j�|���|���tjd��dS)NzHTestProgram.usageExit() is deprecated and will be removed in Python 3.13�)	r<�warn�DeprecationWarning�print�_discovery_parser�_initArgParsers�_print_helpr4r6)rD�msgs  r�	usageExitzTestProgram.usageExithsr���
�0�1C�	E�	E�	E��	��#�J�J�J��!�)�� � �"�"�"��������������rc�Z�|j�_t|j�����ttd|jiz��|j���dSt|j�����ttd|jiz��dS)N�prog)	r1rK�_main_parser�format_help�
MAIN_EXAMPLESrArL�
print_help�MODULE_EXAMPLES)rD�args�kwargss   rrNzTestProgram._print_helprs����;���$�#�/�/�1�1�2�2�2��-�6�4�=�"9�9�:�:�:��"�-�-�/�/�/�/�/��$�#�/�/�1�1�2�2�2��/�V�T�]�$;�;�<�<�<�<�<rc���|���|j��t|��dkr=|d���dkr|�|dd���dS|j�|dd�|��|js|�g��dSn#|j�|dd�|��|jr,t|j��|_	tdkrd|_nP|j�d|_	nAt|jt��r|jf|_	nt|j��|_	|���dS)Nr�discoverrHr*)rMr1�lenr�
_do_discoveryrS�
parse_args�testsr#�	testNames�__name__r=r.r/�list�createTests)rDr5s  rrBzTestProgram.parseArgs{s^���������;���4�y�y�1�}�}��a������J�!>�!>��"�"�4����8�,�,�,�����(�(��a�b�b��4�8�8�8��:�
��"�"�2�&�&�&���	
�
��(�(��a�b�b��4�8�8�8��:�	4�+�D�J�7�7�D�N��:�%�%�"����
�
�
%�!�D�N�N�
��(�#�
.�
.�	4�"�.�0�D�N�N�!�$�"2�3�3�D�N��������rc�^�|jr|j|j_|r;|�|jn	|��}|j|j|j|j��|_dS|j�&|j�|j	��|_dS|j�
|j|j	��|_dS�N)�testNamePatternsr?r[�startr&�top�testr`�loadTestsFromModuler1�loadTestsFromNames)rD�from_discovery�Loaderrs    rrczTestProgram.createTests�s���� �	E�/3�/D�D�O�,��	H�(.��T�_�_�F�F�H�H�F�'����
�D�L�$�(�K�K�D�I�I�I�
�^�
#���;�;�D�K�H�H�D�I�I�I���:�:�4�>�;?�;�H�H�D�I�I�Irc��|���}|�|��|_|�|��|_dSre)�_getParentArgParser�_getMainArgParserrS�_getDiscoveryArgParserrL)rD�
parent_parsers  rrMzTestProgram._initArgParsers�sE���0�0�2�2�
� �2�2�=�A�A���!%�!<�!<�]�!K�!K����rc��tjd���}|�dddddd�	��|�d
ddddd
�	��|�dddd���|j�!|�ddddd���d|_|j�!|�ddddd���d|_|j�!|�ddddd���d|_|j�&|�dd d!td"�#��g|_|S)$NF)�add_helpz-vz	--verboser9�store_constrHzVerbose output)�dest�action�const�helpz-qz--quietrzQuiet outputz--localsr+�
store_truez"Show local variables in tracebacks)rvrwryz-fz
--failfastr7zStop on first fail or errorz-cz--catchr8z'Catch Ctrl-C and display results so farz-bz--bufferr:z%Buffer stdout and stderr during testsz-krf�appendz.Only run tests which match the given substring)rvrw�typery)�argparse�ArgumentParser�add_argumentr7r8r:rfr')rD�parsers  rrozTestProgram._getParentArgParser�s����(�%�8�8�8�����D�+�K�#0��!1�	�	3�	3�	3�	���D�)�+�#0��!/�	�	1�	1�	1�	���J�[�#/�!E�	�	G�	G�	G��=� �����l��'3�%B�
 �
D�
D�
D�"�D�M��?�"�����i�l�'3�%N�
 �
P�
P�
P�$�D�O��;������j�x�'3�%L�
 �
N�
N�
N� �D�K�� �(�����+=�'/�6M�%U�
 �
W�
W�
W�%'�D�!��
rc��tj|g���}|j|_|j|_|�ddd���|S)N��parentsr_r%z?a list of any number of test modules, classes and test methods.)�nargsry)r}r~rArRrNrVr)rD�parentr�s   rrpzTestProgram._getMainArgParser�sX���(�&��:�:�:���m��� �,������G�3�"8�	�	9�	9�	9��
rc�X�tj|g���}d|jz|_d|_|�dddd���|�d	d
dd���|�d
ddd���dD]/}|�|dtjtj����0|S)Nr�z%s discoverzcFor test discovery all test modules must be importable from the top level directory of the project.z-sz--start-directoryrgz*Directory to start discovery ('.' default))rvryz-pz	--patternr&z+Pattern to match tests ('test*.py' default)z-tz--top-level-directoryrhz<Top level directory of project (defaults to start directory))rgr&rh�?)r�r-ry)r}r~rArR�epilogr�SUPPRESS)rDr�r��args    rrqz"TestProgram._getDiscoveryArgParser�s����(�&��:�:�:��#�d�m�3���$��
�	���D�"5�G�!M�	�	O�	O�	O����D�+�I�!N�	�	P�	P�	P����D�"9��"4�	�	5�	5�	5�/�	8�	8�C�����3�(0�(9�%-�%6�
 �
8�
8�
8�
8��
rc���d|_d|_d|_|�6|j�|���|j�||��|�d|���dS)Nr
ztest*.pyT)rlrm)rgr&rhrLrMr^rc)rDr5rms   rr]zTestProgram._do_discovery�sp����
�!���������%�-��$�$�&�&�&��"�-�-�d�D�9�9�9�����V��<�<�<�<�<rc�z�|jrt��|j�tj|_t|jt��r�		|�|j|j|j	|j
|j���}n=#t$r0|�|j|j|j	|j
���}YnwxYwn+#t$r|���}YnwxYw|j}|�
|j��|_|jr.t#j|j�����dSdS)N)r9r7r:r<r+)r9r7r:r<)r8rr>r�TextTestRunnerr.r|r9r7r:r<r+�	TypeError�runri�resultr6r4�
wasSuccessful)rDr>s  rrCzTestProgram.runTests�sY���?�	������?�"�$�3�D�O��d�o�t�,�,�	)�
/�I�!%���4�>�:>�-�8<��:>�-�;?�>�	"1�"K�"K�J�J��
!�I�I�I�!%���4�>�:>�-�8<��:>�-�"1�"I�"I�J�J�J�I�������
/�
/�
/�!�_�_�.�.�
�
�
�
/����
��J� �n�n�T�Y�/�/����9�	6��H���2�2�4�4�4�5�5�5�5�5�	6�	6s0�
3A>�=B<�>7B8�5B<�7B8�8B<�<C�Cre)FN)ra�
__module__�__qualname__r1r9r7r8r:rAr<rfrLr�defaultTestLoaderrFrPrNrBrcrMrorprqr]rCrrrr)r)8s9��������F��I�NR�R�H�R�z�R�F�R�X�R��;K���(�d��#��0H���T�d��$�$�>C�$�$�$�$�$�L����=�=�=����:
H�
H�
H�
H�L�L�L�
!�!�!�F	�	�	����*=�=�=�=�6�6�6�6�6rr))r4r}rr<�rr�signalsr�
__unittestrUrWrr#r'�objectr)�mainrrr�<module>r�s����
�
�
�
�����	�	�	�	�������������#�#�#�#�#�#�
�
��
������ 3�3�3����\6�\6�\6�\6�\6�&�\6�\6�\6�|���r__pycache__/__main__.cpython-311.opt-2.pyc000064400000001204152401764000014132 0ustar00�

���xc������	ddlZejd�d��r1ddlZej�ej��Zedzejd<[dZddl	m	Z	e	d���dS)�Nz__main__.pyz -m unittestT�)�main)�module)
�sys�argv�endswith�os.path�os�path�basename�
executable�
__unittestr���</opt/alt/python-internal/lib/python3.11/unittest/__main__.py�<module>rs����
�
�
�
��8�A�;���
�&�&���N�N�N�
��!�!�#�.�1�1�J��~�-�C�H�Q�K�
�
�
���������D������r__pycache__/__init__.cpython-311.opt-1.pyc000064400000010232152401764000014151 0ustar00�

N@�s�D����dZgd�Ze�gd���dZddlmZddlmZmZm	Z	m
Z
mZmZm
Z
mZmZmZddlmZmZddlmZmZdd	lmZmZdd
lmZmZddlmZmZmZm Z ddlm!Z!m"Z"m#Z#eZ$d
�Z%d�Z&d�Z'dS)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�doModuleCleanups�enterModuleContext)�getTestCaseNames�	makeSuite�
findTestCasesT�)r)
rrrrrr
rrrr)�
BaseTestSuiter)rr
)�TestProgramr	)rr)rrrr)rrrc�v�ddl}|j�t��}|�||���S)N�)�	start_dir�pattern)�os.path�path�dirname�__file__�discover)�loader�testsr!�os�this_dirs     �</opt/alt/python-internal/lib/python3.11/unittest/__init__.py�
load_testsr,Os4���N�N�N��w���x�(�(�H��?�?�X�w�?�?�?�?�c�J�t�����dhzS)Nr)�globals�keys�r-r+�__dir__r2Zs���9�9�>�>���8�9�9�9r-c�\�|dkr
ddlmatStdt�d|�����)Nrr)rzmodule z has no attribute )�
async_caser�AttributeError�__name__)�names r+�__getattr__r8]sE���(�(�(�7�7�7�7�7�7�&�&�
�I�8�I�I��I�I�
J�
J�Jr-N)(�__doc__�__all__�extend�
__unittest�resultr�caserrrrrr
rrrr�suiterrr'rr
r	r�runnerrr�signalsrrrrrrr�_TextTestResultr,r2r8r1r-r+�<module>rCs���,�,�\I�I�I�����A�A�A�B�B�B�
�
�������'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�'�,�+�+�+�+�+�+�+�1�1�1�1�1�1�1�1�#�#�#�#�#�#�#�#�2�2�2�2�2�2�2�2�P�P�P�P�P�P�P�P�P�P�P�P�>�>�>�>�>�>�>�>�>�>�!��@�@�@�:�:�:�K�K�K�K�Kr-__pycache__/util.cpython-311.opt-1.pyc000064400000020045152401764000013372 0ustar00�

���B�����dZddlmZmZddlmZdZdZdZdZ	dZ
dZee	ezezeze
zz
Zd�Z
d	�Zdd�Zd�Zd
�Zd�Zd�Zedd��Zd�Zd�ZdS)zVarious utility functions.�)�
namedtuple�Counter)�commonprefixT�P��c��t|��|z
|z
}|tkr(d|d|�||t|��|z
d�fz}|S)Nz%s[%d chars]%s)�len�_PLACEHOLDER_LEN)�s�	prefixlen�	suffixlen�skips    �8/opt/alt/python-internal/lib/python3.11/unittest/util.py�_shortenrsW���q�6�6�I��	�)�D�������*�9�*�
�t�Q�s�1�v�v�	�7I�7J�7J�5K�L�L���H�c����ttt|����}ttt|����}|t
kr|St
|���t	����t
|�z
tztzz
}|tkr2t�t|���t��fd�|D����St�tt���t��fd�|D����S)Nc3�2�K�|]}�|�d�zV��dS�N���.0r�prefixr
s  ��r�	<genexpr>z'_common_shorten_repr.<locals>.<genexpr>'s0�����:�:��V�a�	�
�
�m�+�:�:�:�:�:�:rc3�d�K�|]*}�t|�d�tt��zV��+dSr)r�
_MIN_DIFF_LEN�_MIN_END_LENrs  ��rrz'_common_shorten_repr.<locals>.<genexpr>*sP����� � ���(�1�Y�Z�Z�=�-��N�N�N� � � � � � r)�tuple�map�	safe_repr�maxr
�_MAX_LENGTHr�_MIN_BEGIN_LENr�_MIN_COMMON_LENr)�args�maxlen�
common_lenrr
s   @@r�_common_shorten_reprr(s������Y��%�%�&�&�D�
��S�$���
 �
 �F�
������
�$�
�
�F��F���I���9�$�~�5�8H�H�J�J��O�#�#��&�.�*�=�=���:�:�:�:�:�T�:�:�:�:�:�:�
�f�n�o�
>�
>�F�� � � � � �� � � � � � rFc���	t|��}n*#t$rt�|��}YnwxYw|rt	|��t
kr|S|dt
�dzS)Nz [truncated]...)�repr�	Exception�object�__repr__r
r")�obj�short�results   rr r -sv��&��c�������&�&�&�����%�%����&������C��K�K�+�-�-��
��,�;�,��"3�3�3s��$9�9c�$�|j�d|j��S)N�.)�
__module__�__qualname__)�clss r�strclassr66s���n�n�n�c�&6�&6�7�7rc��dx}}g}g}		||}||}||kr8|�|��|dz
}|||kr|dz
}|||k�n�||kr8|�|��|dz
}|||kr|dz
}|||k�nm|dz
}	|||kr|dz
}|||k�|dz
}|||kr|dz
}|||k�n'#|dz
}|||kr|dz
}|||k�wxYwnJ#t$r=|�||d���|�||d���YnwxYw��G||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.
    rT�N)�append�
IndexError�extend)�expected�actual�i�j�missing�
unexpected�e�as        r�sorted_list_differencerD9s���
�I�A���G��J��	����A��q�	�A��1�u�u����q�!�!�!��Q����q�k�Q�&�&���F�A��q�k�Q�&�&���Q����!�!�!�$�$�$��Q����Q�i�1�n�n���F�A��Q�i�1�n�n���Q����"�1�+��*�*��Q���#�1�+��*�*���F�A� ��)�q�.�.��Q���!��)�q�.�.�����F�A� ��)�q�.�.��Q���!��)�q�.�.�.�.�.�.����	�	�	��N�N�8�A�B�B�<�(�(�(����f�Q�R�R�j�)�)�)��E�	����/�6�J��s+�BD�C�:#D�$D�D�AE�Ec��g}|rR|���}	|�|��n%#t$r|�|��YnwxYw|�R||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�
ValueErrorr9)r<r=r@�items    r�unorderable_list_differencerJbs����G�
�!��|�|�~�~��	!��M�M�$�������	!�	!�	!��N�N�4� � � � � �	!����	�!��F�?�s�0�A�Ac��||k||kz
S)z.Return -1 if x < y, 0 if x == y and 1 if x > yr)�x�ys  r�
three_way_cmprNss��
��E�a�!�e��r�Mismatchzactual expected valuec��t|��t|��}}t|��t|��}}t��}g}t|��D]�\}}	|	|ur�
dx}
}t	||��D]}|||	kr
|
dz
}
|||<�t|��D]\}}
|
|	kr
|dz
}|||<�|
|kr&t|
||	��}|�|����t|��D][\}}	|	|ur�
d}t	||��D]}|||	kr
|dz
}|||<�td||	��}|�|���\|S)�HReturns list of (cnt_act, cnt_exp, elem) triples where the counts differrr8)�listr
r,�	enumerate�range�	_Mismatchr9)r=r<r�t�m�n�NULLr0r>�elem�cnt_s�cnt_tr?�
other_elem�diffs               r�_count_diff_all_purposer_ys�����<�<��h���q�A��q�6�6�3�q�6�6�q�A��8�8�D�
�F��Q�<�<� � ���4��4�<�<�������q�!���	�	�A���t�t�|�|���
����!���&�q�\�\�	�	�M�A�z��T�!�!���
����!����E�>�>��U�E�4�0�0�D��M�M�$������Q�<�<�	�	���4��4�<�<�����q�!���	�	�A���t�t�|�|���
����!�����E�4�(�(���
�
�d������Mrc��t|��t|��}}g}|���D]G\}}|�|d��}||kr&t|||��}|�|���H|���D]/\}}||vr&td||��}|�|���0|S)rQr)r�items�getrUr9)	r=r<rrVr0rZr[r\r^s	         r�_count_diff_hashablerc�s����6�?�?�G�H�-�-�q�A�
�F��w�w�y�y� � ���e����d�A�����E�>�>��U�E�4�0�0�D��M�M�$������w�w�y�y� � ���e��q�=�=��Q��t�,�,�D��M�M�$������MrN)F)�__doc__�collectionsrr�os.pathr�
__unittestr"rr#rr$rrr(r r6rDrJrNrUr_rcrrr�<module>rhs(�� � �+�+�+�+�+�+�+�+� � � � � � �
�
�������������!1�1�O�C� �!�#/�0�1�
�

�
�
� � � �*4�4�4�4�8�8�8�&�&�&�R���"���
�J�z�#:�;�;�	�!�!�!�F����r__pycache__/mock.cpython-311.opt-2.pyc000064400000325313152401764000013355 0ustar00�

|@���pA���`�dZddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
ddlmZddlmZmZddlmZGd�d	e��Zd
�ee��D��ZdZeZd�Zd
�Zd�Zd�Zd�Z d�Z!dyd�Z"d�Z#d�Z$d�Z%d�Z&dyd�Z'd�Z(d�Z)d�Z*Gd�de+��Z,Gd�de+��Z-e-��Z.e.j/Z/e.j0Z1e.j2Z3hd �Z4d!�Z5Gd"�d#e6��Z7d$�Z8Gd%�d&e+��Z9Gd'�d(e+��Z:Gd)�d*e:��Z;ej<e;j=��Z>Gd+�d,e6��Z?d-�Z@Gd.�d/e:��ZAGd0�d1eAe;��ZBd2�ZCGd3�d4e+��ZDd5�ZEe/dddddfdd6�d7�ZF		dzd8�ZGe/dddddfdd6�d9�ZHGd:�d;e+��ZId<�ZJd=�ZKeFeH_+eIeH_LeGeH_MeKeH_Nd>eH_Od?ZPd@ZQdA�RdB�eQ�S��D����ZTdA�RdC�eQ�S��D����ZUhdD�ZVdE�ZWdF�dA�RePeQeTeUg���S��D��ZXhdG�ZYdHhZZeYeZzZ[eXeVzZ\e\e[zZ]hdI�Z^dJ�dK�dL�dM�dN�Z_e`e`e`e`dOddddPdQddOddR�
ZadS�ZbdT�ZcdU�ZddV�ZeebecedeedW�ZfdX�ZgGdY�dZe:��ZhGd[�d\ehe;��ZiGd]�d^eh��ZjGd_�d`eheB��ZkGda�dbe:��ZlGdc�dde:��ZmGde�dfemejeB��ZnGdg�dhe+��Zoeo��Zpdi�ZqGdj�dker��Zsesd�l��Zt		d{dd6�dm�Zudn�ZvGdo�dpe+��Zwexeu��exepjy��fZzda{da|dq�Z}d|ds�Z~Gdt�dueB��Zdv�Z�Gdw�dx��Z�dS)})�Mock�	MagicMock�patch�sentinel�DEFAULT�ANY�call�create_autospec�	AsyncMock�
FILTER_DIR�NonCallableMock�NonCallableMagicMock�	mock_open�PropertyMock�seal�N)�iscoroutinefunction)�CodeType�
ModuleType�
MethodType)�	safe_repr)�wraps�partial)�RLockc��eZdZdS)�InvalidSpecErrorN��__name__�
__module__�__qualname__���8/opt/alt/python-internal/lib/python3.11/unittest/mock.pyrr)s������B�Br!rc�<�h|]}|�d���|��S��_��
startswith)�.0�names  r"�	<setcomp>r*-s)��H�H�H�d�4�?�?�3�3G�3G�H�T�H�H�Hr!Tc���t|��rt|t��sdSt|d��rt	|d��}t|��pt
j|��S)NF�__func__)�_is_instance_mock�
isinstancer
�hasattr�getattrr�inspect�isawaitable��objs r"�
_is_async_objr55sg�������j��i�&@�&@���u��s�J���'��c�:�&�&���s�#�#�?�w�':�3�'?�'?�?r!c�F�t|dd��rt|��SdS)N�__code__F)r0r)�funcs r"�_is_async_funcr9=s)���t�Z��&�&��"�4�(�(�(��ur!c�F�tt|��t��S�N)�
issubclass�typerr3s r"r-r-Ds���d�3�i�i��1�1�1r!c��t|t��p)t|t��ot|t��Sr;)r.�
BaseExceptionr=r<r3s r"�
_is_exceptionr@Js6���3�
�&�&�	A��3����@�*�S�-�"@�"@�r!c�^�t|t��rt|d��r|jS|S�N�mock)r.�
FunctionTypesr/rCr3s r"�
_extract_mockrEQs3���#�}�%�%��'�#�v�*>�*>���x���
r!c��	t|t��r|s
|j}d}njt|ttf��rt|t��rd}|j}n/t|t��s	|j}n#t$rYdSwxYw|rt|d��}n|}	|tj|��fS#t$rYdSwxYw�NT)
r.r=�__init__�classmethod�staticmethodr,rD�__call__�AttributeErrorrr1�	signature�
ValueError)r8�as_instance�eat_self�sig_funcs    r"�_get_signature_objectrRZs���
�$�����k���}�����	�D�;��5�	6�	6���d�K�(�(�	��H��}���
��m�
,�
,��	��=�D�D���	�	�	��4�4�	�������4��&�&�������W�&�x�0�0�0�0�������t�t����s$�4A<�<
B
�	B
�#B9�9
C�CFc���t|||�����dS�\}��fd�}t||��|t|��_�t|��_dS)Nc�"���j|i|��dSr;��bind)�self�args�kwargs�sigs   �r"�checksigz"_check_signature.<locals>.checksig�� ������$�!�&�!�!�!�!�!r!)rR�_copy_func_detailsr=�_mock_check_sig�
__signature__)r8rC�	skipfirst�instancer[rZs     @r"�_check_signaturerb}sr���
��h�	�
:�
:�C�
�{����I�D�#�"�"�"�"�"��t�X�&�&�&�!)�D��J�J��"�D��J�J���r!c	�p�dD]2}	t||t||�����##t$rY�/wxYwdS)N)r�__doc__�__text_signature__r�__defaults__�__kwdefaults__)�setattrr0rL)r8�funcopy�	attributes   r"r]r]�sa�����	�	��G�Y���i�(@�(@�A�A�A�A���	�	�	��D�	����
�s�&�
3�3c���t|t��rdSt|tttf��rt|j��St|dd���dSdS)NTrKF)r.r=rJrIr�	_callabler,r0r3s r"rlrl�s^���#�t�����t��#��k�:�>�?�?�'����&�&�&��s�J��%�%�1��t��5r!c�<�t|��ttfvSr;)r=�list�tupler3s r"�_is_listrp�s����9�9��u�
�%�%r!c��	t|t��st|dd��duS|f|jzD]}|j�d���dS� dS)NrKTF)r.r=r0�__mro__�__dict__�get)r4�bases  r"�_instance_callablerv�sr��@��c�4� � �:��s�J��-�-�T�9�9�����$�����=���Z�(�(�4��4�4�5��5r!c�0��t|t��}t|||��}|�|S|\}��fd�}t||��|j}|���sd}||d�}d|z}	t
|	|��||}
t|
|���|
S)Nc�"���j|i|��dSr;rU)rXrYrZs  �r"r[z _set_signature.<locals>.checksig�r\r!ri)�
_checksig_rCzYdef %s(*args, **kwargs):
    _checksig_(*args, **kwargs)
    return mock(*args, **kwargs))r.r=rRr]r�isidentifier�exec�_setup_func)rC�originalrar`�resultr8r[r)�context�srcrirZs           @r"�_set_signaturer��s����
�8�T�*�*�I�
"�8�X�y�
A�
A�F�
�~����I�D�#�"�"�"�"�"��t�X�&�&�&���D���������%�t�4�4�G�$�&*�+�C�	�#�w�����d�m�G����s�#�#�#��Nr!c�������_�fd�}�fd�}�fd�}�fd�}�fd�}�fd�}�fd�}	��fd�}
d	�_d
�_d�_t	���_t	���_t	���_�j�_�j	�_	�j
�_
|�_|�_|�_
|	�_|
�_|�_|�_|�_|�_��_dS)Nc����j|i|��Sr;)�assert_called_with�rXrYrCs  �r"r�z'_setup_func.<locals>.assert_called_with�����&�t�&��7��7�7�7r!c����j|i|��Sr;)�
assert_calledr�s  �r"r�z"_setup_func.<locals>.assert_called�s���!�t�!�4�2�6�2�2�2r!c����j|i|��Sr;)�assert_not_calledr�s  �r"r�z&_setup_func.<locals>.assert_not_called�s���%�t�%�t�6�v�6�6�6r!c����j|i|��Sr;)�assert_called_oncer�s  �r"r�z'_setup_func.<locals>.assert_called_once�r�r!c����j|i|��Sr;)�assert_called_once_withr�s  �r"r�z,_setup_func.<locals>.assert_called_once_with�s���+�t�+�T�<�V�<�<�<r!c����j|i|��Sr;)�assert_has_callsr�s  �r"r�z%_setup_func.<locals>.assert_has_calls�s���$�t�$�d�5�f�5�5�5r!c����j|i|��Sr;)�assert_any_callr�s  �r"r�z$_setup_func.<locals>.assert_any_call�s���#�t�#�T�4�V�4�4�4r!c����t���_t���_�����j}t|��r|�ur|���dSdSdSr;)�	_CallList�method_calls�
mock_calls�
reset_mock�return_valuer-)�retrirCs ��r"r�z_setup_func.<locals>.reset_mock�so���(�{�{���&�[�[����������"���S�!�!�	�#��+�+��N�N������	�	�+�+r!Fr)rC�called�
call_count�	call_argsr��call_args_listr�r�r��side_effect�_mock_childrenr�r�r�r�r�r�r�r�r_�_mock_delegate)rirCrZr�r�r�r�r�r�r�r�s``         r"r|r|�s������G�L�8�8�8�8�8�3�3�3�3�3�7�7�7�7�7�8�8�8�8�8�=�=�=�=�=�6�6�6�6�6�5�5�5�5�5��������G�N��G���G��&�[�[�G��$�;�;�G��"���G���,�G���*�G��!�0�G��!3�G��&=�G�#�/�G��-�G��#�G��)�G�� 1�G��!3�G���G��!�D���r!c	����tjj�_d�_d�_t���_�fd�}dD]!}t�|t||�����"dS)Nrc�:��t�j|��|i|��Sr;)r0rC)�attrrXrYrCs   �r"�wrapperz"_setup_async_mock.<locals>.wrapper
s$���'�w�t�y�$�'�'��8��8�8�8r!)�assert_awaited�assert_awaited_once�assert_awaited_with�assert_awaited_once_with�assert_any_await�assert_has_awaits�assert_not_awaited)	�asyncio�
coroutines�
_is_coroutine�await_count�
await_argsr��await_args_listrhr)rCr�rjs`  r"�_setup_async_mockr�s���� �+�9�D���D���D�O�$�;�;�D��
9�9�9�9�9�,�>�>�	�	��i���)�!<�!<�=�=�=�=�>�>r!c�$�d|dd�z|kS)N�__%s__����r �r)s r"�	_is_magicr�s���d�1�R�4�j� �D�(�(r!c�"�eZdZ	d�Zd�Zd�ZdS)�_SentinelObjectc��||_dSr;r��rWr)s  r"rHz_SentinelObject.__init__"s
����	�	�	r!c��d|jzS�Nzsentinel.%sr��rWs r"�__repr__z_SentinelObject.__repr__%����t�y�(�(r!c��d|jzSr�r�r�s r"�
__reduce__z_SentinelObject.__reduce__(r�r!N)rrrrHr�r�r r!r"r�r� sD������'����)�)�)�)�)�)�)�)r!r�c�"�eZdZ	d�Zd�Zd�ZdS)�	_Sentinelc��i|_dSr;)�
_sentinelsr�s r"rHz_Sentinel.__init__.s
������r!c�l�|dkrt�|j�|t|����S)N�	__bases__)rLr��
setdefaultr�r�s  r"�__getattr__z_Sentinel.__getattr__1s3���;��� � ���)�)�$���0E�0E�F�F�Fr!c��dS)Nrr r�s r"r�z_Sentinel.__reduce__7s���zr!N)rrrrHr�r�r r!r"r�r�,sG������K����G�G�G�����r!r�>�
_mock_namer��_mock_parentr��_mock_new_name�_mock_new_parent�_mock_side_effect�_mock_return_valuec�x�t�|��d|z}||fd�}||fd�}t||��S)N�_mock_c�T�|j}|�t||��St||��Sr;)r�r0)rWr)�	_the_namerZs    r"�_getz"_delegating_property.<locals>._getLs/���!���;��4��+�+�+��s�D�!�!�!r!c�R�|j}|�||j|<dSt|||��dSr;)r�rsrh)rW�valuer)r�rZs     r"�_setz"_delegating_property.<locals>._setQs9���!���;�',�D�M�)�$�$�$��C��u�%�%�%�%�%r!)�_allowed_names�add�property)r)r�r�r�s    r"�_delegating_propertyr�Ise�����t�����4��I��	�"�"�"�"�
 $�y�&�&�&�&��D�$���r!c��eZdZd�Zd�ZdS)r�c��t|t��st�||��St|��}t|��}||krdSt	d||z
dz��D]}||||z�}||krdS�dS)NFr�T)r.rn�__contains__�len�range)rWr��	len_value�len_self�i�sub_lists      r"r�z_CallList.__contains__^s����%��&�&�	2��$�$�T�5�1�1�1���J�J�	��t�9�9���x����5��q�(�Y�.��2�3�3�	�	�A��A�a�	�k�M�*�H��5� � ��t�t�!��ur!c�D�tjt|����Sr;)�pprint�pformatrnr�s r"r�z_CallList.__repr__ls���~�d�4�j�j�)�)�)r!N)rrrr�r�r r!r"r�r�\s2���������*�*�*�*�*r!r�c���t|��}t|��sdS|js|js|j�|j�dS|}|�||urdS|j}|�|r||_||_|r||_||_dS)NFT)rEr-r�r�r�r�)�parentr�r)�new_name�_parents     r"�_check_and_set_parentr�ps����%� � �E��U�#�#���u�	�	��U�1��	�	�	'�	�	�	+��u��G�
�
��e����5��*���
��(�!'���'���� �#�������4r!c��eZdZd�Zd�ZdS)�	_MockIterc�.�t|��|_dSr;)�iterr4)rWr4s  r"rHz_MockIter.__init__�s����9�9����r!c�*�t|j��Sr;)�nextr4r�s r"�__next__z_MockIter.__next__�s���D�H�~�~�r!N)rrrrHr�r r!r"r�r��s2�������������r!r�c��eZdZeZdZd�ZdS)�BaseNc��dSr;r �rWrXrYs   r"rHz
Base.__init__�s���r!)rrrrr�r�rHr r!r"r�r��s/������ ����
�
�
�
�
r!r�c��eZdZ	e��Zd�Z			d,d�Zd�Zd-d�Z		d.d�Z	d	�Z
d
�ZdZe
e
ee��Ze
d���Zed
��Zed��Zed��Zed��Zed��Zd�Zd�Ze
ee��Zd/ddd�d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d0d�Z"d �Z#d!�Z$d"�Z%d#�Z&d$�Z'd%�Z(d&�Z)d-d'�Z*d(�Z+d)�Z,d1d+�Z-dS)2rc�z�|f}t|t��s]tj|g|�Ri|��j}|�d|�d����}|�t
|��r	t|f}t|j|d|j	i��}tt|���|��}|S)N�spec_set�specrd)
r<�AsyncMockMixin�	_MOCK_SIG�bind_partial�	argumentsrtr5r=rrd�_safe_superr�__new__)�clsrX�kw�bases�
bound_args�spec_arg�newras        r"rzNonCallableMock.__new__�s�������#�~�.�.�	.�"�/��A�d�A�A�A�b�A�A�K�J�!�~�~�j�*�.�.��2H�2H�I�I�H��#�
�h�(?�(?�#�'��-���3�<���C�K�(@�A�A�����4�4�<�<�S�A�A���r!N�Fc��|�|}|j}
||
d<||
d<||
d<||
d<d|
d<|�|}d}|
�|du}
|�|||	|
��i|
d<||
d	<d|
d
<d|
d<d|
d<d
|
d<t��|
d<t��|
d<t��|
d<||
d<|r
|jdi|��t	t
|���||||||��dS)Nr�r�r�r�F�_mock_sealedTr��_mock_wrapsr��_mock_called�_mock_call_argsr�_mock_call_count�_mock_call_args_list�_mock_mock_callsr��_mock_unsafer )rs�_mock_add_specr��configure_mockrrrH)rWr�rr)r�r��_spec_state�	_new_name�_new_parent�_spec_as_instance�	_eat_self�unsaferYrss              r"rHzNonCallableMock.__init__�sV��
�� �K��=��#)��� �!%����%.��!�"�'2��#�$�#(��� ����D��H����d�*�I����D�(�,=�y�I�I�I�%'��!�"�"'����%)��!�"�#(��� �&*��"�#�'(��#�$�+4�;�;��'�(�'0�{�{��#�$�#,�;�;��� �#)��� ��	*��D��)�)�&�)�)�)��O�T�*�*�3�3��%��x���	
�	
�	
�	
�	
r!c��	t|��}d|_d|_d|_d|_t|||��dS�Nr)rEr�r�r�r�rh)rWrCrj�
inner_mocks    r"�attach_mockzNonCallableMock.attach_mock�sO��	C�#�4�(�(�
�"&�
��&*�
�#� "�
��$(�
�!���i��&�&�&�&�&r!c�4�	|�||��dSr;)r�rWr�r�s   r"�
mock_add_speczNonCallableMock.mock_add_spec�s&��	N�
	
���D�(�+�+�+�+�+r!c���t|��rtd|�d����d}d}g}t|��D]5}tt	||d����r|�|���6|�`t
|��sQt|t��r|}nt|��}t|||��}	|	o|	d}t|��}|j
}
||
d<||
d<||
d<||
d<||
d<dS)	Nz#Cannot spec a Mock object. [object=�]r��_spec_class�	_spec_set�_spec_signature�
_mock_methods�_spec_asyncs)r-r�dirrr0�appendrpr.r=rRrs)rWr�r�rrr'r)r+r��resrss           r"rzNonCallableMock._mock_add_spec�s'���T�"�"�	T�"�#R��#R�#R�#R�S�S�S���������I�I�	*�	*�D�"�7�4��t�#<�#<�=�=�
*��#�#�D�)�)�)����H�T�N�N���$��%�%�
)�"���"�4�j�j��'��(9�9�F�F�C�!�n�c�!�f�O��t�9�9�D��=��"-���� (����&5��"�#�$(���!�#/��� � � r!c��|j}|j�|jj}|tur%|j�|�|d���}||_|S)N�()�rr)r�r�r�rr�_get_child_mock)rWr�s  r"�__get_return_valuez"NonCallableMock.__get_return_values]���%����*��%�2�C��'�>�>�d�.�6��&�&� �D�'���C�!$�D���
r!c�b�|j�||j_dS||_t||dd��dS)Nr0)r�r�r�r�)rWr�s  r"�__set_return_valuez"NonCallableMock.__set_return_value%s>����*�/4�D��,�,�,�&+�D�#�!�$��t�T�:�:�:�:�:r!z1The value to be returned when the mock is called.c�<�|j�t|��S|jSr;)r'r=r�s r"�	__class__zNonCallableMock.__class__1s ����#���:�:����r!r�r�r�r�r�c���|j}|�|jS|j}|�It|��s:t	|t
��s%t
|��st|��}||_|Sr;)r�r�r��callabler.r�r@)rW�	delegated�sfs   r"�__get_side_effectz!NonCallableMock.__get_side_effect>sj���'�	����)�)�
�
"���N�8�B�<�<�N�"�2�y�1�1�
�:G��:K�:K�
��2���B�$&�I�!��	r!c�V�t|��}|j}|�	||_dS||_dSr;)�	_try_iterr�r�r�)rWr�r:s   r"�__set_side_effectz!NonCallableMock.__set_side_effectIs9���%� � ���'�	���%*�D�"�"�"�$)�I�!�!�!r!�r�r�c�P�	|�g}t|��|vrdS|�t|����d|_d|_d|_t��|_t��|_t��|_|rt|_
|rd|_|j�
��D]9}t|t��s	|t ur�!|�|||����:|j
}t%|��r||ur|�|��dSdSdS)NFrr@)�idr-r�r�r�r�r�r�r�rr�r�r��valuesr.�
_SpecState�_deletedr�r-)rW�visitedr�r��childr�s      r"r�zNonCallableMock.reset_mockTs8��7��?��G�
�d�8�8�w����F����r�$�x�x� � � ����������#�+�+���'�k�k���%�K�K����	.�&-�D�#��	*�%)�D�"��(�/�/�1�1�	Z�	Z�E��%��,�,�
���0A�0A�����W�<�[��Y�Y�Y�Y��%���S�!�!�	$�c��o�o��N�N�7�#�#�#�#�#�	$�	$�o�or!c��	t|���d����D]V\}}|�d��}|���}|}|D]}t	||��}�t|||���WdS)Nc�8�|d�d��S)Nr�.)�count)�entrys r"�<lambda>z0NonCallableMock.configure_mock.<locals>.<lambda>s���q�����1D�1D�r!)�keyrJ)�sorted�items�split�popr0rh)rWrY�arg�valrX�finalr4rLs        r"rzNonCallableMock.configure_mockrs���	,��v�|�|�~�~�$E�#D�	F�F�F�
	%�
	%�H�C��
�9�9�S�>�>�D��H�H�J�J�E��C��
*�
*���c�5�)�)����C���$�$�$�$�
	%�
	%r!c
��|dvrt|���|j�%||jvs	|tvrtd|z���nt|��rt|���|js:|jr	||jvr*|�d��rt|�d|�d����tj5|j�	|��}|turt|���|�Cd}|j�t|j|��}|�
|||||���}||j|<n�t|t��rv	t!|j|j|j|j|j��}n>#t,$r1|jdp|}t-d|�d	|�d
|�d|j�d�	���wxYw||j|<ddd��n#1swxYwY|S)
N>rr*zMock object has no attribute %r)�assert�assret�asert�aseert�assrtz6 is not a valid assertion. Use a spec for the mock if z is meant to be an attribute.)r�r)rrrr��Cannot autospec attr �
 from target �, as it has already been mocked out. [target=�, attr=r&)rLr*�_all_magicsr�rr'r�_lockr�rtrErr0r2r.rDr	r�r�rar�r)rrs)rWr)r~r�target_names     r"r�zNonCallableMock.__getattr__�s����4�4�4� ��&�&�&�
�
�
+��4�-�-�-���1D�1D�$�%F��%M�N�N�N�2E�
�t�_�_�	'� ��&�&�&�� �	N�$�*<�	N��D�L^�@^�@^����O�P�P�
N�$��M�M�'+�M�M�M�N�N�N��
"�	4�	4��(�,�,�T�2�2�F���!�!�$�T�*�*�*������#�/�$�D�$4�d�;�;�E��-�-��d�%�4� $�.����.4��#�D�)�)��F�J�/�/�
4�
D�,���V�_�f�o��
�v�{���F�F��(�D�D�D�"&�-��"=�"E��K�*�C��C�C�&�C�C�#'�C�C�28�+�C�C�C�D�D�D�D����.4��#�D�)�;	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4����	4�	4�	4�	4�>�
s+�+B
F:�9,E&�%F:�&;F!�!
F:�:F>�F>c�n�|jg}|j}|}d}|dgkrd}|�7|}|�|j|z��d}|jdkrd}|j}|�7tt	|����}|jpd}t
|��dkr|ddvr|dz
}||d<d�|��S)NrJr0rrCr�)r0z().r)r�r�r-rn�reversedr�r��join)rW�
_name_listr��last�dot�_firsts      r"�_extract_mock_namez"NonCallableMock._extract_mock_name�s����)�*�
��'�������$�����C��!��D����g�4�s�:�;�;�;��C��%��-�-����.�G��!��(�:�.�.�/�/�
���*�F���z�?�?�Q����!�}�M�1�1��#�
���
�1�
��w�w�z�"�"�"r!c���|���}d}|dvrd|z}d}|j�d}|jrd}||jjz}dt	|��j�|�|�dt|���d�S)	Nr)rCzmock.z name=%rz spec=%rz spec_set=%r�<z id='z'>)rjr'r(rr=rB)rWr)�name_string�spec_strings    r"r�zNonCallableMock.__repr__�s����&�&�(�(�����(�(�(�$�t�+�K�����'�$�K��~�
-�,��%��(8�(A�A�K����J�J����K��K�K��t�H�H�H�H�	
�	
r!c�x�	tst�|��S|jpg}t	t|����}t
|j��}d�|j�	��D��}d�|D��}d�|D��}tt||z|z|z����S)Nc�*�g|]\}}|tu�|��Sr )rE)r(�m_name�m_values   r"�
<listcomp>z+NonCallableMock.__dir__.<locals>.<listcomp>�s1��(�(�(�&�v�w��h�&�&�
�&�&�&r!c�<�g|]}|�d���|��Sr$r&�r(�es  r"rsz+NonCallableMock.__dir__.<locals>.<listcomp>�s)��C�C�C�1����c�1B�1B�C�Q�C�C�Cr!c�Z�g|](}|�d��rt|���&|��)Sr$)r'r�rus  r"rsz+NonCallableMock.__dir__.<locals>.<listcomp>�sE��#�#�#�1����c�1B�1B�#��q�\�\�#�Q�#�#�#r!)r�object�__dir__r*r,r=rnrsr�rPrO�set)rW�extras�	from_type�	from_dict�from_child_mockss     r"ryzNonCallableMock.__dir__�s���F��	(��>�>�$�'�'�'��#�)�r����T�
�
�O�O�	����'�'�	�(�(�*.�*=�*C�*C�*E�*E�(�(�(��D�C�	�C�C�C�	�#�#�	�#�#�#�	��c�&�9�,�y�8�;K�K�L�L�M�M�Mr!c�T���|tvrt��||��S�jr+�j�$|�jvr|�jvrt
d|z���|tvrd|z}t
|���|tvr��j�|�jvrt
d|z���t|��s5tt���|t||����|���fd�}nft�|d|��tt���||��|�j|<n+|dkr	|�_dSt�|||��r
|�j|<�jr;t#�|��s+�����d|��}t
d|�����t��||��S)Nz!Mock object has no attribute '%s'z.Attempting to set unsupported magic method %r.c�����g|�Ri|��Sr;r )rXrr}rWs  ��r"rMz-NonCallableMock.__setattr__.<locals>.<lambda>s!���H�H�T�,G�D�,G�,G�,G�B�,G�,G�r!r7rJzCannot set )r�rx�__setattr__r(r*rsrL�_unsupported_magicsr`r-rhr=�_get_methodr�r�r'rr/rj)rWr)r��msg�	mock_namer}s`    @r"r�zNonCallableMock.__setattr__�s������>�!�!��%�%�d�D�%�8�8�8��n�	2��!3�!?���*�*�*���
�%�%� �!D�t�!K�L�L�L�
�(�
(�
(�B�T�I�C� ��%�%�%�
�[�
 �
 ��!�-�$�d�>P�2P�2P�$�%H�4�%O�P�P�P�$�U�+�+�	
2���T�
�
�D�+�d�E�*B�*B�C�C�C� ��G�G�G�G�G���&�d�E�4��>�>�>���T�
�
�D�%�0�0�0�,1��#�D�)�)�
�[�
 �
 �$�D���F�$�T�5�$��=�=�
2�,1��#�D�)���	<�W�T�4�%8�%8�	<��2�2�4�4�=�=�t�=�=�I� �!:�y�!:�!:�;�;�;��!�!�$��e�4�4�4r!c��|tvr>|t|��jvr(tt|��|��||jvrdS|j�|t��}||jvr)tt|���	|��n|turt|���|tur|j|=t|j|<dSr;)r`r=rs�delattrr�rt�_missingrr�__delattr__rErL)rWr)r4s   r"r�zNonCallableMock.__delattr__!s����;���4�4��:�:�+>�#>�#>��D��J�J��%�%�%��4�=�(�(����!�%�%�d�H�5�5���4�=� � ����.�.�:�:�4�@�@�@�@�
�H�_�_� ��&�&�&��h����#�D�)�$,���D�!�!�!r!c�6�|jpd}t|||��SrB)r��_format_call_signature�rWrXrYr)s    r"�_format_mock_call_signaturez+NonCallableMock._format_mock_call_signature3s ����(�&��%�d�D�&�9�9�9r!rc�d�d}|�||��}|j}|j|�}||||fzS)Nz0expected %s not found.
Expected: %s
  Actual: %s)r�r�)rWrXrY�action�message�expected_stringr��
actual_strings        r"�_format_mock_failure_messagez,NonCallableMock._format_mock_failure_message8sD��F���:�:�4��H�H���N�	�8��8�)�D�
��&�/�=�A�A�Ar!c��	|s|jSd}|�dd���d��}|j}|D]M}|�|��}|�t|t��rnt|��}|j}|j}�N|S)Nr0rrJ)r)�replacerQr�rtr.rDrE)rWr)rZ�names�childrenrGs      r"�_get_call_signature_from_namez-NonCallableMock._get_call_signature_from_name@s���		��	(��'�'������T�2�&�&�,�,�S�1�1���&���
	,�
	,�D��L�L��&�&�E��}�
�5�*� =� =�}���
&�e�,�,�� �/���+����
r!c��	t|t��r/t|��dkr|�|d��}n|j}|�vt|��dkrd}|\}}n|\}}}	|j|i|��}t
||j|j��S#t$r}|�
d��cYd}~Sd}~wwxYw|S)Nr�rr)r.ror�r�r)rVrrXrY�	TypeError�with_traceback)rW�_callrZr)rXrY�
bound_callrvs        r"�
_call_matcherzNonCallableMock._call_matcheras���	��e�U�#�#�	'��E�
�
�Q����4�4�U�1�X�>�>�C�C��&�C��?��5�z�z�Q�����$���f�f�%*�"��d�F�
.�%�S�X�t�6�v�6�6�
��D�*�/�:�3D�E�E�E���
.�
.�
.��'�'��-�-�-�-�-�-�-�-�����
.�����Ls�1'B�
C�#B=�7C�=Cc��	|jdkr8d|jpd�d|j�d|�����}t|���dS)Nr�
Expected 'rCz"' to not have been called. Called � times.�r�r��_calls_repr�AssertionError�rWr�s  r"r�z!NonCallableMock.assert_not_called|sa��	��?�a�����o�/��/�/��o�o�o��&�&�(�(�(�*�C�!��%�%�%� �r!c�T�	|jdkrd|jpdz}t|���dS)Nrz"Expected '%s' to have been called.rC)r�r�r�r�s  r"r�zNonCallableMock.assert_called�s>��	��?�a���7��O�-�v�/�C� ��%�%�%� �r!c��	|jdks8d|jpd�d|j�d|�����}t|���dS)Nr�r�rCz#' to have been called once. Called r�r�r�s  r"r�z"NonCallableMock.assert_called_once�sa��	���!�#�#�#��o�/��/�/��o�o�o��&�&�(�(�(�*�C�!��%�%�%�$�#r!c�v����	�j�/������}d}d|�d|��}t|������fd�}��t	��fd�����}���j��}||kr1t|t��r|nd}t|����|�dS)Nznot called.z#expected call not found.
Expected: z
  Actual: c�4��������}|Sr;�r��r�rXrYrWs ���r"�_error_messagez:NonCallableMock.assert_called_with.<locals>._error_message�s����3�3�D�&�A�A�C��Jr!T��two)r�r�r�r��_Callr.�	Exception)rWrXrY�expected�actual�
error_messager��causes```     r"r�z"NonCallableMock.assert_called_with�s������	3��>�!��7�7��f�E�E�H�"�F�F��x�x���)�M� ��/�/�/�	�	�	�	�	�	�	��%�%�e�T�6�N��&E�&E�&E�F�F���#�#�D�N�3�3���X��� *�8�Y� ?� ?�I�H�H�T�E� ���!1�!1�2�2��=��r!c��	|jdks8d|jpd�d|j�d|�����}t|���|j|i|��S)Nr�r�rCz' to be called once. Called r�)r�r�r�r�r��rWrXrYr�s    r"r�z'NonCallableMock.assert_called_once_with�sq��	)���!�#�#�#��o�/��/�/��o�o�o��&�&�(�(�(�*�C�!��%�%�%�&�t�&��7��7�7�7r!c���	�fd�|D��}td�|D��d��}t�fd��jD����}|su||vro|�d}nd�d�|D����}t	|�dt|�����d�	���d
������|�dSt|��}g}|D]=}	|�|���#t$r|�
|��Y�:wxYw|r-t	�jpd�dt|���d
|�d���|�dS)Nc�:��g|]}��|����Sr �r��r(�crWs  �r"rsz4NonCallableMock.assert_has_calls.<locals>.<listcomp>��'���9�9�9�a�D�&�&�q�)�)�9�9�9r!c3�DK�|]}t|t���|V��dSr;�r.r�rus  r"�	<genexpr>z3NonCallableMock.assert_has_calls.<locals>.<genexpr>��1����F�F�A�Z��9�-E�-E�F�a�F�F�F�F�F�Fr!c3�B�K�|]}��|��V��dSr;r�r�s  �r"r�z3NonCallableMock.assert_has_calls.<locals>.<genexpr>�s1�����M�M��d�0�0��3�3�M�M�M�M�M�Mr!zCalls not found.z+Error processing expected calls.
Errors: {}c�@�g|]}t|t��r|nd��Sr;r�rus  r"rsz4NonCallableMock.assert_has_calls.<locals>.<listcomp>��;��$7�$7�$7�()�*4�A�y�)A�)A�$K�A�A�t�$7�$7�$7r!�
Expected: z  Actual)�prefixrJrCz does not contain all of z in its call list, found z instead)
r�r�r��formatr�r��rstriprn�removerNr-r�ro)	rW�calls�	any_orderr�r��	all_calls�problem�	not_found�kalls	`        r"r�z NonCallableMock.assert_has_calls�s����	1�:�9�9�9�5�9�9�9���F�F��F�F�F��M�M���M�M�M�M�T�_�M�M�M�M�M�	��	��y�(�(��=�0�G�G� ,�-3�V�$7�$7�-5�$7�$7�$7�.8�.8��%��I�I�!*�5�!1�!1�I��'�'�z�'�:�:�A�A�#�F�F�I�I����	�

�F���O�O�	��	��	'�	'�D�
'�� � ��&�&�&�&���
'�
'�
'�� � ��&�&�&�&�&�
'�����	� �&*�o�&?��&?�&?�&+�I�&6�&6�&6�&6�	�	�	�C����	
�	�	s�C.�.D�Dc�&��	��t||fd�����}t|t��r|nd}�fd��jD��}|s|t|��vr)��||��}td|z��|�dS)NTr�c�:��g|]}��|����Sr r�r�s  �r"rsz3NonCallableMock.assert_any_call.<locals>.<listcomp>�s'���E�E�E�A�$�$�$�Q�'�'�E�E�Er!z%s call not found)r�r�r.r�r��_AnyComparerr�r��rWrXrYr�r�r�r�s`      r"r�zNonCallableMock.assert_any_call�s����	,�
�%�%�e�T�6�N��&E�&E�&E�F�F��&�x��;�;�E�����E�E�E�E��1D�E�E�E���	�H�L��$8�$8�8�8�"�>�>�t�V�L�L�O� �#�o�5����
�9�8r!c��	|jr7d|vrd|d��nd}|���|z}t|���|�d��}||jdvrtdi|��St
|��}t|t��r|tvrt
}n�t|t��r)|tvs|jr||jvrt}ndt
}n\t|t��s:t|t��rt}n*t|t��rt }n
|jd}|di|��S)Nr)rJr0rr+r�r )rrjrLrtrsr
r=r<r�_async_method_magicsr�_all_sync_magicsr*�
CallableMixinr
rrrr)rWrrjr�r�_type�klasss       r"r2zNonCallableMock._get_child_mock�s`��	!���	,�,2�b�L�L�(�B�v�J�(�(�(�d�I��/�/�1�1�I�=�I� ��+�+�+��F�F�;�'�'�	���
�n�5�5�5��?�?�r�?�?�"��T�
�
���e�Y�'�'�	%�I�9M�,M�,M��E�E�
��~�
.�
.�
	%��-�-�-��&�.�+4��8J�+J�+J�!���!����E�=�1�1�	%��%�!5�6�6�
�!����E�?�3�3�
�����M�!�$�E��u�{�{�r�{�{�r!�Callsc�L�	|jsdSd|�dt|j���d�S)Nr�
z: rJ)r�r)rWr�s  r"r�zNonCallableMock._calls_reprs;��	���	��2�;�F�;�;�i���8�8�;�;�;�;r!)NNNNNNrNFNF�F)FFr;)r)r�).rrrrrarrHr!r$r�"_NonCallableMock__get_return_value�"_NonCallableMock__set_return_value�"_NonCallableMock__return_value_docr�r�r7r�r�r�r�r�r��!_NonCallableMock__get_side_effect�!_NonCallableMock__set_side_effectr�r�rr�rjr�ryr�r�r�r�r�r�r�r�r�r�r�r�r�r2r�r r!r"rr�s�������*�
�E�G�G�E�
�
�
�">B�EI�<A�*
�*
�*
�*
�Z'�'�'�,�,�,�,�@E�!&�0�0�0�0�>
�
�
�;�;�;�M���8�.�0B�.�0�0�L�� � ��X� �
"�
!�(�
+�
+�F�%�%�l�3�3�J�$�$�[�1�1�I�)�)�*:�;�;�N�%�%�l�3�3�J�	�	�	�*�*�*��(�,�.?�@�@�K�$�u�%�$�$�$�$�$�<%�%�%�,-�-�-�`#�#�#�6
�
�
�*N�N�N�$$5�$5�$5�N-�-�-�$:�:�:�
B�B�B�B����B���6&�&�&�&�&�&�&�&�&�>�>�>�,	8�	8�	8�*�*�*�*�Z
�
�
� #�#�#�L
<�
<�
<�
<�
<�
<r!rc��eZdZ	d�ZdS)r�c�d�|D],}td�t||��D����rdS�-dS)Nc� �g|]\}}||k��Sr r )r(r�r�s   r"rsz-_AnyComparer.__contains__.<locals>.<listcomp>5s1�����$�H�f��F�"���r!TF)�all�zip)rW�itemr�s   r"r�z_AnyComparer.__contains__2s^���	�	�E����(+�D�%�(8�(8������
��t�t�	
�
�ur!N)rrrr�r r!r"r�r�-s(�����������r!r�c��|�|St|��r|St|��r|S	t|��S#t$r|cYSwxYwr;)r@rlr�r�r3s r"r>r>=sk��
�{��
��S�����
���~�~���
���C�y�y��������
�
�
����s�7�A�Ac
�H�eZdZddedddddddf
d�Zd�Zd�Zd�Zd�Zd�Z	dS)	r�Nrc
�x�||jd<tt|��j|||||||	|
fi|��||_dS)Nr�)rsrr�rHr�)rWr�r�r�rr)r�r�rrrrYs            r"rHzCallableMixin.__init__Nsa��/;��
�*�+�1��M�4�(�(�1��%��x����K�	
�	
�39�	
�	
�	
�
'����r!c��dSr;r r�s   r"r^zCallableMixin._mock_check_sigZs���r!c�P�|j|i|��|j|i|��|j|i|��Sr;)r^�_increment_mock_call�
_mock_callr�s   r"rKzCallableMixin.__call___sK��	���d�-�f�-�-�-�!��!�4�2�6�2�2�2��t���/��/�/�/r!c��|j|i|��Sr;)�_execute_mock_callr�s   r"r�zCallableMixin._mock_callgs��&�t�&��7��7�7�7r!c�~�d|_|xjdz
c_t||fd���}||_|j�|��|jdu}|j}|j}|dk}|j	�td||f����|j
}|��|rB|j�t|||f����|jdu}|r
|jdz|z}t|||f��}	|j	�|	��|jr|rd}
nd}
|jdk}|j|
z|z}|j
}|��dSdS)NTr�r�r0rrJ)r�r�r�r�r�r-r�r�r�r�r�r�)rWrXrYr��do_method_calls�method_call_name�mock_call_name�	is_a_callr�this_mock_callrhs           r"r�z"CallableMixin._increment_mock_calljs���������1����
�t�V�n�$�/�/�/�������"�"�5�)�)�)��+�4�7���?���,��"�d�*�	�����u�b�$��%7�8�8�9�9�9��+���%��
W��(�/�/��7G��v�6V�0W�0W�X�X�X�"-�":�$�"F��"�W�'2�'=��'C�FV�'V�$�#�N�D�&�#A�B�B�N��"�)�)�.�9�9�9��)�
S����C�C��C�'�6�$�>�	�!,�!;�c�!A�N�!R��&�6�K�-�%�%�%�%�%r!c�^�|j}|�Tt|��r|�t|��s!t|��}t|��r|�n||i|��}|tur|S|jtur|jS|jr|jjtur|jS|j�
|j|i|��S|jSr;)	r�r@rlr�rr�r�r�r)rWrXrY�effectr~s     r"r�z CallableMixin._execute_mock_call�s����!�����V�$�$�
1����v�&�&�
1��f���� ��(�(�!� �L�!� ���0��0�0���W�$�$��
��"�'�1�1��$�$���	%�4�#6�#C�7�#R�#R��$�$���'�#�4�#�T�4�V�4�4�4�� � r!)
rrrrrHr^rKr�r�r�r r!r"r�r�Ls������� �d���$��d�!�R�T�	'�	'�	'�	'�
�
�
�
0�0�0�8�8�8�,7�,7�,7�\!�!�!�!�!r!r�c��eZdZdS)rNrr r!r"rr�s������5�5r!rc�@�d}|D]}||vrt|�d�����dS)N)�	autospect�	auto_spec�set_specz5 might be a typo; use unsafe=True if this is intended)�RuntimeError)�kwargs_to_check�typos�typos   r"�_check_spec_arg_typosr�sN��2�E������?�"�"���P�P�P���
�#��r!c�~�eZdZdZgZdd�d�Zd�Zd�Zd�Ze	j
d���Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�ZdS)�_patchNF�rc
��|�)|turtd���|�td���|
st|	��t|��rt	d|�d|�d����t|��rt	d|�d|�d����||_||_||_||_||_	||_
d|_||_||_
|	|_g|_dS)Nz,Cannot use 'new' and 'new_callable' togetherz1Cannot use 'autospec' and 'new_callable' togetherzCannot spec attr z0 as the spec has already been mocked out. [spec=r&z? as the spec_set target has already been mocked out. [spec_set=F)rrNrr-r�getterrjr�new_callabler��create�	has_localr��autospecrY�additional_patchers)rWrrjrr�r	r�rrrYrs           r"rHz_patch.__init__sV���#��'�!�!� �B�����#� �G�����	*�!�&�)�)�)��T�"�"�	A�"�@�I�@�@�6:�@�@�@�A�A�
A��X�&�&�	P�"�O�I�O�O�AI�O�O�O�P�P�
P����"������(�����	������� ��
� ��
����#%�� � � r!c���t|j|j|j|j|j|j|j|j|j	�	�	}|j
|_
d�|jD��|_|S)Nc�6�g|]}|�����Sr )�copy)r(�ps  r"rsz_patch.copy.<locals>.<listcomp>,s-��'
�'
�'
��A�F�F�H�H�'
�'
�'
r!)rrrjrr�r	r�rrrY�attribute_namer)rW�patchers  r"rz_patch.copy%sq����K�����4�9��K����M�4�,�d�k�
�
��
"&�!4���'
�'
�"�6�'
�'
�'
��#��r!c���t|t��r|�|��Stj|��r|�|��S|�|��Sr;�r.r=�decorate_classr1r�decorate_async_callable�decorate_callable)rWr8s  r"rKz_patch.__call__2sc���d�D�!�!�	-��&�&�t�,�,�,��&�t�,�,�	6��/�/��5�5�5��%�%�d�+�+�+r!c��t|��D]q}|�tj��s�"t	||��}t|d��s�C|���}t||||�����r|S�NrK)r,r'r�TEST_PREFIXr0r/rrh)rWr�r��
attr_valuers     r"rz_patch.decorate_class:s�����J�J�		6�		6�D��?�?�5�#4�5�5�
�� ���-�-�J��:�z�2�2�
���i�i�k�k�G��E�4����!4�!4�5�5�5�5��r!c#�TK�g}tj��5}|jD]W}|�|��}|j�|�|���4|jtur|�|���X|t|��z
}||fV�ddd��dS#1swxYwYdSr;)
�
contextlib�	ExitStack�	patchings�
enter_contextr�updaterrr-ro)rW�patchedrX�keywargs�
extra_args�
exit_stack�patchingrSs        r"�decoration_helperz_patch.decoration_helperHs�����
�
�
!�
#�
#�		#�z�#�-�
+�
+�� �.�.�x�8�8���*�6��O�O�C�(�(�(�(��\�W�,�,��%�%�c�*�*�*���E�*�%�%�%�D���"�"�"�"�		#�		#�		#�		#�		#�		#�		#�		#�		#�		#�		#�		#����		#�		#�		#�		#�		#�		#s�A8B�B!�$B!c�����t�d��r�j�����St������fd�����g�_�S)Nrc�|�����||��5\}}�|i|��cddd��S#1swxYwYdSr;�r'�rXr#�newargs�newkeywargsr8r"rWs    ���r"r"z)_patch.decorate_callable.<locals>.patched]s�����'�'��(,�(0�2�2�
5�5K�g�{��t�W�4��4�4�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5�
5����
5�
5�
5�
5�
5�
5s�1�5�5�r/rr-r�rWr8r"s``@r"rz_patch.decorate_callableWsv������4��%�%�	��N�!�!�$�'�'�'��K�	�t���	5�	5�	5�	5�	5�	5�
��	5�"�F����r!c�����t�d��r�j�����St������fd�����g�_�S)Nrc���K����||��5\}}�|i|���d{V��cddd��S#1swxYwYdSr;r*r+s    ���r"r"z/_patch.decorate_async_callable.<locals>.patchedns�������'�'��(,�(0�2�2�
;�5K�g�{�!�T�7�:�k�:�:�:�:�:�:�:�:�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;����
;�
;�
;�
;�
;�
;s
�9�=�=r.r/s``@r"rz_patch.decorate_async_callablehsv������4��%�%�	��N�!�!�$�'�'�'��K�	�t���	;�	;�	;�	;�	;�	;�
��	;�"�F����r!c�`�|���}|j}t}d}	|j|}d}n-#tt
f$rt
||t��}YnwxYw|tvrt|t��rd|_
|j
s|turt	|�d|�����||fS)NFTz does not have the attribute )rrjrrsrL�KeyErrorr0�	_builtinsr.rr	)rW�targetr)r}�locals     r"�get_originalz_patch.get_originalys����������~������	���t�,�H��E�E����)�	6�	6�	6��v�t�W�5�5�H�H�H�	6����
�9����F�J�!?�!?���D�K��{�	�x�7�2�2� �7=�v�v�t�t�D���
����s�
6�'A �A c��	|j|j|j}}}|j|j}}|j}|���|_|durd}|durd}|durd}|�|�td���|�|�|dvrtd���|�	��\}}|tu�r�|���d}	|dur|}|dur|}d}n|�	|dur|}d}n|dur|}|�|�/|turtd���t|t��rd}	|�t|��rt}
nt}
i}|�|}
nN|�|�J|}|�|}t!|��rd|v}
nt#|��}
t|��rt}
n	|
rt$}
|�||d<|�||d	<t|
t��r&t'|
t(��r|jr
|j|d
<|�|��|
di|��}|	r_t/|��rP|}|�|}t!|��st1|��st$}
|�d
��|
d|dd�|��|_n�|��|turtd
���|turtd���t7|��}|dur|}t/|j��r#t9d|j�d|j�d|�d����t/|��rAt;|jd|j��}t9d|j�d|�d|j�d|�d�	���t=|f||jd�|��}n|rtd���|}||_||_ tCj"��|_#	tI|j|j|��|j%�ci}|jtur
|||j%<|j&D]?}|j#�'|��}|jtur|�|���@|S|S#|j(tSj*���s�YdSxYw)NFzCan't specify spec and autospec)TNz6Can't provide explicit spec_set *and* spec or autospecTz!Can't use 'spec' with create=TruerKr�r�r)r0r1zBautospec creates the mock for you. Can't specify autospec and new.z%Can't use 'autospec' with create=Truer\z: as the patch target has already been mocked out. [target=r_r&rr]r^)r��_namez.Can't pass kwargs to a mock we aren't creatingr )+rr�r�rrYrrr5r�r7rr.r=r5r
rrpr9r
r<rrjr!r-rvrRr��boolrr0r	�
temp_original�is_localrr�_exit_stackrhrrr �__exit__�sys�exc_info)rWrr�r�rrYrr}r6�inherit�Klass�_kwargs�	this_spec�not_callablerb�new_attrr$r&rSs                   r"�	__enter__z_patch.__enter__�s��� �"�h��	�4�=�8�T���=�$�+�&���(���k�k�m�m����5�=�=��D��u����H��u����H���� 4��=�>�>�>�
�
��!5��L�(�(��T�U�U�U��+�+�-�-���%��'�>�>�h�.��G��t�|�|����t�#�#�'�H��D���!��t�#�#�#�H��D���T�!�!�#����8�#7��w�&�&�#�$G�H�H�H��h��-�-�#�"�G��|�
�h� 7� 7�|�!���!���G��'�$����!�X�%9� �	��'� (�I��I�&�&�;�#-�Y�#>�L�L�'/�	�':�':�#:�L� ��+�+�1�%�E�E�!�1�0�E���"&�����#�&.��
�#��5�$�'�'�
1��5�/�2�2�
1�7;�~�
1�"&�.�����N�N�6�"�"�"��%�"�"�'�"�"�C��
4�,�S�1�1�
4�!�	��'� (�I� ��+�+�1�&�y�1�1�1�0�E����F�#�#�#�#(�5�$4�S�D�$4�$4�+2�$4�$4�� ��
�
!��'�!�!��(�����7�"�"�� G�H�H�H��H�~�~�H��4���#�� ���-�-�
D�&�C�D�N�C�C�#�{�C�C�5=�C�C�C�D�D�D�!��*�*�
D�%�d�k�:�t�{�K�K��&�C�D�N�C�C�"�C�C�#�{�C�C�5=�C�C�C�D�D�D�
"�(�B�X�(,��B�B�:@�B�B�C�C�
�	N��L�M�M�M���%�����
�%�/�1�1���	��D�K����:�:�:��"�.��
��8�w�&�&�7:�J�t�2�3� $� 8�/�/�H��*�8�8��B�B�C��|�w�.�.�"�)�)�#�.�.�.��!�!��J��	� �4�=�#�,�.�.�1�
��
�
�
���s�BO�O�O=c�j�	|jr/|jtur!t|j|j|j��ndt
|j|j��|jsCt|j|j��r	|jdvr t|j|j|j��|`|`|`|j	}|`	|j
|�S)N)rdrrf�__annotations__rg)r<r;rrhr5rjr�r	r/r=r>)rWr@r%s   r"r>z_patch.__exit__#s�����=�		I�T�/�w�>�>��D�K����1C�D�D�D�D��D�K���0�0�0��;�
I����T�^�(L�(L�
I���+=�=�=����T�^�T�5G�H�H�H����M��K��%�
���"�z�"�H�-�-r!c�d�	|���}|j�|��|Sr;)rG�_active_patchesr-�rWr~s  r"�startz_patch.start8s0��;����!�!����#�#�D�)�)�)��
r!c��		|j�|��n#t$rYdSwxYw|�ddd��Sr;)rKr�rNr>r�s r"�stopz_patch.stop?s^��#�	�� �'�'��-�-�-�-���	�	�	��4�4�	�����}�}�T�4��.�.�.s��
,�,)rrrrrKrHrrKrr�contextmanagerr'rrr7rGr>rMrOr r!r"rr�s��������N��O�AF�"&�"&�"&�"&�"&�J
�
�
�,�,�,������#�#���#����"���"���0P�P�P�d.�.�.�*���/�/�/�/�/r!rc���	|�dd��\}}n-#tttf$rtd|�����wxYwt	t
j|��|fS)NrJr�z,Need a valid target to patch. You supplied: )�rsplitr�rNrLr�pkgutil�resolve_name)r5rjs  r"�_get_targetrUKs���G�"�M�M�#�q�1�1���	�	���z�>�2�G�G�G��E�6�E�E�G�G�	G�G�����7�'��0�0�)�;�;s	��*Arc���	t���turt��d�����fd�}
t|
||||||||	|��
�
S)Nz3 must be the actual object to be patched, not a strc����Sr;r �r5s�r"rMz_patch_object.<locals>.<lambda>js���V�r!r)r=�strr�r)r5rjrr�r	r�rrrrYrs`          r"�
_patch_objectrZTss���
��F�|�|�s�����L�L�L�
�
�	
��^�^�^�F���	�3��f��(�L�&�����r!c���	t���turttj���}n�fd�}|std���t
|�����}|d\}	}
t||	|
|||||i�	�	}|	|_	|dd�D]=\}	}
t||	|
|||||i�	�	}|	|_	|j
�|���>|S)Nc����Sr;r rXs�r"rMz!_patch_multiple.<locals>.<lambda>�s����r!z=Must supply at least one keyword argument with patch.multiplerr�)r=rYrrSrTrNrnrPrrrr-)
r5r�r	r�rrrYrrPrjrr�this_patchers
`            r"�_patch_multipler^qs����(�F�|�|�s�����-�v�6�6���������
��K�
�
�	
�
������ � �E��1�X�N�I�s���	�3��f�h��,����G�'�G������)�9�9��	�3���I�s�D�&�(��l�B�
�
��'0��#��#�*�*�<�8�8�8�8��Nr!c�Z�	t|��\}	}
t|	|
||||||||��
�
S)Nr)rUr)r5rr�r	r�rrrrYrrjs           r"rr�sJ��F�N$�F�+�+��F�I���	�3��f��(�L�&�����r!c�T�eZdZ	dd�Zd�Zd�Zd�Zd�Zd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
dS)�_patch_dictr Fc��||_t|��|_|j�|��||_d|_dSr;)�in_dict�dictrCr!�clear�	_original)rWrcrCrerYs     r"rHz_patch_dict.__init__s>������6�l�l�������6�"�"�"���
�����r!c���t|t��r|�|��Stj|��r|�|��S|�|��Sr;r)rW�fs  r"rKz_patch_dict.__call__sc���a����	*��&�&�q�)�)�)��&�q�)�)�	3��/�/��2�2�2��%�%�a�(�(�(r!c�@���t�����fd���}|S)Nc�������	�|i|������S#����wxYwr;�ra�
_unpatch_dict�rXrrhrWs  ��r"�_innerz-_patch_dict.decorate_callable.<locals>._inner#sV���������
%��q�$�~�"�~�~��"�"�$�$�$�$���"�"�$�$�$�$���s	�3�A	�r�rWrhrns`` r"rz_patch_dict.decorate_callable"�9����	�q���	%�	%�	%�	%�	%�
��	%��
r!c�@���t�����fd���}|S)Nc���K�����	�|i|���d{V��	����S#����wxYwr;rkrms  ��r"rnz3_patch_dict.decorate_async_callable.<locals>._inner/so�����������
%��Q��^��^�^�+�+�+�+�+�+�+��"�"�$�$�$�$���"�"�$�$�$�$���s	�
<�Arorps`` r"rz#_patch_dict.decorate_async_callable.rqr!c� �t|��D]}}t||��}|�tj��rLt|d��r<t
|j|j|j	��}||��}t|||���~|Sr)r,r0r'rrr/rarcrCrerh)rWr�r�r�	decorator�	decorateds      r"rz_patch_dict.decorate_class:s�����J�J�	0�	0�D� ���-�-�J����� 1�2�2�
0���Z�0�0�
0�'���d�k�4�:�N�N�	�%�I�j�1�1�	���t�Y�/�/�/���r!c�:�	|���|jSr;)rarcr�s r"rGz_patch_dict.__enter__Es����������|�r!c��|j}t|jt��rt	j|j��|_|j}|j}	|���}n"#t$ri}|D]
}||||<�YnwxYw||_	|rt|��	|�|��dS#t$r|D]
}||||<�YdSwxYwr;)rCr.rcrYrSrTrerrLrf�_clear_dictr!)rWrCrcrer}rNs      r"raz_patch_dict._patch_dictKs!������d�l�C�(�(�	>�"�/���=�=�D�L��,���
��	-��|�|�~�~�H�H���	-�	-�	-��H��
-�
-�� '�����
�
�
-�
-�		-����"����	!��� � � �	+��N�N�6�"�"�"�"�"���	+�	+�	+��
+�
+��%�c�{�����
+�
+�
+�	+���s$�A$�$B�B�B6�6C�Cc��|j}|j}t|��	|�|��dS#t$r|D]
}||||<�YdSwxYwr;)rcrfryr!rL)rWrcr}rNs    r"rlz_patch_dict._unpatch_dictgs����,���>���G����	-��N�N�8�$�$�$�$�$���	-�	-�	-��
-�
-��'��}�����
-�
-�
-�	-���s�6�A�Ac�>�	|j�|���dS�NF)rfrl)rWrXs  r"r>z_patch_dict.__exit__ts$����>�%���� � � ��ur!c�n�	|���}tj�|��|Sr;)rGrrKr-rLs  r"rMz_patch_dict.start{s0��;����!�!����%�%�d�+�+�+��
r!c��		tj�|��n#t$rYdSwxYw|�ddd��Sr;)rrKr�rNr>r�s r"rOz_patch_dict.stop�s^��#�	��"�)�)�$�/�/�/�/���	�	�	��4�4�	�����}�}�T�4��.�.�.s�#�
1�1N)r F)rrrrHrKrrrrGrarlr>rMrOr r!r"rara�s��������8����)�)�)�	�	�	�	�	�	�������+�+�+�8
-�
-�
-�������/�/�/�/�/r!rac��	|���dS#t$rt|��}|D]}||=�YdSwxYwr;)rerLrn)rc�keysrNs   r"ryry�se����
�
������������G�}�}���	�	�C�����	�	�	����s��!=�=c�h�	ttj��D]}|����dSr;)rdrrKrO)rs r"�_patch_stopallr��s8��A��&�0�1�1����
�
�
������r!�testz�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 zDadd sub mul matmul truediv floordiv mod lshift rshift and xor or pow� c#� K�|]	}d|zV��
dS)zi%sNr �r(�ns  r"r�r��s&����7�7��5�1�9�7�7�7�7�7�7r!c#� K�|]	}d|zV��
dS)zr%sNr r�s  r"r�r��s&����5�5�q����5�5�5�5�5�5r!>ry�__get__�__set__r��
__delete__�
__format__r��__missing__�__getstate__�__reversed__�__setstate__�
__getformat__�
__reduce_ex__�__getnewargs__�__subclasses__�__getinitargs__�__getnewargs_ex__c�"��	�fd�}||_|S)Nc����|g|�Ri|��Sr;r )rWrXrr8s   �r"�methodz_get_method.<locals>.method�s#����t�D�&�4�&�&�&�2�&�&�&r!)r)r)r8r�s ` r"r�r��s+���@�'�'�'�'�'��F�O��Mr!c��h|]}d|z��S)r�r )r(r�s  r"r*r*�s*����� �H�v����r!>�	__aexit__�	__anext__�
__aenter__�	__aiter__>�__del__rrHr��__prepare__r��__instancecheck__�__subclasscheck__c�6�t�|��Sr;)rx�__hash__r�s r"rMrM�s��V�_�_�T�2�2�r!c�6�t�|��Sr;)rx�__str__r�s r"rMrM�s��F�N�N�4�0�0�r!c�6�t�|��Sr;)rx�
__sizeof__r�s r"rMrM�s��v�0�0��6�6�r!c�x�t|��j�d|����dt|����S)N�/)r=rrjrBr�s r"rMrM�s;��$�t�*�*�"5�^�^��8O�8O�8Q�8Q�^�^�TV�W[�T\�T\�^�^�r!)r�r�r��
__fspath__r�y�?g�?)
�__lt__�__gt__�__le__�__ge__�__int__r��__len__r>�__complex__�	__float__�__bool__�	__index__r�c����fd�}|S)Nc�L���jj}|tur|S�|urdStSrG)�__eq__r�r�NotImplemented)�other�ret_valrWs  �r"r�z_get_eq.<locals>.__eq__�s1����+�0���'�!�!��N��5�=�=��4��r!r )rWr�s` r"�_get_eqr��s#���������Mr!c����fd�}|S)Nc�R���jjturtS�|urdStSr|)�__ne__r�rr�)r�rWs �r"r�z_get_ne.<locals>.__ne__s,����;�)��8�8��N��5�=�=��5��r!r )rWr�s` r"�_get_ner�s#���������Mr!c����fd�}|S)Nc�j���jj}|turtg��St|��Sr;)�__iter__r�rr��r�rWs �r"r�z_get_iter.<locals>.__iter__s1����-�2���g�����8�8�O��G�}�}�r!r )rWr�s` r"�	_get_iterr�
s#���������Or!c����fd�}|S)Nc����jj}|turtt	g����Stt	|����Sr;)r�r�r�_AsyncIteratorr�r�s �r"r�z"_get_async_iter.<locals>.__aiter__s@����.�3���g���!�$�r�(�(�+�+�+��d�7�m�m�,�,�,r!r )rWr�s` r"�_get_async_iterr�s$���-�-�-�-�-�
�r!)r�r�r�r�c�&�t�|t��}|tur	||_dSt�|��}|�||��}||_dSt
�|��}|�||��|_dSdSr;)�_return_valuesrtrr��_calculate_return_value�_side_effect_methodsr�)rCr�r)�fixed�return_calculatorr��
side_effectors       r"�_set_return_valuer�(s������t�W�-�-�E��G���#�����/�3�3�D�9�9���$�(�(��.�.��*�����(�,�,�T�2�2�M�� �*�]�4�0�0�����!� r!c��eZdZd�Zd�ZdS)�
MagicMixinc��|���tt|��j|i|��|���dSr;)�_mock_set_magicsrr�rH�rWrXrs   r"rHzMagicMixin.__init__;sN��������.��J��%�%�.��;��;�;�;��������r!c	��ttz}|}t|dd���X|�|j��}t��}||z
}|D](}|t
|��jvrt||���)|tt
|��j��z
}t
|��}|D]!}t||t||�����"dS)Nr*)�_magicsr�r0�intersectionr*rzr=rsr�rh�
MagicProxy)rW�orig_magics�these_magics�
remove_magicsrLr�s      r"r�zMagicMixin._mock_set_magicsAs���� 4�4��"���4��$�/�/�;�&�3�3�D�4F�G�G�L��E�E�M�'�,�6�M�&�
)�
)���D��J�J�/�/�/��D�%�(�(�(��$�c�$�t�*�*�*=�&>�&>�>���T�
�
��!�	;�	;�E��E�5�*�U�D�"9�"9�:�:�:�:�	;�	;r!N)rrrrHr�r r!r"r�r�:s2������ � � �;�;�;�;�;r!r�c��eZdZ	dd�ZdS)r
Fc�\�	|�||��|���dSr;�rr�r#s   r"r$z"NonCallableMagicMock.mock_add_spec[�8��	N�
	
���D�(�+�+�+��������r!Nr��rrrr$r r!r"r
r
Ys+������7� � � � � � r!r
c��eZdZd�ZdS)�AsyncMagicMixinc��|���tt|��j|i|��|���dSr;)r�rr�rHr�s   r"rHzAsyncMagicMixin.__init__fsN��������3��O�T�*�*�3�T�@�R�@�@�@��������r!N�rrrrHr r!r"r�r�es#������ � � � � r!r�c��eZdZ	dd�ZdS)rFc�\�	|�||��|���dSr;r�r#s   r"r$zMagicMock.mock_add_specvr�r!Nr�r�r r!r"rrks-������	� � � � � � r!rc�"�eZdZd�Zd�Zdd�ZdS)r�c�"�||_||_dSr;�r)r�)rWr)r�s   r"rHzMagicProxy.__init__�s����	�����r!c��|j}|j}|�|||���}t|||��t	|||��|S)N)r)rr)r)r�r2rhr�)rWrLr��ms    r"�create_mockzMagicProxy.create_mock�sZ���	������"�"���/5�
#�
7�
7�����q�!�!�!��&�!�U�+�+�+��r!Nc�*�|���Sr;)r�)rWr4r�s   r"r�zMagicProxy.__get__�s�����!�!�!r!r;)rrrrHr�r�r r!r"r�r��sF������������"�"�"�"�"�"r!r�c���eZdZed��Zed��Zed��Z�fd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
dd�Zd
�Z�fd�Z�xZS)rr�r�r�c����t��j|i|��tjj|jd<d|jd<d|jd<t
��|jd<tt���}tj
tjztjz|_
d|_d|_d|_d|_||jd<d	|jd
<t%��|jd<i|jd<d|jd
<dS)Nr�r�_mock_await_count�_mock_await_args�_mock_await_args_list�r�)rXrYr7r
rrfrgrI)�superrHr�r�r�rsr�rrr1�CO_COROUTINE�
CO_VARARGS�CO_VARKEYWORDS�co_flags�co_argcount�co_varnames�co_posonlyargcount�co_kwonlyargcountro)rWrXrY�	code_mockr7s    �r"rHzAsyncMockMixin.__init__�s���������$�)�&�)�)�)�*1�);�)I��
�o�&�-.��
�)�*�,0��
�(�)�1:����
�-�.�#�X�6�6�6�	�� �� �
!��$�
%�	��
!"�	�� 2�	��'(�	�$�&'�	�#�$-��
�j�!�$/��
�j�!�(-����
�n�%�*,��
�&�'�+/��
�'�(�(�(r!c��`K�t||fd���}|xjdz
c_||_|j�|��|j}|��t
|��r|�t|��s8	t|��}n#t$rt�wxYwt
|��r|�n&t|��r||i|���d{V��}n||i|��}|tur|S|j
tur|jS|j�4t|j��r|j|i|���d{V��S|j|i|��S|jS)NTr�r�)r�r�r�r�r-r�r@rlr��
StopIteration�StopAsyncIterationrrr�r�r)rWrXrYr�r�r~s      r"r�z!AsyncMockMixin._execute_mock_call�s������t�V�n�$�/�/�/�����A���������#�#�E�*�*�*��!�����V�$�$�
1����v�&�&�
1�-�!�&�\�\�F�F��$�-�-�-�-�,�-����!��(�(�!� �L�!�$�V�,�,�
1�%�v�t�6�v�6�6�6�6�6�6�6�6������0��0�0���W�$�$��
��"�'�1�1��$�$���'�"�4�#3�4�4�
?�-�T�-�t�>�v�>�>�>�>�>�>�>�>�>�#�4�#�T�4�V�4�4�4�� � s�1B�Bc�V�	|jdkrd|jpd�d�}t|���dS)Nr�	Expected rCz to have been awaited.�r�r�r�r�s  r"r�zAsyncMockMixin.assert_awaited�sD��	���q� � �O�d�o�7��O�O�O�C� ��%�%�%�!� r!c�f�	|jdks$d|jpd�d|j�d�}t|���dS�Nr�rrCz$ to have been awaited once. Awaited r�rr�s  r"r�z"AsyncMockMixin.assert_awaited_once�s\��	���1�$�$�9�t��8�&�9�9�#�/�9�9�9�C� ��%�%�%�%�$r!c�j����	�j�)������}td|�d�������fd�}��t	��fd�����}���j��}||kr1t|t��r|nd}t|����|�dS)NzExpected await: z
Not awaitedc�8������d���}|S)N�await)r�r�r�s ���r"r�z:AsyncMockMixin.assert_awaited_with.<locals>._error_message�s"����3�3�D�&��3�Q�Q�C��Jr!Tr�)r�r�r�r�r�r.r�)rWrXrYr�r�r�r�s```    r"r�z"AsyncMockMixin.assert_awaited_with�s������	��?�"��7�7��f�E�E�H� �!K�H�!K�!K�!K�L�L�L�	�	�	�	�	�	�	��%�%�e�T�6�N��&E�&E�&E�F�F���#�#�D�O�4�4���X��� *�8�Y� ?� ?�I�H�H�T�E� ���!1�!1�2�2��=��r!c�|�	|jdks$d|jpd�d|j�d�}t|���|j|i|��Sr)r�r�r�r�r�s    r"r�z'AsyncMockMixin.assert_awaited_once_with�sl��	���1�$�$�9�t��8�&�9�9�#�/�9�9�9�C� ��%�%�%�'�t�'��8��8�8�8r!c�&��	��t||fd�����}t|t��r|nd}�fd��jD��}|s|t|��vr)��||��}td|z��|�dS)NTr�c�:��g|]}��|����Sr r�r�s  �r"rsz3AsyncMockMixin.assert_any_await.<locals>.<listcomp>	s'���F�F�F�A�$�$�$�Q�'�'�F�F�Fr!z%s await not found)r�r�r.r�r�r�r�r�r�s`      r"r�zAsyncMockMixin.assert_any_await
	s����	��%�%�e�T�6�N��&E�&E�&E�F�F��&�x��;�;�E�����F�F�F�F��1E�F�F�F���	�H�L��$8�$8�8�8�"�>�>�t�V�L�L�O� �$��6����
�9�8r!Fc�,��	�fd�|D��}td�|D��d��}t�fd��jD����}|sT||vrN|�d}nd�d�|D����}t	|�dt|���d�j����|�dSt|��}g}|D]=}	|�|���#t$r|�|��Y�:wxYw|r t	t|���d	���|�dS)
Nc�:��g|]}��|����Sr r�r�s  �r"rsz4AsyncMockMixin.assert_has_awaits.<locals>.<listcomp>#	r�r!c3�DK�|]}t|t���|V��dSr;r�rus  r"r�z3AsyncMockMixin.assert_has_awaits.<locals>.<genexpr>$	r�r!c3�B�K�|]}��|��V��dSr;r�r�s  �r"r�z3AsyncMockMixin.assert_has_awaits.<locals>.<genexpr>%	s1�����S�S��t�1�1�!�4�4�S�S�S�S�S�Sr!zAwaits not found.z,Error processing expected awaits.
Errors: {}c�@�g|]}t|t��r|nd��Sr;r�rus  r"rsz4AsyncMockMixin.assert_has_awaits.<locals>.<listcomp>-	r�r!r�z	
Actual: z not all found in await list)
r�r�r�r�r�rnr�rNr-ro)	rWr�r�r�r��
all_awaitsr�r�r�s	`        r"r�z AsyncMockMixin.assert_has_awaits	s����
	�:�9�9�9�5�9�9�9���F�F��F�F�F��M�M���S�S�S�S�d�>R�S�S�S�S�S�
��	��z�)�)��=�1�G�G� ,�-3�V�$7�$7�-5�$7�$7�$7�.8�.8��%��6�6�!*�5�!1�!1�6�6�#�3�6�6����	�

�F��*�%�%�
��	��	'�	'�D�
'��!�!�$�'�'�'�'���
'�
'�
'�� � ��&�&�&�&�&�
'�����	� �49�)�4D�4D�4D�4D�F����
�	�	s�7C
�
C/�.C/c�f�	|jdkr$d|jpd�d|j�d�}t|���dS)NrrrCz# to not have been awaited. Awaited r�rr�s  r"r�z!AsyncMockMixin.assert_not_awaitedC	s\��	���q� � �9�t��8�&�9�9�#�/�9�9�9�C� ��%�%�%�!� r!c�~��	t��j|i|��d|_d|_t	��|_dS�Nr)r�r�r�r�r�r�)rWrXrYr7s   �r"r�zAsyncMockMixin.reset_mockL	sG���	�	�����D�+�F�+�+�+�������(�{�{����r!r�)rrrr�r�r�r�rHr�r�r�r�r�r�r�r�r��
__classcell__)r7s@r"rr�s�������&�&�}�5�5�K�%�%�l�3�3�J�*�*�+<�=�=�O�0�0�0�0�0�8&!�&!�&!�P&�&�&�&�&�&�>�>�>�$	9�	9�	9����*�*�*�*�X&�&�&�+�+�+�+�+�+�+�+�+r!rc��eZdZdS)r
Nrr r!r"r
r
V	s������'�'r!r
c�"�eZdZ	d�Zd�Zd�ZdS)�_ANYc��dSrGr �rWr�s  r"r�z_ANY.__eq__�	s���tr!c��dSr|r rs  r"r�z_ANY.__ne__�	s���ur!c��dS)Nz<ANY>r r�s r"r�z
_ANY.__repr__�	s���wr!N)rrrr�r�r�r r!r"rr�	sD������8�����������r!rc���d|z}d}d�d�|D����}d�d�|���D����}|r|}|r|r|dz
}||z
}||zS)Nz%s(%%s)rz, c�,�g|]}t|����Sr )�repr)r(rSs  r"rsz*_format_call_signature.<locals>.<listcomp>�	s��7�7�7�3�T�#�Y�Y�7�7�7r!c�"�g|]\}}|�d|����
S)�=r )r(rNr�s   r"rsz*_format_call_signature.<locals>.<listcomp>�	s4�����#-�3��3�3�3������r!)rerP)r)rXrYr��formatted_args�args_string�
kwargs_strings       r"r�r��	s����$��G��N��)�)�7�7�$�7�7�7�8�8�K��I�I���17����������M��%�$���(��	#��d�"�N��-�'���^�#�#r!c��eZdZ			dd�Z		dd�Zd�ZejZd	�Zd
�Z	d�Z
d�Zed
���Z
ed���Zd�Zd�ZdS)r�r rNFTc��d}i}t|��}|dkr|\}}}n~|dkr<|\}	}
t|	t��r|	}t|
t��r|
}nD|
}nA|	|
}}n<|dkr6|\}t|t��r|}nt|t��r|}n|}|rt�|||f��St�||||f��S)Nr �r�r�)r�r.rYror)rr�r)r�r��	from_kallrXrY�_len�first�seconds           r"rz
_Call.__new__�	s�������5�z�z���1�9�9�!&��D�$���
�Q�Y�Y�!�M�E�6��%��%�%�
-����f�e�,�,�$�!�D�D�#�F�F�$�f�f���
�Q�Y�Y��F�E��%��%�%�
�����E�5�)�)�
�������	6��=�=��t�V�n�5�5�5��}�}�S�4��v�"6�7�7�7r!c�0�||_||_||_dSr;)r�r��_mock_from_kall)rWr�r)r�r�r*s      r"rHz_Call.__init__�	s�����"���(����r!c�r�	t|��}n#t$r
tcYSwxYwd}t|��dkr|\}}n|\}}}t|dd��r#t|dd��r|j|jkrdSd}|dkrdi}}n�|dkr|\}}}n�|dkr?|\}	t|	t��r|	}i}nit|	t��r|	}di}}nMd}|	}nH|dkr@|\}
}t|
t��r!|
}t|t��r|i}}nd|}}n|
|}}ndS|r||krdS||f||fkS)	Nrr�r�Frr r)r�)r�r�r�r0r�r.rorY)rWr��	len_other�	self_name�	self_args�self_kwargs�
other_name�
other_args�other_kwargsr�r,r-s            r"r�z_Call.__eq__�	s���	"��E�
�
�I�I���	"�	"�	"�!�!�!�!�	"�����	��t�9�9��>�>�%)�"�I�{�{�04�-�I�y�+��D�.�$�/�/�	�G�E�>�SW�4X�4X�	��%��);�;�;��5��
���>�>�')�2��J�J�
�!�^�^�38�0�J�
�L�L�
�!�^�^��F�E��%��'�'�
%�"�
�!����E�3�'�'�
%�"�
�+-�r�L�
�
��
�$���
�!�^�^�!�M�E�6��%��%�%�
9�"�
��f�e�,�,�:�/5�r��J�J�/1�6��J�J�+0�&�L�
�
��5��	��y�0�0��5��L�)�i��-E�E�Es��&�&c��|j�td||fd���S|jdz}t|j||f||���S)Nrr0r�r��r�r�r�s    r"rKz_Call.__call__
sN���?�"��"�d�F�+�$�7�7�7�7����%���d�o�t�V�4�4��M�M�M�Mr!c�n�|j�t|d���S|j�d|��}t||d���S)NF)r)r*rJ)r)r�r*r9)rWr�r)s   r"r�z_Call.__getattr__
sD���?�"��d�e�4�4�4�4��/�/�/�4�4�0���$�t�u�=�=�=�=r!c�b�|tjvrt�t�||��Sr;)rorsrL�__getattribute__)rWr�s  r"r<z_Call.__getattribute__$
s+���5�>�!�!� � ��%�%�d�D�1�1�1r!c�H�t|��dkr|\}}n|\}}}||fS)Nr�)r�r�s    r"�_get_call_argumentsz_Call._get_call_arguments*
s2���t�9�9��>�>��L�D�&�&�!%��D�$���V�|�r!c�6�|���dSr�r>r�s r"rXz
_Call.args2
����'�'�)�)�!�,�,r!c�6�|���dS)Nr�r@r�s r"rYz_Call.kwargs6
rAr!c��|js%|jpd}|�d��rd|z}|St|��dkrd}|\}}n+|\}}}|sd}n |�d��sd|z}nd|z}t	|||��S)Nrr0zcall%sr�zcall.%s)r/r�r'r�r�)rWr)rXrYs    r"r�z_Call.__repr__:
s����#�	��?�,�f�D����t�$�$�
'��$����K��t�9�9��>�>��D��L�D�&�&�!%��D�$���
'�����_�_�T�*�*�
'� �4�'����$���%�d�D�&�9�9�9r!c��	g}|}|�%|jr|�|��|j}|�%tt	|����Sr;)r/r-r�r�rd)rW�vals�things   r"�	call_listz_Call.call_listO
s\��	��������$�
#����E�"�"�"��&�E�����$���(�(�(r!)r rNFT)r NNFT)rrrrrHr�rxr�rKr�r<r>r�rXrYr�rGr r!r"r�r��	s�������$:?��8�8�8�8�@>C��)�)�)�)�2F�2F�2F�j�]�F�N�N�N�>�>�>�2�2�2�����-�-��X�-��-�-��X�-�:�:�:�*
)�
)�
)�
)�
)r!r�)r*c	�&�	t|��rt|��}t|t��}t|��rt	d|�d����t|��}d|i}	|rd|i}	n|�i}	|	r|rd|	d<|st
|��|	�|��t}
tj
|��ri}	nL|r|rtd���t}
n1t|��st}
n|r|rt|��st}
|	�d|��}|}|�d	}|
d||||d
�|	��}t|t"��r"t%||��}|rt'|��nt)||||��|�|s
||j|<|�d��}
|r |sd|vrt/||dd
||
���|_t3|��D�];}t5|��r�	t7||��}n#t8$rY�1wxYwd|i}|
r&t;|
|��r|�|���|rd|i}t|t"��st=|||||��}||j|<n{|}t|t"��r|j}tA|||��}||d<tC|��rt}nt}|d||||d�|��}||j|<t)|||���t|t"��rtE|||����=|S)Nz'Cannot autospec a Mock object. [object=r&r�r�TrzJInstance can not be True when create_autospec is mocking an async functionr)r)r�rrr)rr�r0)rar9r�rror)r�r)rr)r`r )#rpr=r.r-rr9rr!rr1�isdatadescriptorr�r
rlr
rvrRrDr�r�rbr�rtr	r�r,r�r0rLr/rDrC�
_must_skiprrh)r�r�rar�r9rrY�is_type�
is_async_funcrCrBrrC�wrappedrLr}rr�r`�child_klasss                    r"r	r	_
s#��,�*��~�~���D�z�z����t�$�$�G�����5�� 4�*.� 4� 4� 4�5�5�	5�"�4�(�(�M��t�n�G����t�$���	
�����,�8�,�'+��#�$��&��f�%�%�%��N�N�6�����E����%�%�%����	�%��	?�� >�?�?�
?����
�t�_�_�%�$���	�%�X�%�&8��&>�&>�%�$���K�K���&�&�E��I����	��5�(��W�	��(�(�&�(�(�D��$�
�&�&�8��d�D�)�)���	$��d�#�#�#����t�W�h�7�7�7���8��(,���u�%��j�j��!�!�G��;�x�;�N�&�$@�$@�+�D�(�T�26��29�;�;�;����T���3&�3&���U���	��	��t�U�+�+�H�H���	�	�	��H�	�����(�#���	*�w�w��.�.�	*��M�M��M�)�)�)��	,� �(�+�F��(�M�2�2�	A��X�x��u�h�G�G�C�),�D���&�&��F��$�
�.�.�
#����"�4���8�8�I�"+�F�;��"�8�,�,�
(�'���'���+�(�V�%�5�*0�(�(� &�(�(�C�*-�D���&��X�s�i�@�@�@�@��c�=�)�)�	&��D�%��%�%�%���Ks�(G9�9
H�Hc�F�	t|t��s|t|di��vrdS|j}|jD]f}|j�|t��}|tur�,t|ttf��rdSt|t��r|cSdS|S)NrsF)r.r=r0r7rrrsrtrrJrIrD)r�rLrKr�r~s     r"rJrJ�
s�����d�D�!�!���G�D�*�b�1�1�1�1��5��~���������#�#�E�7�3�3���W�����f�|�[�9�:�:�	��5�5�
��
�
.�
.�	��N�N�N��5�5��Nr!c��eZdZ		dd�ZdS)rDFNc�Z�||_||_||_||_||_||_dSr;)r��idsr�r�rar))rWr�r�r�r)rRras       r"rHz_SpecState.__init__s0����	���� ��
���� ��
���	�	�	r!)FNNNFr�r r!r"rDrD
s.������48�/4������r!rDc�|�t|t��rtj|��Stj|��Sr;)r.�bytes�io�BytesIO�StringIO)�	read_datas r"�
_to_streamrY%s4���)�U�#�#�&��z�)�$�$�$��{�9�%�%�%r!rc	�X���	�
��	t���}|dg�
�
�fd�}�
�fd�}��
fd��	�
�fd���
�fd�}t�dddl}tt	t|j�����t	t|j��������at�2ddl}tt	t|j
������a	|�tdt���}tt�	�����j_
d�j_
d�j_
d�j_
d�j_
|�j_�	���
d
<�
d
�j_|�j_��j_|�j_�	�
��fd�}||_�|_
|S)Nc�Z���jj��jjS�dj|i|��Sr)�	readlinesr��rXrY�_state�handles  ��r"�_readlines_side_effectz)mock_open.<locals>._readlines_side_effect;s7�����(�4��#�0�0�"�v�a�y�"�D�3�F�3�3�3r!c�Z���jj��jjS�dj|i|��Sr)�readr�r]s  ��r"�_read_side_effectz$mock_open.<locals>._read_side_effect@s4����;�#�/��;�+�+��v�a�y�~�t�.�v�.�.�.r!c?�V�K����Ed{V��	�dj|i|��V���NTr)�readline)rXrY�_iter_side_effectr^s  ��r"�_readline_side_effectz(mock_open.<locals>._readline_side_effectEsT�����$�$�&�&�&�&�&�&�&�&�&�	6�$�&��)�$�d�5�f�5�5�5�5�5�	6r!c3�b�K��jj�	�jjV���dD]}|V��dSre)rfr�)�liner^r_s ��r"rgz$mock_open.<locals>._iter_side_effectJsU������?�'�3�
3��o�2�2�2�2�
3��1�I�	�	�D��J�J�J�J�	�	r!c�^���jj��jjSt�d��Sr)rfr�r�)r^r_s��r"�_next_side_effectz$mock_open.<locals>._next_side_effectQs)����?�'�3��?�/�/��F�1�I���r!r�open)r)r�)r�r�c���t����d<�jj�dkr����d<�d�j_tS)Nrr�)rYrfr�r)rXrYrhr^r_rXs  ����r"�
reset_datazmock_open.<locals>.reset_dataqsM����y�)�)��q�	��?�&�&��)�3�3�-�-�/�/�F�1�I�*0��)�F�O�'��r!)rY�	file_spec�_iornrzr,�
TextIOWrapper�unionrV�	open_specrmrrGr��writerbrfr\r�r�r�)rCrX�
_read_datar`rcrlrqrorgrhr^r_s `      @@@@r"rr,s�������
��I�&�&�J��$�
�F�4�4�4�4�4�4�
/�/�/�/�/�/�
6�6�6�6�6�6�
���������������
�
�
���S��!2�3�3�4�4�:�:�3�s�3�;�?O�?O�;P�;P�Q�Q�R�R�	����
�
�
���S���]�]�+�+�,�,�	��|��f�9�5�5�5��
�I�
&�
&�
&�F�$*�F��!� $�F�L��#�F�K��#'�F�O� �$(�F��!�/�F�K��%�%�'�'�F�1�I�"(��)�F�O��#9�F�� �"3�F�O��"3�F�O����������"�D���D���Kr!c�$�eZdZ	d�Zdd�Zd�ZdS)rc��tdi|��S)Nr )r)rWrYs  r"r2zPropertyMock._get_child_mock�s���"�"�6�"�"�"r!Nc��|��Sr;r )rWr4�obj_types   r"r�zPropertyMock.__get__�s
���t�v�v�
r!c��||��dSr;r )rWr4rTs   r"r�zPropertyMock.__set__�s����S�	�	�	�	�	r!r;)rrrr2r�r�r r!r"rr~sK�������#�#�#���������r!rc�6�	d|_t|��D]�}	t||��}n#t$rY� wxYwt	|t
��s�:t	|j�|��t��r�h|j	|urt|����dSrG)rr,r0rLr.rr�rtrDr�r)rCr�r�s   r"rr�s�����D���D�	�	�
�
��	���d�#�#�A�A���	�	�	��H�	�����!�_�-�-�	���a�&�*�*�4�0�0�*�=�=�	�����%�%���G�G�G��
�
s�,�
9�9c��eZdZ	d�Zd�ZdS)r�c�t�||_tt���}tj|_||jd<dS)Nr�r7)�iteratorrrr1�CO_ITERABLE_COROUTINEr�rs)rWrr�s   r"rHz_AsyncIterator.__init__�s6�� ��
�#�X�6�6�6�	�$�:�	��$-��
�j�!�!�!r!c��^K�	t|j��S#t$rYnwxYwt�r;)r�rrrr�s r"r�z_AsyncIterator.__anext__�sA����	���
�&�&�&���	�	�	��D�	���� � s��
%�%N)rrrrHr�r r!r"r�r��s7�������.�.�.�!�!�!�!�!r!r�r�)NFNNN)FFNNr)��__all__r�rrUr1r�r?�builtinsrSr�typesrrr�
unittest.utilr�	functoolsrr�	threadingrr�rr,r4rr�rr5r9r-r@rErRrbr]rlrprvr�r|r�r�rxr�r�rr�MISSINGr��DELETEDrEr�r�rnr�r�r�r�rrMrHrr�r>r�rrrrUrZr^rraryr�rd�multiple�stopallr�
magic_methods�numericsrerQ�inplace�right�
_non_defaultsr�r�r��_sync_async_magics�
_async_magicsr�r`r�r�r�r�r�r�r�r�r�r�r�r
r�rr�rr
rrr�ror�rr	rJrDr=r�rDrprtrYrrrr�r r!r"�<module>r�s5
����&��������	�	�	�	�����
�
�
�
�
�
�
�
���������'�'�'�'�'�'�2�2�2�2�2�2�2�2�2�2�#�#�#�#�#�#�$�$�$�$�$�$�$�$�������C�C�C�C�C�y�C�C�C�
I�H�c�c�(�m�m�H�H�H�	�
�
���@�@�@����2�2�2������� � � �F	#�	#�	#�	#�
�
�
����&�&�&��������6."�."�."�b>�>�>�6)�)�)�	)�	)�	)�	)�	)�f�	)�	)�	)�����������9�;�;��
�
������������ � � �&*�*�*�*�*��*�*�*�(���6���������
�
�
�
�
�6�
�
�
�N
<�N
<�N
<�N
<�N
<�d�N
<�N
<�N
<�b
�G��o�6�7�7�	�
�
�
�
�
�4�
�
�
� ���g!�g!�g!�g!�g!�D�g!�g!�g!�V6�6�6�6�6�=�/�6�6�6�v���L/�L/�L/�L/�L/�V�L/�L/�L/�`
<�<�<� '�T��t�d���&+������:?C�04�.�.�.�.�d�$�u���4�O�CH�O�O�O�O�O�dV/�V/�V/�V/�V/�&�V/�V/�V/�r���������
��
� �����
����
��"K�	��(�(�7�7�h�n�n�&6�&6�7�7�7�
7�
7�����5�5�H�N�N�$4�$4�5�5�5�5�5�����
�������H�H�m�X�w��
6�7�7�=�=�?�?�����@�?�?��!�]��$�'9�9�
��]�*����.������3�2�0�0�6�6�^�^�	�������������������"��������������� �	���1�1�1�$;�;�;�;�;��;�;�;�>	 �	 �	 �	 �	 �:��	 �	 �	 � � � � � �j� � � � � � � � �
�D� � � �,"�"�"�"�"��"�"�"�$@+�@+�@+�@+�@+�T�@+�@+�@+�F(�(�(�(�(����(�(�(�V
�
�
�
�
�6�
�
�
��d�f�f��$�$�$�$v)�v)�v)�v)�v)�E�v)�v)�v)�r
�u�u�����CG��O�*/�O�O�O�O�O�d���8	�	�	�	�	��	�	�	�	�D�����D�����	�
�
�	��	�&�&�&�O�O�O�O�d�����4����$���0!�!�!�!�!�!�!�!�!�!r!__pycache__/result.cpython-311.opt-1.pyc000064400000031272152401764000013737 0ustar00�

Vs�L�R�\��h�dZddlZddlZddlZddlmZddlmZdZd�Z	dZ
d	ZGd
�de��Z
dS)zTest result object�N�)�util��wrapsTc�<��t����fd���}|S)Nc�f��t|dd��r|����|g|�Ri|��S)N�failfastF)�getattr�stop)�self�args�kw�methods   ��:/opt/alt/python-internal/lib/python3.11/unittest/result.py�innerzfailfast.<locals>.inner
sD����4��U�+�+�	��I�I�K�K�K��v�d�(�T�(�(�(�R�(�(�(�r)rrs` rr	r	s3���
�6�]�]�)�)�)�)��]�)��Lrz
Stdout:
%sz
Stderr:
%sc���eZdZdZdZdZdZdd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zed���Zed
���Zd�Zd�Zd�Zd�Zed���Zd�Zd�Zd�Zd�Zd�Zd�Zd�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.
    NFc��d|_g|_g|_d|_g|_g|_g|_d|_d|_d|_	d|_
d|_tj
|_tj|_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�stream�descriptions�	verbositys    r�__init__zTestResult.__init__&s|����
���
������
���� "���#%�� ����������"���"��� #�
��� #�
���"����rc��dS)z#Called by TestRunner after test runN��rs r�printErrorszTestResult.printErrors7����rc�\�|xjdz
c_d|_|���dS)z-Called when the given test is about to be runrFN)rr&�_setupStdout�r�tests  r�	startTestzTestResult.startTest:s2���
�
���
�
�"����������rc���|jr[|j�0tj��|_tj��|_|jt
_|jt
_dSdS)N)rr �io�StringIOrr!r"r$r-s rr1zTestResult._setupStdout@sS���;�	-��"�*�&(�k�m�m��#�&(�k�m�m��#��,�C�J��,�C�J�J�J�	-�	-rc��dS)zpCalled once before any tests are executed.

        See startTest for a method called before each test.
        Nr,r-s r�startTestRunzTestResult.startTestRunHr/rc�<�|���d|_dS)z'Called when the given test has been runFN)�_restoreStdoutr&r2s  r�stopTestzTestResult.stopTestNs"��������"����rc��|j�rI|jr�tj���}tj���}|r<|�d��s|dz
}|j�t|z��|r<|�d��s|dz
}|j
�t|z��|jt_|j
t_|j�
d��|j���|j�
d��|j���dSdS)N�
r)rr&r!r"�getvaluer$�endswithr#�write�STDOUT_LINEr%�STDERR_LINEr�seek�truncater )r�output�errors   rr;zTestResult._restoreStdoutSs>���;�	+��!�

E���,�,�.�.���
�+�+�-�-���F�!�?�?�4�0�0�'��$����)�/�/��f�0D�E�E�E��E� �>�>�$�/�/�&���
���)�/�/��e�0C�D�D�D��.�C�J��.�C�J���$�$�Q�'�'�'���(�(�*�*�*���$�$�Q�'�'�'���(�(�*�*�*�*�*�%	+�	+rc��dS)zmCalled once after all tests are executed.

        See stopTest for a method called after each test.
        Nr,r-s r�stopTestRunzTestResult.stopTestRunhr/rc�t�|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r3�errs   r�addErrorzTestResult.addErrorns=��
	
����D�$�":�":�3��"E�"E�F�G�G�G�!����rc�t�|j�||�||��f��d|_dS)zdCalled when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info().TN)rrKrLr&rMs   r�
addFailurezTestResult.addFailurevs=��	
�
���d�D�$<�$<�S�$�$G�$G�H�I�I�I�!����rc��|��t|dd��r|���t|d|j��r|j}n|j}|�||�||��f��d|_dSdS)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().
        Nr	FrT)	r
r�
issubclass�failureExceptionrrrKrLr&)rr3�subtestrNrs     r�
addSubTestzTestResult.addSubTest}s����?��t�Z��/�/�
��	�	�����#�a�&�$�"7�8�8�
%���������M�M�7�D�$<�$<�S�$�$G�$G�H�I�I�I�!%�D�����?rc��dS)z-Called when a test has completed successfullyNr,r2s  r�
addSuccesszTestResult.addSuccess�s���rc�>�|j�||f��dS)zCalled when a test is skipped.N)rrK)rr3�reasons   r�addSkipzTestResult.addSkip�s"������T�6�N�+�+�+�+�+rc�f�|j�||�||��f��dS)z/Called when an expected failure/error occurred.N)rrKrLrMs   r�addExpectedFailurezTestResult.addExpectedFailure�s?����$�$�
�4�+�+�C��6�6�7�	9�	9�	9�	9�	9rc�:�|j�|��dS)z5Called when a test was expected to fail, but succeed.N)rrKr2s  r�addUnexpectedSuccesszTestResult.addUnexpectedSuccess�s!��	
� �'�'��-�-�-�-�-rc��t|j��t|j��cxkodknco(t|d��pt|j��dkS)z/Tells whether or not this result was a success.rr)�lenrr�hasattrrr-s r�
wasSuccessfulzTestResult.wasSuccessful�sj��
�T�]�#�#�s�4�;�'7�'7�<�<�<�<�1�<�<�<�<�5��T�#8�9�9�9�4��T�-�.�.�!�3�	6rc��d|_dS)z+Indicates that the tests should be aborted.TN)rr-s rrzTestResult.stop�s
������rc�P�|\}}}|�||||��}tj||||jd���}t	|�����}|jr�tj�	��}tj
�	��}	|r7|�d��s|dz
}|�t|z��|	r7|	�d��s|	dz
}	|�t|	z��d�|��S)z>Converts a sys.exc_info()-style tuple of values into a string.T)�capture_locals�compactr>�)�_clean_tracebacks�	traceback�TracebackExceptionr�list�formatrr!r"r?r$r@rKrBrC�join)
rrNr3�exctype�value�tb�tb_e�msgLinesrFrGs
          rrLzTestResult._exc_info_to_string�s�� �����
�
#�
#�G�U�B��
=�
=���+��U�B��>�4�9�9�9������
�
�&�&���;�
	5��Z�(�(�*�*�F��J�'�'�)�)�E��
6����t�,�,�#��d�N�F�����f� 4�5�5�5��
5��~�~�d�+�+�"��T�M�E�����e� 3�4�4�4��w�w�x� � � rc��d}d}|||fg}t|��h}|r�|���\}}}|r3|�|��r|j}|r|�|���||jur|�|��|r|}d}n||_|�p|j|jfD]a}	|	�]t|	��|vrL|�	t|	��|	|	jf��|�t|	�����b|��|S)NTF)�id�pop�_is_relevant_tb_level�tb_nextrT�_remove_unittest_tb_frames�
__traceback__�	__cause__�__context__rK�type�add)
rrorprqr3�ret�first�excs�seen�cs
          rrizTestResult._clean_tracebacks�sC�������%��$�%���5�	�	�{���	(�#'�8�8�:�:� �W�e�R��
 ��3�3�B�7�7�
 ��Z���
 ��3�3�B�7�7�
 ��$�/�/�/��/�/��3�3�3��
)������&(��#�� ��/�5�+<�=�(�(�A��}��A���d�):�):����T�!�W�W�a���$A�B�B�B�����A�������)�	(�*�
rc��d|jjvS)N�
__unittest)�tb_frame�	f_globals)rrqs  rrwz TestResult._is_relevant_tb_level�s���r�{�4�4�4rc��d}|r5|�|��s |}|j}|r|�|��� |�	d|_dSdS)aTruncates usercode tb at the first unittest frame.

        If the first frame of the traceback is in user code,
        the prefix up to the first unittest frame is returned.
        If the first frame is already in the unittest module,
        the traceback is not modified.
        N)rwrx)rrq�prevs   rryz%TestResult._remove_unittest_tb_frames�sl�����	��3�3�B�7�7�	��D���B��	��3�3�B�7�7�	����D�L�L�L��rc��dtj|j��|jt	|j��t	|j��fzS)Nz!<%s run=%i errors=%i failures=%i>)r�strclass�	__class__rrarrr-s r�__repr__zTestResult.__repr__�s@��3��
�d�n�-�-�t�}�c�$�+�>N�>N��D�M�"�"�$�$�	%r)NNN)�__name__�
__module__�__qualname__�__doc__�_previousTestClass�_testRunEntered�_moduleSetUpFailedr*r.r4r1r9r<r;rIr	rOrQrVrXr[r]r_rcrrLrirwryr�r,rrrrs�������	�	����O���#�#�#�#�".�.�.����-�-�-����#�#�#�
+�+�+�*����"�"��X�"��"�"��X�"�&�&�&�"
�
�
�,�,�,�9�9�9�
�.�.��X�.�6�6�6����!�!�!�,���85�5�5�
 �
 �
 �%�%�%�%�%rr)r�r6r!rjrhr�	functoolsrr�r	rBrC�objectrr,rr�<module>r�s�����	�	�	�	�
�
�
�
�����������������
�
��������\%�\%�\%�\%�\%��\%�\%�\%�\%�\%r__pycache__/__main__.cpython-311.opt-1.pyc000064400000001244152401764000014135 0ustar00�

���xc������dZddlZejd�d��r1ddlZej�ej��Zedzejd<[dZ	ddl
m
Z
e
d���dS)	zMain entry point�Nz__main__.pyz -m unittestT�)�main)�module)�__doc__�sys�argv�endswith�os.path�os�path�basename�
executable�
__unittestr���</opt/alt/python-internal/lib/python3.11/unittest/__main__.py�<module>rs�����
�
�
�
��8�A�;���
�&�&���N�N�N�
��!�!�#�.�1�1�J��~�-�C�H�Q�K�
�
�
���������D������r__pycache__/result.cpython-311.pyc000064400000031272152401764000013000 0ustar00�

Vs�L�R�\��h�dZddlZddlZddlZddlmZddlmZdZd�Z	dZ
d	ZGd
�de��Z
dS)zTest result object�N�)�util��wrapsTc�<��t����fd���}|S)Nc�f��t|dd��r|����|g|�Ri|��S)N�failfastF)�getattr�stop)�self�args�kw�methods   ��:/opt/alt/python-internal/lib/python3.11/unittest/result.py�innerzfailfast.<locals>.inner
sD����4��U�+�+�	��I�I�K�K�K��v�d�(�T�(�(�(�R�(�(�(�r)rrs` rr	r	s3���
�6�]�]�)�)�)�)��]�)��Lrz
Stdout:
%sz
Stderr:
%sc���eZdZdZdZdZdZdd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zed���Zed
���Zd�Zd�Zd�Zd�Zed���Zd�Zd�Zd�Zd�Zd�Zd�Zd�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.
    NFc��d|_g|_g|_d|_g|_g|_g|_d|_d|_d|_	d|_
d|_tj
|_tj|_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�stream�descriptions�	verbositys    r�__init__zTestResult.__init__&s|����
���
������
���� "���#%�� ����������"���"��� #�
��� #�
���"����rc��dS)z#Called by TestRunner after test runN��rs r�printErrorszTestResult.printErrors7����rc�\�|xjdz
c_d|_|���dS)z-Called when the given test is about to be runrFN)rr&�_setupStdout�r�tests  r�	startTestzTestResult.startTest:s2���
�
���
�
�"����������rc���|jr[|j�0tj��|_tj��|_|jt
_|jt
_dSdS)N)rr �io�StringIOrr!r"r$r-s rr1zTestResult._setupStdout@sS���;�	-��"�*�&(�k�m�m��#�&(�k�m�m��#��,�C�J��,�C�J�J�J�	-�	-rc��dS)zpCalled once before any tests are executed.

        See startTest for a method called before each test.
        Nr,r-s r�startTestRunzTestResult.startTestRunHr/rc�<�|���d|_dS)z'Called when the given test has been runFN)�_restoreStdoutr&r2s  r�stopTestzTestResult.stopTestNs"��������"����rc��|j�rI|jr�tj���}tj���}|r<|�d��s|dz
}|j�t|z��|r<|�d��s|dz
}|j
�t|z��|jt_|j
t_|j�
d��|j���|j�
d��|j���dSdS)N�
r)rr&r!r"�getvaluer$�endswithr#�write�STDOUT_LINEr%�STDERR_LINEr�seek�truncater )r�output�errors   rr;zTestResult._restoreStdoutSs>���;�	+��!�

E���,�,�.�.���
�+�+�-�-���F�!�?�?�4�0�0�'��$����)�/�/��f�0D�E�E�E��E� �>�>�$�/�/�&���
���)�/�/��e�0C�D�D�D��.�C�J��.�C�J���$�$�Q�'�'�'���(�(�*�*�*���$�$�Q�'�'�'���(�(�*�*�*�*�*�%	+�	+rc��dS)zmCalled once after all tests are executed.

        See stopTest for a method called after each test.
        Nr,r-s r�stopTestRunzTestResult.stopTestRunhr/rc�t�|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r3�errs   r�addErrorzTestResult.addErrorns=��
	
����D�$�":�":�3��"E�"E�F�G�G�G�!����rc�t�|j�||�||��f��d|_dS)zdCalled when an error has occurred. 'err' is a tuple of values as
        returned by sys.exc_info().TN)rrKrLr&rMs   r�
addFailurezTestResult.addFailurevs=��	
�
���d�D�$<�$<�S�$�$G�$G�H�I�I�I�!����rc��|��t|dd��r|���t|d|j��r|j}n|j}|�||�||��f��d|_dSdS)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().
        Nr	FrT)	r
r�
issubclass�failureExceptionrrrKrLr&)rr3�subtestrNrs     r�
addSubTestzTestResult.addSubTest}s����?��t�Z��/�/�
��	�	�����#�a�&�$�"7�8�8�
%���������M�M�7�D�$<�$<�S�$�$G�$G�H�I�I�I�!%�D�����?rc��dS)z-Called when a test has completed successfullyNr,r2s  r�
addSuccesszTestResult.addSuccess�s���rc�>�|j�||f��dS)zCalled when a test is skipped.N)rrK)rr3�reasons   r�addSkipzTestResult.addSkip�s"������T�6�N�+�+�+�+�+rc�f�|j�||�||��f��dS)z/Called when an expected failure/error occurred.N)rrKrLrMs   r�addExpectedFailurezTestResult.addExpectedFailure�s?����$�$�
�4�+�+�C��6�6�7�	9�	9�	9�	9�	9rc�:�|j�|��dS)z5Called when a test was expected to fail, but succeed.N)rrKr2s  r�addUnexpectedSuccesszTestResult.addUnexpectedSuccess�s!��	
� �'�'��-�-�-�-�-rc��t|j��t|j��cxkodknco(t|d��pt|j��dkS)z/Tells whether or not this result was a success.rr)�lenrr�hasattrrr-s r�
wasSuccessfulzTestResult.wasSuccessful�sj��
�T�]�#�#�s�4�;�'7�'7�<�<�<�<�1�<�<�<�<�5��T�#8�9�9�9�4��T�-�.�.�!�3�	6rc��d|_dS)z+Indicates that the tests should be aborted.TN)rr-s rrzTestResult.stop�s
������rc�P�|\}}}|�||||��}tj||||jd���}t	|�����}|jr�tj�	��}tj
�	��}	|r7|�d��s|dz
}|�t|z��|	r7|	�d��s|	dz
}	|�t|	z��d�|��S)z>Converts a sys.exc_info()-style tuple of values into a string.T)�capture_locals�compactr>�)�_clean_tracebacks�	traceback�TracebackExceptionr�list�formatrr!r"r?r$r@rKrBrC�join)
rrNr3�exctype�value�tb�tb_e�msgLinesrFrGs
          rrLzTestResult._exc_info_to_string�s�� �����
�
#�
#�G�U�B��
=�
=���+��U�B��>�4�9�9�9������
�
�&�&���;�
	5��Z�(�(�*�*�F��J�'�'�)�)�E��
6����t�,�,�#��d�N�F�����f� 4�5�5�5��
5��~�~�d�+�+�"��T�M�E�����e� 3�4�4�4��w�w�x� � � rc��d}d}|||fg}t|��h}|r�|���\}}}|r3|�|��r|j}|r|�|���||jur|�|��|r|}d}n||_|�p|j|jfD]a}	|	�]t|	��|vrL|�	t|	��|	|	jf��|�t|	�����b|��|S)NTF)�id�pop�_is_relevant_tb_level�tb_nextrT�_remove_unittest_tb_frames�
__traceback__�	__cause__�__context__rK�type�add)
rrorprqr3�ret�first�excs�seen�cs
          rrizTestResult._clean_tracebacks�sC�������%��$�%���5�	�	�{���	(�#'�8�8�:�:� �W�e�R��
 ��3�3�B�7�7�
 ��Z���
 ��3�3�B�7�7�
 ��$�/�/�/��/�/��3�3�3��
)������&(��#�� ��/�5�+<�=�(�(�A��}��A���d�):�):����T�!�W�W�a���$A�B�B�B�����A�������)�	(�*�
rc��d|jjvS)N�
__unittest)�tb_frame�	f_globals)rrqs  rrwz TestResult._is_relevant_tb_level�s���r�{�4�4�4rc��d}|r5|�|��s |}|j}|r|�|��� |�	d|_dSdS)aTruncates usercode tb at the first unittest frame.

        If the first frame of the traceback is in user code,
        the prefix up to the first unittest frame is returned.
        If the first frame is already in the unittest module,
        the traceback is not modified.
        N)rwrx)rrq�prevs   rryz%TestResult._remove_unittest_tb_frames�sl�����	��3�3�B�7�7�	��D���B��	��3�3�B�7�7�	����D�L�L�L��rc��dtj|j��|jt	|j��t	|j��fzS)Nz!<%s run=%i errors=%i failures=%i>)r�strclass�	__class__rrarrr-s r�__repr__zTestResult.__repr__�s@��3��
�d�n�-�-�t�}�c�$�+�>N�>N��D�M�"�"�$�$�	%r)NNN)�__name__�
__module__�__qualname__�__doc__�_previousTestClass�_testRunEntered�_moduleSetUpFailedr*r.r4r1r9r<r;rIr	rOrQrVrXr[r]r_rcrrLrirwryr�r,rrrrs�������	�	����O���#�#�#�#�".�.�.����-�-�-����#�#�#�
+�+�+�*����"�"��X�"��"�"��X�"�&�&�&�"
�
�
�,�,�,�9�9�9�
�.�.��X�.�6�6�6����!�!�!�,���85�5�5�
 �
 �
 �%�%�%�%�%rr)r�r6r!rjrhr�	functoolsrr�r	rBrC�objectrr,rr�<module>r�s�����	�	�	�	�
�
�
�
�����������������
�
��������\%�\%�\%�\%�\%��\%�\%�\%�\%�\%rmock.py000064400000313510152401764000006051 0ustar00# 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',
)


import asyncio
import contextlib
import io
import inspect
import pprint
import sys
import builtins
import pkgutil
from asyncio import iscoroutinefunction
from types import CodeType, ModuleType, MethodType
from unittest.util import safe_repr
from functools import wraps, partial
from threading import RLock


class InvalidSpecError(Exception):
    """Indicates that an invalid value was used as a mock spec."""


_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 iscoroutinefunction(obj) or inspect.isawaitable(obj)


def _is_async_func(func):
    if getattr(func, '__code__', None):
        return 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 isinstance(func, (classmethod, staticmethod)):
        if isinstance(func, classmethod):
            # Skip the `cls` argument of a class method
            eat_self = True
        # Use the original decorated method to extract the correct function signature
        func = func.__func__
    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`"""

    # Store a mutex as a class attribute in order to protect concurrent access
    # to mock attributes. Using a class attribute allows all NonCallableMock
    # instances to share the mutex for simplicity.
    #
    # See https://github.com/python/cpython/issues/98624 for why this is
    # necessary.
    _lock = RLock()

    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, AsyncMockMixin):
            # Check if spec is an async object or function
            bound_args = _MOCK_SIG.bind_partial(cls, *args, **kw).arguments
            spec_arg = bound_args.get('spec_set', bound_args.get('spec'))
            if spec_arg is not None and _is_async_obj(spec_arg):
                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):
        if _is_instance_mock(spec):
            raise InvalidSpecError(f'Cannot spec a Mock object. [object={spec!r}]')

        _spec_class = None
        _spec_signature = None
        _spec_asyncs = []

        for attr in dir(spec):
            if 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 and self._mock_wraps is None:
            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, return_value=return_value, side_effect=side_effect)

        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 and (not self._mock_methods or name not in self._mock_methods):
            if name.startswith(('assert', 'assret', 'asert', 'aseert', 'assrt')):
                raise AttributeError(
                    f"{name!r} is not a valid assertion. Use a spec "
                    f"for the mock if {name!r} is meant to be an attribute.")

        with NonCallableMock._lock:
            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):
                try:
                    result = create_autospec(
                        result.spec, result.spec_set, result.instance,
                        result.parent, result.name
                    )
                except InvalidSpecError:
                    target_name = self.__dict__['_mock_name'] or self
                    raise InvalidSpecError(
                        f'Cannot autospec attr {name!r} from target '
                        f'{target_name!r} as it has already been mocked out. '
                        f'[target={self!r}, attr={result.spec!r}]')
                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\n  Actual: %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:
                bound_call = sig.bind(*args, **kwargs)
                return call(name, bound_call.args, bound_call.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\n  Actual: %s'
                    % (expected, actual))
            raise AssertionError(error_message)

        def _error_message():
            msg = self._format_mock_failure_message(args, kwargs)
            return msg
        expected = self._call_matcher(_Call((args, kwargs), two=True))
        actual = self._call_matcher(self.call_args)
        if actual != expected:
            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(_Call((args, kwargs), two=True))
        cause = expected if isinstance(expected, Exception) else None
        actual = [self._call_matcher(c) for c in self.call_args_list]
        if cause or expected not in _AnyComparer(actual):
            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)."""
        if self._mock_sealed:
            attribute = f".{kw['name']}" if "name" in kw else "()"
            mock_name = self._extract_mock_name() + attribute
            raise AttributeError(mock_name)

        _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]
        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)}."


_MOCK_SIG = inspect.signature(NonCallableMock.__init__)


class _AnyComparer(list):
    """A list which checks if it contains a call which may have an
    argument of ANY, flipping the components of item and self from
    their traditional locations so that ANY is guaranteed to be on
    the left."""
    def __contains__(self, item):
        for _call in self:
            assert len(item) == len(_call)
            if all([
                expected == actual
                for expected, actual in zip(item, _call)
            ]):
                return True
        return False


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_delegate and self._mock_delegate.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.

    * `unsafe`: By default, accessing any attribute whose name starts with
      *assert*, *assret*, *asert*, *aseert* or *assrt* will raise an
       AttributeError. Passing `unsafe=True` will allow access to
      these attributes.

    * `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.
    """


# _check_spec_arg_typos takes kwargs from commands like patch and checks that
# they don't contain common misspellings of arguments related to autospeccing.
def _check_spec_arg_typos(kwargs_to_check):
    typos = ("autospect", "auto_spec", "set_spec")
    for typo in typos:
        if typo in kwargs_to_check:
            raise RuntimeError(
                f"{typo!r} might be a typo; use unsafe=True if this is intended"
            )


class _patch(object):

    attribute_name = None
    _active_patches = []

    def __init__(
            self, getter, attribute, new, spec, create,
            spec_set, autospec, new_callable, kwargs, *, unsafe=False
        ):
        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"
                )
        if not unsafe:
            _check_spec_arg_typos(kwargs)
        if _is_instance_mock(spec):
            raise InvalidSpecError(
                f'Cannot spec attr {attribute!r} as the spec '
                f'has already been mocked out. [spec={spec!r}]')
        if _is_instance_mock(spec_set):
            raise InvalidSpecError(
                f'Cannot spec attr {attribute!r} as the spec_set '
                f'target has already been mocked out. [spec_set={spec_set!r}]')

        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

            if _is_instance_mock(self.target):
                raise InvalidSpecError(
                    f'Cannot autospec attr {self.attribute!r} as the patch '
                    f'target has already been mocked out. '
                    f'[target={self.target!r}, attr={autospec!r}]')
            if _is_instance_mock(autospec):
                target_name = getattr(self.target, '__name__', self.target)
                raise InvalidSpecError(
                    f'Cannot autospec attr {self.attribute!r} from target '
                    f'{target_name!r} as it has already been mocked out. '
                    f'[target={self.target!r}, attr={autospec!r}]')

            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, AttributeError):
        raise TypeError(
            f"Need a valid target to patch. You supplied: {target!r}")
    return partial(pkgutil.resolve_name, target), attribute


def _patch_object(
        target, attribute, new=DEFAULT, spec=None,
        create=False, spec_set=None, autospec=None,
        new_callable=None, *, unsafe=False, **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, unsafe=unsafe
    )


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 = partial(pkgutil.resolve_name, 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, *, unsafe=False, **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 will raise a `RuntimeError` if passed some common misspellings of
    the arguments autospec and spec_set. Pass the argument `unsafe` with the
    value True to disable that check.

    `patch` takes arbitrary keyword arguments. These will be passed to
    `AsyncMock` if the patched object is asynchronous, to `MagicMock`
    otherwise or to `new_callable` if specified.

    `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, unsafe=unsafe
    )


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)
        if inspect.iscoroutinefunction(f):
            return self.decorate_async_callable(f)
        return self.decorate_callable(f)


    def decorate_callable(self, f):
        @wraps(f)
        def _inner(*args, **kw):
            self._patch_dict()
            try:
                return f(*args, **kw)
            finally:
                self._unpatch_dict()

        return _inner


    def decorate_async_callable(self, f):
        @wraps(f)
        async def _inner(*args, **kw):
            self._patch_dict()
            try:
                return await 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 = pkgutil.resolve_name(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."""
        if self._original is not None:
            self._unpatch_dict()
        return False


    def start(self):
        """Activate a patch, returning any created mock."""
        result = self.__enter__()
        _patch._active_patches.append(self)
        return result


    def stop(self):
        """Stop an active patch."""
        try:
            _patch._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 _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 truediv floordiv mod lshift rshift and xor or pow"
)
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__',
    '__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)
        # 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
            + inspect.CO_VARARGS
            + inspect.CO_VARKEYWORDS
        )
        code_mock.co_argcount = 0
        code_mock.co_varnames = ('args', 'kwargs')
        code_mock.co_posonlyargcount = 0
        code_mock.co_kwonlyargcount = 0
        self.__dict__['__code__'] = code_mock
        self.__dict__['__name__'] = 'AsyncMock'
        self.__dict__['__defaults__'] = tuple()
        self.__dict__['__kwdefaults__'] = {}
        self.__dict__['__annotations__'] = None

    async def _execute_mock_call(self, /, *args, **kwargs):
        # This is nearly just like super(), except for special 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 propagate a StopIteration
                    # through coroutines because of PEP 479
                    raise StopAsyncIteration
                if _is_exception(result):
                    raise result
            elif 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 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(_Call((args, kwargs), two=True))
        actual = self._call_matcher(self.await_args)
        if actual != expected:
            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(_Call((args, kwargs), two=True))
        cause = expected if isinstance(expected, Exception) else None
        actual = [self._call_matcher(c) for c in self.await_args_list]
        if cause or expected not in _AnyComparer(actual):
            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()
    >>> 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):
        try:
            len_other = len(other)
        except TypeError:
            return NotImplemented

        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 _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, *, unsafe=False, **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` will raise a `RuntimeError` if passed some common
    misspellings of the arguments autospec and spec_set. Pass the argument
    `unsafe` with the value True to disable that check.

    `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)
    if _is_instance_mock(spec):
        raise InvalidSpecError(f'Cannot autospec a Mock object. '
                               f'[object={spec!r}]')
    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
    if not unsafe:
        _check_spec_arg_typos(kwargs)

    _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

    wrapped = kwargs.get('wraps')

    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,
                                            wraps=wrapped)

    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}
        # Wrap child attributes also.
        if wrapped and hasattr(wrapped, entry):
            kwargs.update(wraps=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 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
open_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))))

    global open_spec
    if open_spec is None:
        import _io
        open_spec = list(set(dir(_io.open)))
    if mock is None:
        mock = MagicMock(name='open', spec=open_spec)

    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 isinstance(m._mock_children.get(attr), _SpecState):
            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

    async def __anext__(self):
        try:
            return next(self.iterator)
        except StopIteration:
            pass
        raise StopAsyncIteration