Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Using the snippet: <|code_start|> rx = range(0, len(value), 30) refs = reduce(lambda a, b: a & b, [count(value[i : i + 30]) for i in rx]) else: refs = db(id.belongs(value)).select(id) return refs and ", ".join(_fieldformat(self.ref, x) for x in value) or "" def auto_...
return name if REGEX_W.match(name) else quotestr % name
Given the code snippet: <|code_start|> new_query = field.endswith(value) else: raise RuntimeError("Invalid operation") elif field._db._adapter.dbengine == "google:datastore" and field.type in ( "list:integer", "list:strin...
if isinstance(field_type, SQLCustomType):
Given snippet: <|code_start|> def tearDownModule(): if os.path.isfile("test.txt"): os.unlink("test.txt") class testPortalocker(unittest.TestCase): def test_LockedFile(self): f = LockedFile("test.txt", mode="wb") f.write(to_bytes("test ok")) f.close() f = LockedFile("te...
@unittest.skipIf(IS_GAE, "GAE has no locks")
Based on the snippet: <|code_start|> def tearDownModule(): if os.path.isfile("test.txt"): os.unlink("test.txt") class testPortalocker(unittest.TestCase): def test_LockedFile(self): f = LockedFile("test.txt", mode="wb") <|code_end|> , predict the immediate next line with the help of imports: ...
f.write(to_bytes("test ok"))
Predict the next line after this snippet: <|code_start|> t1 = threading.Thread(target=worker1) th.append(t1) t1.start() for t in th: t.join() with open("test.txt") as g: content = g.read() results = [line.strip().split("\t") for line in...
lock(f, LOCK_EX)
Given the code snippet: <|code_start|> f1.close() f = LockedFile("test.txt", mode="wb") f.write(to_bytes("")) f.close() th = [] for x in range(10): t1 = threading.Thread(target=worker1) th.append(t1) t1.start() for t in th: ...
unlock(fh)
Based on the snippet: <|code_start|> with open("test.txt") as g: content = g.read() results = [line.strip().split("\t") for line in content.split("\n") if line] # all started at more or less the same time starts = [1 for line in results if float(line[0]) - t0 < 1] end...
content = read_locked("test.txt")
Predict the next line for this snippet: <|code_start|> @unittest.skipIf(IS_GAE, "GAE has no locks") def test_read_locked(self): def worker(fh): time.sleep(2) fh.close() f = LockedFile("test.txt", mode="wb") f.write(to_bytes("test ok")) t1 = threading.Thre...
write_locked("test.txt", to_bytes("test ok"))
Given snippet: <|code_start|> def tearDownModule(): if os.path.isfile("test.txt"): os.unlink("test.txt") class testPortalocker(unittest.TestCase): def test_LockedFile(self): <|code_end|> , continue by predicting the next line. Consider current file imports: import os import threading import time fro...
f = LockedFile("test.txt", mode="wb")
Given the following code snippet before the placeholder: <|code_start|> t1 = threading.Thread(target=worker1) th.append(t1) t1.start() for t in th: t.join() with open("test.txt") as g: content = g.read() results = [line.strip().split("\...
lock(f, LOCK_EX)
Predict the next line for this snippet: <|code_start|> REGEX_SQUARE_BRACKETS, tokens[-1] ): new_patterns = self.auto_table( tokens[-1][tokens[-1].find("[") + 1 : -1], "/".join(tokens[:-1]) ) patterns =...
if re.match(REGEX_SEARCH_PATTERN, tag):
Given the code snippet: <|code_start|> parser = db.parse_as_rest(patterns,args,vars) if parser.status == 200: return dict(content=parser.response) else: raise HTTP(parser.status,parser.error) ...
REGEX_SQUARE_BRACKETS, tokens[-1]
Given the following code snippet before the placeholder: <|code_start|> def to_num(num): result = 0 try: <|code_end|> , predict the next line using imports from the current file: import re from .regex import REGEX_SEARCH_PATTERN, REGEX_SQUARE_BRACKETS from .._compat import long and context including class na...
result = long(num)
Based on the snippet: <|code_start|> _custom_ = {} def _json_parse(self, o): if hasattr(o, "custom_json") and callable(o.custom_json): return o.custom_json() if isinstance(o, (datetime.date, datetime.datetime, datetime.time)): return o.isoformat()[:19].replace("T", " ") ...
if PY2:
Based on the snippet: <|code_start|> colset, db, tablename, id = self.colset, self.db, self.tablename, self.id table = db[tablename] newfields = fields or dict(colset) for fieldname in list(newfields.keys()): if fieldname not in table.fields or table[fieldname].type == "id": ...
if PY2:
Continue the code snippet: <|code_start|> @staticmethod def try_create_web2py_filesystem(db): if db._uri not in DatabaseStoredFile.web2py_filesystems: if db._adapter.dbengine not in ("mysql", "postgres", "sqlite"): raise NotImplementedError( "DatabaseStored...
elif exists(filename):
Given snippet: <|code_start|> def keys(self): return self.__dict__.keys() def iterkeys(self): return iterkeys(self.__dict__) def values(self): return self.__dict__.values() def itervalues(self): return itervalues(self.__dict__) def items(self): return self...
copyreg.pickle(BasicStorage, pickle_basicstorage)
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- class cachedprop(object): #: a read-only @property that is only evaluated once. def __init__(self, fget, doc=None): self.fget = fget self.__doc__ = doc or fget.__doc__ self.__name__ = fget....
@implements_bool
Given the code snippet: <|code_start|> return self.__dict__.__getitem__(str(key)) __setitem__ = object.__setattr__ def __delitem__(self, key): try: delattr(self, key) except AttributeError: raise KeyError(key) def __bool__(self): return len(self.__di...
def iterkeys(self):
Given the following code snippet before the placeholder: <|code_start|> delattr(self, key) except AttributeError: raise KeyError(key) def __bool__(self): return len(self.__dict__) > 0 __iter__ = lambda self: self.__dict__.__iter__() __str__ = lambda self: self.__dic...
def itervalues(self):
Using the snippet: <|code_start|> __iter__ = lambda self: self.__dict__.__iter__() __str__ = lambda self: self.__dict__.__str__() __repr__ = lambda self: self.__dict__.__repr__() has_key = __contains__ = lambda self, key: key in self.__dict__ def get(self, key, default=None): return self...
def iteritems(self):
Based on the snippet: <|code_start|> @staticmethod def try_create_web2py_filesystem(db): if db._uri not in DatabaseStoredFile.web2py_filesystems: if db._adapter.dbengine not in ("mysql", "postgres", "sqlite"): raise NotImplementedError( "DatabaseStoredFile...
self.data = to_bytes(rows[0][0])
Continue the code snippet: <|code_start|> def itervalues(self): return itervalues(self._values) def items(self): return self._values.items() def iteritems(self): return iteritems(self._values) def op_values(self): return [(self._fields[key], value) for key, value in ite...
class Reference(long):
Given the code snippet: <|code_start|> def keys(self): return self._values.keys() def iterkeys(self): return iterkeys(self._values) def values(self): return self._values.values() def itervalues(self): return itervalues(self._values) def items(self): return ...
return serializers.xml(self.as_dict(flat=True, sanitize=sanitize))
Given snippet: <|code_start|> children = list() for e in node.edges: children.append(self._conv_etree2tree(nodes.get(e[1]), nodes, e[0], include_edgelabels)) return nltk.Tree(cat, children) return None def _cached(obj, filepath, constructor): if obj is not...
class TigerCorpusReader(Corpus):
Given the code snippet: <|code_start|># coding: utf-8 ''' File: convenience.py Author: Oliver Zscheyge Description: Convenience functions for handling PDF conversions. ''' def PDF2XMLstring(filepath): <|code_end|> , generate the next line using the imports in this file: from xml.dom.minidom import parseString ...
pdfminer = PDFMinerWrapper()
Given the code snippet: <|code_start|> take_from_new_lines = False while i < len(lines): l = lines[i].strip() if take_from_new_lines: l = new_lines[i] new_lines.pop() take_from_new_lines = False if l.endswith(u"-"): if i + 1 < len(lines): ...
, xml_util.getChildElementsByTagName(dom_textgroup, "textbox"))
Based on the snippet: <|code_start|># it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY without even...
BoolProperty("auto-play", "auto-play", False, optional=True),
Predict the next line after this snippet: <|code_start|># # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This progr...
StringProperty("Level File", "name", ""),
Predict the next line after this snippet: <|code_start|># the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY without even the implied warranty of # MERCHANTABILITY or FITNE...
SpriteProperty("Sprite", "sprite"),
Given the code snippet: <|code_start|># (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. #...
InlineTilePosProperty()
Given snippet: <|code_start|># Flexlay - A Generic 2D Game Editor # Copyright (C) 2015 Karkus476 <karkus476@yahoo.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the L...
self.objmap_object = make_sprite_object(self, self.sprite)
Predict the next line for this snippet: <|code_start|># Flexlay - A Generic 2D Game Editor # Copyright (C) 2014 Ingo Ruhnke <grumbel@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, ...
blit_clear(target)
Here is a snippet: <|code_start|># Flexlay - A Generic 2D Game Editor # Copyright (C) 2014 Ingo Ruhnke <grumbel@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of t...
blit_opaque(target, source, -x, -y)
Using the snippet: <|code_start|># # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. class InputEvent: MOUSE_LEFT = 1 MOUSE_RIGHT = 2 MOUSE_MIDDLE = 3 MOUSE_WHEEL_UP = 4 MOUSE_WHEEL_DOWN = 5 MOUSE_NO_...
result.mouse_pos = Point(event.x(), event.y())
Continue the code snippet: <|code_start|># Flexlay - A Generic 2D Game Editor # Copyright (C) 2015 Karkus476 <karkus476@yahoo.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either versio...
class SaveAddonDialog(SaveDirectoryDialog):
Using the snippet: <|code_start|># Flexlay - A Generic 2D Game Editor # Copyright (C) 2014 Ingo Ruhnke <grumbel@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of t...
raise SExprParseError("Error: '%s' is not a '%s' file" % (filename, root_symbol))
Given the following code snippet before the placeholder: <|code_start|># Flexlay - A Generic 2D Game Editor # Copyright (C) 2014 Ingo Ruhnke <grumbel@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Soft...
self.sig_select = Signal()
Based on the snippet: <|code_start|># Flexlay - A Generic 2D Game Editor # Copyright (C) 2015 Karkus476 <karkus476@yahoo.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 o...
class SaveLevelFileDialog(SaveFileDialog):
Predict the next line for this snippet: <|code_start|># Flexlay - A Generic 2D Game Editor # Copyright (C) 2014 Ingo Ruhnke <grumbel@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, ...
self.tile_brush = TileBrush(1, 1)
Continue the code snippet: <|code_start|> self.tree_view = QTreeView() self.vbox.addWidget(self.toolbar) self.model = QFileSystemModel() # self.data = [ # ("SuperTux addon", [ # ("levels", []), # ("images", []), # ("sounds",...
self.call_signal = Signal()
Given snippet: <|code_start|> def draw_line(self, x1, y1, x2, y2, color): self.painter.setPen(color.to_qt()) self.painter.drawLine(QLineF(x1, y1, x2, y2)) def push_modelview(self): self.painter.save() def pop_modelview(self): self.painter.restore() def translate(self, x...
return Rectf()
Here is a snippet: <|code_start|># the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR...
self.finish_callback = Signal()
Predict the next line after this snippet: <|code_start|># # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This progr...
self.widget = ObjectSelectorWidget(obj_w, obj_h, self.scroll_area.viewport())
Given the code snippet: <|code_start|> height = 0 start = 0 reverse = False def __init__(self, id, name, width, height, max_width, max_height, start, reverse): self.id = id self.name = name self.width = width self.height = height self.max_width = max_width ...
brush = TileBrush(self.width, self.height)
Based on the snippet: <|code_start|> self.width_label = QLabel("Width: ") self.width_input = QSpinBox(self) self.height_label = QLabel("Height: ") self.height_input = QSpinBox(self) self.width_box = QHBoxLayout() self.width_box.addWidget(self.width_label) self.wid...
ToolContext.current.tile_brush = self.brush
Next line prediction: <|code_start|># Flexlay - A Generic 2D Game Editor # Copyright (C) 2015 Karkus476 <karkus476@yahoo.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 o...
GenericDialog("Generic Dialog Test")
Predict the next line after this snippet: <|code_start|># Copyright (C) 2014 Ingo Ruhnke <grumbel@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or...
return Icon(action)
Predict the next line after this snippet: <|code_start|>""" Tests for ESMTP extension parsing. """ def test_basic_extension_parsing(): response = """size.does.matter.af.MIL offers FIFTEEN extensions: 8BITMIME PIPELINING DSN ENHANCEDSTATUSCODES EXPN HELP SAML SEND SOML TURN XADR XSTA ETRN XGEN SIZE 51200000 "...
extensions, auth_types = parse_esmtp_extensions(response)
Next line prediction: <|code_start|>""" Compat method tests. """ @pytest.mark.asyncio async def test_get_running_loop(event_loop): running_loop = get_running_loop() assert running_loop is event_loop def test_get_running_loop_runtime_error(event_loop): with pytest.raises(RuntimeError): get_runn...
if PY37_OR_LATER:
Given the code snippet: <|code_start|>""" Compat method tests. """ @pytest.mark.asyncio async def test_get_running_loop(event_loop): running_loop = get_running_loop() assert running_loop is event_loop def test_get_running_loop_runtime_error(event_loop): with pytest.raises(RuntimeError): get_ru...
tasks = all_tasks(event_loop)
Given the following code snippet before the placeholder: <|code_start|>""" Compat method tests. """ @pytest.mark.asyncio async def test_get_running_loop(event_loop): <|code_end|> , predict the next line using imports from the current file: import asyncio import pytest from aiosmtplib.compat import PY37_OR_LATER, a...
running_loop = get_running_loop()
Continue the code snippet: <|code_start|> ) -> SMTPResponse: """ Sends an SMTP DATA command to the server, followed by encoded message content. Automatically quotes lines beginning with a period per RFC821. Lone \\\\r and \\\\n characters are converted to \\\\r\\\\n character...
async def start_tls(
Based on the snippet: <|code_start|> async with self._command_lock: self.write(command) response = await self.read_response(timeout=timeout) return response async def execute_data_command( self, message: bytes, timeout: Optional[float] = None ) -> SMTPResponse: ...
raise SMTPDataError(start_response.code, start_response.message)
Next line prediction: <|code_start|> if message_complete: response = SMTPResponse( code, bytes(message).decode("utf-8", "surrogateescape") ) del self._buffer[:offset] return response else: return None async def read_respons...
raise SMTPReadTimeoutError("Timed out waiting for server response") from exc
Predict the next line after this snippet: <|code_start|> self._response_waiter.set_exception(exc) else: if response is not None: self._response_waiter.set_result(response) def eof_received(self) -> bool: exc = SMTPServerDisconnected("Unexpected EOF received") ...
raise SMTPResponseException(
Predict the next line after this snippet: <|code_start|> for waiter in filter(None, waiters): if waiter.done() and not waiter.cancelled(): # Avoid 'Future exception was never retrieved' warnings waiter.exception() def _get_close_waiter(self, stream: asyncio.Stream...
smtp_exc = SMTPServerDisconnected("Connection lost")
Predict the next line for this snippet: <|code_start|> ) -> SMTPResponse: """ Puts the connection to the SMTP server into TLS mode. """ if self._over_ssl: raise RuntimeError("Already using TLS.") if self._command_lock is None: raise SMTPServerDisconnect...
raise SMTPTimeoutError("Timed out while upgrading transport") from exc
Given the code snippet: <|code_start|> return self._buffer.extend(data) # If we got an obvious partial message, don't try to parse the buffer last_linebreak = data.rfind(b"\n") if ( last_linebreak == -1 or data[last_linebreak + 3 : last_linebreak + 4]...
def _read_response_from_buffer(self) -> Optional[SMTPResponse]:
Given the code snippet: <|code_start|> else: if response is not None: self._response_waiter.set_result(response) def eof_received(self) -> bool: exc = SMTPServerDisconnected("Unexpected EOF received") if self._response_waiter and not self._response_waiter.done(): ...
SMTPStatus.unrecognized_command, "Response too long"
Given the following code snippet before the placeholder: <|code_start|>async def test_send_compat32_message_smtputf8_recipient( smtp_client_smtputf8, smtpd_server_smtputf8, compat32_message, received_commands, received_messages, ): recipient_bytes = bytes("reçipïént@exåmple.com", "utf-8") co...
with pytest.raises(SMTPNotSupported):
Here is a snippet: <|code_start|> monkeypatch.setattr(smtpd_class, "smtp_EHLO", response_handler) async with smtp_client: errors, response = await smtp_client.sendmail( sender_str, [recipient_str], message_str ) assert not errors assert response != "" async def tes...
with pytest.raises(SMTPRecipientsRefused) as excinfo:
Continue the code snippet: <|code_start|> async def test_sendmail_without_size_option( smtp_client, smtpd_server, smtpd_class, smtpd_response_handler_factory, monkeypatch, sender_str, recipient_str, message_str, received_commands, ): response_handler = smtpd_response_handler_fact...
with pytest.raises(SMTPResponseException) as excinfo:
Given snippet: <|code_start|> ) assert not errors assert response != "" async def test_sendmail_with_mail_option( smtp_client, smtpd_server, sender_str, recipient_str, message_str ): async with smtp_client: errors, response = await smtp_client.sendmail( sender_str, ...
"{} done".format(SMTPStatus.completed)
Predict the next line for this snippet: <|code_start|> received_messages, ): recipient_bytes = bytes("reçipïént@exåmple.com", "utf-8") compat32_message["To"] = email.header.Header(recipient_bytes, "utf-8") async with smtp_client_smtputf8: errors, response = await smtp_client_smtputf8.send_messag...
message["To"] = formataddr(("æøå", "someotheruser@example.com"))
Using the snippet: <|code_start|>""" send coroutine testing. """ pytestmark = pytest.mark.asyncio() async def test_send(hostname, smtpd_server_port, message, received_messages): <|code_end|> , determine the next line of code. You have imports: import pytest from aiosmtplib import send and context (class names, f...
errors, response = await send(message, hostname=hostname, port=smtpd_server_port)
Using the snippet: <|code_start|> self.server = self.loop.run_until_complete( self.loop.create_server( self.factory, host=self.hostname, port=self.port, ssl=self.ssl_context, family=socket.AF_I...
shutdown_loop(self.loop)
Next line prediction: <|code_start|> loop.run_until_complete(_await_with_future(coro, result)) finally: shutdown_loop(loop) return result.result() async def _await_with_future(coro: Awaitable, future: asyncio.Future) -> None: try: result = await coro except Exception as exc: ...
if PY36_OR_LATER:
Continue the code snippet: <|code_start|>) -> Any: if loop is None: loop = asyncio.get_event_loop() if loop.is_running(): raise RuntimeError("Event loop is already running.") result = loop.create_future() try: loop.run_until_complete(_await_with_future(coro, result)) final...
tasks = all_tasks(loop=loop)
Based on the snippet: <|code_start|> ["alice@example.com", "Bob@example.com"], ), ( Address(display_name="ålice Smith", username="ålice", domain="example.com"), Address(display_name="Bøb", username="Bøb", domain="example.com"), Header("ålice Smith <ålice@ex...
mime_recipients = extract_recipients(mime_message)
Based on the snippet: <|code_start|>@pytest.mark.parametrize( "mime_header,compat32_header,expected_sender", ( ( "Alice Smith <alice@example.com>", "Alice Smith <alice@example.com>", "alice@example.com", ), ( Address(display_name="Alice Smi...
mime_sender = extract_sender(mime_message)
Next line prediction: <|code_start|> "address, expected_address", ( ('"A.Smith" <asmith+foo@example.com>', "<asmith+foo@example.com>"), ("Pepé Le Pew <pépe@example.com>", "<pépe@example.com>"), ("<a@new.topleveldomain>", "<a@new.topleveldomain>"), ("email@[123.123.123.123]", "<ema...
flat_message = flatten_message(message)
Continue the code snippet: <|code_start|>""" Test message and address parsing/formatting functions. """ @pytest.mark.parametrize( "address, expected_address", ( ('"A.Smith" <asmith+foo@example.com>', "asmith+foo@example.com"), ("Pepé Le Pew <pépe@example.com>", "pépe@example.com"), (...
parsed_address = parse_address(address)
Predict the next line after this snippet: <|code_start|> ("<a@new.topleveldomain>", "a@new.topleveldomain"), ("B. Smith <b@example.com", "b@example.com"), ), ids=("quotes", "nonascii", "newtld", "missing_end_<"), ) def test_parse_address_with_display_names(address, expected_address): parsed_a...
quoted_address = quote_address(address)
Based on the snippet: <|code_start|> await smtp_client.mail("j@example.com") with pytest.raises(UnicodeEncodeError): await smtp_client.rcpt("tést@exåmple.com", options=["SMTPUTF8"]) async def test_data_ok(smtp_client, smtpd_server): async with smtp_client: await smtp_client.mai...
with pytest.raises(SMTPDataError) as exception_info:
Given the following code snippet before the placeholder: <|code_start|> return bad_data_response async def test_helo_ok(smtp_client, smtpd_server): async with smtp_client: response = await smtp_client.helo() assert response.code == SMTPStatus.completed async def test_helo_with_hostname(smtp...
with pytest.raises(SMTPHeloError) as exception_info:
Next line prediction: <|code_start|> await smtp_client.noop() assert exception_info.value.code == error_code async def test_vrfy_ok(smtp_client, smtpd_server): nice_address = "test@example.com" async with smtp_client: response = await smtp_client.vrfy(nice_address) assert r...
with pytest.raises(SMTPNotSupported):
Continue the code snippet: <|code_start|> response_handler = smtpd_response_handler_factory( "{} retry in 5 minutes".format(SMTPStatus.domain_unavailable), close_after=True ) monkeypatch.setattr(smtpd_class, "smtp_EHLO", response_handler) async with smtp_client: with pytest.raises(SMTPHe...
with pytest.raises(SMTPResponseException) as exception_info:
Continue the code snippet: <|code_start|>""" Lower level SMTP command tests. """ pytestmark = pytest.mark.asyncio() @pytest.fixture(scope="session") def bad_data_response_handler(request): async def bad_data_response(smtpd, *args, **kwargs): smtpd._writer.write(b"250 \xFF\xFF\xFF\xFF\r\n") awai...
assert response.code == SMTPStatus.completed
Predict the next line after this snippet: <|code_start|> sender_str, [recipient_str], message_str ) assert not errors assert isinstance(errors, dict) assert response != "" def test_send_message_sync(event_loop, smtp_client_threaded, message): errors, response = smtp_client_threaded.send_me...
result = async_to_sync(test_func())
Next line prediction: <|code_start|> assert excinfo.value.message == message @pytest.mark.parametrize( "error_class", (SMTPServerDisconnected, SMTPConnectError, SMTPConnectTimeoutError) ) @given(message=text()) def test_connection_exceptions(message, error_class): with pytest.raises(error_class) as excinfo...
"error_class", (SMTPHeloError, SMTPDataError, SMTPAuthenticationError)
Here is a snippet: <|code_start|>""" Test error class imports, arguments, and inheritance. """ @given(text()) def test_raise_smtp_exception(message): with pytest.raises(SMTPException) as excinfo: raise SMTPException(message) assert excinfo.value.message == message @given(integers(), text()) def t...
"error_class", (SMTPServerDisconnected, SMTPConnectError, SMTPConnectTimeoutError)
Given snippet: <|code_start|>""" Test error class imports, arguments, and inheritance. """ @given(text()) def test_raise_smtp_exception(message): with pytest.raises(SMTPException) as excinfo: raise SMTPException(message) assert excinfo.value.message == message @given(integers(), text()) def test_...
"error_class", (SMTPServerDisconnected, SMTPConnectError, SMTPConnectTimeoutError)
Continue the code snippet: <|code_start|> assert excinfo.value.message == message @pytest.mark.parametrize( "error_class", (SMTPServerDisconnected, SMTPConnectError, SMTPConnectTimeoutError) ) @given(message=text()) def test_connection_exceptions(message, error_class): with pytest.raises(error_class) as ex...
"error_class", (SMTPHeloError, SMTPDataError, SMTPAuthenticationError)
Given the following code snippet before the placeholder: <|code_start|>""" Test error class imports, arguments, and inheritance. """ @given(text()) def test_raise_smtp_exception(message): <|code_end|> , predict the next line using imports from the current file: import asyncio import pytest from hypothesis import g...
with pytest.raises(SMTPException) as excinfo:
Based on the snippet: <|code_start|> assert excinfo.value.message == message @pytest.mark.parametrize( "error_class", (SMTPServerDisconnected, SMTPConnectError, SMTPConnectTimeoutError) ) @given(message=text()) def test_connection_exceptions(message, error_class): with pytest.raises(error_class) as excinfo...
"error_class", (SMTPHeloError, SMTPDataError, SMTPAuthenticationError)
Here is a snippet: <|code_start|> raise SMTPSenderRefused(code, message, sender) assert issubclass(excinfo.type, SMTPResponseException) assert excinfo.value.code == code assert excinfo.value.message == message assert excinfo.value.sender == sender @given(integers(), text(), text()) def test_ra...
with pytest.raises(SMTPNotSupported) as excinfo:
Given the following code snippet before the placeholder: <|code_start|> with pytest.raises(SMTPException) as excinfo: raise SMTPException(message) assert excinfo.value.message == message @given(integers(), text()) def test_raise_smtp_response_exception(code, message): with pytest.raises(SMTPRespon...
"error_class", (SMTPTimeoutError, SMTPConnectTimeoutError, SMTPReadTimeoutError)
Predict the next line after this snippet: <|code_start|> assert issubclass(excinfo.type, asyncio.TimeoutError) assert excinfo.value.message == message @pytest.mark.parametrize( "error_class", (SMTPHeloError, SMTPDataError, SMTPAuthenticationError) ) @given(code=integers(), message=text()) def test_simple_r...
with pytest.raises(SMTPRecipientRefused) as excinfo:
Here is a snippet: <|code_start|> assert issubclass(excinfo.type, SMTPResponseException) assert excinfo.value.code == code assert excinfo.value.message == message @given(integers(), text(), text()) def test_raise_smtp_sender_refused(code, message, sender): with pytest.raises(SMTPSenderRefused) as exci...
with pytest.raises(SMTPRecipientsRefused) as excinfo:
Given snippet: <|code_start|>""" Test error class imports, arguments, and inheritance. """ @given(text()) def test_raise_smtp_exception(message): with pytest.raises(SMTPException) as excinfo: raise SMTPException(message) assert excinfo.value.message == message @given(integers(), text()) def test_...
with pytest.raises(SMTPResponseException) as excinfo:
Next line prediction: <|code_start|> @pytest.mark.parametrize( "error_class", (SMTPTimeoutError, SMTPConnectTimeoutError, SMTPReadTimeoutError) ) @given(message=text()) def test_timeout_exceptions(message, error_class): with pytest.raises(error_class) as excinfo: raise error_class(message) assert ...
with pytest.raises(SMTPSenderRefused) as excinfo:
Next line prediction: <|code_start|>""" Test error class imports, arguments, and inheritance. """ @given(text()) def test_raise_smtp_exception(message): with pytest.raises(SMTPException) as excinfo: raise SMTPException(message) assert excinfo.value.message == message @given(integers(), text()) de...
"error_class", (SMTPServerDisconnected, SMTPConnectError, SMTPConnectTimeoutError)
Given the following code snippet before the placeholder: <|code_start|> with pytest.raises(SMTPException) as excinfo: raise SMTPException(message) assert excinfo.value.message == message @given(integers(), text()) def test_raise_smtp_response_exception(code, message): with pytest.raises(SMTPRespon...
"error_class", (SMTPTimeoutError, SMTPConnectTimeoutError, SMTPReadTimeoutError)
Predict the next line for this snippet: <|code_start|> field_module = 'models' django_kwargs = {} if self.node_attrs['model'] == 'CharField': django_kwargs['max_length'] = 255 django_kwargs['blank'] = not self.node_attrs['required'] try: django_kwargs['defa...
ast_source = source_parser.parse_source_file(script_path)
Given snippet: <|code_start|> field_kwargs['initial'] = initial field = getattr(forms, field) return field(**field_kwargs) def get_group_forms(self, model=None, pk=None, initial=None): pk = int(pk) if pk is not None else pk if pk is not None and pk in self.djangui_forms: ...
form = DjanguiForm()
Given snippet: <|code_start|>from __future__ import absolute_import __author__ = 'chris' class DjanguiFormFactory(object): djangui_forms = {} @staticmethod def get_field(param, initial=None): field = param.form_field choices = json.loads(param.choices) field_kwargs = {'label': p...
initial = utils.get_storage_object(initial) if not hasattr(initial, 'path') else initial
Based on the snippet: <|code_start|>from __future__ import absolute_import __author__ = 'chris' class DjanguiOutputFileField(models.FileField): def formfield(self, **kwargs): # TODO: Make this from an app that is plugged in <|code_end|> , predict the immediate next line with the help of imports: from djan...
defaults = {'form_class': djangui_form_fields.DjanguiOutputFileField}
Predict the next line for this snippet: <|code_start|> class FileCleanupMixin(object): def tearDown(self): for i in DjanguiFile.objects.all(): <|code_end|> with the help of current file imports: import shutil from ..models import Script, DjanguiFile, DjanguiJob from ..backend import utils and context fr...
utils.get_storage().delete(i.filepath.path)
Given snippet: <|code_start|> A Corpus is built from a directory that contains the text files that become `WitnessText` objects. """ def __init__(self, path, tokenizer): self._logger = logging.getLogger(__name__) self._path = os.path.abspath(path) self._tokenizer = tokenizer ...
def get_witness(self, work, siglum, text_class=WitnessText):