__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

www-data@216.73.216.10: ~ $
# -*- test-case-name: twisted.trial.test.test_tests -*-
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.

"""
Definitions of test cases with various interesting error-related behaviors, to
be used by test modules to exercise different features of trial's test runner.

See the L{twisted.trial.test.test_tests} module docstring for details about how
this code is arranged.

Some of these tests are also used by L{twisted.trial._dist.test}.
"""


from unittest import skipIf

from twisted.internet import defer, protocol, reactor
from twisted.internet.task import deferLater
from twisted.trial import unittest, util


class FoolishError(Exception):
    pass


class LargeError(Exception):
    """
    An exception which has a string representation of at least a specified
    number of characters.
    """

    def __init__(self, minSize: int) -> None:
        Exception.__init__(self)
        self.minSize = minSize

    def __str__(self):
        large = "x" * self.minSize
        return f"LargeError<I fail: {large}>"


class FailureInSetUpMixin:
    def setUp(self):
        raise FoolishError("I am a broken setUp method")

    def test_noop(self):
        pass


class SynchronousTestFailureInSetUp(FailureInSetUpMixin, unittest.SynchronousTestCase):
    pass


class AsynchronousTestFailureInSetUp(FailureInSetUpMixin, unittest.TestCase):
    pass


class FailureInTearDownMixin:
    def tearDown(self):
        raise FoolishError("I am a broken tearDown method")

    def test_noop(self):
        pass


class SynchronousTestFailureInTearDown(
    FailureInTearDownMixin, unittest.SynchronousTestCase
):
    pass


class AsynchronousTestFailureInTearDown(FailureInTearDownMixin, unittest.TestCase):
    pass


class FailureButTearDownRunsMixin:
    """
    A test fails, but its L{tearDown} still runs.
    """

    tornDown = False

    def tearDown(self):
        self.tornDown = True

    def test_fails(self):
        """
        A test that fails.
        """
        raise FoolishError("I am a broken test")


class SynchronousTestFailureButTearDownRuns(
    FailureButTearDownRunsMixin, unittest.SynchronousTestCase
):
    pass


class AsynchronousTestFailureButTearDownRuns(
    FailureButTearDownRunsMixin, unittest.TestCase
):
    pass


class TestRegularFail(unittest.SynchronousTestCase):
    def test_fail(self):
        self.fail("I fail")

    def test_subfail(self):
        self.subroutine()

    def subroutine(self):
        self.fail("I fail inside")


class TestAsynchronousFail(unittest.TestCase):
    """
    Test failures for L{unittest.TestCase} based classes.
    """

    text = "I fail"

    def test_fail(self) -> defer.Deferred[None]:
        """
        A test which fails in the callback of the returned L{defer.Deferred}.
        """
        return deferLater(reactor, 0, self.fail, "I fail later")  # type: ignore[arg-type]

    def test_failGreaterThan64k(self) -> defer.Deferred[None]:
        """
        A test which fails in the callback of the returned L{defer.Deferred}
        with a very long string.
        """
        return deferLater(reactor, 0, self.fail, "I fail later: " + "x" * 2**16)  # type: ignore[arg-type]

    def test_exception(self) -> None:
        """
        A test which raises an exception synchronously.
        """
        raise Exception(self.text)

    def test_exceptionGreaterThan64k(self) -> None:
        """
        A test which raises an exception with a long string representation
        synchronously.
        """
        raise LargeError(2**16)

    def test_exceptionGreaterThan64kEncoded(self) -> None:
        """
        A test which synchronously raises an exception with a long string
        representation including non-ascii content.
        """
        # The exception text itself is not greater than 64k but SNOWMAN
        # encodes to 3 bytes with UTF-8 so the length of the UTF-8 encoding of
        # the string representation of this exception will be greater than 2
        # ** 16.
        raise Exception("\N{SNOWMAN}" * 2**15)


