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 test_saveKeyEmptyPassphrase(self): """ L{_saveKey} will choose an empty string for the passphrase if no-passphrase is C{True}. """ base = FilePath(self.mktemp()) base.makedirs() filename = base.child('id_rsa').path key = Key.fromString(privateRSA_openssh) _saveKey(key, {'filename': filename, 'no-passphrase': True, 'format': 'md5-hex'}) self.assertEqual( key.fromString( base.child('id_rsa').getContent(), None, b''), key)
L{_saveKey} will choose an empty string for the passphrase if no-passphrase is C{True}.
test_saveKeyEmptyPassphrase
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_saveKeyECDSAEmptyPassphrase(self): """ L{_saveKey} will choose an empty string for the passphrase if no-passphrase is C{True}. """ base = FilePath(self.mktemp()) base.makedirs() filename = base.child('id_ecdsa').path key = Key.fromString(privateECDSA_openssh) _saveKey(key, {'filename': filename, 'no-passphrase': True, 'format': 'md5-hex'}) self.assertEqual( key.fromString( base.child('id_ecdsa').getContent(), None), key)
L{_saveKey} will choose an empty string for the passphrase if no-passphrase is C{True}.
test_saveKeyECDSAEmptyPassphrase
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_saveKeyNoFilename(self): """ When no path is specified, it will ask for the path used to store the key. """ base = FilePath(self.mktemp()) base.makedirs() keyPath = base.child('custom_key').path import twisted.conch.scripts.ckeygen self.patch(twisted.conch.scripts.ckeygen, 'raw_input', lambda _: keyPath) key = Key.fromString(privateRSA_openssh) _saveKey(key, {'filename': None, 'no-passphrase': True, 'format': 'md5-hex'}) persistedKeyContent = base.child('custom_key').getContent() persistedKey = key.fromString(persistedKeyContent, None, b'') self.assertEqual(key, persistedKey)
When no path is specified, it will ask for the path used to store the key.
test_saveKeyNoFilename
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_displayPublicKey(self): """ L{displayPublicKey} prints out the public key associated with a given private key. """ filename = self.mktemp() pubKey = Key.fromString(publicRSA_openssh) FilePath(filename).setContent(privateRSA_openssh) displayPublicKey({'filename': filename}) displayed = self.stdout.getvalue().strip('\n') if isinstance(displayed, unicode): displayed = displayed.encode("ascii") self.assertEqual( displayed, pubKey.toString('openssh'))
L{displayPublicKey} prints out the public key associated with a given private key.
test_displayPublicKey
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_displayPublicKeyEncrypted(self): """ L{displayPublicKey} prints out the public key associated with a given private key using the given passphrase when it's encrypted. """ filename = self.mktemp() pubKey = Key.fromString(publicRSA_openssh) FilePath(filename).setContent(privateRSA_openssh_encrypted) displayPublicKey({'filename': filename, 'pass': 'encrypted'}) displayed = self.stdout.getvalue().strip('\n') if isinstance(displayed, unicode): displayed = displayed.encode("ascii") self.assertEqual( displayed, pubKey.toString('openssh'))
L{displayPublicKey} prints out the public key associated with a given private key using the given passphrase when it's encrypted.
test_displayPublicKeyEncrypted
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_displayPublicKeyEncryptedPassphrasePrompt(self): """ L{displayPublicKey} prints out the public key associated with a given private key, asking for the passphrase when it's encrypted. """ filename = self.mktemp() pubKey = Key.fromString(publicRSA_openssh) FilePath(filename).setContent(privateRSA_openssh_encrypted) self.patch(getpass, 'getpass', lambda x: 'encrypted') displayPublicKey({'filename': filename}) displayed = self.stdout.getvalue().strip('\n') if isinstance(displayed, unicode): displayed = displayed.encode("ascii") self.assertEqual( displayed, pubKey.toString('openssh'))
L{displayPublicKey} prints out the public key associated with a given private key, asking for the passphrase when it's encrypted.
test_displayPublicKeyEncryptedPassphrasePrompt
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_displayPublicKeyWrongPassphrase(self): """ L{displayPublicKey} fails with a L{BadKeyError} when trying to decrypt an encrypted key with the wrong password. """ filename = self.mktemp() FilePath(filename).setContent(privateRSA_openssh_encrypted) self.assertRaises( BadKeyError, displayPublicKey, {'filename': filename, 'pass': 'wrong'})
L{displayPublicKey} fails with a L{BadKeyError} when trying to decrypt an encrypted key with the wrong password.
test_displayPublicKeyWrongPassphrase
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_changePassphrase(self): """ L{changePassPhrase} allows a user to change the passphrase of a private key interactively. """ oldNewConfirm = makeGetpass('encrypted', 'newpass', 'newpass') self.patch(getpass, 'getpass', oldNewConfirm) filename = self.mktemp() FilePath(filename).setContent(privateRSA_openssh_encrypted) changePassPhrase({'filename': filename}) self.assertEqual( self.stdout.getvalue().strip('\n'), 'Your identification has been saved with the new passphrase.') self.assertNotEqual(privateRSA_openssh_encrypted, FilePath(filename).getContent())
L{changePassPhrase} allows a user to change the passphrase of a private key interactively.
test_changePassphrase
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_changePassphraseWithOld(self): """ L{changePassPhrase} allows a user to change the passphrase of a private key, providing the old passphrase and prompting for new one. """ newConfirm = makeGetpass('newpass', 'newpass') self.patch(getpass, 'getpass', newConfirm) filename = self.mktemp() FilePath(filename).setContent(privateRSA_openssh_encrypted) changePassPhrase({'filename': filename, 'pass': 'encrypted'}) self.assertEqual( self.stdout.getvalue().strip('\n'), 'Your identification has been saved with the new passphrase.') self.assertNotEqual(privateRSA_openssh_encrypted, FilePath(filename).getContent())
L{changePassPhrase} allows a user to change the passphrase of a private key, providing the old passphrase and prompting for new one.
test_changePassphraseWithOld
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_changePassphraseWithBoth(self): """ L{changePassPhrase} allows a user to change the passphrase of a private key by providing both old and new passphrases without prompting. """ filename = self.mktemp() FilePath(filename).setContent(privateRSA_openssh_encrypted) changePassPhrase( {'filename': filename, 'pass': 'encrypted', 'newpass': 'newencrypt'}) self.assertEqual( self.stdout.getvalue().strip('\n'), 'Your identification has been saved with the new passphrase.') self.assertNotEqual(privateRSA_openssh_encrypted, FilePath(filename).getContent())
L{changePassPhrase} allows a user to change the passphrase of a private key by providing both old and new passphrases without prompting.
test_changePassphraseWithBoth
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_changePassphraseWrongPassphrase(self): """ L{changePassPhrase} exits if passed an invalid old passphrase when trying to change the passphrase of a private key. """ filename = self.mktemp() FilePath(filename).setContent(privateRSA_openssh_encrypted) error = self.assertRaises( SystemExit, changePassPhrase, {'filename': filename, 'pass': 'wrong'}) self.assertEqual('Could not change passphrase: old passphrase error', str(error)) self.assertEqual(privateRSA_openssh_encrypted, FilePath(filename).getContent())
L{changePassPhrase} exits if passed an invalid old passphrase when trying to change the passphrase of a private key.
test_changePassphraseWrongPassphrase
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_changePassphraseEmptyGetPass(self): """ L{changePassPhrase} exits if no passphrase is specified for the C{getpass} call and the key is encrypted. """ self.patch(getpass, 'getpass', makeGetpass('')) filename = self.mktemp() FilePath(filename).setContent(privateRSA_openssh_encrypted) error = self.assertRaises( SystemExit, changePassPhrase, {'filename': filename}) self.assertEqual( 'Could not change passphrase: Passphrase must be provided ' 'for an encrypted key', str(error)) self.assertEqual(privateRSA_openssh_encrypted, FilePath(filename).getContent())
L{changePassPhrase} exits if no passphrase is specified for the C{getpass} call and the key is encrypted.
test_changePassphraseEmptyGetPass
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_changePassphraseBadKey(self): """ L{changePassPhrase} exits if the file specified points to an invalid key. """ filename = self.mktemp() FilePath(filename).setContent(b'foobar') error = self.assertRaises( SystemExit, changePassPhrase, {'filename': filename}) if _PY3: expected = "Could not change passphrase: cannot guess the type of b'foobar'" else: expected = "Could not change passphrase: cannot guess the type of 'foobar'" self.assertEqual(expected, str(error)) self.assertEqual(b'foobar', FilePath(filename).getContent())
L{changePassPhrase} exits if the file specified points to an invalid key.
test_changePassphraseBadKey
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_changePassphraseCreateError(self): """ L{changePassPhrase} doesn't modify the key file if an unexpected error happens when trying to create the key with the new passphrase. """ filename = self.mktemp() FilePath(filename).setContent(privateRSA_openssh) def toString(*args, **kwargs): raise RuntimeError('oops') self.patch(Key, 'toString', toString) error = self.assertRaises( SystemExit, changePassPhrase, {'filename': filename, 'newpass': 'newencrypt'}) self.assertEqual( 'Could not change passphrase: oops', str(error)) self.assertEqual(privateRSA_openssh, FilePath(filename).getContent())
L{changePassPhrase} doesn't modify the key file if an unexpected error happens when trying to create the key with the new passphrase.
test_changePassphraseCreateError
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_changePassphraseEmptyStringError(self): """ L{changePassPhrase} doesn't modify the key file if C{toString} returns an empty string. """ filename = self.mktemp() FilePath(filename).setContent(privateRSA_openssh) def toString(*args, **kwargs): return '' self.patch(Key, 'toString', toString) error = self.assertRaises( SystemExit, changePassPhrase, {'filename': filename, 'newpass': 'newencrypt'}) if _PY3: expected = ( "Could not change passphrase: cannot guess the type of b''") else: expected = ( "Could not change passphrase: cannot guess the type of ''") self.assertEqual(expected, str(error)) self.assertEqual(privateRSA_openssh, FilePath(filename).getContent())
L{changePassPhrase} doesn't modify the key file if C{toString} returns an empty string.
test_changePassphraseEmptyStringError
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_changePassphrasePublicKey(self): """ L{changePassPhrase} exits when trying to change the passphrase on a public key, and doesn't change the file. """ filename = self.mktemp() FilePath(filename).setContent(publicRSA_openssh) error = self.assertRaises( SystemExit, changePassPhrase, {'filename': filename, 'newpass': 'pass'}) self.assertEqual( 'Could not change passphrase: key not encrypted', str(error)) self.assertEqual(publicRSA_openssh, FilePath(filename).getContent())
L{changePassPhrase} exits when trying to change the passphrase on a public key, and doesn't change the file.
test_changePassphrasePublicKey
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def setUp(self): """ Create a passwd-like file with a user. """ self.filename = self.mktemp() with open(self.filename, 'wb') as f: f.write(b':'.join(self.usernamePassword)) self.options = manhole_tap.Options()
Create a passwd-like file with a user.
setUp
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole_tap.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole_tap.py
MIT
def test_requiresPort(self): """ L{manhole_tap.makeService} requires either 'telnetPort' or 'sshPort' to be given. """ with self.assertRaises(usage.UsageError) as e: manhole_tap.Options().parseOptions([]) self.assertEqual(e.exception.args[0], ("At least one of --telnetPort " "and --sshPort must be specified"))
L{manhole_tap.makeService} requires either 'telnetPort' or 'sshPort' to be given.
test_requiresPort
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole_tap.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole_tap.py
MIT
def test_telnetPort(self): """ L{manhole_tap.makeService} will make a telnet service on the port defined by C{--telnetPort}. It will not make a SSH service. """ self.options.parseOptions(["--telnetPort", "tcp:222"]) service = manhole_tap.makeService(self.options) self.assertIsInstance(service, MultiService) self.assertEqual(len(service.services), 1) self.assertIsInstance(service.services[0], StreamServerEndpointService) self.assertIsInstance(service.services[0].factory.protocol, manhole_tap.makeTelnetProtocol) self.assertEqual(service.services[0].endpoint._port, 222)
L{manhole_tap.makeService} will make a telnet service on the port defined by C{--telnetPort}. It will not make a SSH service.
test_telnetPort
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole_tap.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole_tap.py
MIT
def test_sshPort(self): """ L{manhole_tap.makeService} will make a SSH service on the port defined by C{--sshPort}. It will not make a telnet service. """ # Why the sshKeyDir and sshKeySize params? To prevent it stomping over # (or using!) the user's private key, we just make a super small one # which will never be used in a temp directory. self.options.parseOptions(["--sshKeyDir", self.mktemp(), "--sshKeySize", "512", "--sshPort", "tcp:223"]) service = manhole_tap.makeService(self.options) self.assertIsInstance(service, MultiService) self.assertEqual(len(service.services), 1) self.assertIsInstance(service.services[0], StreamServerEndpointService) self.assertIsInstance(service.services[0].factory, manhole_ssh.ConchFactory) self.assertEqual(service.services[0].endpoint._port, 223)
L{manhole_tap.makeService} will make a SSH service on the port defined by C{--sshPort}. It will not make a telnet service.
test_sshPort
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole_tap.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole_tap.py
MIT
def test_passwd(self): """ The C{--passwd} command-line option will load a passwd-like file. """ self.options.parseOptions(['--telnetPort', 'tcp:22', '--passwd', self.filename]) service = manhole_tap.makeService(self.options) portal = service.services[0].factory.protocol.portal self.assertEqual(len(portal.checkers.keys()), 2) # Ensure it's the passwd file we wanted by trying to authenticate self.assertTrue(self.successResultOf( portal.login(UsernamePassword(*self.usernamePassword), None, telnet.ITelnetProtocol))) self.assertIsInstance(self.failureResultOf( portal.login(UsernamePassword(b"wrong", b"user"), None, telnet.ITelnetProtocol)).value, error.UnauthorizedLogin)
The C{--passwd} command-line option will load a passwd-like file.
test_passwd
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole_tap.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_manhole_tap.py
MIT
def makeTCPConnection(self, reactor): """ Fake that connection was established for first connectTCP request made on C{reactor}. @param reactor: Reactor on which to fake the connection. @type reactor: A reactor. """ factory = reactor.tcpClients[0][2] connector = reactor.connectors[0] protocol = factory.buildProtocol(None) transport = StringTransport(peerAddress=connector.getDestination()) protocol.makeConnection(transport)
Fake that connection was established for first connectTCP request made on C{reactor}. @param reactor: Reactor on which to fake the connection. @type reactor: A reactor.
makeTCPConnection
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_forwarding.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_forwarding.py
MIT
def test_channelOpenHostnameRequests(self): """ When a hostname is sent as part of forwarding requests, it is resolved using HostnameEndpoint's resolver. """ sut = forwarding.SSHConnectForwardingChannel( hostport=('fwd.example.org', 1234)) # Patch channel and resolver to not touch the network. memoryReactor = MemoryReactorClock() sut._reactor = deterministicResolvingReactor(memoryReactor, ['::1']) sut.channelOpen(None) self.makeTCPConnection(memoryReactor) self.successResultOf(sut._channelOpenDeferred) # Channel is connected using a forwarding client to the resolved # address of the requested host. self.assertIsInstance(sut.client, forwarding.SSHForwardingClient) self.assertEqual( IPv6Address('TCP', '::1', 1234), sut.client.transport.getPeer())
When a hostname is sent as part of forwarding requests, it is resolved using HostnameEndpoint's resolver.
test_channelOpenHostnameRequests
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_forwarding.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_forwarding.py
MIT
def _ecmaCodeTableCoordinate(column, row): """ Return the byte in 7- or 8-bit code table identified by C{column} and C{row}. "An 8-bit code table consists of 256 positions arranged in 16 columns and 16 rows. The columns and rows are numbered 00 to 15." "A 7-bit code table consists of 128 positions arranged in 8 columns and 16 rows. The columns are numbered 00 to 07 and the rows 00 to 15 (see figure 1)." p.5 of "Standard ECMA-35: Character Code Structure and Extension Techniques", 6th Edition (December 1994). """ # 8 and 15 both happen to take up 4 bits, so the first number # should be shifted by 4 for both the 7- and 8-bit tables. return bytes(bytearray([(column << 4) | row]))
Return the byte in 7- or 8-bit code table identified by C{column} and C{row}. "An 8-bit code table consists of 256 positions arranged in 16 columns and 16 rows. The columns and rows are numbered 00 to 15." "A 7-bit code table consists of 128 positions arranged in 8 columns and 16 rows. The columns are numbered 00 to 07 and the rows 00 to 15 (see figure 1)." p.5 of "Standard ECMA-35: Character Code Structure and Extension Techniques", 6th Edition (December 1994).
_ecmaCodeTableCoordinate
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def __init__(self, methods=None, callReturnValue=default): """ @param methods: Mapping of names to return values @param callReturnValue: object __call__ should return """ self.occurrences = [] if methods is None: methods = {} self.methods = methods if callReturnValue is not default: self.callReturnValue = callReturnValue
@param methods: Mapping of names to return values @param callReturnValue: object __call__ should return
__init__
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_applicationDataBytes(self): """ Contiguous non-control bytes are passed to a single call to the C{write} method of the terminal to which the L{ClientProtocol} is connected. """ occs = occurrences(self.proto) self.parser.dataReceived(b'a') self.assertCall(occs.pop(0), "write", (b"a",)) self.parser.dataReceived(b'bc') self.assertCall(occs.pop(0), "write", (b"bc",))
Contiguous non-control bytes are passed to a single call to the C{write} method of the terminal to which the L{ClientProtocol} is connected.
test_applicationDataBytes
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_shiftInAfterApplicationData(self): """ Application data bytes followed by a shift-in command are passed to a call to C{write} before the terminal's C{shiftIn} method is called. """ self._applicationDataTest( b'ab\x15', [ ("write", (b"ab",)), ("shiftIn",)])
Application data bytes followed by a shift-in command are passed to a call to C{write} before the terminal's C{shiftIn} method is called.
test_shiftInAfterApplicationData
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_shiftOutAfterApplicationData(self): """ Application data bytes followed by a shift-out command are passed to a call to C{write} before the terminal's C{shiftOut} method is called. """ self._applicationDataTest( b'ab\x14', [ ("write", (b"ab",)), ("shiftOut",)])
Application data bytes followed by a shift-out command are passed to a call to C{write} before the terminal's C{shiftOut} method is called.
test_shiftOutAfterApplicationData
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_cursorBackwardAfterApplicationData(self): """ Application data bytes followed by a cursor-backward command are passed to a call to C{write} before the terminal's C{cursorBackward} method is called. """ self._applicationDataTest( b'ab\x08', [ ("write", (b"ab",)), ("cursorBackward",)])
Application data bytes followed by a cursor-backward command are passed to a call to C{write} before the terminal's C{cursorBackward} method is called.
test_cursorBackwardAfterApplicationData
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_escapeAfterApplicationData(self): """ Application data bytes followed by an escape character are passed to a call to C{write} before the terminal's handler method for the escape is called. """ # Test a short escape self._applicationDataTest( b'ab\x1bD', [ ("write", (b"ab",)), ("index",)]) # And a long escape self._applicationDataTest( b'ab\x1b[4h', [ ("write", (b"ab",)), ("setModes", ([4],))])
Application data bytes followed by an escape character are passed to a call to C{write} before the terminal's handler method for the escape is called.
test_escapeAfterApplicationData
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_cursorUp(self): """ L{ServerProtocol.cursorUp} writes the control sequence ending with L{CSFinalByte.CUU} to its transport. """ self.protocol.cursorUp(1) self.assertEqual(self.transport.value(), self.CSI + b'1' + CSFinalByte.CUU.value)
L{ServerProtocol.cursorUp} writes the control sequence ending with L{CSFinalByte.CUU} to its transport.
test_cursorUp
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_cursorDown(self): """ L{ServerProtocol.cursorDown} writes the control sequence ending with L{CSFinalByte.CUD} to its transport. """ self.protocol.cursorDown(1) self.assertEqual(self.transport.value(), self.CSI + b'1' + CSFinalByte.CUD.value)
L{ServerProtocol.cursorDown} writes the control sequence ending with L{CSFinalByte.CUD} to its transport.
test_cursorDown
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_cursorForward(self): """ L{ServerProtocol.cursorForward} writes the control sequence ending with L{CSFinalByte.CUF} to its transport. """ self.protocol.cursorForward(1) self.assertEqual(self.transport.value(), self.CSI + b'1' + CSFinalByte.CUF.value)
L{ServerProtocol.cursorForward} writes the control sequence ending with L{CSFinalByte.CUF} to its transport.
test_cursorForward
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_cursorBackward(self): """ L{ServerProtocol.cursorBackward} writes the control sequence ending with L{CSFinalByte.CUB} to its transport. """ self.protocol.cursorBackward(1) self.assertEqual(self.transport.value(), self.CSI + b'1' + CSFinalByte.CUB.value)
L{ServerProtocol.cursorBackward} writes the control sequence ending with L{CSFinalByte.CUB} to its transport.
test_cursorBackward
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_cursorPosition(self): """ L{ServerProtocol.cursorPosition} writes a control sequence ending with L{CSFinalByte.CUP} and containing the expected coordinates to its transport. """ self.protocol.cursorPosition(0, 0) self.assertEqual(self.transport.value(), self.CSI + b'1;1' + CSFinalByte.CUP.value)
L{ServerProtocol.cursorPosition} writes a control sequence ending with L{CSFinalByte.CUP} and containing the expected coordinates to its transport.
test_cursorPosition
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_cursorHome(self): """ L{ServerProtocol.cursorHome} writes a control sequence ending with L{CSFinalByte.CUP} and no parameters, so that the client defaults to (1, 1). """ self.protocol.cursorHome() self.assertEqual(self.transport.value(), self.CSI + CSFinalByte.CUP.value)
L{ServerProtocol.cursorHome} writes a control sequence ending with L{CSFinalByte.CUP} and no parameters, so that the client defaults to (1, 1).
test_cursorHome
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_index(self): """ L{ServerProtocol.index} writes the control sequence ending in the 8-bit code table coordinates 4, 4. Note that ECMA48 5th Edition removes C{IND}. """ self.protocol.index() self.assertEqual(self.transport.value(), self.ESC + _ecmaCodeTableCoordinate(4, 4))
L{ServerProtocol.index} writes the control sequence ending in the 8-bit code table coordinates 4, 4. Note that ECMA48 5th Edition removes C{IND}.
test_index
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_reverseIndex(self): """ L{ServerProtocol.reverseIndex} writes the control sequence ending in the L{C1SevenBit.RI}. """ self.protocol.reverseIndex() self.assertEqual(self.transport.value(), self.ESC + C1SevenBit.RI.value)
L{ServerProtocol.reverseIndex} writes the control sequence ending in the L{C1SevenBit.RI}.
test_reverseIndex
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_nextLine(self): """ L{ServerProtocol.nextLine} writes C{"\r\n"} to its transport. """ # Why doesn't it write ESC E? Because ESC E is poorly supported. For # example, gnome-terminal (many different versions) fails to scroll if # it receives ESC E and the cursor is already on the last row. self.protocol.nextLine() self.assertEqual(self.transport.value(), b"\r\n")
L{ServerProtocol.nextLine} writes C{"\r\n"} to its transport.
test_nextLine
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_setModes(self): """ L{ServerProtocol.setModes} writes a control sequence containing the requested modes and ending in the L{CSFinalByte.SM}. """ modesToSet = [modes.KAM, modes.IRM, modes.LNM] self.protocol.setModes(modesToSet) self.assertEqual(self.transport.value(), self.CSI + b';'.join(map(intToBytes, modesToSet)) + CSFinalByte.SM.value)
L{ServerProtocol.setModes} writes a control sequence containing the requested modes and ending in the L{CSFinalByte.SM}.
test_setModes
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_setPrivateModes(self): """ L{ServerProtocol.setPrivatesModes} writes a control sequence containing the requested private modes and ending in the L{CSFinalByte.SM}. """ privateModesToSet = [privateModes.ERROR, privateModes.COLUMN, privateModes.ORIGIN] self.protocol.setModes(privateModesToSet) self.assertEqual(self.transport.value(), self.CSI + b';'.join(map(intToBytes, privateModesToSet)) + CSFinalByte.SM.value)
L{ServerProtocol.setPrivatesModes} writes a control sequence containing the requested private modes and ending in the L{CSFinalByte.SM}.
test_setPrivateModes
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_resetModes(self): """ L{ServerProtocol.resetModes} writes the control sequence ending in the L{CSFinalByte.RM}. """ modesToSet = [modes.KAM, modes.IRM, modes.LNM] self.protocol.resetModes(modesToSet) self.assertEqual(self.transport.value(), self.CSI + b';'.join(map(intToBytes, modesToSet)) + CSFinalByte.RM.value)
L{ServerProtocol.resetModes} writes the control sequence ending in the L{CSFinalByte.RM}.
test_resetModes
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_singleShift2(self): """ L{ServerProtocol.singleShift2} writes an escape sequence followed by L{C1SevenBit.SS2} """ self.protocol.singleShift2() self.assertEqual(self.transport.value(), self.ESC + C1SevenBit.SS2.value)
L{ServerProtocol.singleShift2} writes an escape sequence followed by L{C1SevenBit.SS2}
test_singleShift2
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_singleShift3(self): """ L{ServerProtocol.singleShift3} writes an escape sequence followed by L{C1SevenBit.SS3} """ self.protocol.singleShift3() self.assertEqual(self.transport.value(), self.ESC + C1SevenBit.SS3.value)
L{ServerProtocol.singleShift3} writes an escape sequence followed by L{C1SevenBit.SS3}
test_singleShift3
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_selectGraphicRendition(self): """ L{ServerProtocol.selectGraphicRendition} writes a control sequence containing the requested attributes and ending with L{CSFinalByte.SGR} """ self.protocol.selectGraphicRendition(str(BLINK), str(UNDERLINE)) self.assertEqual(self.transport.value(), self.CSI + intToBytes(BLINK) + b';' + intToBytes(UNDERLINE) + CSFinalByte.SGR.value)
L{ServerProtocol.selectGraphicRendition} writes a control sequence containing the requested attributes and ending with L{CSFinalByte.SGR}
test_selectGraphicRendition
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_horizontalTabulationSet(self): """ L{ServerProtocol.horizontalTabulationSet} writes the escape sequence ending in L{C1SevenBit.HTS} """ self.protocol.horizontalTabulationSet() self.assertEqual(self.transport.value(), self.ESC + C1SevenBit.HTS.value)
L{ServerProtocol.horizontalTabulationSet} writes the escape sequence ending in L{C1SevenBit.HTS}
test_horizontalTabulationSet
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_eraseToLineEnd(self): """ L{ServerProtocol.eraseToLineEnd} writes the control sequence sequence ending in L{CSFinalByte.EL} and no parameters, forcing the client to default to 0 (from the active present position's current location to the end of the line.) """ self.protocol.eraseToLineEnd() self.assertEqual(self.transport.value(), self.CSI + CSFinalByte.EL.value)
L{ServerProtocol.eraseToLineEnd} writes the control sequence sequence ending in L{CSFinalByte.EL} and no parameters, forcing the client to default to 0 (from the active present position's current location to the end of the line.)
test_eraseToLineEnd
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_eraseToLineBeginning(self): """ L{ServerProtocol.eraseToLineBeginning} writes the control sequence sequence ending in L{CSFinalByte.EL} and a parameter of 1 (from the beginning of the line up to and include the active present position's current location.) """ self.protocol.eraseToLineBeginning() self.assertEqual(self.transport.value(), self.CSI + b'1' + CSFinalByte.EL.value)
L{ServerProtocol.eraseToLineBeginning} writes the control sequence sequence ending in L{CSFinalByte.EL} and a parameter of 1 (from the beginning of the line up to and include the active present position's current location.)
test_eraseToLineBeginning
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_eraseLine(self): """ L{ServerProtocol.eraseLine} writes the control sequence sequence ending in L{CSFinalByte.EL} and a parameter of 2 (the entire line.) """ self.protocol.eraseLine() self.assertEqual(self.transport.value(), self.CSI + b'2' + CSFinalByte.EL.value)
L{ServerProtocol.eraseLine} writes the control sequence sequence ending in L{CSFinalByte.EL} and a parameter of 2 (the entire line.)
test_eraseLine
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_eraseToDisplayEnd(self): """ L{ServerProtocol.eraseToDisplayEnd} writes the control sequence sequence ending in L{CSFinalByte.ED} and no parameters, forcing the client to default to 0 (from the active present position's current location to the end of the page.) """ self.protocol.eraseToDisplayEnd() self.assertEqual(self.transport.value(), self.CSI + CSFinalByte.ED.value)
L{ServerProtocol.eraseToDisplayEnd} writes the control sequence sequence ending in L{CSFinalByte.ED} and no parameters, forcing the client to default to 0 (from the active present position's current location to the end of the page.)
test_eraseToDisplayEnd
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_eraseToDisplayBeginning(self): """ L{ServerProtocol.eraseToDisplayBeginning} writes the control sequence sequence ending in L{CSFinalByte.ED} a parameter of 1 (from the beginning of the page up to and include the active present position's current location.) """ self.protocol.eraseToDisplayBeginning() self.assertEqual(self.transport.value(), self.CSI + b'1' + CSFinalByte.ED.value)
L{ServerProtocol.eraseToDisplayBeginning} writes the control sequence sequence ending in L{CSFinalByte.ED} a parameter of 1 (from the beginning of the page up to and include the active present position's current location.)
test_eraseToDisplayBeginning
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_eraseToDisplay(self): """ L{ServerProtocol.eraseDisplay} writes the control sequence sequence ending in L{CSFinalByte.ED} a parameter of 2 (the entire page) """ self.protocol.eraseDisplay() self.assertEqual(self.transport.value(), self.CSI + b'2' + CSFinalByte.ED.value)
L{ServerProtocol.eraseDisplay} writes the control sequence sequence ending in L{CSFinalByte.ED} a parameter of 2 (the entire page)
test_eraseToDisplay
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_deleteCharacter(self): """ L{ServerProtocol.deleteCharacter} writes the control sequence containing the number of characters to delete and ending in L{CSFinalByte.DCH} """ self.protocol.deleteCharacter(4) self.assertEqual(self.transport.value(), self.CSI + b'4' + CSFinalByte.DCH.value)
L{ServerProtocol.deleteCharacter} writes the control sequence containing the number of characters to delete and ending in L{CSFinalByte.DCH}
test_deleteCharacter
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_insertLine(self): """ L{ServerProtocol.insertLine} writes the control sequence containing the number of lines to insert and ending in L{CSFinalByte.IL} """ self.protocol.insertLine(5) self.assertEqual(self.transport.value(), self.CSI + b'5' + CSFinalByte.IL.value)
L{ServerProtocol.insertLine} writes the control sequence containing the number of lines to insert and ending in L{CSFinalByte.IL}
test_insertLine
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_deleteLine(self): """ L{ServerProtocol.deleteLine} writes the control sequence containing the number of lines to delete and ending in L{CSFinalByte.DL} """ self.protocol.deleteLine(6) self.assertEqual(self.transport.value(), self.CSI + b'6' + CSFinalByte.DL.value)
L{ServerProtocol.deleteLine} writes the control sequence containing the number of lines to delete and ending in L{CSFinalByte.DL}
test_deleteLine
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_setScrollRegionNoArgs(self): """ With no arguments, L{ServerProtocol.setScrollRegion} writes a control sequence with no parameters, but a parameter separator, and ending in C{b'r'}. """ self.protocol.setScrollRegion() self.assertEqual(self.transport.value(), self.CSI + b';' + b'r')
With no arguments, L{ServerProtocol.setScrollRegion} writes a control sequence with no parameters, but a parameter separator, and ending in C{b'r'}.
test_setScrollRegionNoArgs
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_setScrollRegionJustFirst(self): """ With just a value for its C{first} argument, L{ServerProtocol.setScrollRegion} writes a control sequence with that parameter, a parameter separator, and finally a C{b'r'}. """ self.protocol.setScrollRegion(first=1) self.assertEqual(self.transport.value(), self.CSI + b'1;' + b'r')
With just a value for its C{first} argument, L{ServerProtocol.setScrollRegion} writes a control sequence with that parameter, a parameter separator, and finally a C{b'r'}.
test_setScrollRegionJustFirst
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_setScrollRegionJustLast(self): """ With just a value for its C{last} argument, L{ServerProtocol.setScrollRegion} writes a control sequence with a parameter separator, that parameter, and finally a C{b'r'}. """ self.protocol.setScrollRegion(last=1) self.assertEqual(self.transport.value(), self.CSI + b';1' + b'r')
With just a value for its C{last} argument, L{ServerProtocol.setScrollRegion} writes a control sequence with a parameter separator, that parameter, and finally a C{b'r'}.
test_setScrollRegionJustLast
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_setScrollRegionFirstAndLast(self): """ When given both C{first} and C{last} L{ServerProtocol.setScrollRegion} writes a control sequence with the first parameter, a parameter separator, the last parameter, and finally a C{b'r'}. """ self.protocol.setScrollRegion(first=1, last=2) self.assertEqual(self.transport.value(), self.CSI + b'1;2' + b'r')
When given both C{first} and C{last} L{ServerProtocol.setScrollRegion} writes a control sequence with the first parameter, a parameter separator, the last parameter, and finally a C{b'r'}.
test_setScrollRegionFirstAndLast
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_reportCursorPosition(self): """ L{ServerProtocol.reportCursorPosition} writes a control sequence ending in L{CSFinalByte.DSR} with a parameter of 6 (the Device Status Report returns the current active position.) """ self.protocol.reportCursorPosition() self.assertEqual(self.transport.value(), self.CSI + b'6' + CSFinalByte.DSR.value)
L{ServerProtocol.reportCursorPosition} writes a control sequence ending in L{CSFinalByte.DSR} with a parameter of 6 (the Device Status Report returns the current active position.)
test_reportCursorPosition
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_insults.py
MIT
def test_interface(self): """ L{telnet.TelnetProtocol} implements L{telnet.ITelnetProtocol} """ p = telnet.TelnetProtocol() verifyObject(telnet.ITelnetProtocol, p)
L{telnet.TelnetProtocol} implements L{telnet.ITelnetProtocol}
test_interface
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
MIT
def test_refusedEnableRequest(self): """ If the peer refuses to enable an option we request it to enable, the L{Deferred} returned by L{TelnetProtocol.do} fires with an L{OptionRefused} L{Failure}. """ # Try to enable an option through the user-level API. This returns a # Deferred that fires when negotiation about the option finishes. Make # sure it fires, make sure state gets updated properly, make sure the # result indicates the option was enabled. self.p.protocol.remoteEnableable = (b'\x42',) d = self.p.do(b'\x42') self.assertEqual(self.t.value(), telnet.IAC + telnet.DO + b'\x42') s = self.p.getOptionState(b'\x42') self.assertEqual(s.him.state, 'no') self.assertEqual(s.us.state, 'no') self.assertTrue(s.him.negotiating) self.assertFalse(s.us.negotiating) self.p.dataReceived(telnet.IAC + telnet.WONT + b'\x42') d = self.assertFailure(d, telnet.OptionRefused) d.addCallback(lambda ignored: self._enabledHelper(self.p.protocol)) d.addCallback( lambda ignored: self.assertFalse(s.him.negotiating)) return d
If the peer refuses to enable an option we request it to enable, the L{Deferred} returned by L{TelnetProtocol.do} fires with an L{OptionRefused} L{Failure}.
test_refusedEnableRequest
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
MIT
def test_refusedEnableOffer(self): """ If the peer refuses to allow us to enable an option, the L{Deferred} returned by L{TelnetProtocol.will} fires with an L{OptionRefused} L{Failure}. """ # Try to offer an option through the user-level API. This returns a # Deferred that fires when negotiation about the option finishes. Make # sure it fires, make sure state gets updated properly, make sure the # result indicates the option was enabled. self.p.protocol.localEnableable = (b'\x42',) d = self.p.will(b'\x42') self.assertEqual(self.t.value(), telnet.IAC + telnet.WILL + b'\x42') s = self.p.getOptionState(b'\x42') self.assertEqual(s.him.state, 'no') self.assertEqual(s.us.state, 'no') self.assertFalse(s.him.negotiating) self.assertTrue(s.us.negotiating) self.p.dataReceived(telnet.IAC + telnet.DONT + b'\x42') d = self.assertFailure(d, telnet.OptionRefused) d.addCallback(lambda ignored: self._enabledHelper(self.p.protocol)) d.addCallback( lambda ignored: self.assertFalse(s.us.negotiating)) return d
If the peer refuses to allow us to enable an option, the L{Deferred} returned by L{TelnetProtocol.will} fires with an L{OptionRefused} L{Failure}.
test_refusedEnableOffer
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
MIT
def applicationDataReceived(self, data): """ Record the given data in C{self.events}. """ self.events.append(('bytes', data))
Record the given data in C{self.events}.
applicationDataReceived
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
MIT
def unhandledCommand(self, command, data): """ Record the given command in C{self.events}. """ self.events.append(('command', command, data))
Record the given command in C{self.events}.
unhandledCommand
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
MIT
def unhandledSubnegotiation(self, command, data): """ Record the given subnegotiation command in C{self.events}. """ self.events.append(('negotiate', command, data))
Record the given subnegotiation command in C{self.events}.
unhandledSubnegotiation
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
MIT
def setUp(self): """ Create an unconnected L{telnet.Telnet} to be used by tests. """ self.protocol = TestTelnet()
Create an unconnected L{telnet.Telnet} to be used by tests.
setUp
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
MIT
def test_enableLocal(self): """ L{telnet.Telnet.enableLocal} should reject all options, since L{telnet.Telnet} does not know how to implement any options. """ self.assertFalse(self.protocol.enableLocal(b'\0'))
L{telnet.Telnet.enableLocal} should reject all options, since L{telnet.Telnet} does not know how to implement any options.
test_enableLocal
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
MIT
def test_enableRemote(self): """ L{telnet.Telnet.enableRemote} should reject all options, since L{telnet.Telnet} does not know how to implement any options. """ self.assertFalse(self.protocol.enableRemote(b'\0'))
L{telnet.Telnet.enableRemote} should reject all options, since L{telnet.Telnet} does not know how to implement any options.
test_enableRemote
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
MIT
def test_disableLocal(self): """ It is an error for L{telnet.Telnet.disableLocal} to be called, since L{telnet.Telnet.enableLocal} will never allow any options to be enabled locally. If a subclass overrides enableLocal, it must also override disableLocal. """ self.assertRaises(NotImplementedError, self.protocol.disableLocal, b'\0')
It is an error for L{telnet.Telnet.disableLocal} to be called, since L{telnet.Telnet.enableLocal} will never allow any options to be enabled locally. If a subclass overrides enableLocal, it must also override disableLocal.
test_disableLocal
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
MIT
def test_disableRemote(self): """ It is an error for L{telnet.Telnet.disableRemote} to be called, since L{telnet.Telnet.enableRemote} will never allow any options to be enabled remotely. If a subclass overrides enableRemote, it must also override disableRemote. """ self.assertRaises(NotImplementedError, self.protocol.disableRemote, b'\0')
It is an error for L{telnet.Telnet.disableRemote} to be called, since L{telnet.Telnet.enableRemote} will never allow any options to be enabled remotely. If a subclass overrides enableRemote, it must also override disableRemote.
test_disableRemote
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
MIT
def test_requestNegotiation(self): """ L{telnet.Telnet.requestNegotiation} formats the feature byte and the payload bytes into the subnegotiation format and sends them. See RFC 855. """ transport = proto_helpers.StringTransport() self.protocol.makeConnection(transport) self.protocol.requestNegotiation(b'\x01', b'\x02\x03') self.assertEqual( transport.value(), # IAC SB feature bytes IAC SE b'\xff\xfa\x01\x02\x03\xff\xf0')
L{telnet.Telnet.requestNegotiation} formats the feature byte and the payload bytes into the subnegotiation format and sends them. See RFC 855.
test_requestNegotiation
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
MIT
def test_requestNegotiationEscapesIAC(self): """ If the payload for a subnegotiation includes I{IAC}, it is escaped by L{telnet.Telnet.requestNegotiation} with another I{IAC}. See RFC 855. """ transport = proto_helpers.StringTransport() self.protocol.makeConnection(transport) self.protocol.requestNegotiation(b'\x01', b'\xff') self.assertEqual( transport.value(), b'\xff\xfa\x01\xff\xff\xff\xf0')
If the payload for a subnegotiation includes I{IAC}, it is escaped by L{telnet.Telnet.requestNegotiation} with another I{IAC}. See RFC 855.
test_requestNegotiationEscapesIAC
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
MIT
def _deliver(self, data, *expected): """ Pass the given bytes to the protocol's C{dataReceived} method and assert that the given events occur. """ received = self.protocol.events = [] self.protocol.dataReceived(data) self.assertEqual(received, list(expected))
Pass the given bytes to the protocol's C{dataReceived} method and assert that the given events occur.
_deliver
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
MIT
def test_oneApplicationDataByte(self): """ One application-data byte in the default state gets delivered right away. """ self._deliver(b'a', ('bytes', b'a'))
One application-data byte in the default state gets delivered right away.
test_oneApplicationDataByte
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
MIT
def test_twoApplicationDataBytes(self): """ Two application-data bytes in the default state get delivered together. """ self._deliver(b'bc', ('bytes', b'bc'))
Two application-data bytes in the default state get delivered together.
test_twoApplicationDataBytes
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
MIT
def test_threeApplicationDataBytes(self): """ Three application-data bytes followed by a control byte get delivered, but the control byte doesn't. """ self._deliver(b'def' + telnet.IAC, ('bytes', b'def'))
Three application-data bytes followed by a control byte get delivered, but the control byte doesn't.
test_threeApplicationDataBytes
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
MIT
def test_escapedControl(self): """ IAC in the escaped state gets delivered and so does another application-data byte following it. """ self._deliver(telnet.IAC) self._deliver(telnet.IAC + b'g', ('bytes', telnet.IAC + b'g'))
IAC in the escaped state gets delivered and so does another application-data byte following it.
test_escapedControl
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
MIT
def test_carriageReturn(self): """ A carriage return only puts the protocol into the newline state. A linefeed in the newline state causes just the newline to be delivered. A nul in the newline state causes a carriage return to be delivered. An IAC in the newline state causes a carriage return to be delivered and puts the protocol into the escaped state. Anything else causes a carriage return and that thing to be delivered. """ self._deliver(b'\r') self._deliver(b'\n', ('bytes', b'\n')) self._deliver(b'\r\n', ('bytes', b'\n')) self._deliver(b'\r') self._deliver(b'\0', ('bytes', b'\r')) self._deliver(b'\r\0', ('bytes', b'\r')) self._deliver(b'\r') self._deliver(b'a', ('bytes', b'\ra')) self._deliver(b'\ra', ('bytes', b'\ra')) self._deliver(b'\r') self._deliver( telnet.IAC + telnet.IAC + b'x', ('bytes', b'\r' + telnet.IAC + b'x'))
A carriage return only puts the protocol into the newline state. A linefeed in the newline state causes just the newline to be delivered. A nul in the newline state causes a carriage return to be delivered. An IAC in the newline state causes a carriage return to be delivered and puts the protocol into the escaped state. Anything else causes a carriage return and that thing to be delivered.
test_carriageReturn
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
MIT
def test_applicationDataBeforeSimpleCommand(self): """ Application bytes received before a command are delivered before the command is processed. """ self._deliver( b'x' + telnet.IAC + telnet.NOP, ('bytes', b'x'), ('command', telnet.NOP, None))
Application bytes received before a command are delivered before the command is processed.
test_applicationDataBeforeSimpleCommand
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
MIT
def test_applicationDataBeforeCommand(self): """ Application bytes received before a WILL/WONT/DO/DONT are delivered before the command is processed. """ self.protocol.commandMap = {} self._deliver( b'y' + telnet.IAC + telnet.WILL + b'\x00', ('bytes', b'y'), ('command', telnet.WILL, b'\x00'))
Application bytes received before a WILL/WONT/DO/DONT are delivered before the command is processed.
test_applicationDataBeforeCommand
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
MIT
def test_applicationDataBeforeSubnegotiation(self): """ Application bytes received before a subnegotiation command are delivered before the negotiation is processed. """ self._deliver( b'z' + telnet.IAC + telnet.SB + b'Qx' + telnet.IAC + telnet.SE, ('bytes', b'z'), ('negotiate', b'Q', [b'x']))
Application bytes received before a subnegotiation command are delivered before the negotiation is processed.
test_applicationDataBeforeSubnegotiation
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py
MIT
def test_interface_implementation(self): """ It implements the ISFTPServer interface. """ self.assertTrue( filetransfer.ISFTPServer.providedBy(self.server.client), "ISFTPServer not provided by %r" % (self.server.client,))
It implements the ISFTPServer interface.
test_interface_implementation
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
MIT
def test_openedFileClosedWithConnection(self): """ A file opened with C{openFile} is close when the connection is lost. """ d = self.client.openFile(b"testfile1", filetransfer.FXF_READ | filetransfer.FXF_WRITE, {}) self._emptyBuffers() oldClose = os.close closed = [] def close(fd): closed.append(fd) oldClose(fd) self.patch(os, "close", close) def _fileOpened(openFile): fd = self.server.openFiles[openFile.handle[4:]].fd self.serverTransport.loseConnection() self.clientTransport.loseConnection() self.serverTransport.clearBuffer() self.clientTransport.clearBuffer() self.assertEqual(self.server.openFiles, {}) self.assertIn(fd, closed) d.addCallback(_fileOpened) return d
A file opened with C{openFile} is close when the connection is lost.
test_openedFileClosedWithConnection
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
MIT
def test_openedDirectoryClosedWithConnection(self): """ A directory opened with C{openDirectory} is close when the connection is lost. """ d = self.client.openDirectory('') self._emptyBuffers() def _getFiles(openDir): self.serverTransport.loseConnection() self.clientTransport.loseConnection() self.serverTransport.clearBuffer() self.clientTransport.clearBuffer() self.assertEqual(self.server.openDirs, {}) d.addCallback(_getFiles) return d
A directory opened with C{openDirectory} is close when the connection is lost.
test_openedDirectoryClosedWithConnection
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
MIT
def test_openFileExtendedAttributes(self): """ Check that L{filetransfer.FileTransferClient.openFile} can send extended attributes, that should be extracted server side. By default, they are ignored, so we just verify they are correctly parsed. """ savedAttributes = {} oldOpenFile = self.server.client.openFile def openFile(filename, flags, attrs): savedAttributes.update(attrs) return oldOpenFile(filename, flags, attrs) self.server.client.openFile = openFile d = self.client.openFile(b"testfile1", filetransfer.FXF_READ | filetransfer.FXF_WRITE, {"ext_foo": b"bar"}) self._emptyBuffers() def check(ign): self.assertEqual(savedAttributes, {"ext_foo": b"bar"}) return d.addCallback(check)
Check that L{filetransfer.FileTransferClient.openFile} can send extended attributes, that should be extracted server side. By default, they are ignored, so we just verify they are correctly parsed.
test_openFileExtendedAttributes
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
MIT
def test_openDirectoryIterator(self): """ Check that the object returned by L{filetransfer.FileTransferClient.openDirectory} can be used as an iterator. """ # This function is a little more complicated than it would be # normally, since we need to call _emptyBuffers() after # creating any SSH-related Deferreds, but before waiting on # them via yield. d = self.client.openDirectory(b'') self._emptyBuffers() openDir = yield d filenames = set() try: for f in openDir: self._emptyBuffers() (filename, _, fileattrs) = yield f filenames.add(filename) finally: d = openDir.close() self._emptyBuffers() yield d self._emptyBuffers() self.assertEqual(filenames, set([b'.testHiddenFile', b'testDirectory', b'testRemoveFile', b'testRenameFile', b'testfile1']))
Check that the object returned by L{filetransfer.FileTransferClient.openDirectory} can be used as an iterator.
test_openDirectoryIterator
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
MIT
def test_openDirectoryIteratorDeprecated(self): """ Using client.openDirectory as an iterator is deprecated. """ d = self.client.openDirectory(b'') self._emptyBuffers() openDir = yield d openDir.next() warnings = self.flushWarnings() message = ( 'Using twisted.conch.ssh.filetransfer.ClientDirectory' ' as an iterator was deprecated in Twisted 18.9.0.' ) self.assertEqual(1, len(warnings)) self.assertEqual(DeprecationWarning, warnings[0]['category']) self.assertEqual(message, warnings[0]['message'])
Using client.openDirectory as an iterator is deprecated.
test_openDirectoryIteratorDeprecated
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
MIT
def test_sessionClose(self): """ Closing a session should notify an SFTP subsystem launched by that session. """ # make a session testSession = session.SSHSession(conn=FakeConn(), avatar=self.avatar) # start an SFTP subsystem on the session testSession.request_subsystem(common.NS(b'sftp')) sftpServer = testSession.client.transport.proto # intercept connectionLost so we can check that it's called self.interceptConnectionLost(sftpServer) # close session testSession.closeReceived() self.assertSFTPConnectionLost()
Closing a session should notify an SFTP subsystem launched by that session.
test_sessionClose
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
MIT
def test_clientClosesChannelOnConnnection(self): """ A client sending CHANNEL_CLOSE should trigger closeReceived on the associated channel instance. """ conn = self.buildServerConnection() # somehow get a session packet = common.NS(b'session') + struct.pack('>L', 0) * 3 conn.ssh_CHANNEL_OPEN(packet) sessionChannel = conn.channels[0] sessionChannel.request_subsystem(common.NS(b'sftp')) sftpServer = sessionChannel.client.transport.proto self.interceptConnectionLost(sftpServer) # intercept closeReceived self.interceptConnectionLost(sftpServer) # close the connection conn.ssh_CHANNEL_CLOSE(struct.pack('>L', 0)) self.assertSFTPConnectionLost()
A client sending CHANNEL_CLOSE should trigger closeReceived on the associated channel instance.
test_clientClosesChannelOnConnnection
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
MIT
def test_stopConnectionServiceClosesChannel(self): """ Closing an SSH connection should close all sessions within it. """ conn = self.buildServerConnection() # somehow get a session packet = common.NS(b'session') + struct.pack('>L', 0) * 3 conn.ssh_CHANNEL_OPEN(packet) sessionChannel = conn.channels[0] sessionChannel.request_subsystem(common.NS(b'sftp')) sftpServer = sessionChannel.client.transport.proto self.interceptConnectionLost(sftpServer) # close the connection conn.serviceStopped() self.assertSFTPConnectionLost()
Closing an SSH connection should close all sessions within it.
test_stopConnectionServiceClosesChannel
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
MIT
def test_constantsAgainstSpec(self): """ The constants used by the SFTP protocol implementation match those found by searching through the spec. """ constants = {} for excerpt in self.filexferSpecExcerpts: for line in excerpt.splitlines(): m = re.match('^\s*#define SSH_([A-Z_]+)\s+([0-9x]*)\s*$', line) if m: constants[m.group(1)] = long(m.group(2), 0) self.assertTrue( len(constants) > 0, "No constants found (the test must be buggy).") for k, v in constants.items(): self.assertEqual(v, getattr(filetransfer, k))
The constants used by the SFTP protocol implementation match those found by searching through the spec.
test_constantsAgainstSpec
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
MIT
def test_packetSTATUS(self): """ A STATUS packet containing a result code, a message, and a language is parsed to produce the result of an outstanding request L{Deferred}. @see: U{section 9.1<http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-9.1>} of the SFTP Internet-Draft. """ d = defer.Deferred() d.addCallback(self._cbTestPacketSTATUS) self.ftc.openRequests[1] = d data = struct.pack('!LL', 1, filetransfer.FX_OK) + common.NS(b'msg') + common.NS(b'lang') self.ftc.packet_STATUS(data) return d
A STATUS packet containing a result code, a message, and a language is parsed to produce the result of an outstanding request L{Deferred}. @see: U{section 9.1<http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-9.1>} of the SFTP Internet-Draft.
test_packetSTATUS
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
MIT
def _cbTestPacketSTATUS(self, result): """ Assert that the result is a two-tuple containing the message and language from the STATUS packet. """ self.assertEqual(result[0], b'msg') self.assertEqual(result[1], b'lang')
Assert that the result is a two-tuple containing the message and language from the STATUS packet.
_cbTestPacketSTATUS
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
MIT
def test_packetSTATUSShort(self): """ A STATUS packet containing only a result code can also be parsed to produce the result of an outstanding request L{Deferred}. Such packets are sent by some SFTP implementations, though not strictly legal. @see: U{section 9.1<http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-9.1>} of the SFTP Internet-Draft. """ d = defer.Deferred() d.addCallback(self._cbTestPacketSTATUSShort) self.ftc.openRequests[1] = d data = struct.pack('!LL', 1, filetransfer.FX_OK) self.ftc.packet_STATUS(data) return d
A STATUS packet containing only a result code can also be parsed to produce the result of an outstanding request L{Deferred}. Such packets are sent by some SFTP implementations, though not strictly legal. @see: U{section 9.1<http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-9.1>} of the SFTP Internet-Draft.
test_packetSTATUSShort
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
MIT
def _cbTestPacketSTATUSShort(self, result): """ Assert that the result is a two-tuple containing empty strings, since the STATUS packet had neither a message nor a language. """ self.assertEqual(result[0], b'') self.assertEqual(result[1], b'')
Assert that the result is a two-tuple containing empty strings, since the STATUS packet had neither a message nor a language.
_cbTestPacketSTATUSShort
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
MIT
def test_packetSTATUSWithoutLang(self): """ A STATUS packet containing a result code and a message but no language can also be parsed to produce the result of an outstanding request L{Deferred}. Such packets are sent by some SFTP implementations, though not strictly legal. @see: U{section 9.1<http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-9.1>} of the SFTP Internet-Draft. """ d = defer.Deferred() d.addCallback(self._cbTestPacketSTATUSWithoutLang) self.ftc.openRequests[1] = d data = struct.pack('!LL', 1, filetransfer.FX_OK) + common.NS(b'msg') self.ftc.packet_STATUS(data) return d
A STATUS packet containing a result code and a message but no language can also be parsed to produce the result of an outstanding request L{Deferred}. Such packets are sent by some SFTP implementations, though not strictly legal. @see: U{section 9.1<http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-9.1>} of the SFTP Internet-Draft.
test_packetSTATUSWithoutLang
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
MIT
def _cbTestPacketSTATUSWithoutLang(self, result): """ Assert that the result is a two-tuple containing the message from the STATUS packet and an empty string, since the language was missing. """ self.assertEqual(result[0], b'msg') self.assertEqual(result[1], b'')
Assert that the result is a two-tuple containing the message from the STATUS packet and an empty string, since the language was missing.
_cbTestPacketSTATUSWithoutLang
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_filetransfer.py
MIT
def _stringRepresentation(self, stringFunction): """ The string representation of C{SSHTransportAddress} should be "SSHTransportAddress(<stringFunction on address>)". """ addr = self.buildAddress() stringValue = stringFunction(addr) addressValue = stringFunction(addr.address) self.assertEqual(stringValue, "SSHTransportAddress(%s)" % addressValue)
The string representation of C{SSHTransportAddress} should be "SSHTransportAddress(<stringFunction on address>)".
_stringRepresentation
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_address.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_address.py
MIT
def buildAddress(self): """ Create an arbitrary new C{SSHTransportAddress}. A new instance is created for each call, but always for the same address. """ return SSHTransportAddress(IPv4Address("TCP", "127.0.0.1", 22))
Create an arbitrary new C{SSHTransportAddress}. A new instance is created for each call, but always for the same address.
buildAddress
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_address.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_address.py
MIT