PHP 8.5.2
Preview: test_reactormixins.py Size: 1.93 KB
/lib/python3/dist-packages/twisted/internet/test/test_reactormixins.py

"""
Tests L{twisted.internet.test.reactormixins}, the reactor-testing support
module.
"""

from hamcrest import assert_that, equal_to, has_length
from typing import NoReturn

# Trial should expose matches_result publically.
# https://github.com/twisted/twisted/issues/11709
from twisted.trial._dist.test.matchers import matches_result
from twisted.trial.reporter import TestResult
from twisted.trial.runner import TestLoader
from twisted.trial.unittest import SynchronousTestCase, TestSuite
from .reactormixins import ReactorBuilder

UNSUPPORTED = "This reactor is unsupported."


def unsupportedReactor(self: ReactorBuilder) -> NoReturn:
    """
    A function that can be used as a factory for L{ReactorBuilder} tests but
    which always raises an exception.

    This gives the appearance of a reactor type which is unsupported in the
    current runtime configuration for some reason.
    """
    raise Exception(UNSUPPORTED)


class ReactorBuilderTests(SynchronousTestCase):
    """
    Tests for L{ReactorBuilder}.
    """

    def test_buildReactorFails(self) -> None:
        """
        If the reactor factory raises any exception then
        L{ReactorBuilder.buildReactor} raises L{SkipTest}.
        """

        class BrokenReactorFactory(ReactorBuilder, SynchronousTestCase):
            _reactors = [
                "twisted.internet.test.test_reactormixins.unsupportedReactor",
            ]

            def test_brokenFactory(self) -> None:
                """
                Try, and fail, to build an unsupported reactor.
                """
                self.buildReactor()

        cases = BrokenReactorFactory.makeTestCaseClasses().values()
        loader = TestLoader()
        suite = TestSuite(loader.loadClass(cls) for cls in cases)
        result = TestResult()
        suite.run(result)

        assert_that(result, matches_result(skips=has_length(1)))
        [(_, skip)] = result.skips
        assert_that(skip, equal_to(UNSUPPORTED))

Directory Contents

Dirs: 2 × Files: 55

Name Size Perms Modified Actions
fake_CAs DIR
- drwxr-xr-x 2026-01-08 12:55:41
Edit Download
- drwxr-xr-x 2026-01-08 12:56:23
Edit Download
19.71 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
1.62 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
1.63 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
547 B lrw-r--r-- 2024-08-27 10:30:39
Edit Download
126 B lrw-r--r-- 2024-08-27 10:30:39
Edit Download
792 B lrw-r--r-- 2024-08-27 10:30:39
Edit Download
1.22 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
16.05 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
2.15 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
8.07 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
9.70 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
14.44 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
2.53 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
3.09 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
10.86 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
3.50 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
6.66 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
4.79 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
147.25 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
7.15 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
1.08 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
13.18 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
2.70 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
7.18 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
3.02 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
11.21 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
18.13 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
7.52 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
1.93 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
1.32 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
6.38 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
1.28 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
11.56 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
10.94 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
44.60 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
18.08 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
1.93 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
19.15 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
1.94 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
3.25 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
9.22 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
6.18 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
105.70 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
16.49 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
7.94 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
3.57 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
12.54 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
16.48 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
4.98 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
34.04 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
6.30 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
5.18 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
4.29 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
3.88 KB lrw-r--r-- 2024-08-27 10:30:39
Edit Download
112 B lrw-r--r-- 2024-08-27 10:30:39
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).