code
stringlengths
26
870k
docstring
stringlengths
1
65.6k
func_name
stringlengths
1
194
language
stringclasses
1 value
repo
stringlengths
8
68
path
stringlengths
5
182
url
stringlengths
46
251
license
stringclasses
4 values
def test_containsModule(self): """ L{PythonPath} implements the C{in} operator so that when it is the right-hand argument and the name of a module which exists on that L{PythonPath} is the left-hand argument, the result is C{True}. """ thePath = modules.PythonPath() self.assertIn('os', thePath)
L{PythonPath} implements the C{in} operator so that when it is the right-hand argument and the name of a module which exists on that L{PythonPath} is the left-hand argument, the result is C{True}.
test_containsModule
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_modules.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_modules.py
MIT
def test_doesntContainModule(self): """ L{PythonPath} implements the C{in} operator so that when it is the right-hand argument and the name of a module which does not exist on that L{PythonPath} is the left-hand argument, the result is C{False}. """ thePath = modules.PythonPath() self.assertNotIn('bogusModule', thePath)
L{PythonPath} implements the C{in} operator so that when it is the right-hand argument and the name of a module which does not exist on that L{PythonPath} is the left-hand argument, the result is C{False}.
test_doesntContainModule
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_modules.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_modules.py
MIT
def test_service(self): """ L{strports.service} returns a L{StreamServerEndpointService} constructed with an endpoint produced from L{endpoint.serverFromString}, using the same syntax. """ reactor = object() # the cake is a lie aFactory = Factory() aGoodPort = 1337 svc = strports.service( 'tcp:' + str(aGoodPort), aFactory, reactor=reactor) self.assertIsInstance(svc, internet.StreamServerEndpointService) # See twisted.application.test.test_internet.EndpointServiceTests. # test_synchronousRaiseRaisesSynchronously self.assertTrue(svc._raiseSynchronously) self.assertIsInstance(svc.endpoint, TCP4ServerEndpoint) # Maybe we should implement equality for endpoints. self.assertEqual(svc.endpoint._port, aGoodPort) self.assertIs(svc.factory, aFactory) self.assertIs(svc.endpoint._reactor, reactor)
L{strports.service} returns a L{StreamServerEndpointService} constructed with an endpoint produced from L{endpoint.serverFromString}, using the same syntax.
test_service
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_strports.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_strports.py
MIT
def test_serviceDefaultReactor(self): """ L{strports.service} will use the default reactor when none is provided as an argument. """ from twisted.internet import reactor as globalReactor aService = strports.service("tcp:80", None) self.assertIs(aService.endpoint._reactor, globalReactor)
L{strports.service} will use the default reactor when none is provided as an argument.
test_serviceDefaultReactor
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_strports.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_strports.py
MIT
def test_connectingCancelledError(self): """ L{error.ConnectingCancelledError} has an C{address} attribute. """ address = object() e = error.ConnectingCancelledError(address) self.assertIs(e.address, address)
L{error.ConnectingCancelledError} has an C{address} attribute.
test_connectingCancelledError
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_error.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_error.py
MIT
def test_connectionLostSubclassOfConnectionClosed(self): """ L{error.ConnectionClosed} is a superclass of L{error.ConnectionLost}. """ self.assertTrue(issubclass(error.ConnectionLost, error.ConnectionClosed))
L{error.ConnectionClosed} is a superclass of L{error.ConnectionLost}.
test_connectionLostSubclassOfConnectionClosed
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_error.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_error.py
MIT
def test_connectionDoneSubclassOfConnectionClosed(self): """ L{error.ConnectionClosed} is a superclass of L{error.ConnectionDone}. """ self.assertTrue(issubclass(error.ConnectionDone, error.ConnectionClosed))
L{error.ConnectionClosed} is a superclass of L{error.ConnectionDone}.
test_connectionDoneSubclassOfConnectionClosed
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_error.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_error.py
MIT
def test_invalidAddressErrorSubclassOfValueError(self): """ L{ValueError} is a superclass of L{error.InvalidAddressError}. """ self.assertTrue(issubclass(error.InvalidAddressError, ValueError))
L{ValueError} is a superclass of L{error.InvalidAddressError}.
test_invalidAddressErrorSubclassOfValueError
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_error.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_error.py
MIT
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)
When called with a tuple with the given errno, L{error.getConnectError} returns an exception which is an instance of the expected class.
assertErrnoException
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_error.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_error.py
MIT
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,))
The given result of L{error.getConnectError} has the given attributes (C{osError} and C{args}), and is an instance of the given class.
assertCorrectException
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_error.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_error.py
MIT
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)
L{error.getConnectError} converts based on errno for C{socket.error}.
test_errno
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_error.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_error.py
MIT
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)
L{error.getConnectError} converts to a L{error.UnknownHostError} given a C{socket.gaierror} instance.
test_gaierror
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_error.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_error.py
MIT
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)
L{error.getConnectError} converts to a L{error.ConnectError} given an argument that cannot be unpacked.
test_nonTuple
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_error.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_error.py
MIT
def test_wordCount(self): """ Compare the number of words. """ words = [] for line in self.output: words.extend(line.split()) wordCount = len(words) sampleTextWordCount = len(self.sampleSplitText) self.assertEqual(wordCount, sampleTextWordCount)
Compare the number of words.
test_wordCount
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_text.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_text.py
MIT
def test_wordMatch(self): """ Compare the lists of words. """ words = [] for line in self.output: words.extend(line.split()) # Using assertEqual here prints out some # rather too long lists. self.assertTrue(self.sampleSplitText == words)
Compare the lists of words.
test_wordMatch
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_text.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_text.py
MIT
def test_lineLength(self): """ Check the length of the lines. """ failures = [] for line in self.output: if not len(line) <= self.lineWidth: failures.append(len(line)) if failures: self.fail("%d of %d lines were too long.\n" "%d < %s" % (len(failures), len(self.output), self.lineWidth, failures))
Check the length of the lines.
test_lineLength
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_text.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_text.py
MIT
def test_doubleNewline(self): """ Allow paragraphs delimited by two \ns. """ sampleText = "et\n\nphone\nhome." result = text.wordWrap(sampleText, self.lineWidth) self.assertEqual(result, ["et", "", "phone home.", ""])
Allow paragraphs delimited by two \ns.
test_doubleNewline
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_text.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_text.py
MIT
def test_isMultiline(self): """ L{text.isMultiline} returns C{True} if the string has a newline in it. """ s = 'This code\n "breaks."' m = text.isMultiline(s) self.assertTrue(m) s = 'This code does not "break."' m = text.isMultiline(s) self.assertFalse(m)
L{text.isMultiline} returns C{True} if the string has a newline in it.
test_isMultiline
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_text.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_text.py
MIT
def test_endsInNewline(self): """ L{text.endsInNewline} returns C{True} if the string ends in a newline. """ s = 'newline\n' m = text.endsInNewline(s) self.assertTrue(m) s = 'oldline' m = text.endsInNewline(s) self.assertFalse(m)
L{text.endsInNewline} returns C{True} if the string ends in a newline.
test_endsInNewline
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_text.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_text.py
MIT
def test_tuple(self): """ Tuple elements are displayed on separate lines. """ s = ('a', 'b') m = text.stringyString(s) self.assertEqual(m, '(a,\n b,)\n')
Tuple elements are displayed on separate lines.
test_tuple
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_text.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_text.py
MIT
def test_dict(self): """ Dicts elements are displayed using C{str()}. """ s = {'a': 0} m = text.stringyString(s) self.assertEqual(m, '{a: 0}')
Dicts elements are displayed using C{str()}.
test_dict
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_text.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_text.py
MIT
def test_list(self): """ List elements are displayed on separate lines using C{str()}. """ s = ['a', 'b'] m = text.stringyString(s) self.assertEqual(m, '[a,\n b,]\n')
List elements are displayed on separate lines using C{str()}.
test_list
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_text.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_text.py
MIT
def test_oneWord(self): """ Splitting strings with one-word phrases. """ s = 'This code "works."' r = text.splitQuoted(s) self.assertEqual(['This', 'code', 'works.'], r)
Splitting strings with one-word phrases.
test_oneWord
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_text.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_text.py
MIT
def setUp(self): """ Create an ident client used in tests. """ self.client = ident.IdentClient()
Create an ident client used in tests.
setUp
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ident.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ident.py
MIT
def test_indentError(self): """ 'UNKNOWN-ERROR' error should map to the L{ident.IdentError} exception. """ d = defer.Deferred() self.client.queries.append((d, 123, 456)) self.client.lineReceived('123, 456 : ERROR : UNKNOWN-ERROR') return self.assertFailure(d, ident.IdentError)
'UNKNOWN-ERROR' error should map to the L{ident.IdentError} exception.
test_indentError
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ident.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ident.py
MIT
def test_noUSerError(self): """ 'NO-USER' error should map to the L{ident.NoUser} exception. """ d = defer.Deferred() self.client.queries.append((d, 234, 456)) self.client.lineReceived('234, 456 : ERROR : NO-USER') return self.assertFailure(d, ident.NoUser)
'NO-USER' error should map to the L{ident.NoUser} exception.
test_noUSerError
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ident.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ident.py
MIT
def test_invalidPortError(self): """ 'INVALID-PORT' error should map to the L{ident.InvalidPort} exception. """ d = defer.Deferred() self.client.queries.append((d, 345, 567)) self.client.lineReceived('345, 567 : ERROR : INVALID-PORT') return self.assertFailure(d, ident.InvalidPort)
'INVALID-PORT' error should map to the L{ident.InvalidPort} exception.
test_invalidPortError
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ident.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ident.py
MIT
def test_hiddenUserError(self): """ 'HIDDEN-USER' error should map to the L{ident.HiddenUser} exception. """ d = defer.Deferred() self.client.queries.append((d, 567, 789)) self.client.lineReceived('567, 789 : ERROR : HIDDEN-USER') return self.assertFailure(d, ident.HiddenUser)
'HIDDEN-USER' error should map to the L{ident.HiddenUser} exception.
test_hiddenUserError
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ident.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ident.py
MIT
def test_lostConnection(self): """ A pending query which failed because of a ConnectionLost should receive an L{ident.IdentError}. """ d = defer.Deferred() self.client.queries.append((d, 765, 432)) self.client.connectionLost(failure.Failure(error.ConnectionLost())) return self.assertFailure(d, ident.IdentError)
A pending query which failed because of a ConnectionLost should receive an L{ident.IdentError}.
test_lostConnection
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ident.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ident.py
MIT
def mocked_open(*args, **kwargs): """ Mock for the open call to prevent actually opening /proc/net/tcp. """ open_calls.append((args, kwargs)) return NativeStringIO(self.sampleFile)
Mock for the open call to prevent actually opening /proc/net/tcp.
testLookupProcNetTcp.mocked_open
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ident.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ident.py
MIT
def testLookupProcNetTcp(self): """ L{ident.ProcServerMixin.lookup} uses the Linux TCP process table. """ open_calls = [] def mocked_open(*args, **kwargs): """ Mock for the open call to prevent actually opening /proc/net/tcp. """ open_calls.append((args, kwargs)) return NativeStringIO(self.sampleFile) self.patch(builtins, 'open', mocked_open) p = ident.ProcServerMixin() self.assertRaises(ident.NoUser, p.lookup, ('127.0.0.1', 26), ('1.2.3.4', 762)) self.assertEqual([(('/proc/net/tcp',), {})], open_calls)
L{ident.ProcServerMixin.lookup} uses the Linux TCP process table.
testLookupProcNetTcp
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ident.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_ident.py
MIT
def getDivisionFailure(*args, **kwargs): """ Make a C{Failure} of a divide-by-zero error. @param args: Any C{*args} are passed to Failure's constructor. @param kwargs: Any C{**kwargs} are passed to Failure's constructor. """ try: 1/0 except: f = failure.Failure(*args, **kwargs) return f
Make a C{Failure} of a divide-by-zero error. @param args: Any C{*args} are passed to Failure's constructor. @param kwargs: Any C{**kwargs} are passed to Failure's constructor.
getDivisionFailure
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_failAndTrap(self): """ Trapping a L{Failure}. """ try: raise NotImplementedError('test') except: f = failure.Failure() error = f.trap(SystemExit, RuntimeError) self.assertEqual(error, RuntimeError) self.assertEqual(f.type, NotImplementedError)
Trapping a L{Failure}.
test_failAndTrap
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_trapRaisesWrappedException(self): """ If the wrapped C{Exception} is not a subclass of one of the expected types, L{failure.Failure.trap} raises the wrapped C{Exception}. """ if not _PY3: raise SkipTest( """ Only expected behaviour on Python 3. @see U{http://twisted.readthedocs.io/en/latest/core/howto/python3.html#twisted-python-failure} """ ) exception = ValueError() try: raise exception except: f = failure.Failure() untrapped = self.assertRaises(ValueError, f.trap, OverflowError) self.assertIs(exception, untrapped)
If the wrapped C{Exception} is not a subclass of one of the expected types, L{failure.Failure.trap} raises the wrapped C{Exception}.
test_trapRaisesWrappedException
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_trapRaisesSelf(self): """ If the wrapped C{Exception} is not a subclass of one of the expected types, L{failure.Failure.trap} raises itself. """ if _PY3: raise SkipTest( """ Only expected behaviour on Python 2. @see U{http://twisted.readthedocs.io/en/latest/core/howto/python3.html#twisted-python-failure} """ ) exception = ValueError() try: raise exception except: f = failure.Failure() untrapped = self.assertRaises(failure.Failure, f.trap, OverflowError) self.assertIs(f, untrapped)
If the wrapped C{Exception} is not a subclass of one of the expected types, L{failure.Failure.trap} raises itself.
test_trapRaisesSelf
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_failureValueFromFailure(self): """ A L{failure.Failure} constructed from another L{failure.Failure} instance, has its C{value} property set to the value of that L{failure.Failure} instance. """ exception = ValueError() f1 = failure.Failure(exception) f2 = failure.Failure(f1) self.assertIs(f2.value, exception)
A L{failure.Failure} constructed from another L{failure.Failure} instance, has its C{value} property set to the value of that L{failure.Failure} instance.
test_failureValueFromFailure
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_failureValueFromFoundFailure(self): """ A L{failure.Failure} constructed without a C{exc_value} argument, will search for an "original" C{Failure}, and if found, its value will be used as the value for the new C{Failure}. """ exception = ValueError() f1 = failure.Failure(exception) try: f1.trap(OverflowError) except: f2 = failure.Failure() self.assertIs(f2.value, exception)
A L{failure.Failure} constructed without a C{exc_value} argument, will search for an "original" C{Failure}, and if found, its value will be used as the value for the new C{Failure}.
test_failureValueFromFoundFailure
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def assertStartsWith(self, s, prefix): """ Assert that C{s} starts with a particular C{prefix}. @param s: The input string. @type s: C{str} @param prefix: The string that C{s} should start with. @type prefix: C{str} """ self.assertTrue(s.startswith(prefix), '%r is not the start of %r' % (prefix, s))
Assert that C{s} starts with a particular C{prefix}. @param s: The input string. @type s: C{str} @param prefix: The string that C{s} should start with. @type prefix: C{str}
assertStartsWith
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def assertEndsWith(self, s, suffix): """ Assert that C{s} end with a particular C{suffix}. @param s: The input string. @type s: C{str} @param suffix: The string that C{s} should end with. @type suffix: C{str} """ self.assertTrue(s.endswith(suffix), '%r is not the end of %r' % (suffix, s))
Assert that C{s} end with a particular C{suffix}. @param s: The input string. @type s: C{str} @param suffix: The string that C{s} should end with. @type suffix: C{str}
assertEndsWith
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def assertTracebackFormat(self, tb, prefix, suffix): """ Assert that the C{tb} traceback contains a particular C{prefix} and C{suffix}. @param tb: The traceback string. @type tb: C{str} @param prefix: The string that C{tb} should start with. @type prefix: C{str} @param suffix: The string that C{tb} should end with. @type suffix: C{str} """ self.assertStartsWith(tb, prefix) self.assertEndsWith(tb, suffix)
Assert that the C{tb} traceback contains a particular C{prefix} and C{suffix}. @param tb: The traceback string. @type tb: C{str} @param prefix: The string that C{tb} should start with. @type prefix: C{str} @param suffix: The string that C{tb} should end with. @type suffix: C{str}
assertTracebackFormat
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def assertDetailedTraceback(self, captureVars=False, cleanFailure=False): """ Assert that L{printDetailedTraceback} produces and prints a detailed traceback. The detailed traceback consists of a header:: *--- Failure #20 --- The body contains the stacktrace:: /twisted/trial/_synctest.py:1180: _run(...) /twisted/python/util.py:1076: runWithWarningsSuppressed(...) --- <exception caught here> --- /twisted/test/test_failure.py:39: getDivisionFailure(...) If C{captureVars} is enabled the body also includes a list of globals and locals:: [ Locals ] exampleLocalVar : 'xyz' ... ( Globals ) ... Or when C{captureVars} is disabled:: [Capture of Locals and Globals disabled (use captureVars=True)] When C{cleanFailure} is enabled references to other objects are removed and replaced with strings. And finally the footer with the L{Failure}'s value:: exceptions.ZeroDivisionError: float division *--- End of Failure #20 --- @param captureVars: Enables L{Failure.captureVars}. @type captureVars: C{bool} @param cleanFailure: Enables L{Failure.cleanFailure}. @type cleanFailure: C{bool} """ if captureVars: exampleLocalVar = 'xyz' # Silence the linter as this variable is checked via # the traceback. exampleLocalVar f = getDivisionFailure(captureVars=captureVars) out = NativeStringIO() if cleanFailure: f.cleanFailure() f.printDetailedTraceback(out) tb = out.getvalue() start = "*--- Failure #%d%s---\n" % (f.count, (f.pickled and ' (pickled) ') or ' ') end = "%s: %s\n*--- End of Failure #%s ---\n" % (reflect.qual(f.type), reflect.safe_str(f.value), f.count) self.assertTracebackFormat(tb, start, end) # Variables are printed on lines with 2 leading spaces. linesWithVars = [line for line in tb.splitlines() if line.startswith(' ')] if captureVars: self.assertNotEqual([], linesWithVars) if cleanFailure: line = ' exampleLocalVar : "\'xyz\'"' else: line = " exampleLocalVar : 'xyz'" self.assertIn(line, linesWithVars) else: self.assertEqual([], linesWithVars) self.assertIn(' [Capture of Locals and Globals disabled (use ' 'captureVars=True)]\n', tb)
Assert that L{printDetailedTraceback} produces and prints a detailed traceback. The detailed traceback consists of a header:: *--- Failure #20 --- The body contains the stacktrace:: /twisted/trial/_synctest.py:1180: _run(...) /twisted/python/util.py:1076: runWithWarningsSuppressed(...) --- <exception caught here> --- /twisted/test/test_failure.py:39: getDivisionFailure(...) If C{captureVars} is enabled the body also includes a list of globals and locals:: [ Locals ] exampleLocalVar : 'xyz' ... ( Globals ) ... Or when C{captureVars} is disabled:: [Capture of Locals and Globals disabled (use captureVars=True)] When C{cleanFailure} is enabled references to other objects are removed and replaced with strings. And finally the footer with the L{Failure}'s value:: exceptions.ZeroDivisionError: float division *--- End of Failure #20 --- @param captureVars: Enables L{Failure.captureVars}. @type captureVars: C{bool} @param cleanFailure: Enables L{Failure.cleanFailure}. @type cleanFailure: C{bool}
assertDetailedTraceback
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def assertBriefTraceback(self, captureVars=False): """ Assert that L{printBriefTraceback} produces and prints a brief traceback. The brief traceback consists of a header:: Traceback: <type 'exceptions.ZeroDivisionError'>: float division The body with the stacktrace:: /twisted/trial/_synctest.py:1180:_run /twisted/python/util.py:1076:runWithWarningsSuppressed And the footer:: --- <exception caught here> --- /twisted/test/test_failure.py:39:getDivisionFailure @param captureVars: Enables L{Failure.captureVars}. @type captureVars: C{bool} """ if captureVars: exampleLocalVar = 'abcde' # Silence the linter as this variable is checked via # the traceback. exampleLocalVar f = getDivisionFailure() out = NativeStringIO() f.printBriefTraceback(out) tb = out.getvalue() stack = '' for method, filename, lineno, localVars, globalVars in f.frames: stack += '%s:%s:%s\n' % (filename, lineno, method) zde = repr(ZeroDivisionError) self.assertTracebackFormat(tb, "Traceback: %s: " % (zde,), "%s\n%s" % (failure.EXCEPTION_CAUGHT_HERE, stack)) if captureVars: self.assertIsNone(re.search('exampleLocalVar.*abcde', tb))
Assert that L{printBriefTraceback} produces and prints a brief traceback. The brief traceback consists of a header:: Traceback: <type 'exceptions.ZeroDivisionError'>: float division The body with the stacktrace:: /twisted/trial/_synctest.py:1180:_run /twisted/python/util.py:1076:runWithWarningsSuppressed And the footer:: --- <exception caught here> --- /twisted/test/test_failure.py:39:getDivisionFailure @param captureVars: Enables L{Failure.captureVars}. @type captureVars: C{bool}
assertBriefTraceback
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def assertDefaultTraceback(self, captureVars=False): """ Assert that L{printTraceback} produces and prints a default traceback. The default traceback consists of a header:: Traceback (most recent call last): The body with traceback:: File "/twisted/trial/_synctest.py", line 1180, in _run runWithWarningsSuppressed(suppress, method) And the footer:: --- <exception caught here> --- File "twisted/test/test_failure.py", line 39, in getDivisionFailure 1/0 exceptions.ZeroDivisionError: float division @param captureVars: Enables L{Failure.captureVars}. @type captureVars: C{bool} """ if captureVars: exampleLocalVar = 'xyzzy' # Silence the linter as this variable is checked via # the traceback. exampleLocalVar f = getDivisionFailure(captureVars=captureVars) out = NativeStringIO() f.printTraceback(out) tb = out.getvalue() stack = '' for method, filename, lineno, localVars, globalVars in f.frames: stack += ' File "%s", line %s, in %s\n' % (filename, lineno, method) stack += ' %s\n' % (linecache.getline( filename, lineno).strip(),) self.assertTracebackFormat(tb, "Traceback (most recent call last):", "%s\n%s%s: %s\n" % (failure.EXCEPTION_CAUGHT_HERE, stack, reflect.qual(f.type), reflect.safe_str(f.value))) if captureVars: self.assertIsNone(re.search('exampleLocalVar.*xyzzy', tb))
Assert that L{printTraceback} produces and prints a default traceback. The default traceback consists of a header:: Traceback (most recent call last): The body with traceback:: File "/twisted/trial/_synctest.py", line 1180, in _run runWithWarningsSuppressed(suppress, method) And the footer:: --- <exception caught here> --- File "twisted/test/test_failure.py", line 39, in getDivisionFailure 1/0 exceptions.ZeroDivisionError: float division @param captureVars: Enables L{Failure.captureVars}. @type captureVars: C{bool}
assertDefaultTraceback
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_printDetailedTraceback(self): """ L{printDetailedTraceback} returns a detailed traceback including the L{Failure}'s count. """ self.assertDetailedTraceback()
L{printDetailedTraceback} returns a detailed traceback including the L{Failure}'s count.
test_printDetailedTraceback
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_printBriefTraceback(self): """ L{printBriefTraceback} returns a brief traceback. """ self.assertBriefTraceback()
L{printBriefTraceback} returns a brief traceback.
test_printBriefTraceback
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_printTraceback(self): """ L{printTraceback} returns a traceback. """ self.assertDefaultTraceback()
L{printTraceback} returns a traceback.
test_printTraceback
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_printDetailedTracebackCapturedVars(self): """ L{printDetailedTraceback} captures the locals and globals for its stack frames and adds them to the traceback, when called on a L{Failure} constructed with C{captureVars=True}. """ self.assertDetailedTraceback(captureVars=True)
L{printDetailedTraceback} captures the locals and globals for its stack frames and adds them to the traceback, when called on a L{Failure} constructed with C{captureVars=True}.
test_printDetailedTracebackCapturedVars
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_printBriefTracebackCapturedVars(self): """ L{printBriefTraceback} returns a brief traceback when called on a L{Failure} constructed with C{captureVars=True}. Local variables on the stack can not be seen in the resulting traceback. """ self.assertBriefTraceback(captureVars=True)
L{printBriefTraceback} returns a brief traceback when called on a L{Failure} constructed with C{captureVars=True}. Local variables on the stack can not be seen in the resulting traceback.
test_printBriefTracebackCapturedVars
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_printTracebackCapturedVars(self): """ L{printTraceback} returns a traceback when called on a L{Failure} constructed with C{captureVars=True}. Local variables on the stack can not be seen in the resulting traceback. """ self.assertDefaultTraceback(captureVars=True)
L{printTraceback} returns a traceback when called on a L{Failure} constructed with C{captureVars=True}. Local variables on the stack can not be seen in the resulting traceback.
test_printTracebackCapturedVars
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_printDetailedTracebackCapturedVarsCleaned(self): """ C{printDetailedTraceback} includes information about local variables on the stack after C{cleanFailure} has been called. """ self.assertDetailedTraceback(captureVars=True, cleanFailure=True)
C{printDetailedTraceback} includes information about local variables on the stack after C{cleanFailure} has been called.
test_printDetailedTracebackCapturedVarsCleaned
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_invalidFormatFramesDetail(self): """ L{failure.format_frames} raises a L{ValueError} if the supplied C{detail} level is unknown. """ self.assertRaises(ValueError, failure.format_frames, None, None, detail='noisia')
L{failure.format_frames} raises a L{ValueError} if the supplied C{detail} level is unknown.
test_invalidFormatFramesDetail
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_stringExceptionConstruction(self): """ Constructing a C{Failure} with a string as its exception value raises a C{TypeError}, as this is no longer supported as of Python 2.6. """ exc = self.assertRaises(TypeError, failure.Failure, "ono!") self.assertIn("Strings are not supported by Failure", str(exc))
Constructing a C{Failure} with a string as its exception value raises a C{TypeError}, as this is no longer supported as of Python 2.6.
test_stringExceptionConstruction
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_ConstructionFails(self): """ Creating a Failure with no arguments causes it to try to discover the current interpreter exception state. If no such state exists, creating the Failure should raise a synchronous exception. """ if sys.version_info < (3, 0): sys.exc_clear() self.assertRaises(failure.NoCurrentExceptionError, failure.Failure)
Creating a Failure with no arguments causes it to try to discover the current interpreter exception state. If no such state exists, creating the Failure should raise a synchronous exception.
test_ConstructionFails
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_getTracebackObject(self): """ If the C{Failure} has not been cleaned, then C{getTracebackObject} returns the traceback object that captured in its constructor. """ f = getDivisionFailure() self.assertEqual(f.getTracebackObject(), f.tb)
If the C{Failure} has not been cleaned, then C{getTracebackObject} returns the traceback object that captured in its constructor.
test_getTracebackObject
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_getTracebackObjectFromCaptureVars(self): """ C{captureVars=True} has no effect on the result of C{getTracebackObject}. """ try: 1/0 except ZeroDivisionError: noVarsFailure = failure.Failure() varsFailure = failure.Failure(captureVars=True) self.assertEqual(noVarsFailure.getTracebackObject(), varsFailure.tb)
C{captureVars=True} has no effect on the result of C{getTracebackObject}.
test_getTracebackObjectFromCaptureVars
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_getTracebackObjectFromClean(self): """ If the Failure has been cleaned, then C{getTracebackObject} returns an object that looks the same to L{traceback.extract_tb}. """ f = getDivisionFailure() expected = traceback.extract_tb(f.getTracebackObject()) f.cleanFailure() observed = traceback.extract_tb(f.getTracebackObject()) self.assertIsNotNone(expected) self.assertEqual(expected, observed)
If the Failure has been cleaned, then C{getTracebackObject} returns an object that looks the same to L{traceback.extract_tb}.
test_getTracebackObjectFromClean
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_getTracebackObjectFromCaptureVarsAndClean(self): """ If the Failure was created with captureVars, then C{getTracebackObject} returns an object that looks the same to L{traceback.extract_tb}. """ f = getDivisionFailure(captureVars=True) expected = traceback.extract_tb(f.getTracebackObject()) f.cleanFailure() observed = traceback.extract_tb(f.getTracebackObject()) self.assertEqual(expected, observed)
If the Failure was created with captureVars, then C{getTracebackObject} returns an object that looks the same to L{traceback.extract_tb}.
test_getTracebackObjectFromCaptureVarsAndClean
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_getTracebackObjectWithoutTraceback(self): """ L{failure.Failure}s need not be constructed with traceback objects. If a C{Failure} has no traceback information at all, C{getTracebackObject} just returns None. None is a good value, because traceback.extract_tb(None) -> []. """ f = failure.Failure(Exception("some error")) self.assertIsNone(f.getTracebackObject())
L{failure.Failure}s need not be constructed with traceback objects. If a C{Failure} has no traceback information at all, C{getTracebackObject} just returns None. None is a good value, because traceback.extract_tb(None) -> [].
test_getTracebackObjectWithoutTraceback
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_tracebackFromExceptionInPython3(self): """ If a L{failure.Failure} is constructed with an exception but no traceback in Python 3, the traceback will be extracted from the exception's C{__traceback__} attribute. """ try: 1/0 except: klass, exception, tb = sys.exc_info() f = failure.Failure(exception) self.assertIs(f.tb, tb)
If a L{failure.Failure} is constructed with an exception but no traceback in Python 3, the traceback will be extracted from the exception's C{__traceback__} attribute.
test_tracebackFromExceptionInPython3
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_cleanFailureRemovesTracebackInPython3(self): """ L{failure.Failure.cleanFailure} sets the C{__traceback__} attribute of the exception to L{None} in Python 3. """ f = getDivisionFailure() self.assertIsNotNone(f.tb) self.assertIs(f.value.__traceback__, f.tb) f.cleanFailure() self.assertIsNone(f.value.__traceback__)
L{failure.Failure.cleanFailure} sets the C{__traceback__} attribute of the exception to L{None} in Python 3.
test_cleanFailureRemovesTracebackInPython3
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_repr(self): """ The C{repr} of a L{failure.Failure} shows the type and string representation of the underlying exception. """ f = getDivisionFailure() typeName = reflect.fullyQualifiedName(ZeroDivisionError) self.assertEqual( repr(f), '<twisted.python.failure.Failure ' '%s: division by zero>' % (typeName,))
The C{repr} of a L{failure.Failure} shows the type and string representation of the underlying exception.
test_repr
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def _brokenValueTest(self, detail): """ Construct a L{Failure} with an exception that raises an exception from its C{__str__} method and then call C{getTraceback} with the specified detail and verify that it returns a string. """ x = BrokenStr() f = failure.Failure(x) traceback = f.getTraceback(detail=detail) self.assertIsInstance(traceback, str)
Construct a L{Failure} with an exception that raises an exception from its C{__str__} method and then call C{getTraceback} with the specified detail and verify that it returns a string.
_brokenValueTest
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_brokenValueBriefDetail(self): """ A L{Failure} might wrap an exception with a C{__str__} method which raises an exception. In this case, calling C{getTraceback} on the failure with the C{"brief"} detail does not raise an exception. """ self._brokenValueTest("brief")
A L{Failure} might wrap an exception with a C{__str__} method which raises an exception. In this case, calling C{getTraceback} on the failure with the C{"brief"} detail does not raise an exception.
test_brokenValueBriefDetail
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_brokenValueDefaultDetail(self): """ Like test_brokenValueBriefDetail, but for the C{"default"} detail case. """ self._brokenValueTest("default")
Like test_brokenValueBriefDetail, but for the C{"default"} detail case.
test_brokenValueDefaultDetail
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def _brokenTypeTest(self, detail): """ Construct a L{Failure} with an exception type that raises an exception from its C{__str__} method and then call C{getTraceback} with the specified detail and verify that it returns a string. """ f = failure.Failure(BrokenExceptionType()) traceback = f.getTraceback(detail=detail) self.assertIsInstance(traceback, str)
Construct a L{Failure} with an exception type that raises an exception from its C{__str__} method and then call C{getTraceback} with the specified detail and verify that it returns a string.
_brokenTypeTest
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_brokenTypeBriefDetail(self): """ A L{Failure} might wrap an exception the type object of which has a C{__str__} method which raises an exception. In this case, calling C{getTraceback} on the failure with the C{"brief"} detail does not raise an exception. """ self._brokenTypeTest("brief")
A L{Failure} might wrap an exception the type object of which has a C{__str__} method which raises an exception. In this case, calling C{getTraceback} on the failure with the C{"brief"} detail does not raise an exception.
test_brokenTypeBriefDetail
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_brokenTypeDefaultDetail(self): """ Like test_brokenTypeBriefDetail, but for the C{"default"} detail case. """ self._brokenTypeTest("default")
Like test_brokenTypeBriefDetail, but for the C{"default"} detail case.
test_brokenTypeDefaultDetail
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_brokenTypeVerboseDetail(self): """ Like test_brokenTypeBriefDetail, but for the C{"verbose"} detail case. """ self._brokenTypeTest("verbose")
Like test_brokenTypeBriefDetail, but for the C{"verbose"} detail case.
test_brokenTypeVerboseDetail
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_findNoFailureInExceptionHandler(self): """ Within an exception handler, _findFailure should return L{None} in case no Failure is associated with the current exception. """ try: 1/0 except: self.assertIsNone(failure.Failure._findFailure()) else: self.fail("No exception raised from 1/0!?")
Within an exception handler, _findFailure should return L{None} in case no Failure is associated with the current exception.
test_findNoFailureInExceptionHandler
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_findNoFailure(self): """ Outside of an exception handler, _findFailure should return None. """ if sys.version_info < (3, 0): sys.exc_clear() self.assertIsNone(sys.exc_info()[-1]) #environment sanity check self.assertIsNone(failure.Failure._findFailure())
Outside of an exception handler, _findFailure should return None.
test_findNoFailure
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_findFailure(self): """ Within an exception handler, it should be possible to find the original Failure that caused the current exception (if it was caused by raiseException). """ f = getDivisionFailure() f.cleanFailure() try: f.raiseException() except: self.assertEqual(failure.Failure._findFailure(), f) else: self.fail("No exception raised from raiseException!?")
Within an exception handler, it should be possible to find the original Failure that caused the current exception (if it was caused by raiseException).
test_findFailure
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_failureConstructionFindsOriginalFailure(self): """ When a Failure is constructed in the context of an exception handler that is handling an exception raised by raiseException, the new Failure should be chained to that original Failure. Means the new failure should still show the same origin frame, but with different complete stack trace (as not thrown at same place). """ f = getDivisionFailure() f.cleanFailure() try: f.raiseException() except: newF = failure.Failure() tb = f.getTraceback().splitlines() new_tb = newF.getTraceback().splitlines() self.assertNotEqual(tb, new_tb) self.assertEqual(tb[-3:], new_tb[-3:]) else: self.fail("No exception raised from raiseException!?")
When a Failure is constructed in the context of an exception handler that is handling an exception raised by raiseException, the new Failure should be chained to that original Failure. Means the new failure should still show the same origin frame, but with different complete stack trace (as not thrown at same place).
test_failureConstructionFindsOriginalFailure
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_failureConstructionWithMungedStackSucceeds(self): """ Pyrex and Cython are known to insert fake stack frames so as to give more Python-like tracebacks. These stack frames with empty code objects should not break extraction of the exception. """ try: raiser.raiseException() except raiser.RaiserException: f = failure.Failure() self.assertTrue(f.check(raiser.RaiserException)) else: self.fail("No exception raised from extension?!")
Pyrex and Cython are known to insert fake stack frames so as to give more Python-like tracebacks. These stack frames with empty code objects should not break extraction of the exception.
test_failureConstructionWithMungedStackSucceeds
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_singleFrame(self): """ A C{_Traceback} object constructed with a single frame should be able to be passed to L{traceback.extract_tb}, and we should get a singleton list containing a (filename, lineno, methodname, line) tuple. """ tb = failure._Traceback([], [['method', 'filename.py', 123, {}, {}]]) # Note that we don't need to test that extract_tb correctly extracts # the line's contents. In this case, since filename.py doesn't exist, # it will just use None. self.assertEqual(traceback.extract_tb(tb), [_tb('filename.py', 123, 'method', None)])
A C{_Traceback} object constructed with a single frame should be able to be passed to L{traceback.extract_tb}, and we should get a singleton list containing a (filename, lineno, methodname, line) tuple.
test_singleFrame
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_manyFrames(self): """ A C{_Traceback} object constructed with multiple frames should be able to be passed to L{traceback.extract_tb}, and we should get a list containing a tuple for each frame. """ tb = failure._Traceback([ ['caller1', 'filename.py', 7, {}, {}], ['caller2', 'filename.py', 8, {}, {}], ], [ ['method1', 'filename.py', 123, {}, {}], ['method2', 'filename.py', 235, {}, {}], ]) self.assertEqual(traceback.extract_tb(tb), [_tb('filename.py', 123, 'method1', None), _tb('filename.py', 235, 'method2', None)]) # We should also be able to extract_stack on it self.assertEqual(traceback.extract_stack(tb.tb_frame), [_tb('filename.py', 7, 'caller1', None), _tb('filename.py', 8, 'caller2', None), _tb('filename.py', 123, 'method1', None), ])
A C{_Traceback} object constructed with multiple frames should be able to be passed to L{traceback.extract_tb}, and we should get a list containing a tuple for each frame.
test_manyFrames
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_fakeFrameAttributes(self): """ L{_Frame} instances have the C{f_globals} and C{f_locals} attributes bound to C{dict} instance. They also have the C{f_code} attribute bound to something like a code object. """ frame = failure._Frame( ("dummyname", "dummyfilename", None, None, None), None ) self.assertIsInstance(frame.f_globals, dict) self.assertIsInstance(frame.f_locals, dict) self.assertIsInstance(frame.f_code, failure._Code)
L{_Frame} instances have the C{f_globals} and C{f_locals} attributes bound to C{dict} instance. They also have the C{f_code} attribute bound to something like a code object.
test_fakeFrameAttributes
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def setUp(self): """ Override pdb.post_mortem so we can make sure it's called. """ # Make sure any changes we make are reversed: post_mortem = pdb.post_mortem origInit = failure.Failure.__init__ def restore(): pdb.post_mortem = post_mortem failure.Failure.__init__ = origInit self.addCleanup(restore) self.result = [] pdb.post_mortem = self.result.append failure.startDebugMode()
Override pdb.post_mortem so we can make sure it's called.
setUp
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_regularFailure(self): """ If startDebugMode() is called, calling Failure() will first call pdb.post_mortem with the traceback. """ try: 1/0 except: typ, exc, tb = sys.exc_info() f = failure.Failure() self.assertEqual(self.result, [tb]) self.assertFalse(f.captureVars)
If startDebugMode() is called, calling Failure() will first call pdb.post_mortem with the traceback.
test_regularFailure
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_captureVars(self): """ If startDebugMode() is called, passing captureVars to Failure() will not blow up. """ try: 1/0 except: typ, exc, tb = sys.exc_info() f = failure.Failure(captureVars=True) self.assertEqual(self.result, [tb]) self.assertTrue(f.captureVars)
If startDebugMode() is called, passing captureVars to Failure() will not blow up.
test_captureVars
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_throwExceptionIntoGenerator(self): """ It should be possible to throw the exception that a Failure represents into a generator. """ stuff = [] def generator(): try: yield except: stuff.append(sys.exc_info()) else: self.fail("Yield should have yielded exception.") g = generator() f = getDivisionFailure() next(g) self._throwIntoGenerator(f, g) self.assertEqual(stuff[0][0], ZeroDivisionError) self.assertIsInstance(stuff[0][1], ZeroDivisionError) self.assertEqual(traceback.extract_tb(stuff[0][2])[-1][-1], "1/0")
It should be possible to throw the exception that a Failure represents into a generator.
test_throwExceptionIntoGenerator
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_findFailureInGenerator(self): """ Within an exception handler, it should be possible to find the original Failure that caused the current exception (if it was caused by throwExceptionIntoGenerator). """ f = getDivisionFailure() f.cleanFailure() foundFailures = [] def generator(): try: yield except: foundFailures.append(failure.Failure._findFailure()) else: self.fail("No exception sent to generator") g = generator() next(g) self._throwIntoGenerator(f, g) self.assertEqual(foundFailures, [f])
Within an exception handler, it should be possible to find the original Failure that caused the current exception (if it was caused by throwExceptionIntoGenerator).
test_findFailureInGenerator
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_failureConstructionFindsOriginalFailure(self): """ When a Failure is constructed in the context of an exception handler that is handling an exception raised by throwExceptionIntoGenerator, the new Failure should be chained to that original Failure. """ f = getDivisionFailure() f.cleanFailure() original_failure_str = f.getTraceback() newFailures = [] def generator(): try: yield except: newFailures.append(failure.Failure()) else: self.fail("No exception sent to generator") g = generator() next(g) self._throwIntoGenerator(f, g) self.assertEqual(len(newFailures), 1) # The original failure should not be changed. self.assertEqual(original_failure_str, f.getTraceback()) # The new failure should be different and contain stack info for # our generator. self.assertNotEqual(newFailures[0].getTraceback(), f.getTraceback()) self.assertIn("generator", newFailures[0].getTraceback()) self.assertNotIn("generator", f.getTraceback())
When a Failure is constructed in the context of an exception handler that is handling an exception raised by throwExceptionIntoGenerator, the new Failure should be chained to that original Failure.
test_failureConstructionFindsOriginalFailure
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_ambiguousFailureInGenerator(self): """ When a generator reraises a different exception, L{Failure._findFailure} inside the generator should find the reraised exception rather than original one. """ def generator(): try: try: yield except: [][1] except: self.assertIsInstance(failure.Failure().value, IndexError) g = generator() next(g) f = getDivisionFailure() self._throwIntoGenerator(f, g)
When a generator reraises a different exception, L{Failure._findFailure} inside the generator should find the reraised exception rather than original one.
test_ambiguousFailureInGenerator
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_ambiguousFailureFromGenerator(self): """ When a generator reraises a different exception, L{Failure._findFailure} above the generator should find the reraised exception rather than original one. """ def generator(): try: yield except: [][1] g = generator() next(g) f = getDivisionFailure() try: self._throwIntoGenerator(f, g) except: self.assertIsInstance(failure.Failure().value, IndexError)
When a generator reraises a different exception, L{Failure._findFailure} above the generator should find the reraised exception rather than original one.
test_ambiguousFailureFromGenerator
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py
MIT
def test_argument(self): """ Test that corce correctly raises NotImplementedError. """ arg = formmethod.Argument("name") self.assertRaises(NotImplementedError, arg.coerce, "")
Test that corce correctly raises NotImplementedError.
test_argument
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_formmethod.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_formmethod.py
MIT
def test_file(self): """ Test the correctness of the coerce function. """ arg = formmethod.File("name", allowNone=0) self.assertEqual(arg.coerce("something"), "something") self.assertRaises(formmethod.InputError, arg.coerce, None) arg2 = formmethod.File("name") self.assertIsNone(arg2.coerce(None))
Test the correctness of the coerce function.
test_file
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_formmethod.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_formmethod.py
MIT
def test_recovery(self): """ DirDBM: test recovery from directory after a faked crash """ k = self.dbm._encode(b"key1") with self.path.child(k + b".rpl").open(mode="wb") as f: f.write(b"value") k2 = self.dbm._encode(b"key2") with self.path.child(k2).open(mode="wb") as f: f.write(b"correct") with self.path.child(k2 + b".rpl").open(mode="wb") as f: f.write(b"wrong") with self.path.child("aa.new").open(mode="wb") as f: f.write(b"deleted") dbm = dirdbm.DirDBM(self.path.path) self.assertEqual(dbm[b"key1"], b"value") self.assertEqual(dbm[b"key2"], b"correct") self.assertFalse(self.path.globChildren("*.new")) self.assertFalse(self.path.globChildren("*.rpl"))
DirDBM: test recovery from directory after a faked crash
test_recovery
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_dirdbm.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_dirdbm.py
MIT
def test_nonStringKeys(self): """ L{dirdbm.DirDBM} operations only support string keys: other types should raise a L{TypeError}. """ self.assertRaises(TypeError, self.dbm.__setitem__, 2, "3") try: self.assertRaises(TypeError, self.dbm.__setitem__, "2", 3) except unittest.FailTest: # dirdbm.Shelf.__setitem__ supports non-string values self.assertIsInstance(self.dbm, dirdbm.Shelf) self.assertRaises(TypeError, self.dbm.__getitem__, 2) self.assertRaises(TypeError, self.dbm.__delitem__, 2) self.assertRaises(TypeError, self.dbm.has_key, 2) self.assertRaises(TypeError, self.dbm.__contains__, 2) self.assertRaises(TypeError, self.dbm.getModificationTime, 2)
L{dirdbm.DirDBM} operations only support string keys: other types should raise a L{TypeError}.
test_nonStringKeys
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_dirdbm.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_dirdbm.py
MIT
def test_failSet(self): """ Failure path when setting an item. """ def _writeFail(path, data): path.setContent(data) raise IOError("fail to write") self.dbm[b"failkey"] = b"test" self.patch(self.dbm, "_writeFile", _writeFail) self.assertRaises(IOError, self.dbm.__setitem__, b"failkey", b"test2")
Failure path when setting an item.
test_failSet
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_dirdbm.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_dirdbm.py
MIT
def test_aybabtuStrictEmpty(self): """ L{styles._aybabtu} of L{Versioned} itself is an empty list. """ self.assertEqual(styles._aybabtu(styles.Versioned), [])
L{styles._aybabtu} of L{Versioned} itself is an empty list.
test_aybabtuStrictEmpty
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_persisted.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_persisted.py
MIT
def test_aybabtuStrictSubclass(self): """ There are no classes I{between} L{VersionedSubClass} and L{Versioned}, so L{styles._aybabtu} returns an empty list. """ self.assertEqual(styles._aybabtu(VersionedSubClass), [])
There are no classes I{between} L{VersionedSubClass} and L{Versioned}, so L{styles._aybabtu} returns an empty list.
test_aybabtuStrictSubclass
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_persisted.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_persisted.py
MIT
def test_aybabtuSubsubclass(self): """ With a sub-sub-class of L{Versioned}, L{styles._aybabtu} returns a list containing the intervening subclass. """ self.assertEqual(styles._aybabtu(VersionedSubSubClass), [VersionedSubClass])
With a sub-sub-class of L{Versioned}, L{styles._aybabtu} returns a list containing the intervening subclass.
test_aybabtuSubsubclass
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_persisted.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_persisted.py
MIT
def test_aybabtuStrict(self): """ For a diamond-shaped inheritance graph, L{styles._aybabtu} returns a list containing I{both} intermediate subclasses. """ self.assertEqual( styles._aybabtu(VersionedDiamondSubClass), [VersionedSubSubClass, VersionedSubClass, SecondVersionedSubClass])
For a diamond-shaped inheritance graph, L{styles._aybabtu} returns a list containing I{both} intermediate subclasses.
test_aybabtuStrict
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_persisted.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_persisted.py
MIT
def __reduce__(self): """ Raise an exception instead of pickling. """ raise TypeError("Not serializable.")
Raise an exception instead of pickling.
__reduce__
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_persisted.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_persisted.py
MIT
def __init__(self): """ Ensure that this object is normally not pickleable. """ self.notPickleable = NotPickleable()
Ensure that this object is normally not pickleable.
__init__
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_persisted.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_persisted.py
MIT
def reduceCopyRegistered(cr): """ Externally implement C{__reduce__} for L{CopyRegistered}. @param cr: The L{CopyRegistered} instance. @return: a 2-tuple of callable and argument list, in this case L{CopyRegisteredLoaded} and no arguments. """ return CopyRegisteredLoaded, ()
Externally implement C{__reduce__} for L{CopyRegistered}. @param cr: The L{CopyRegistered} instance. @return: a 2-tuple of callable and argument list, in this case L{CopyRegisteredLoaded} and no arguments.
reduceCopyRegistered
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_persisted.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_persisted.py
MIT
def test_classMethod(self): """ After importing L{twisted.persisted.styles}, it is possible to pickle classmethod objects. """ pickl = pickle.dumps(Pickleable.getX) o = pickle.loads(pickl) self.assertEqual(o, Pickleable.getX)
After importing L{twisted.persisted.styles}, it is possible to pickle classmethod objects.
test_classMethod
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_persisted.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_persisted.py
MIT
def test_unpickleBytesIO(self): """ A cStringIO pickled with bytes in it will yield an L{io.BytesIO} on python 3. """ pickledStringIWithText = ( b"ctwisted.persisted.styles\nunpickleStringI\np0\n" b"(S'test'\np1\nI0\ntp2\nRp3\n." ) loaded = pickle.loads(pickledStringIWithText) self.assertIsInstance(loaded, io.StringIO) self.assertEqual(loaded.getvalue(), u"test")
A cStringIO pickled with bytes in it will yield an L{io.BytesIO} on python 3.
test_unpickleBytesIO
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_persisted.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_persisted.py
MIT
def test_methodNotSelfIdentity(self): """ If a class change after an instance has been created, L{aot.unjellyFromSource} shoud raise a C{TypeError} when trying to unjelly the instance. """ a = A() b = B() a.bmethod = b.bmethod b.a = a savedbmethod = B.bmethod del B.bmethod try: self.assertRaises(TypeError, aot.unjellyFromSource, aot.jellyToSource(b)) finally: B.bmethod = savedbmethod
If a class change after an instance has been created, L{aot.unjellyFromSource} shoud raise a C{TypeError} when trying to unjelly the instance.
test_methodNotSelfIdentity
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_persisted.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_persisted.py
MIT
def test_unsupportedType(self): """ L{aot.jellyToSource} should raise a C{TypeError} when trying to jelly an unknown type without a C{__dict__} property or C{__getstate__} method. """ class UnknownType(object): @property def __dict__(self): raise AttributeError() self.assertRaises(TypeError, aot.jellyToSource, UnknownType())
L{aot.jellyToSource} should raise a C{TypeError} when trying to jelly an unknown type without a C{__dict__} property or C{__getstate__} method.
test_unsupportedType
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_persisted.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_persisted.py
MIT