Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_assert_imap_protocol_with_message(self):
assert_imap_protocol(True, 'foo')
with self.assertRaises(ProtocolError):
assert_imap_protocol(False, 'foo')
def test_assert_imap_protocol(self):
assert_imap_protocol(True)
with self.assertRaises(ProtocolError):
assert_imap_protocol(False)
def test_assert_imap_protocol_with_message(self):
assert_imap_protocol(True, 'foo')
with self.assertRaises(ProtocolError):
assert_imap_protocol(False, 'foo')
def test_assert_imap_protocol(self):
assert_imap_protocol(True)
with self.assertRaises(ProtocolError):
assert_imap_protocol(False)
def _parse_untagged_response(text):
assert_imap_protocol(text.startswith(b'* '))
text = text[2:]
if text.startswith((b'OK ', b'NO ')):
return tuple(text.split(b' ', 1))
return parse_response([text])
def __init__(self, lexer, resp_record):
self.lexer = lexer
if isinstance(resp_record, tuple):
# A 'record' with a string which includes a literal marker, and
# the literal itself.
self.src_text = resp_record[0]
assert_imap_protocol(self.src_text.endswith(b"}"), self.src_text)
self.literal = resp_record[1]
else:
# just a line with no literals.
self.src_text = resp_record
self.literal = None
stream_i.push(nextchar)
break # done skipping over the whitespace
# Non-whitespace
token = bytearray()
for nextchar in stream_i:
if nextchar in wordchars:
token.append(nextchar)
elif nextchar == OPEN_SQUARE:
token.append(nextchar)
token.extend(read_until(stream_i, CLOSE_SQUARE, escape=False))
else:
if nextchar in whitespace:
yield token
elif nextchar == DOUBLE_QUOTE:
assert_imap_protocol(not token)
token.append(nextchar)
token.extend(read_until(stream_i, nextchar))
yield token
else:
# Other punctuation, eg. "(". This ends the current token.
if token:
yield token
yield bytearray([nextchar])
break
else:
if token:
yield token
break