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
194
url
stringlengths
46
254
license
stringclasses
4 values
def __init__(self, transport=None): """ Initialize our instance variables. """ self.data = {} self.extData = {} self.requests = {} self.eofs = {} self.closes = {} self.transport = transport
Initialize our instance variables.
__init__
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def logPrefix(self): """ Return our logging prefix. """ return "MockConnection"
Return our logging prefix.
logPrefix
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def sendData(self, channel, data): """ Record the sent data. """ self.data.setdefault(channel, []).append(data)
Record the sent data.
sendData
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def sendExtendedData(self, channel, type, data): """ Record the sent extended data. """ self.extData.setdefault(channel, []).append((type, data))
Record the sent extended data.
sendExtendedData
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def sendRequest(self, channel, request, data, wantReply=False): """ Record the sent channel request. """ self.requests.setdefault(channel, []).append((request, data, wantReply)) if wantReply: return defer.succeed(None)
Record the sent channel request.
sendRequest
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def sendEOF(self, channel): """ Record the sent EOF. """ self.eofs[channel] = True
Record the sent EOF.
sendEOF
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def sendClose(self, channel): """ Record the sent close. """ self.closes[channel] = True
Record the sent close.
sendClose
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def getPeer(self): """ Return an arbitrary L{IAddress}. """ return IPv4Address('TCP', 'remotehost', 8888)
Return an arbitrary L{IAddress}.
getPeer
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def getHost(self): """ Return an arbitrary L{IAddress}. """ return IPv4Address('TCP', 'localhost', 9999)
Return an arbitrary L{IAddress}.
getHost
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def write(self, data): """ Record data in the buffer. """ self.buf += data
Record data in the buffer.
write
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def loseConnection(self): """ Note that the connection was closed. """ self.close = True
Note that the connection was closed.
loseConnection
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def setTcpNoDelay(self, enabled): """ Pretend to set C{TCP_NODELAY}. """
Pretend to set C{TCP_NODELAY}.
setTcpNoDelay
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def writeErr(self, data): """ Record the extended data in the buffer. This was an old interface that allowed the Transports from ISession.openShell() or ISession.execCommand() to receive extended data from the client. """ self.err += data
Record the extended data in the buffer. This was an old interface that allowed the Transports from ISession.openShell() or ISession.execCommand() to receive extended data from the client.
writeErr
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def setUp(self): """ Make an SSHSession object to test. Give the channel some window so that it's allowed to send packets. 500 and 100 are arbitrary values. """ self.session = session.SSHSession(remoteWindow=500, remoteMaxPacket=100, conn=StubConnection(), avatar=StubAvatar())
Make an SSHSession object to test. Give the channel some window so that it's allowed to send packets. 500 and 100 are arbitrary values.
setUp
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def assertSessionIsStubSession(self): """ Asserts that self.session.session is an instance of StubSessionForStubOldAvatar. """ self.assertIsInstance(self.session.session, StubSessionForStubAvatar)
Asserts that self.session.session is an instance of StubSessionForStubOldAvatar.
assertSessionIsStubSession
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_init(self): """ SSHSession initializes its buffer (buf), client, and ISession adapter. The avatar should not need to be adaptable to an ISession immediately. """ s = session.SSHSession(avatar=object) # use object because it doesn't # have an adapter self.assertEqual(s.buf, b'') self.assertIsNone(s.client) self.assertIsNone(s.session)
SSHSession initializes its buffer (buf), client, and ISession adapter. The avatar should not need to be adaptable to an ISession immediately.
test_init
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_client_dataReceived(self): """ SSHSession.dataReceived() passes data along to a client. If the data comes before there is a client, the data should be discarded. """ self.session.dataReceived(b'1') self.session.client = StubClient() self.session.dataReceived(b'2') self.assertEqual(self.session.client.transport.buf, b'2')
SSHSession.dataReceived() passes data along to a client. If the data comes before there is a client, the data should be discarded.
test_client_dataReceived
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_client_extReceived(self): """ SSHSession.extReceived() passed data of type EXTENDED_DATA_STDERR along to the client. If the data comes before there is a client, or if the data is not of type EXTENDED_DATA_STDERR, it is discared. """ self.session.extReceived(connection.EXTENDED_DATA_STDERR, b'1') self.session.extReceived(255, b'2') # 255 is arbitrary self.session.client = StubClient() self.session.extReceived(connection.EXTENDED_DATA_STDERR, b'3') self.assertEqual(self.session.client.transport.err, b'3')
SSHSession.extReceived() passed data of type EXTENDED_DATA_STDERR along to the client. If the data comes before there is a client, or if the data is not of type EXTENDED_DATA_STDERR, it is discared.
test_client_extReceived
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_client_extReceivedWithoutWriteErr(self): """ SSHSession.extReceived() should handle the case where the transport on the client doesn't have a writeErr method. """ client = self.session.client = StubClient() client.transport = StubTransport() # doesn't have writeErr # should not raise an error self.session.extReceived(connection.EXTENDED_DATA_STDERR, b'ignored')
SSHSession.extReceived() should handle the case where the transport on the client doesn't have a writeErr method.
test_client_extReceivedWithoutWriteErr
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_client_closed(self): """ SSHSession.closed() should tell the transport connected to the client that the connection was lost. """ self.session.client = StubClient() self.session.closed() self.assertTrue(self.session.client.transport.close) self.session.client.transport.close = False
SSHSession.closed() should tell the transport connected to the client that the connection was lost.
test_client_closed
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_badSubsystemDoesNotCreateClient(self): """ When a subsystem request fails, SSHSession.client should not be set. """ ret = self.session.requestReceived( b'subsystem', common.NS(b'BadSubsystem')) self.assertFalse(ret) self.assertIsNone(self.session.client)
When a subsystem request fails, SSHSession.client should not be set.
test_badSubsystemDoesNotCreateClient
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_lookupSubsystem(self): """ When a client requests a subsystem, the SSHSession object should get the subsystem by calling avatar.lookupSubsystem, and attach it as the client. """ ret = self.session.requestReceived( b'subsystem', common.NS(b'TestSubsystem') + b'data') self.assertTrue(ret) self.assertIsInstance(self.session.client, protocol.ProcessProtocol) self.assertIs(self.session.client.transport.proto, self.session.avatar.subsystem)
When a client requests a subsystem, the SSHSession object should get the subsystem by calling avatar.lookupSubsystem, and attach it as the client.
test_lookupSubsystem
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_lookupSubsystemDoesNotNeedISession(self): """ Previously, if one only wanted to implement a subsystem, an ISession adapter wasn't needed because subsystems were looked up using the lookupSubsystem method on the avatar. """ s = session.SSHSession(avatar=SubsystemOnlyAvatar(), conn=StubConnection()) ret = s.request_subsystem( common.NS(b'subsystem') + b'data') self.assertTrue(ret) self.assertIsNotNone(s.client) self.assertIsNone(s.conn.closes.get(s)) s.eofReceived() self.assertTrue(s.conn.closes.get(s)) # these should not raise errors s.loseConnection() s.closed()
Previously, if one only wanted to implement a subsystem, an ISession adapter wasn't needed because subsystems were looked up using the lookupSubsystem method on the avatar.
test_lookupSubsystemDoesNotNeedISession
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_lookupSubsystem_data(self): """ After having looked up a subsystem, data should be passed along to the client. Additionally, subsystems were passed the entire request packet as data, instead of just the additional data. We check for the additional tidle to verify that the data passed through the client. """ #self.session.dataReceived('1') # subsystems didn't get extended data #self.session.extReceived(connection.EXTENDED_DATA_STDERR, '2') self.session.requestReceived(b'subsystem', common.NS(b'TestSubsystem') + b'data') self.assertEqual(self.session.conn.data[self.session], [b'\x00\x00\x00\x0dTestSubsystemdata~']) self.session.dataReceived(b'more data') self.assertEqual(self.session.conn.data[self.session][-1], b'more data~')
After having looked up a subsystem, data should be passed along to the client. Additionally, subsystems were passed the entire request packet as data, instead of just the additional data. We check for the additional tidle to verify that the data passed through the client.
test_lookupSubsystem_data
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_lookupSubsystem_closeReceived(self): """ SSHSession.closeReceived() should sent a close message to the remote side. """ self.session.requestReceived(b'subsystem', common.NS(b'TestSubsystem') + b'data') self.session.closeReceived() self.assertTrue(self.session.conn.closes[self.session])
SSHSession.closeReceived() should sent a close message to the remote side.
test_lookupSubsystem_closeReceived
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def assertRequestRaisedRuntimeError(self): """ Assert that the request we just made raised a RuntimeError (and only a RuntimeError). """ errors = self.flushLoggedErrors(RuntimeError) self.assertEqual(len(errors), 1, "Multiple RuntimeErrors raised: %s" % '\n'.join([repr(error) for error in errors])) errors[0].trap(RuntimeError)
Assert that the request we just made raised a RuntimeError (and only a RuntimeError).
assertRequestRaisedRuntimeError
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_requestShell(self): """ When a client requests a shell, the SSHSession object should get the shell by getting an ISession adapter for the avatar, then calling openShell() with a ProcessProtocol to attach. """ # gets a shell the first time ret = self.session.requestReceived(b'shell', b'') self.assertTrue(ret) self.assertSessionIsStubSession() self.assertIsInstance(self.session.client, session.SSHSessionProcessProtocol) self.assertIs(self.session.session.shellProtocol, self.session.client) # doesn't get a shell the second time self.assertFalse(self.session.requestReceived(b'shell', b'')) self.assertRequestRaisedRuntimeError()
When a client requests a shell, the SSHSession object should get the shell by getting an ISession adapter for the avatar, then calling openShell() with a ProcessProtocol to attach.
test_requestShell
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_requestShellWithData(self): """ When a client executes a shell, it should be able to give pass data back and forth between the local and the remote side. """ ret = self.session.requestReceived(b'shell', b'') self.assertTrue(ret) self.assertSessionIsStubSession() self.session.dataReceived(b'some data\x00') self.assertEqual(self.session.session.shellTransport.data, b'some data\x00') self.assertEqual(self.session.conn.data[self.session], [b'some data\x00', b'\r\n']) self.assertTrue(self.session.session.shellTransport.closed) self.assertEqual(self.session.conn.requests[self.session], [(b'exit-status', b'\x00\x00\x00\x00', False)])
When a client executes a shell, it should be able to give pass data back and forth between the local and the remote side.
test_requestShellWithData
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_requestExec(self): """ When a client requests a command, the SSHSession object should get the command by getting an ISession adapter for the avatar, then calling execCommand with a ProcessProtocol to attach and the command line. """ ret = self.session.requestReceived(b'exec', common.NS(b'failure')) self.assertFalse(ret) self.assertRequestRaisedRuntimeError() self.assertIsNone(self.session.client) self.assertTrue(self.session.requestReceived(b'exec', common.NS(b'success'))) self.assertSessionIsStubSession() self.assertIsInstance(self.session.client, session.SSHSessionProcessProtocol) self.assertIs(self.session.session.execProtocol, self.session.client) self.assertEqual(self.session.session.execCommandLine, b'success')
When a client requests a command, the SSHSession object should get the command by getting an ISession adapter for the avatar, then calling execCommand with a ProcessProtocol to attach and the command line.
test_requestExec
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_requestExecWithData(self): """ When a client executes a command, it should be able to give pass data back and forth. """ ret = self.session.requestReceived(b'exec', common.NS(b'repeat hello')) self.assertTrue(ret) self.assertSessionIsStubSession() self.session.dataReceived(b'some data') self.assertEqual(self.session.session.execTransport.data, b'some data') self.assertEqual(self.session.conn.data[self.session], [b'hello', b'some data', b'\r\n']) self.session.eofReceived() self.session.closeReceived() self.session.closed() self.assertTrue(self.session.session.execTransport.closed) self.assertEqual(self.session.conn.requests[self.session], [(b'exit-status', b'\x00\x00\x00\x00', False)])
When a client executes a command, it should be able to give pass data back and forth.
test_requestExecWithData
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_requestPty(self): """ When a client requests a PTY, the SSHSession object should make the request by getting an ISession adapter for the avatar, then calling getPty with the terminal type, the window size, and any modes the client gave us. """ # 'bad' terminal type fails ret = self.session.requestReceived( b'pty_req', session.packRequest_pty_req( b'bad', (1, 2, 3, 4), b'')) self.assertFalse(ret) self.assertSessionIsStubSession() self.assertRequestRaisedRuntimeError() # 'good' terminal type succeeds self.assertTrue(self.session.requestReceived(b'pty_req', session.packRequest_pty_req(b'good', (1, 2, 3, 4), b''))) self.assertEqual(self.session.session.ptyRequest, (b'good', (1, 2, 3, 4), []))
When a client requests a PTY, the SSHSession object should make the request by getting an ISession adapter for the avatar, then calling getPty with the terminal type, the window size, and any modes the client gave us.
test_requestPty
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_requestWindowChange(self): """ When the client requests to change the window size, the SSHSession object should make the request by getting an ISession adapter for the avatar, then calling windowChanged with the new window size. """ ret = self.session.requestReceived( b'window_change', session.packRequest_window_change((0, 0, 0, 0))) self.assertFalse(ret) self.assertRequestRaisedRuntimeError() self.assertSessionIsStubSession() self.assertTrue(self.session.requestReceived(b'window_change', session.packRequest_window_change((1, 2, 3, 4)))) self.assertEqual(self.session.session.windowChange, (1, 2, 3, 4))
When the client requests to change the window size, the SSHSession object should make the request by getting an ISession adapter for the avatar, then calling windowChanged with the new window size.
test_requestWindowChange
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_eofReceived(self): """ When an EOF is received and an ISession adapter is present, it should be notified of the EOF message. """ self.session.session = session.ISession(self.session.avatar) self.session.eofReceived() self.assertTrue(self.session.session.gotEOF)
When an EOF is received and an ISession adapter is present, it should be notified of the EOF message.
test_eofReceived
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_closeReceived(self): """ When a close is received, the session should send a close message. """ ret = self.session.closeReceived() self.assertIsNone(ret) self.assertTrue(self.session.conn.closes[self.session])
When a close is received, the session should send a close message.
test_closeReceived
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_closed(self): """ When a close is received and an ISession adapter is present, it should be notified of the close message. """ self.session.session = session.ISession(self.session.avatar) self.session.closed() self.assertTrue(self.session.session.gotClosed)
When a close is received and an ISession adapter is present, it should be notified of the close message.
test_closed
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def assertSessionProvidesISession(self): """ self.session.session should provide I{ISession}. """ self.assertTrue(session.ISession.providedBy(self.session.session), "ISession not provided by %r" % self.session.session)
self.session.session should provide I{ISession}.
assertSessionProvidesISession
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_requestShellGetsSession(self): """ If an ISession adapter isn't already present, request_shell should get one. """ self.session.requestReceived(b'shell', b'') self.assertSessionProvidesISession()
If an ISession adapter isn't already present, request_shell should get one.
test_requestShellGetsSession
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_requestExecGetsSession(self): """ If an ISession adapter isn't already present, request_exec should get one. """ self.session.requestReceived(b'exec', common.NS(b'success')) self.assertSessionProvidesISession()
If an ISession adapter isn't already present, request_exec should get one.
test_requestExecGetsSession
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_requestPtyReqGetsSession(self): """ If an ISession adapter isn't already present, request_pty_req should get one. """ self.session.requestReceived(b'pty_req', session.packRequest_pty_req( b'term', (0, 0, 0, 0), b'')) self.assertSessionProvidesISession()
If an ISession adapter isn't already present, request_pty_req should get one.
test_requestPtyReqGetsSession
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_requestWindowChangeGetsSession(self): """ If an ISession adapter isn't already present, request_window_change should get one. """ self.session.requestReceived( b'window_change', session.packRequest_window_change( (1, 1, 1, 1))) self.assertSessionProvidesISession()
If an ISession adapter isn't already present, request_window_change should get one.
test_requestWindowChangeGetsSession
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_wrapProtocol(self): """ L{wrapProtocol}, when passed a L{Protocol} should return something that has write(), writeSequence(), loseConnection() methods which call the Protocol's dataReceived() and connectionLost() methods, respectively. """ protocol = MockProtocol() protocol.transport = StubTransport() protocol.connectionMade() wrapped = session.wrapProtocol(protocol) wrapped.dataReceived(b'dataReceived') self.assertEqual(protocol.transport.buf, b'dataReceived') wrapped.write(b'data') wrapped.writeSequence([b'1', b'2']) wrapped.loseConnection() self.assertEqual(protocol.data, b'data12') protocol.reason.trap(error.ConnectionDone)
L{wrapProtocol}, when passed a L{Protocol} should return something that has write(), writeSequence(), loseConnection() methods which call the Protocol's dataReceived() and connectionLost() methods, respectively.
test_wrapProtocol
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_wrapProcessProtocol_Protocol(self): """ L{wrapPRocessProtocol}, when passed a L{Protocol} should return something that follows the L{IProcessProtocol} interface, with connectionMade() mapping to connectionMade(), outReceived() mapping to dataReceived() and processEnded() mapping to connectionLost(). """ protocol = MockProtocol() protocol.transport = StubTransport() process_protocol = session.wrapProcessProtocol(protocol) process_protocol.connectionMade() process_protocol.outReceived(b'data') self.assertEqual(protocol.transport.buf, b'data~') process_protocol.processEnded(failure.Failure( error.ProcessTerminated(0, None, None))) protocol.reason.trap(error.ProcessTerminated)
L{wrapPRocessProtocol}, when passed a L{Protocol} should return something that follows the L{IProcessProtocol} interface, with connectionMade() mapping to connectionMade(), outReceived() mapping to dataReceived() and processEnded() mapping to connectionLost().
test_wrapProcessProtocol_Protocol
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_parseRequest_pty_req(self): """ The payload of a pty-req message is:: string terminal uint32 columns uint32 rows uint32 x pixels uint32 y pixels string modes Modes are:: byte mode number uint32 mode value """ self.assertEqual(session.parseRequest_pty_req(common.NS(b'xterm') + struct.pack('>4L', 1, 2, 3, 4) + common.NS( struct.pack('>BL', 5, 6))), (b'xterm', (2, 1, 3, 4), [(5, 6)]))
The payload of a pty-req message is:: string terminal uint32 columns uint32 rows uint32 x pixels uint32 y pixels string modes Modes are:: byte mode number uint32 mode value
test_parseRequest_pty_req
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_packRequest_pty_req_old(self): """ See test_parseRequest_pty_req for the payload format. """ packed = session.packRequest_pty_req(b'xterm', (2, 1, 3, 4), b'\x05\x00\x00\x00\x06') self.assertEqual(packed, common.NS(b'xterm') + struct.pack('>4L', 1, 2, 3, 4) + common.NS(struct.pack('>BL', 5, 6)))
See test_parseRequest_pty_req for the payload format.
test_packRequest_pty_req_old
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_packRequest_pty_req(self): """ See test_parseRequest_pty_req for the payload format. """ packed = session.packRequest_pty_req(b'xterm', (2, 1, 3, 4), b'\x05\x00\x00\x00\x06') self.assertEqual(packed, common.NS(b'xterm') + struct.pack('>4L', 1, 2, 3, 4) + common.NS(struct.pack('>BL', 5, 6)))
See test_parseRequest_pty_req for the payload format.
test_packRequest_pty_req
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_parseRequest_window_change(self): """ The payload of a window_change request is:: uint32 columns uint32 rows uint32 x pixels uint32 y pixels parseRequest_window_change() returns (rows, columns, x pixels, y pixels). """ self.assertEqual(session.parseRequest_window_change( struct.pack('>4L', 1, 2, 3, 4)), (2, 1, 3, 4))
The payload of a window_change request is:: uint32 columns uint32 rows uint32 x pixels uint32 y pixels parseRequest_window_change() returns (rows, columns, x pixels, y pixels).
test_parseRequest_window_change
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_packRequest_window_change(self): """ See test_parseRequest_window_change for the payload format. """ self.assertEqual(session.packRequest_window_change((2, 1, 3, 4)), struct.pack('>4L', 1, 2, 3, 4))
See test_parseRequest_window_change for the payload format.
test_packRequest_window_change
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def assertSessionClosed(self): """ Assert that C{self.session} is closed. """ self.assertTrue(self.session.conn.closes[self.session])
Assert that C{self.session} is closed.
assertSessionClosed
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def assertRequestsEqual(self, expectedRequests): """ Assert that C{self.session} has sent the C{expectedRequests}. """ self.assertEqual( self.session.conn.requests[self.session], expectedRequests)
Assert that C{self.session} has sent the C{expectedRequests}.
assertRequestsEqual
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_init(self): """ SSHSessionProcessProtocol should set self.session to the session passed to the __init__ method. """ self.assertEqual(self.pp.session, self.session)
SSHSessionProcessProtocol should set self.session to the session passed to the __init__ method.
test_init
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_getHost(self): """ SSHSessionProcessProtocol.getHost() just delegates to its session.conn.transport.getHost(). """ self.assertEqual( self.session.conn.transport.getHost(), self.pp.getHost())
SSHSessionProcessProtocol.getHost() just delegates to its session.conn.transport.getHost().
test_getHost
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_getPeer(self): """ SSHSessionProcessProtocol.getPeer() just delegates to its session.conn.transport.getPeer(). """ self.assertEqual( self.session.conn.transport.getPeer(), self.pp.getPeer())
SSHSessionProcessProtocol.getPeer() just delegates to its session.conn.transport.getPeer().
test_getPeer
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_connectionMade(self): """ SSHSessionProcessProtocol.connectionMade() should check if there's a 'buf' attribute on its session and write it to the transport if so. """ self.session.buf = b'buffer' self.pp.connectionMade() self.assertEqual(self.transport.buf, b'buffer')
SSHSessionProcessProtocol.connectionMade() should check if there's a 'buf' attribute on its session and write it to the transport if so.
test_connectionMade
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_getSignalName(self): """ _getSignalName should return the name of a signal when given the signal number. """ for signalName in session.SUPPORTED_SIGNALS: signalName = 'SIG' + signalName signalValue = getattr(signal, signalName) sshName = self.pp._getSignalName(signalValue) self.assertEqual(sshName, signalName, "%i: %s != %s" % (signalValue, sshName, signalName))
_getSignalName should return the name of a signal when given the signal number.
test_getSignalName
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_getSignalNameWithLocalSignal(self): """ If there are signals in the signal module which aren't in the SSH RFC, we map their name to [signal name]@[platform]. """ signal.SIGTwistedTest = signal.NSIG + 1 # value can't exist normally # Force reinitialization of signals self.pp._signalValuesToNames = None self.assertEqual(self.pp._getSignalName(signal.SIGTwistedTest), 'SIGTwistedTest@' + sys.platform)
If there are signals in the signal module which aren't in the SSH RFC, we map their name to [signal name]@[platform].
test_getSignalNameWithLocalSignal
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_outReceived(self): """ When data is passed to the outReceived method, it should be sent to the session's write method. """ self.pp.outReceived(b'test data') self.assertEqual(self.session.conn.data[self.session], [b'test data'])
When data is passed to the outReceived method, it should be sent to the session's write method.
test_outReceived
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_write(self): """ When data is passed to the write method, it should be sent to the session channel's write method. """ self.pp.write(b'test data') self.assertEqual(self.session.conn.data[self.session], [b'test data'])
When data is passed to the write method, it should be sent to the session channel's write method.
test_write
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_writeSequence(self): """ When a sequence is passed to the writeSequence method, it should be joined together and sent to the session channel's write method. """ self.pp.writeSequence([b'test ', b'data']) self.assertEqual(self.session.conn.data[self.session], [b'test data'])
When a sequence is passed to the writeSequence method, it should be joined together and sent to the session channel's write method.
test_writeSequence
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_errReceived(self): """ When data is passed to the errReceived method, it should be sent to the session's writeExtended method. """ self.pp.errReceived(b'test data') self.assertEqual(self.session.conn.extData[self.session], [(1, b'test data')])
When data is passed to the errReceived method, it should be sent to the session's writeExtended method.
test_errReceived
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_outConnectionLost(self): """ When outConnectionLost and errConnectionLost are both called, we should send an EOF message. """ self.pp.outConnectionLost() self.assertFalse(self.session in self.session.conn.eofs) self.pp.errConnectionLost() self.assertTrue(self.session.conn.eofs[self.session])
When outConnectionLost and errConnectionLost are both called, we should send an EOF message.
test_outConnectionLost
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_errConnectionLost(self): """ Make sure reverse ordering of events in test_outConnectionLost also sends EOF. """ self.pp.errConnectionLost() self.assertFalse(self.session in self.session.conn.eofs) self.pp.outConnectionLost() self.assertTrue(self.session.conn.eofs[self.session])
Make sure reverse ordering of events in test_outConnectionLost also sends EOF.
test_errConnectionLost
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_loseConnection(self): """ When loseConnection() is called, it should call loseConnection on the session channel. """ self.pp.loseConnection() self.assertTrue(self.session.conn.closes[self.session])
When loseConnection() is called, it should call loseConnection on the session channel.
test_loseConnection
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_connectionLost(self): """ When connectionLost() is called, it should call loseConnection() on the session channel. """ self.pp.connectionLost(failure.Failure( ProcessDone(0)))
When connectionLost() is called, it should call loseConnection() on the session channel.
test_connectionLost
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_processEndedWithExitCode(self): """ When processEnded is called, if there is an exit code in the reason it should be sent in an exit-status method. The connection should be closed. """ self.pp.processEnded(Failure(ProcessDone(None))) self.assertRequestsEqual( [(b'exit-status', struct.pack('>I', 0) , False)]) self.assertSessionClosed()
When processEnded is called, if there is an exit code in the reason it should be sent in an exit-status method. The connection should be closed.
test_processEndedWithExitCode
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_processEndedWithExitSignalCoreDump(self): """ When processEnded is called, if there is an exit signal in the reason it should be sent in an exit-signal message. The connection should be closed. """ self.pp.processEnded( Failure(ProcessTerminated(1, signal.SIGTERM, 1 << 7))) # 7th bit means core dumped self.assertRequestsEqual( [(b'exit-signal', common.NS(b'TERM') # signal name + b'\x01' # core dumped is true + common.NS(b'') # error message + common.NS(b''), # language tag False)]) self.assertSessionClosed()
When processEnded is called, if there is an exit signal in the reason it should be sent in an exit-signal message. The connection should be closed.
test_processEndedWithExitSignalCoreDump
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_processEndedWithExitSignalNoCoreDump(self): """ When processEnded is called, if there is an exit signal in the reason it should be sent in an exit-signal message. If no core was dumped, don't set the core-dump bit. """ self.pp.processEnded( Failure(ProcessTerminated(1, signal.SIGTERM, 0))) # see comments in test_processEndedWithExitSignalCoreDump for the # meaning of the parts in the request self.assertRequestsEqual( [(b'exit-signal', common.NS(b'TERM') + b'\x00' + common.NS(b'') + common.NS(b''), False)]) self.assertSessionClosed()
When processEnded is called, if there is an exit signal in the reason it should be sent in an exit-signal message. If no core was dumped, don't set the core-dump bit.
test_processEndedWithExitSignalNoCoreDump
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def test_dataReceived(self): """ When data is received, it should be sent to the transport. """ client = session.SSHSessionClient() client.transport = StubTransport() client.dataReceived(b'test data') self.assertEqual(client.transport.buf, b'test data')
When data is received, it should be sent to the transport.
test_dataReceived
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_session.py
MIT
def determineDefaultFunctionName(): """ Return the string used by Python as the name for code objects which are compiled from interactive input or at the top-level of modules. """ try: 1 // 0 except: # The last frame is this function. The second to last frame is this # function's caller, which is module-scope, which is what we want, # so -2. return traceback.extract_stack()[-2][2]
Return the string used by Python as the name for code objects which are compiled from interactive input or at the top-level of modules.
determineDefaultFunctionName
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_resetBuffer(self): """ L{ManholeInterpreter.resetBuffer} should empty the input buffer. """ interpreter = manhole.ManholeInterpreter(None) interpreter.buffer.extend(["1", "2"]) interpreter.resetBuffer() self.assertFalse(interpreter.buffer)
L{ManholeInterpreter.resetBuffer} should empty the input buffer.
test_resetBuffer
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_interruptResetsInterpreterBuffer(self): """ L{manhole.Manhole.handle_INT} should cause the interpreter input buffer to be reset. """ transport = StringTransport() terminal = insults.ServerProtocol(manhole.Manhole) terminal.makeConnection(transport) protocol = terminal.terminalProtocol interpreter = protocol.interpreter interpreter.buffer.extend(["1", "2"]) protocol.handle_INT() self.assertFalse(interpreter.buffer)
L{manhole.Manhole.handle_INT} should cause the interpreter input buffer to be reset.
test_interruptResetsInterpreterBuffer
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_Integer(self): """ Colorize an integer. """ manhole.lastColorizedLine("1")
Colorize an integer.
test_Integer
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_DoubleQuoteString(self): """ Colorize an integer in double quotes. """ manhole.lastColorizedLine('"1"')
Colorize an integer in double quotes.
test_DoubleQuoteString
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_SingleQuoteString(self): """ Colorize an integer in single quotes. """ manhole.lastColorizedLine("'1'")
Colorize an integer in single quotes.
test_SingleQuoteString
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_TripleSingleQuotedString(self): """ Colorize an integer in triple quotes. """ manhole.lastColorizedLine("'''1'''")
Colorize an integer in triple quotes.
test_TripleSingleQuotedString
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_TripleDoubleQuotedString(self): """ Colorize an integer in triple and double quotes. """ manhole.lastColorizedLine('"""1"""')
Colorize an integer in triple and double quotes.
test_TripleDoubleQuotedString
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_FunctionDefinition(self): """ Colorize a function definition. """ manhole.lastColorizedLine("def foo():")
Colorize a function definition.
test_FunctionDefinition
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_ClassDefinition(self): """ Colorize a class definition. """ manhole.lastColorizedLine("class foo:")
Colorize a class definition.
test_ClassDefinition
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_unicode(self): """ Colorize a Unicode string. """ res = manhole.lastColorizedLine(u"\u0438") self.assertTrue(isinstance(res, bytes))
Colorize a Unicode string.
test_unicode
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_bytes(self): """ Colorize a UTF-8 byte string. """ res = manhole.lastColorizedLine(b"\xd0\xb8") self.assertTrue(isinstance(res, bytes))
Colorize a UTF-8 byte string.
test_bytes
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_identicalOutput(self): """ The output of UTF-8 bytestrings and Unicode strings are identical. """ self.assertEqual(manhole.lastColorizedLine(b"\xd0\xb8"), manhole.lastColorizedLine(u"\u0438"))
The output of UTF-8 bytestrings and Unicode strings are identical.
test_identicalOutput
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_SimpleExpression(self): """ Evaluate simple expression. """ done = self.recvlineClient.expect(b"done") self._testwrite( b"1 + 1\n" b"done") def finished(ign): self._assertBuffer( [b">>> 1 + 1", b"2", b">>> done"]) return done.addCallback(finished)
Evaluate simple expression.
test_SimpleExpression
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_TripleQuoteLineContinuation(self): """ Evaluate line continuation in triple quotes. """ done = self.recvlineClient.expect(b"done") self._testwrite( b"'''\n'''\n" b"done") def finished(ign): self._assertBuffer( [b">>> '''", b"... '''", b"'\\n'", b">>> done"]) return done.addCallback(finished)
Evaluate line continuation in triple quotes.
test_TripleQuoteLineContinuation
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_FunctionDefinition(self): """ Evaluate function definition. """ done = self.recvlineClient.expect(b"done") self._testwrite( b"def foo(bar):\n" b"\tprint(bar)\n\n" b"foo(42)\n" b"done") def finished(ign): self._assertBuffer( [b">>> def foo(bar):", b"... print(bar)", b"... ", b">>> foo(42)", b"42", b">>> done"]) return done.addCallback(finished)
Evaluate function definition.
test_FunctionDefinition
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_ClassDefinition(self): """ Evaluate class definition. """ done = self.recvlineClient.expect(b"done") self._testwrite( b"class Foo:\n" b"\tdef bar(self):\n" b"\t\tprint('Hello, world!')\n\n" b"Foo().bar()\n" b"done") def finished(ign): self._assertBuffer( [b">>> class Foo:", b"... def bar(self):", b"... print('Hello, world!')", b"... ", b">>> Foo().bar()", b"Hello, world!", b">>> done"]) return done.addCallback(finished)
Evaluate class definition.
test_ClassDefinition
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_Exception(self): """ Evaluate raising an exception. """ done = self.recvlineClient.expect(b"done") self._testwrite( b"raise Exception('foo bar baz')\n" b"done") def finished(ign): self._assertBuffer( [b">>> raise Exception('foo bar baz')", b"Traceback (most recent call last):", b' File "<console>", line 1, in ' + defaultFunctionName.encode("utf-8"), b"Exception: foo bar baz", b">>> done"]) return done.addCallback(finished)
Evaluate raising an exception.
test_Exception
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_ControlC(self): """ Evaluate interrupting with CTRL-C. """ done = self.recvlineClient.expect(b"done") self._testwrite( b"cancelled line" + manhole.CTRL_C + b"done") def finished(ign): self._assertBuffer( [b">>> cancelled line", b"KeyboardInterrupt", b">>> done"]) return done.addCallback(finished)
Evaluate interrupting with CTRL-C.
test_ControlC
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_interruptDuringContinuation(self): """ Sending ^C to Manhole while in a state where more input is required to complete a statement should discard the entire ongoing statement and reset the input prompt to the non-continuation prompt. """ continuing = self.recvlineClient.expect(b"things") self._testwrite(b"(\nthings") def gotContinuation(ignored): self._assertBuffer( [b">>> (", b"... things"]) interrupted = self.recvlineClient.expect(b">>> ") self._testwrite(manhole.CTRL_C) return interrupted continuing.addCallback(gotContinuation) def gotInterruption(ignored): self._assertBuffer( [b">>> (", b"... things", b"KeyboardInterrupt", b">>> "]) continuing.addCallback(gotInterruption) return continuing
Sending ^C to Manhole while in a state where more input is required to complete a statement should discard the entire ongoing statement and reset the input prompt to the non-continuation prompt.
test_interruptDuringContinuation
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_ControlBackslash(self): """ Evaluate cancelling with CTRL-\. """ self._testwrite(b"cancelled line") partialLine = self.recvlineClient.expect(b"cancelled line") def gotPartialLine(ign): self._assertBuffer( [b">>> cancelled line"]) self._testwrite(manhole.CTRL_BACKSLASH) d = self.recvlineClient.onDisconnection return self.assertFailure(d, error.ConnectionDone) def gotClearedLine(ign): self._assertBuffer( [b""]) return partialLine.addCallback(gotPartialLine).addCallback( gotClearedLine)
Evaluate cancelling with CTRL-\.
test_ControlBackslash
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_controlD(self): """ A CTRL+D in the middle of a line doesn't close a connection, but at the beginning of a line it does. """ self._testwrite(b"1 + 1") yield self.recvlineClient.expect(br"\+ 1") self._assertBuffer([b">>> 1 + 1"]) self._testwrite(manhole.CTRL_D + b" + 1") yield self.recvlineClient.expect(br"\+ 1") self._assertBuffer([b">>> 1 + 1 + 1"]) self._testwrite(b"\n") yield self.recvlineClient.expect(b"3\n>>> ") self._testwrite(manhole.CTRL_D) d = self.recvlineClient.onDisconnection yield self.assertFailure(d, error.ConnectionDone)
A CTRL+D in the middle of a line doesn't close a connection, but at the beginning of a line it does.
test_controlD
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_ControlL(self): """ CTRL+L is generally used as a redraw-screen command in terminal applications. Manhole doesn't currently respect this usage of it, but it should at least do something reasonable in response to this event (rather than, say, eating your face). """ # Start off with a newline so that when we clear the display we can # tell by looking for the missing first empty prompt line. self._testwrite(b"\n1 + 1") yield self.recvlineClient.expect(br"\+ 1") self._assertBuffer([b">>> ", b">>> 1 + 1"]) self._testwrite(manhole.CTRL_L + b" + 1") yield self.recvlineClient.expect(br"1 \+ 1 \+ 1") self._assertBuffer([b">>> 1 + 1 + 1"])
CTRL+L is generally used as a redraw-screen command in terminal applications. Manhole doesn't currently respect this usage of it, but it should at least do something reasonable in response to this event (rather than, say, eating your face).
test_ControlL
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_controlA(self): """ CTRL-A can be used as HOME - returning cursor to beginning of current line buffer. """ self._testwrite(b'rint "hello"' + b'\x01' + b'p') d = self.recvlineClient.expect(b'print "hello"') def cb(ignore): self._assertBuffer([b'>>> print "hello"']) return d.addCallback(cb)
CTRL-A can be used as HOME - returning cursor to beginning of current line buffer.
test_controlA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_controlE(self): """ CTRL-E can be used as END - setting cursor to end of current line buffer. """ self._testwrite(b'rint "hello' + b'\x01' + b'p' + b'\x05' + b'"') d = self.recvlineClient.expect(b'print "hello"') def cb(ignore): self._assertBuffer([b'>>> print "hello"']) return d.addCallback(cb)
CTRL-E can be used as END - setting cursor to end of current line buffer.
test_controlE
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_deferred(self): """ When a deferred is returned to the manhole REPL, it is displayed with a sequence number, and when the deferred fires, the result is printed. """ self._testwrite( b"from twisted.internet import defer, reactor\n" b"d = defer.Deferred()\n" b"d\n") yield self.recvlineClient.expect(b"<Deferred #0>") self._testwrite( b"c = reactor.callLater(0.1, d.callback, 'Hi!')\n") yield self.recvlineClient.expect(b">>> ") yield self.recvlineClient.expect( b"Deferred #0 called back: 'Hi!'\n>>> ") self._assertBuffer( [b">>> from twisted.internet import defer, reactor", b">>> d = defer.Deferred()", b">>> d", b"<Deferred #0>", b">>> c = reactor.callLater(0.1, d.callback, 'Hi!')", b"Deferred #0 called back: 'Hi!'", b">>> "])
When a deferred is returned to the manhole REPL, it is displayed with a sequence number, and when the deferred fires, the result is printed.
test_deferred
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_mainClassNotFound(self): """ Will raise an exception when called with an argument which is a dotted patch which can not be imported.. """ exception = self.assertRaises( ValueError, stdio.main, argv=['no-such-class'], ) self.assertEqual('Empty module name', exception.args[0])
Will raise an exception when called with an argument which is a dotted patch which can not be imported..
test_mainClassNotFound
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole.py
MIT
def test_printableCharacters(self): """ When L{HistoricRecvLine} receives a printable character, it adds it to the current line buffer. """ self.p.keystrokeReceived(b'x', None) self.p.keystrokeReceived(b'y', None) self.p.keystrokeReceived(b'z', None) self.assertEqual(self.p.currentLineBuffer(), (b'xyz', b''))
When L{HistoricRecvLine} receives a printable character, it adds it to the current line buffer.
test_printableCharacters
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
MIT
def test_horizontalArrows(self): """ When L{HistoricRecvLine} receives a LEFT_ARROW or RIGHT_ARROW keystroke it moves the cursor left or right in the current line buffer, respectively. """ kR = lambda ch: self.p.keystrokeReceived(ch, None) for ch in iterbytes(b'xyz'): kR(ch) self.assertEqual(self.p.currentLineBuffer(), (b'xyz', b'')) kR(self.pt.RIGHT_ARROW) self.assertEqual(self.p.currentLineBuffer(), (b'xyz', b'')) kR(self.pt.LEFT_ARROW) self.assertEqual(self.p.currentLineBuffer(), (b'xy', b'z')) kR(self.pt.LEFT_ARROW) self.assertEqual(self.p.currentLineBuffer(), (b'x', b'yz')) kR(self.pt.LEFT_ARROW) self.assertEqual(self.p.currentLineBuffer(), (b'', b'xyz')) kR(self.pt.LEFT_ARROW) self.assertEqual(self.p.currentLineBuffer(), (b'', b'xyz')) kR(self.pt.RIGHT_ARROW) self.assertEqual(self.p.currentLineBuffer(), (b'x', b'yz')) kR(self.pt.RIGHT_ARROW) self.assertEqual(self.p.currentLineBuffer(), (b'xy', b'z')) kR(self.pt.RIGHT_ARROW) self.assertEqual(self.p.currentLineBuffer(), (b'xyz', b'')) kR(self.pt.RIGHT_ARROW) self.assertEqual(self.p.currentLineBuffer(), (b'xyz', b''))
When L{HistoricRecvLine} receives a LEFT_ARROW or RIGHT_ARROW keystroke it moves the cursor left or right in the current line buffer, respectively.
test_horizontalArrows
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
MIT
def test_newline(self): """ When {HistoricRecvLine} receives a newline, it adds the current line buffer to the end of its history buffer. """ kR = lambda ch: self.p.keystrokeReceived(ch, None) for ch in iterbytes(b'xyz\nabc\n123\n'): kR(ch) self.assertEqual(self.p.currentHistoryBuffer(), ((b'xyz', b'abc', b'123'), ())) kR(b'c') kR(b'b') kR(b'a') self.assertEqual(self.p.currentHistoryBuffer(), ((b'xyz', b'abc', b'123'), ())) kR(b'\n') self.assertEqual(self.p.currentHistoryBuffer(), ((b'xyz', b'abc', b'123', b'cba'), ()))
When {HistoricRecvLine} receives a newline, it adds the current line buffer to the end of its history buffer.
test_newline
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
MIT
def test_verticalArrows(self): """ When L{HistoricRecvLine} receives UP_ARROW or DOWN_ARROW keystrokes it move the current index in the current history buffer up or down, and resets the current line buffer to the previous or next line in history, respectively for each. """ kR = lambda ch: self.p.keystrokeReceived(ch, None) for ch in iterbytes(b'xyz\nabc\n123\n'): kR(ch) self.assertEqual(self.p.currentHistoryBuffer(), ((b'xyz', b'abc', b'123'), ())) self.assertEqual(self.p.currentLineBuffer(), (b'', b'')) kR(self.pt.UP_ARROW) self.assertEqual(self.p.currentHistoryBuffer(), ((b'xyz', b'abc'), (b'123',))) self.assertEqual(self.p.currentLineBuffer(), (b'123', b'')) kR(self.pt.UP_ARROW) self.assertEqual(self.p.currentHistoryBuffer(), ((b'xyz',), (b'abc', b'123'))) self.assertEqual(self.p.currentLineBuffer(), (b'abc', b'')) kR(self.pt.UP_ARROW) self.assertEqual(self.p.currentHistoryBuffer(), ((), (b'xyz', b'abc', b'123'))) self.assertEqual(self.p.currentLineBuffer(), (b'xyz', b'')) kR(self.pt.UP_ARROW) self.assertEqual(self.p.currentHistoryBuffer(), ((), (b'xyz', b'abc', b'123'))) self.assertEqual(self.p.currentLineBuffer(), (b'xyz', b'')) for i in range(4): kR(self.pt.DOWN_ARROW) self.assertEqual(self.p.currentHistoryBuffer(), ((b'xyz', b'abc', b'123'), ()))
When L{HistoricRecvLine} receives UP_ARROW or DOWN_ARROW keystrokes it move the current index in the current history buffer up or down, and resets the current line buffer to the previous or next line in history, respectively for each.
test_verticalArrows
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
MIT
def test_home(self): """ When L{HistoricRecvLine} receives a HOME keystroke it moves the cursor to the beginning of the current line buffer. """ kR = lambda ch: self.p.keystrokeReceived(ch, None) for ch in iterbytes(b'hello, world'): kR(ch) self.assertEqual(self.p.currentLineBuffer(), (b'hello, world', b'')) kR(self.pt.HOME) self.assertEqual(self.p.currentLineBuffer(), (b'', b'hello, world'))
When L{HistoricRecvLine} receives a HOME keystroke it moves the cursor to the beginning of the current line buffer.
test_home
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
MIT
def test_end(self): """ When L{HistoricRecvLine} receives an END keystroke it moves the cursor to the end of the current line buffer. """ kR = lambda ch: self.p.keystrokeReceived(ch, None) for ch in iterbytes(b'hello, world'): kR(ch) self.assertEqual(self.p.currentLineBuffer(), (b'hello, world', b'')) kR(self.pt.HOME) kR(self.pt.END) self.assertEqual(self.p.currentLineBuffer(), (b'hello, world', b''))
When L{HistoricRecvLine} receives an END keystroke it moves the cursor to the end of the current line buffer.
test_end
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
MIT