class ErrorTest(unittest.SynchronousTestCase):
    """
    A test case which has a L{test_foo} which will raise an error.

    @ivar ran: boolean indicating whether L{test_foo} has been run.
    """

    ran = False

    def test_foo(self):
        """
        Set C{self.ran} to True and raise a C{ZeroDivisionError}
        """
        self.ran = True
        1 / 0


@skipIf(True, "skipping this test")
class TestSkipTestCase(unittest.SynchronousTestCase):
    pass


class DelayedCall(unittest.TestCase):
    hiddenExceptionMsg = "something blew up"

    def go(self):
        raise RuntimeError(self.hiddenExceptionMsg)

    def testHiddenException(self):
        """
        What happens if an error is raised in a DelayedCall and an error is
        also raised in the test?

        L{test_reporter.ErrorReportingTests.testHiddenException} checks that
        both errors get reported.

        Note that this behaviour is deprecated. A B{real} test would return a
        Deferred that got triggered by the callLater. This would guarantee the
        delayed call error gets reported.
        """
        reactor.callLater(0, self.go)
        reactor.iterate(0.01)
        self.fail("Deliberate failure to mask the hidden exception")

    testHiddenException.suppress = [  # type: ignore[attr-defined]
        util.suppress(
            message=r"reactor\.iterate cannot be used.*", category=DeprecationWarning
        )
    ]


class ReactorCleanupTests(unittest.TestCase):
    def test_leftoverPendingCalls(self):
        def _():
            print("foo!")

        reactor.callLater(10000.0, _)


class SocketOpenTest(unittest.TestCase):
    def test_socketsLeftOpen(self):
        f = protocol.Factory()
        f.protocol = protocol.Protocol
        reactor.listenTCP(0, f)


class TimingOutDeferred(unittest.TestCase):
    def test_alpha(self):
        pass

    def test_deferredThatNeverFires(self):
        self.methodCalled = True
        d = defer.Deferred()
        return d

    def test_omega(self):
        pass


def unexpectedException(self):
    """i will raise an unexpected exception...
    ... *CAUSE THAT'S THE KINDA GUY I AM*

    >>> 1/0
    """


class EventuallyFailingTestCase(unittest.SynchronousTestCase):
    """
    A test suite that fails after it is run a few times.
    """

    n: int = 0

    def test_it(self):
        """
        Run successfully a few times and then fail forever after.
        """
        self.n += 1
        if self.n >= 5:
            self.fail("eventually failing")

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
__init__.py File 1.68 KB 0644
detests.py File 5.63 KB 0644
erroneous.py File 6.44 KB 0644
matchers.py File 2.88 KB 0644
mockcustomsuite.py File 544 B 0644
mockcustomsuite2.py File 541 B 0644
mockcustomsuite3.py File 684 B 0644
mockdoctest.py File 2.36 KB 0644
moduleself.py File 178 B 0644
moduletest.py File 302 B 0644
novars.py File 182 B 0644
ordertests.py File 912 B 0644
packages.py File 4.54 KB 0644
pyunitcases.py File 3.1 KB 0644
sample.py File 2.13 KB 0644
scripttest.py File 457 B 0755
skipping.py File 5.99 KB 0644
suppression.py File 2.44 KB 0644
test_assertions.py File 59.39 KB 0644
test_asyncassertions.py File 2.49 KB 0644
test_deferred.py File 9.63 KB 0644
test_doctest.py File 1.76 KB 0644
test_keyboard.py File 3.96 KB 0644
test_loader.py File 23.95 KB 0644
test_log.py File 7.85 KB 0644
test_matchers.py File 2.97 KB 0644
test_output.py File 5.26 KB 0644
test_plugins.py File 1.43 KB 0644
test_pyunitcompat.py File 7.88 KB 0644
test_reporter.py File 56.44 KB 0644
test_runner.py File 31.5 KB 0644
test_script.py File 32.41 KB 0644
test_skip.py File 2.69 KB 0644
test_suppression.py File 5.77 KB 0644
test_testcase.py File 1.94 KB 0644
test_tests.py File 48.83 KB 0644
test_util.py File 21.65 KB 0644
test_warning.py File 18.4 KB 0644
weird.py File 675 B 0644
Filemanager