/usr/lib/python3/dist-packages/twisted/test
NameSizeModeActions
__pycache__/-0755rm
cert.pem.no_trailing_newline14140644editdlrm
crash_test_dummy.py5430644editdlrm
iosim.py178430644editdlrm
key.pem.no_trailing_newline17070644editdlrm
mock_win32process.py14990644editdlrm
myrebuilder1.py1580644editdlrm
myrebuilder2.py1580644editdlrm
plugin_basic.py9430644editdlrm
plugin_extra1.py4070644editdlrm
plugin_extra2.py5790644editdlrm
process_cmdline.py1620644editdlrm
process_echoer.py2140644editdlrm
process_fds.py9450644editdlrm
process_getargv.py2830644editdlrm
process_getenv.py2680644editdlrm
process_linger.py2860644editdlrm
process_reader.py1880644editdlrm
process_signal.py2140644editdlrm
process_stdinreader.py8570644editdlrm
process_tester.py10350644editdlrm
process_tty.py1300644editdlrm
process_twisted.py12060644editdlrm
proto_helpers.py286870644editdlrm
raiser.cpython-38-x86_64-linux-gnu.so238640644editdlrm
reflect_helper_IE.py610644editdlrm
reflect_helper_VE.py820644editdlrm
reflect_helper_ZDE.py470644editdlrm
server.pem44440644editdlrm
ssl_helpers.py10320644editdlrm
stdio_test_consumer.py12160644editdlrm
stdio_test_halfclose.py19380644editdlrm
stdio_test_hostpeer.py10210644editdlrm
stdio_test_lastwrite.py12060644editdlrm
stdio_test_loseconn.py15480644editdlrm
stdio_test_producer.py15070644editdlrm
stdio_test_write.py9230644editdlrm
stdio_test_writeseq.py9150644editdlrm
testutils.py53210644editdlrm
test_abstract.py34970644editdlrm
test_adbapi.py261480644editdlrm
test_amp.py1105530644editdlrm
test_application.py328160644editdlrm
test_compat.py292780644editdlrm
test_context.py15150644editdlrm
test_cooperator.py214670644editdlrm
test_defer.py1034070644editdlrm
test_defgen.py107010644editdlrm
test_dict.py14420644editdlrm
test_dirdbm.py66950644editdlrm
test_error.py85930644editdlrm
test_factories.py46370644editdlrm
test_failure.py322880644editdlrm
test_fdesc.py73710644editdlrm
test_finger.py19970644editdlrm
test_formmethod.py36450644editdlrm
test_ftp.py1303210644editdlrm
test_ftp_options.py26850644editdlrm
test_htb.py31900644editdlrm
test_ident.py70150644editdlrm
test_internet.py464220644editdlrm
test_iosim.py90600644editdlrm
test_iutils.py134450644editdlrm
test_lockfile.py155060644editdlrm
test_log.py363300644editdlrm
test_logfile.py182270644editdlrm
test_loopback.py144860644editdlrm
test_main.py25010644editdlrm
test_memcache.py251430644editdlrm
test_modules.py178880644editdlrm
test_monkey.py56370644editdlrm
test_nooldstyle.py59550644editdlrm
test_paths.py743570644editdlrm
test_pcp.py125510644editdlrm
test_persisted.py146240644editdlrm
test_plugin.py261130644editdlrm
test_policies.py334990644editdlrm
test_postfix.py42430644editdlrm
test_process.py861200644editdlrm
test_protocols.py74500644editdlrm
test_randbytes.py33570644editdlrm
test_rebuild.py84950644editdlrm
test_reflect.py260850644editdlrm
test_roots.py18120644editdlrm
test_shortcut.py19910644editdlrm
test_sip.py252840644editdlrm
test_sob.py56320644editdlrm
test_socks.py177380644editdlrm
test_ssl.py238460644editdlrm
test_sslverify.py1133220644editdlrm
test_stateful.py20210644editdlrm
test_stdio.py131560644editdlrm
test_strerror.py51830644editdlrm
test_stringtransport.py132640644editdlrm
test_strports.py17970644editdlrm
test_task.py393260644editdlrm
test_tcp.py658200644editdlrm
test_tcp_internals.py131170644editdlrm
test_text.py64560644editdlrm
test_threadable.py37380644editdlrm
test_threadpool.py222040644editdlrm
test_threads.py132680644editdlrm
test_tpfile.py16010644editdlrm
test_twistd.py742010644editdlrm
test_twisted.py111730644editdlrm
test_udp.py246760644editdlrm
test_unix.py151570644editdlrm
test_usage.py236450644editdlrm
__init__.py1030644editdlrm
Edit: /usr/lib/python3/dist-packages/twisted/test/test_error.py (8593B)
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. from __future__ import division, absolute_import import socket, errno from twisted.trial import unittest from twisted.internet import error from twisted.python.runtime import platformType class StringificationTests(unittest.SynchronousTestCase): """Test that the exceptions have useful stringifications. """ listOfTests = [ #(output, exception[, args[, kwargs]]), ("An error occurred binding to an interface.", error.BindError), ("An error occurred binding to an interface: foo.", error.BindError, ['foo']), ("An error occurred binding to an interface: foo bar.", error.BindError, ['foo', 'bar']), ("Couldn't listen on eth0:4242: Foo.", error.CannotListenError, ('eth0', 4242, socket.error('Foo'))), ("Message is too long to send.", error.MessageLengthError), ("Message is too long to send: foo bar.", error.MessageLengthError, ['foo', 'bar']), ("DNS lookup failed.", error.DNSLookupError), ("DNS lookup failed: foo bar.", error.DNSLookupError, ['foo', 'bar']), ("An error occurred while connecting.", error.ConnectError), ("An error occurred while connecting: someOsError.", error.ConnectError, ['someOsError']), ("An error occurred while connecting: foo.", error.ConnectError, [], {'string': 'foo'}), ("An error occurred while connecting: someOsError: foo.", error.ConnectError, ['someOsError', 'foo']), ("Couldn't bind.", error.ConnectBindError), ("Couldn't bind: someOsError.", error.ConnectBindError, ['someOsError']), ("Couldn't bind: someOsError: foo.", error.ConnectBindError, ['someOsError', 'foo']), ("Hostname couldn't be looked up.", error.UnknownHostError), ("No route to host.", error.NoRouteError), ("Connection was refused by other side.", error.ConnectionRefusedError), ("TCP connection timed out.", error.TCPTimedOutError), ("File used for UNIX socket is no good.", error.BadFileError), ("Service name given as port is unknown.", error.ServiceNameUnknownError), ("User aborted connection.", error.UserError), ("User timeout caused connection failure.", error.TimeoutError), ("An SSL error occurred.", error.SSLError), ("Connection to the other side was lost in a non-clean fashion.", error.ConnectionLost), ("Connection to the other side was lost in a non-clean fashion: foo bar.", error.ConnectionLost, ['foo', 'bar']), ("Connection was closed cleanly.", error.ConnectionDone), ("Connection was closed cleanly: foo bar.", error.ConnectionDone, ['foo', 'bar']), ("Uh.", #TODO nice docstring, you've got there. error.ConnectionFdescWentAway), ("Tried to cancel an already-called event.", error.AlreadyCalled), ("Tried to cancel an already-called event: foo bar.", error.AlreadyCalled, ['foo', 'bar']), ("Tried to cancel an already-cancelled event.", error.AlreadyCancelled), ("Tried to cancel an already-cancelled event: x 2.", error.AlreadyCancelled, ["x", "2"]), ("A process has ended without apparent errors: process finished with exit code 0.", error.ProcessDone, [None]), ("A process has ended with a probable error condition: process ended.", error.ProcessTerminated), ("A process has ended with a probable error condition: process ended with exit code 42.", error.ProcessTerminated, [], {'exitCode': 42}), ("A process has ended with a probable error condition: process ended by signal SIGBUS.", error.ProcessTerminated, [], {'signal': 'SIGBUS'}), ("The Connector was not connecting when it was asked to stop connecting.", error.NotConnectingError), ("The Connector was not connecting when it was asked to stop connecting: x 13.", error.NotConnectingError, ["x", "13"]), ("The Port was not listening when it was asked to stop listening.", error.NotListeningError), ("The Port was not listening when it was asked to stop listening: a 12.", error.NotListeningError, ["a", "12"]), ] def testThemAll(self): for entry in self.listOfTests: output = entry[0] exception = entry[1] try: args = entry[2] except IndexError: args = () try: kwargs = entry[3] except IndexError: kwargs = {} self.assertEqual( str(exception(*args, **kwargs)), output) def test_connectingCancelledError(self): """ L{error.ConnectingCancelledError} has an C{address} attribute. """ address = object() e = error.ConnectingCancelledError(address) self.assertIs(e.address, address) class SubclassingTests(unittest.SynchronousTestCase): """ Some exceptions are subclasses of other exceptions. """ def test_connectionLostSubclassOfConnectionClosed(self): """ L{error.ConnectionClosed} is a superclass of L{error.ConnectionLost}. """ self.assertTrue(issubclass(error.ConnectionLost, error.ConnectionClosed)) def test_connectionDoneSubclassOfConnectionClosed(self): """ L{error.ConnectionClosed} is a superclass of L{error.ConnectionDone}. """ self.assertTrue(issubclass(error.ConnectionDone, error.ConnectionClosed)) def test_invalidAddressErrorSubclassOfValueError(self): """ L{ValueError} is a superclass of L{error.InvalidAddressError}. """ self.assertTrue(issubclass(error.InvalidAddressError, ValueError)) class GetConnectErrorTests(unittest.SynchronousTestCase): """ Given an exception instance thrown by C{socket.connect}, L{error.getConnectError} returns the appropriate high-level Twisted exception instance. """ def assertErrnoException(self, errno, expectedClass): """ When called with a tuple with the given errno, L{error.getConnectError} returns an exception which is an instance of the expected class. """ e = (errno, "lalala") result = error.getConnectError(e) self.assertCorrectException(errno, "lalala", result, expectedClass) def assertCorrectException(self, errno, message, result, expectedClass): """ The given result of L{error.getConnectError} has the given attributes (C{osError} and C{args}), and is an instance of the given class. """ # Want exact class match, not inherited classes, so no isinstance(): self.assertEqual(result.__class__, expectedClass) self.assertEqual(result.osError, errno) self.assertEqual(result.args, (message,)) def test_errno(self): """ L{error.getConnectError} converts based on errno for C{socket.error}. """ self.assertErrnoException(errno.ENETUNREACH, error.NoRouteError) self.assertErrnoException(errno.ECONNREFUSED, error.ConnectionRefusedError) self.assertErrnoException(errno.ETIMEDOUT, error.TCPTimedOutError) if platformType == "win32": self.assertErrnoException(errno.WSAECONNREFUSED, error.ConnectionRefusedError) self.assertErrnoException(errno.WSAENETUNREACH, error.NoRouteError) def test_gaierror(self): """ L{error.getConnectError} converts to a L{error.UnknownHostError} given a C{socket.gaierror} instance. """ result = error.getConnectError(socket.gaierror(12, "hello")) self.assertCorrectException(12, "hello", result, error.UnknownHostError) def test_nonTuple(self): """ L{error.getConnectError} converts to a L{error.ConnectError} given an argument that cannot be unpacked. """ e = Exception() result = error.getConnectError(e) self.assertCorrectException(None, e, result, error.ConnectError)