Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Given the following code snippet before the placeholder: <|code_start|> def tick(agent): agent.log_info('tick') if __name__ == '__main__': ns = run_nameserver() a0 = run_agent('Agent0') a1 = run_agent('Agent1') a0.each(1, tick) a1.each(1, tick) time.sleep(3) a0.shutdown() <|code_e...
time.sleep(3)
Predict the next line after this snippet: <|code_start|> if __name__ == '__main__': # System deployment ns = run_nameserver() run_agent('Agent0') run_agent('Agent1') run_agent('Agent2') # Show agents registered in the name server for alias in ns.agents(): <|code_end|> using the current fi...
print(alias)
Continue the code snippet: <|code_start|> def publish(agent): agent.send('publisher', 'Publication...') def reply_back(agent, message): return 'Received %s' % message def read_subscription(agent, message): agent.log_info('Read: "%s"' % message) def process_reply(agent, message): agent.log_info('...
addr = publisher.bind('SYNC_PUB', alias='publisher', handler=reply_back)
Given snippet: <|code_start|> def publish(agent): agent.send('publisher', 'Publication...') def reply_back(agent, message): return 'Received %s' % message def read_subscription(agent, message): agent.log_info('Read: "%s"' % message) def process_reply(agent, message): agent.log_info('Publisher re...
client_b.connect(addr, alias='publisher', handler=read_subscription)
Given the code snippet: <|code_start|> def reply(agent, message): return 'Received ' + str(message) if __name__ == '__main__': ns = run_nameserver() alice = run_agent('Alice') bob = run_agent('Bob') addr = alice.bind('REP', alias='main', handler=reply) <|code_end|> , generate the next line usin...
bob.connect(addr, alias='main')
Next line prediction: <|code_start|> def reply(agent, message): return 'Received ' + str(message) if __name__ == '__main__': ns = run_nameserver() alice = run_agent('Alice') bob = run_agent('Bob') addr = alice.bind('REP', alias='main', handler=reply) <|code_end|> . Use current file imports: (f...
bob.connect(addr, alias='main')
Based on the snippet: <|code_start|> def set_x(self, value): self.x = value def set_y(self, value): self.y = value def add_xy(self): return self.x + self.y if __name__ == '__main__': # System deployment ns = run_nameserver() agent = run_agent('Example') # System configuration <|code...
agent.set_method(set_x, set_y, add=add_xy)
Using the snippet: <|code_start|> def set_x(self, value): self.x = value def set_y(self, value): <|code_end|> , determine the next line of code. You have imports: from osbrain import run_agent from osbrain import run_nameserver and context (class names, function names, or code) available: # Path: osbrain/agen...
self.y = value
Here is a snippet: <|code_start|> @pytest.mark.parametrize( 'serializer', AgentAddressSerializer.SERIALIZER_SEPARATOR ) <|code_end|> . Write the next line using the current file imports: import pytest from osbrain import run_agent from osbrain.address import AgentAddressSerializer from osbrain.helper import las...
def test_pubsub_topics_separator(nsproxy, serializer):
Using the snippet: <|code_start|> @pytest.mark.parametrize( 'serializer', AgentAddressSerializer.SERIALIZER_SEPARATOR ) <|code_end|> , determine the next line of code. You have imports: import pytest from osbrain import run_agent from osbrain.address import AgentAddressSerializer from osbrain.helper import last...
def test_pubsub_topics_separator(nsproxy, serializer):
Given snippet: <|code_start|> def heavy_processing(agent, message): agent.log_info('%s seconds task...' % message) time.sleep(message) <|code_end|> , continue by predicting the next line. Consider current file imports: import time from osbrain import run_agent from osbrain import run_nameserver and context:...
agent.send('results', '%s finished with %s' % (agent.name, message))
Continue the code snippet: <|code_start|> def delayed(agent, message): agent.log_info(message) if __name__ == '__main__': ns = run_nameserver() agent = run_agent('a0') agent.after(1, delayed, 'Hello!') # Timer ID returned timer0 = agent.after(1, delayed, 'Never logged') # Timer alias s...
agent.stop_timer('timer_alias')
Given the following code snippet before the placeholder: <|code_start|> if __name__ == '__main__': # System deployment ns = run_nameserver() run_agent('Agent0') run_agent('Agent1') run_agent('Agent2') # Create a proxy to Agent1 and log a message <|code_end|> , predict the next line using impor...
agent = ns.proxy('Agent1')
Given snippet: <|code_start|> def log_message(agent, message): agent.log_info('Received: %s' % message) if __name__ == '__main__': # System deployment ns = run_nameserver() alice = run_agent('Alice') bob = run_agent('Bob') eve = run_agent('Eve') # System configuration <|code_end|> , co...
addr = alice.bind('PUB', alias='main')
Using the snippet: <|code_start|> def log_message(agent, message): agent.log_info('Received: %s' % message) if __name__ == '__main__': # System deployment ns = run_nameserver() alice = run_agent('Alice') bob = run_agent('Bob') eve = run_agent('Eve') # System configuration addr = al...
time.sleep(1)
Based on the snippet: <|code_start|> def reply_late(agent, message): time.sleep(1) return 'Hello, Bob!' <|code_end|> , predict the immediate next line with the help of imports: import time from osbrain import run_agent from osbrain import run_nameserver and context (classes, functions, sometimes code) fro...
def process_reply(agent, message):
Based on the snippet: <|code_start|> def reply_late(agent, message): time.sleep(1) return 'Hello, Bob!' def process_reply(agent, message): agent.log_info('Processed reply: %s' % message) if __name__ == '__main__': ns = run_nameserver() alice = run_agent('Alice') bob = run_agent('Bob') ...
time.sleep(2)
Based on the snippet: <|code_start|> if __name__ == '__main__': ns = run_nameserver() alice = run_agent('Alice') bob = run_agent('Bob') addr = alice.bind('REP', handler=lambda agent, msg: 'Received ' + str(msg)) bob.connect(addr, alias='main') for i in range(10): bob.send('main', i) ...
print(reply)
Next line prediction: <|code_start|> if __name__ == '__main__': ns = run_nameserver() alice = run_agent('Alice') bob = run_agent('Bob') addr = alice.bind('REP', handler=lambda agent, msg: 'Received ' + str(msg)) <|code_end|> . Use current file imports: (from osbrain import run_agent from osbrain impo...
bob.connect(addr, alias='main')
Predict the next line after this snippet: <|code_start|> @pytest.fixture(scope='function') def nsproxy(request): ns = run_nameserver() yield ns ns.shutdown() @pytest.fixture(scope='function') <|code_end|> using the current file's imports: import pytest from osbrain import run_agent from osbrain import...
def agent_logger(request):
Next line prediction: <|code_start|> @pytest.fixture(scope='function') def nsproxy(request): ns = run_nameserver() yield ns ns.shutdown() @pytest.fixture(scope='function') def agent_logger(request): ns = run_nameserver() agent = run_agent('a0') logger = run_logger('logger') <|code_end|> . Us...
agent.set_logger(logger)
Here is a snippet: <|code_start|> @pytest.fixture(scope='function') def nsproxy(request): ns = run_nameserver() yield ns ns.shutdown() @pytest.fixture(scope='function') def agent_logger(request): ns = run_nameserver() agent = run_agent('a0') logger = run_logger('logger') agent.set_logger...
yield agent, logger
Predict the next line after this snippet: <|code_start|> def rep_handler(agent, message): if not agent.tasks: return None return agent.tasks.pop() def request_work(agent): x = agent.send_recv('dispatcher', 'READY!') if not x: agent.shutdown() return time.sleep(x) agent....
worker.connect(dispatcher_addr, alias='dispatcher')
Continue the code snippet: <|code_start|> def rep_handler(agent, message): if not agent.tasks: return None <|code_end|> . Use current file imports: import time from osbrain import run_agent from osbrain import run_nameserver and context (classes, functions, or code) from other files: # Path: osbrain/ag...
return agent.tasks.pop()
Given the code snippet: <|code_start|> if __name__ == '__main__': # System deployment ns = run_nameserver() agent = run_agent('Example') # Log a message <|code_end|> , generate the next line using the imports in this file: from osbrain import run_agent from osbrain import run_nameserver and context ...
agent.log_info('Hello world!')
Predict the next line for this snippet: <|code_start|> if __name__ == '__main__': # System deployment ns = run_nameserver() agent = run_agent('Example') # Log a message agent.log_info('Hello world!') <|code_end|> with the help of current file imports: from osbrain import run_agent from osbrain ...
ns.shutdown()
Continue the code snippet: <|code_start|> def log_message(agent, message): agent.log_info('Received: %s' % message) if __name__ == '__main__': # System deployment ns = run_nameserver() alice = run_agent('Alice') bob = run_agent('Bob') # System configuration addr = alice.bind('PUSH', al...
ns.shutdown()
Predict the next line after this snippet: <|code_start|> logger = logging.getLogger(__name__) class TFTPState(tftpy.TftpStates.TftpState): def __int__(self, context): super().__init__(context) def handle(self, pkt, raddress, rport): <|code_end|> using the current file's imports: import fs import os...
raise NotImplementedError
Here is a snippet: <|code_start|> session = conpot_core.get_session( "kamstrup_management_protocol", address[0], address[1], sock.getsockname()[0], sock.getsockname()[1], ) logger.info( "New Kamstrup connection from %s:%s. (%...
request = data.decode()
Continue the code snippet: <|code_start|># # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. logger = logging.getLogger(__name__) @conpot_protocol clas...
address[1],
Here is a 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 2 # of the License, or (at your option) any later version. # # This program is distributed in the ...
self.syslog_client = None
Based on the snippet: <|code_start|> self.enabled = True def _process_sessions(self): sessions = self.session_manager._sessions try: session_timeout = self.config.get("session", "timeout") except (configparser.NoSectionError, configparser.NoOptionError): sess...
self._process_sessions()
Based on the snippet: <|code_start|> ssl_lists = {} def __init__( self, pdu_type=0, reserved=0, request_id=0, result_info=0, parameters="", data="", ): self.magic = 0x32 self.pdu_type = pdu_type self.reserved = reserved ...
0x1A: ("request_download", self.request_not_implemented),
Continue the code snippet: <|code_start|># You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. logger = logging.getLogger(__name__) class KamstrupProtocolB...
)
Predict the next line for this snippet: <|code_start|> def __repr__(self): tot = ( self.data_channel_bytes_recv + self.data_channel_bytes_send + self.command_chanel_bytes_recv + self.command_chanel_bytes_send ) s = """ Total data trans...
Start time : {}
Continue the code snippet: <|code_start|> self.start_time = time.time() self.data_channel_bytes_recv = 0 self.data_channel_bytes_send = 0 self.command_chanel_bytes_send = 0 self.command_chanel_bytes_recv = 0 self.last_active = self.start_time # basically we need a ...
Command channel sent : {} (bytes)
Here is a snippet: <|code_start|># Copyright (C) 2013 Daniel creo Haslinger <creo-conpot@blackmesa.at> # Derived from plcscan by Dmitry Efanov (Positive Research) # # 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 S...
)
Given the code snippet: <|code_start|> class LogQueueFake: def __init__(self): self.events = [] def put(self, event): self.events.append(event) def test_add_event_is_logged(): protocol = "testing" source_ip = "1.2.3.4" source_port = 11 destination_ip = "5.6.7.8" destinati...
logged = log_queue.events[0]
Predict the next line for this snippet: <|code_start|># GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...
if self.cmd_responder:
Given the code snippet: <|code_start|># # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. logger = logging.getLogger(__name__) port_start_range = 1 port_...
self._sock.connect((self.ip_address, self.port))
Given the code snippet: <|code_start|> maxApduLengthAccepted=int(apdu_length_key), segmentationSupported=segmentation_key, vendorName=vendor_name_key, vendorIdentifier=int(vendor_identifier_key), ) self.bacnet_app = None self.server = None # Initia...
logger.warning("DecodingError - PDU: {}".format(pdu))
Continue the code snippet: <|code_start|># Copyright (C) 2015 Peter Sooky <xsooky00@stud.fit.vubtr.cz> # # 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 2 # of the License, or (a...
def __init__(self, template, template_directory, args):
Given the following code snippet before the placeholder: <|code_start|> else: self.parsing = True escape_escape_byte = False if self.data_escaped: self.bytes[position] ^= 0xFF if d is kamstrup_constants.EOT_MAGIC: ...
del self.bytes[: position + 1]
Given snippet: <|code_start|># GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. logger = logging.getLogg...
d = self.bytes[position]
Given the code snippet: <|code_start|> self.data_escaped = True del self.bytes[position] bytes_len -= 1 continue assert self.data_escaped is False if d is kamstrup_constants.EOT_MAGIC and not escape_escape_b...
def valid_crc(cls, message):
Using the snippet: <|code_start|> status = status.value with open( os.path.join(docpath, "statuscodes", str(int(status)) + ".status"), "rb", ) as f: payload = f.read() except IOError as e: ...
chunks = "0"
Predict the next line after this snippet: <|code_start|># modified by Sooky Peter <xsooky00@stud.fit.vutbr.cz> # Brno University of Technology, Faculty of Information Technology # Following imports are required for modbus template evaluation logger = logging.getLogger(__name__) @conpot_protocol class ModbusServer(...
self.timeout = 5
Using the snippet: <|code_start|> def __init__(self, template, template_directory, args): self.timeout = 5 self.delay = None self.mode = None self.host = None self.port = None self.server = None databank = slave_db.SlaveBase(template) # Constructor: i...
sys.exit(3)
Next line prediction: <|code_start|> return "Response discarded due to invalid CRC." comm_address = self.out_data[1] if self.out_data[2] in self.response_map: result = self.response_map[ self.out_data[2] ...
message += ", "
Given the following code snippet before the placeholder: <|code_start|># 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. # # You should have received a copy of the GNU General Public License # a...
)
Next line prediction: <|code_start|> class COTP(object): def __init__(self, tpdu_type=0, opt_field=0, payload="", trailer=""): self.tpdu_type = tpdu_type self.opt_field = opt_field self.payload = payload self.trailer = trailer if self.tpdu_type == 240: self.pack...
return (
Next line prediction: <|code_start|> # Packet format: # +--------+--------+----------------+-----------....---------------+ # |version |reserved| packet length | TPDU | # +----------------------------------------------....---------------+ # <8 bits> <8 bits> < 16 bits > ...
return self
Based on the snippet: <|code_start|> # sleeps the thread for $delay ( should be either 1 float to apply a static period of time to sleep, # or 2 floats seperated by semicolon to sleep a randomized period of time determined by ( rand[x;y] ) lbound, _, ubound = delay.partition(";") if not...
threshold_individual,
Given the following code snippet before the placeholder: <|code_start|> result['VerifyInfo']['URL'] =target_url result['VerifyInfo']['payload']=payload result['VerifyInfo']['result'] =info except Exception,e: print e.text ...
print P().verify(ip='222.29.81.19',port='8080')
Next line prediction: <|code_start|> __all__ = ['RequestContext', 'build_routes', 'get_couchdb_server', 'get_database_name', 'get_mailbox_slug', 'get_mailbox', 'get_mailbox_db_prefix', 'iter_mailboxes', 'TEMPLATE_FILTERS','TEMPLATE_CONTEXT_PROCESSORS'] log = logging.getLogger(__name_...
class RequestContext(object):
Given snippet: <|code_start|> __all__ = ['RequestContext', 'build_routes', 'get_couchdb_server', 'get_database_name', 'get_mailbox_slug', 'get_mailbox', 'get_mailbox_db_prefix', 'iter_mailboxes', <|code_end|> , continue by predicting the next line. Consider current file imports: import base64 i...
'TEMPLATE_FILTERS','TEMPLATE_CONTEXT_PROCESSORS']
Predict the next line after this snippet: <|code_start|> __all__ = ['RequestContext', 'build_routes', 'get_couchdb_server', 'get_database_name', 'get_mailbox_slug', 'get_mailbox', 'get_mailbox_db_prefix', 'iter_mailboxes', <|code_end|> using the current file's imports: import base64 import log...
'TEMPLATE_FILTERS','TEMPLATE_CONTEXT_PROCESSORS']
Next line prediction: <|code_start|> __all__ = ['RequestContext', 'build_routes', 'get_couchdb_server', 'get_database_name', 'get_mailbox_slug', 'get_mailbox', 'get_mailbox_db_prefix', 'iter_mailboxes', <|code_end|> . Use current file imports: (import base64 import logging import mimetypes impo...
'TEMPLATE_FILTERS','TEMPLATE_CONTEXT_PROCESSORS']
Continue the code snippet: <|code_start|> __all__ = ['RequestContext', 'build_routes', 'get_couchdb_server', 'get_database_name', 'get_mailbox_slug', 'get_mailbox', 'get_mailbox_db_prefix', 'iter_mailboxes', <|code_end|> . Use current file imports: import base64 import logging import mimetypes ...
'TEMPLATE_FILTERS','TEMPLATE_CONTEXT_PROCESSORS']
Continue the code snippet: <|code_start|> __all__ = ['RequestContext', 'build_routes', 'get_couchdb_server', 'get_database_name', 'get_mailbox_slug', 'get_mailbox', 'get_mailbox_db_prefix', 'iter_mailboxes', 'TEMPLATE_FILTERS','TEMPLATE_CONTEXT_PROCESSORS'] log = logging.getLogger(__...
class RequestContext(object):
Continue the code snippet: <|code_start|> ###################################### # # view helpers # ###################################### def handle_unauth(request): if request.context.user.is_anonymous(): # redirect to login with any additional info login_url = request.context.url_for('login', ne...
return controller_action(*args, **kw)
Given snippet: <|code_start|> def signup(request): if request.method == 'GET': return render_to_response('radar/signup.html', TemplateContext(request, {})) def front_page(request): return render_to_response('radar/front_page.html', TemplateContext(request, {})) d...
res.allow = ['GET']
Using the snippet: <|code_start|> messages.append(Message.wrap(row.doc)) if next_key: next_params = {'start': next_key} else: next_params = None return _render_messages(request, mb, messages, next_params=next_params) def _render_messages(request, mailbox, messages, next_par...
for k, v in q.items():
Given snippet: <|code_start|>def front_page(request): return render_to_response('radar/front_page.html', TemplateContext(request, {})) def list_mailboxes(request): ctx = request.context mailboxes = [] for mb in ctx.iter_mailboxes(): if not ctx.user.has_perm(PERM_R...
return handle_unauth(request)
Given the following code snippet before the placeholder: <|code_start|> return controller_action(*args, **kw) wrapped_action.__name__ = controller_action.__name__ return wrapped_action ##################################### # # views # ###################################### def login(request): c...
def list_mailboxes(request):
Based on the snippet: <|code_start|> ctx = request.context if not ctx.user.has_perm(PERM_CREATE_MAILBOX): return handle_unauth(request) return render_to_response('radar/create_mailbox.html', TemplateContext(request, {})) def view_mailbox_latest(request, mailbo...
else:
Based on the snippet: <|code_start|> }) return render_to_response('radar/list_mailboxes.html', TemplateContext(request, {'mailboxes': mailboxes})) def create_mailbox(request): if request.method != 'GET': res = HttpResponse(status=405) res.allow = ['GET...
'include_docs': True,
Based on the snippet: <|code_start|> return wrapped_action ##################################### # # views # ###################################### def login(request): ctx = {} next_page = request.params.get('next') if next_page: ctx = {'next': next_page} return render_to_response('radar/lo...
mailboxes = []
Given snippet: <|code_start|> ###################################### # # view helpers # ###################################### def handle_unauth(request): if request.context.user.is_anonymous(): # redirect to login with any additional info login_url = request.context.url_for('login', next=request.u...
def login_required(controller_action):
Given the code snippet: <|code_start|> TemplateContext(request, {})) def view_mailbox_latest(request, mailbox_slug): ctx = request.context mb = ctx.get_mailbox(mailbox_slug) if mb is None: return HttpResponse(status=404) if not ctx.user.has_perm(PERM_READ, mb): ...
else:
Given the following code snippet before the placeholder: <|code_start|> class HelpCommand(BasicCommand): command_name = 'help' description = 'print help for commands' @classmethod def setup_options(cls, parser): <|code_end|> , predict the next line using imports from the current file: from operator ...
parser.set_usage(r"%prog " + "%s <command> [options]" % cls.command_name)
Using the snippet: <|code_start|> class HelpCommand(BasicCommand): command_name = 'help' description = 'print help for commands' @classmethod def setup_options(cls, parser): <|code_end|> , determine the next line of code. You have imports: from operator import attrgetter from radarpost.cli import CO...
parser.set_usage(r"%prog " + "%s <command> [options]" % cls.command_name)
Here is a snippet: <|code_start|> class HelpCommand(BasicCommand): command_name = 'help' description = 'print help for commands' @classmethod def setup_options(cls, parser): parser.set_usage(r"%prog " + "%s <command> [options]" % cls.command_name) def __call__(self, command_name=None): <...
if command_name is None:
Given the code snippet: <|code_start|> class HelpCommand(BasicCommand): command_name = 'help' description = 'print help for commands' @classmethod def setup_options(cls, parser): parser.set_usage(r"%prog " + "%s <command> [options]" % cls.command_name) def __call__(self, command_name=Non...
else:
Predict the next line for this snippet: <|code_start|> class HelpCommand(BasicCommand): command_name = 'help' description = 'print help for commands' @classmethod def setup_options(cls, parser): parser.set_usage(r"%prog " + "%s <command> [options]" % cls.command_name) def __call__(self, ...
command.print_usage()
Given the code snippet: <|code_start|> def test_user_password(): user = User(username='joe', password='fr3d') assert user.username == 'joe' assert user.check_password('fr3d') <|code_end|> , generate the next line using the imports in this file: from helpers import * from radarpost.user import Us...
assert not user.check_password('fr01d')
Predict the next line for this snippet: <|code_start|> class CreateUserCommand(BasicCommand): command_name = 'create_user' description = 'create a user' @classmethod def setup_options(cls, parser): parser.set_usage(r"%prog" + "%s <username> [options]" % cls.command_name) parser.add_opt...
default=False,
Continue the code snippet: <|code_start|> class CreateUserCommand(BasicCommand): command_name = 'create_user' description = 'create a user' @classmethod def setup_options(cls, parser): parser.set_usage(r"%prog" + "%s <username> [options]" % cls.command_name) parser.add_option('--admin'...
parser.add_option('--locked', action="store_true", dest="is_locked",
Predict the next line for this snippet: <|code_start|> class CreateUserCommand(BasicCommand): command_name = 'create_user' description = 'create a user' @classmethod <|code_end|> with the help of current file imports: from couchdb import Server, ResourceNotFound from radarpost.cli import COMMANDLINE_PLU...
def setup_options(cls, parser):
Given the code snippet: <|code_start|># config['http.port'] = int(config['http.port']) # CONFIG_INI_PARSER_PLUGIN = 'radarpost.config.configiniparser' # # provide defaults that are used to fill in templated values in # configuration like %(whatever) etc. # # should be a function that accepts no arguments and r...
config['%s.%s' % (section, key)] = val
Predict the next line after this snippet: <|code_start|> TEST_INI_KEY = 'RADAR_TEST_CONFIG' DEFAULT_RADAR_TEST_CONFIG = path.join(dn(dn(dn(__file__))), 'test.ini') TEST_DATA_DIR = path.join(dn(__file__), 'data') TEST_MAILBOX_ID = 'rp_test_mailbox' def get_config_filename(): <|code_end|> using the current file's impo...
filename = os.environ.get('RADAR_TEST_CONFIG', None)
Predict the next line after this snippet: <|code_start|> filename = DEFAULT_RADAR_TEST_CONFIG return filename def load_test_config(): return load_config(get_config_filename()) def get_data(filename): return open(path.join(TEST_DATA_DIR, filename)).read() def create_test_mailbox(config=None, name=T...
def rfc3339(value):
Here is a snippet: <|code_start|># -*- coding: UTF-8 -*- @pytest.mark.parametrize('word,pair', ( ('=dynamic=true', ('dynamic', True)), ('=dynamic=false', ('dynamic', False)), )) <|code_end|> . Write the next line using the current file imports: import pytest from unittest.mock import MagicMock, patch from ...
def test_bool_parse_word(word, pair):
Predict the next line for this snippet: <|code_start|># -*- coding: UTF-8 -*- @pytest.mark.parametrize('word,pair', ( ('=dynamic=true', ('dynamic', True)), ('=dynamic=false', ('dynamic', False)), )) <|code_end|> with the help of current file imports: import pytest from unittest.mock import MagicMock, patc...
def test_bool_parse_word(word, pair):
Using the snippet: <|code_start|># -*- coding: UTF-8 -*- @pytest.mark.parametrize('word,pair', ( ('=dynamic=true', ('dynamic', True)), ('=dynamic=false', ('dynamic', False)), <|code_end|> , determine the next line of code. You have imports: import pytest from unittest.mock import MagicMock, patch from libr...
))
Continue the code snippet: <|code_start|> def test_add_then_remove(routeros_api): ips = routeros_api.path('ip', 'address') new_id = ips.add(interface='ether1', address='192.168.1.1/24') ips.remove(new_id) _id = Key('.id') assert tuple() == tuple(ips.select(_id).where(_id == new_id)) <|code_end|> ...
def test_add_then_update(routeros_api):
Continue the code snippet: <|code_start|># -*- coding: UTF-8 -*- class Test_SocketTransport: def setup(self): self.transport = SocketTransport(sock=MagicMock(spec=socket)) def test_calls_socket_close(self): self.transport.close() self.transport.sock.close.assert_called_once() ...
self.transport.write(b'some message')
Predict the next line for this snippet: <|code_start|> class Test_SocketTransport: def setup(self): self.transport = SocketTransport(sock=MagicMock(spec=socket)) def test_calls_socket_close(self): self.transport.close() self.transport.sock.close.assert_called_once() def test_clos...
def test_read_raises_when_recv_returns_empty_byte_string(self):
Given the code snippet: <|code_start|> def __init__(self, path, keys: typing.Sequence[Key], api): self.path = path self.keys = keys self.api = api self.query: typing.Tuple[str, ...] = tuple() def where(self, *args: str): self.query = tuple(chain.from_iterable(args)) ...
yield from chain.from_iterable(rest)
Predict the next line for this snippet: <|code_start|> yield f'?<{self}={cast_to_api(other)}' def __gt__(self, other): yield f'?>{self}={cast_to_api(other)}' def __str__(self) -> str: return str(self.name) # pylint: disable=invalid-name def In(self, one, *elems): yield ...
cmd = str(self.path.join('print'))
Given the code snippet: <|code_start|># -*- coding: UTF-8 -*- class Key: def __init__(self, name: str): self.name = name def __eq__(self, other): yield f'?={self}={cast_to_api(other)}' def __ne__(self, other): yield from self == other yield '?#!' <|code_end|> , generate...
def __lt__(self, other):
Given snippet: <|code_start|># -*- coding: UTF-8 -*- def test_api_path_returns_Path(): api = Api(protocol=MagicMock()) new = api.path('ip', 'address') <|code_end|> , continue by predicting the next line. Consider current file imports: from unittest.mock import ( MagicMock, ) from librouteros.api import (...
assert new.path == '/ip/address'
Predict the next line for this snippet: <|code_start|> def test_api_path_returns_Path(): api = Api(protocol=MagicMock()) new = api.path('ip', 'address') assert new.path == '/ip/address' assert new.api == api assert isinstance(new, Path) class Test_Path: def setup(self): self.path = Pa...
new = self.path.select('disabled', 'name')
Next line prediction: <|code_start|> def test_remove(self): self.path.remove('*1', '*2', '*3') self.path.api.assert_called_once_with('/interface/remove', **{'.id': '*1,*2,*3'}) # Check if returned generator was consumed assert self.path.api.return_value.__iter__.call_count == 1 d...
self.path.api.assert_called_once_with('/system/script/run')
Given the following code snippet before the placeholder: <|code_start|># -*- coding: UTF-8 -*- def test_TrapError_newlines(): r"""Assert that string representation replaces \r\n with comma.""" error = TrapError(message='some\r\n string') <|code_end|> , predict the next line using imports from the current fil...
assert str(error) == 'some, string'
Given the following code snippet before the placeholder: <|code_start|> @pytest.mark.parametrize('param, expected', ( (True, 'yes'), (False, 'no'), ('yes', 'yes'), (1, '1'), )) def test_eq(self, param, expected): result = tuple(self.key == param)[0] assert resu...
result = tuple(self.key > param)[0]
Given the code snippet: <|code_start|># -*- coding: UTF-8 -*- class Test_Query: def setup(self): self.query = Query( path=MagicMock(), api=MagicMock(), keys=MagicMock(), ) def test_after_init_query_is_empty_tuple(self): assert self.query.query == t...
def test_where_returns_self(self):
Next line prediction: <|code_start|> 'key1', 'key2', ) class Test_Key: def setup(self): self.key = Key(name='key_name', ) @pytest.mark.parametrize('param, expected', ( (True, 'yes'), (False, 'no'), ('yes', 'yes'), (1, '1'), )) de...
result = tuple(self.key < param)[0]
Given the code snippet: <|code_start|> self.key = Key(name='key_name', ) @pytest.mark.parametrize('param, expected', ( (True, 'yes'), (False, 'no'), ('yes', 'yes'), (1, '1'), )) def test_eq(self, param, expected): result = tuple(self.key == param)[0] a...
))
Here is a snippet: <|code_start|> class SHORTEN(Enum): SHORT = 0 MID_SHORT = 1 MID = 2 LONG = 3 class Illusion(Chain): <|code_end|> . Write the next line using the current file imports: import melee from melee.enums import Action, Button from Chains.chain import Chain from enum import Enum and contex...
def __init__(self, length=SHORTEN.LONG):