Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Given snippet: <|code_start|> class TestMouser(TestCase): def setUp(self): self.api = MouserApi() @skip <|code_end|> , continue by predicting the next line. Consider current file imports: from django.test import TestCase from .mouser import MouserApi from unittest import skip and context: # Path: b...
def test_search_keyword(self):
Next line prediction: <|code_start|> path('part/<int:part_id>/rev/<int:part_revision_id>/remove-subpart/<int:subpart_id>/', views.remove_subpart, name='part-remove-subpart'), path('part/<int:part_id>/rev/<int:part_revision_id>/manage-bom/', views.manage_bom, name='part-manage-bom'), path('part/<int:part_id>/...
path('json/', include((json_patterns, 'json'))),
Here is a snippet: <|code_start|> path('part/<int:part_id>/rev/<int:part_revision_id>/edit-subpart/<int:subpart_id>', views.edit_subpart, name='part-edit-subpart'), path('part/<int:part_id>/rev/<int:part_revision_id>/remove-subpart/<int:subpart_id>/', views.remove_subpart, name='part-remove-subpart'), path('...
path('google-drive/', include((google_drive_patterns, 'google-drive'))),
Given snippet: <|code_start|> return self.get_synoynms(hdr_name)[0] if synonyms is not None else None # Preserves order of definitions as listed in all_header_defns: def get_default_all(self): return [d.name for d in self.all_headers_defns] # Given a list of header names returns the default...
def validate_header_names(self, headers):
Given the code snippet: <|code_start|> 'part_synopsis': self.part_revision.synopsis(), 'part_revision': self.part_revision.revision, 'part_manufacturer': self.part.primary_manufacturer_part.manufacturer.name if self.part.primary_manufacturer_part is not None and self.part.primary_manu...
def as_dict_for_export(self):
Here is a snippet: <|code_start|> pr.save() except ValueError: pr.searchable_synopsis = pr.description pr.save() pass class Migration(migrations.Migration): dependencies = [ ('bom', '0023_auto_20191205_2351'), ] operations = [ migrati...
('QFN', 'QFN'), ('QFP', 'QFP'), ('QFT', 'QFT'), ('PLCC', 'PLCC'), ('VGA', 'VGA'), ('Other', 'Other')], default=None, max_length=16, null=True),
Next line prediction: <|code_start|># -*- coding: utf-8 -*- vim:fileencoding=utf-8: # Copyright (C) 2010-2014 GRNET S.A. # # 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...
]
Based on the snippet: <|code_start|># -*- coding: utf-8 -*- vim:fileencoding=utf-8: # Copyright (C) 2010-2014 GRNET S.A. # # 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...
organization = form.cleaned_data['organization']
Based on the snippet: <|code_start|> datetime_now = datetime.datetime.now class UserProfile(models.Model): user = models.OneToOneField(User) first_login = models.BooleanField(default=True) force_logout_date = models.DateTimeField(null=True, blank=True) organization = models.ForeignKey(Organization,...
UserProfile.objects.create(user=instance)
Predict the next line after this snippet: <|code_start|># 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. # # You should have re...
r'^password_reset/done/$',
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 PU...
auth_views.password_reset_confirm, name='password_reset_confirm'),
Next line prediction: <|code_start|># -*- coding: utf-8 -*- vim:fileencoding=utf-8: # Copyright (C) 2010-2014 GRNET S.A. # # 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...
]
Given 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. # # You s...
}
Next line prediction: <|code_start|> region = parsed_args.region if not username: raise ValueError('Missing required argument: username') if not api_key: raise ValueError('Missing required argument: api-key') kwargs = {} if api_url is not None: kwargs['base_url'] = api_url...
metadata_str += ', '
Predict the next line for this snippet: <|code_start|> kwargs = {} if api_url is not None: kwargs['base_url'] = api_url if region is not None: kwargs['region'] = region c = Client(username=username, api_key=api_key, **kwargs) return c def format_metadata(metadata_dict): meta...
return ''
Predict the next line after this snippet: <|code_start|># Copyright 2013 Rackspace # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this ...
'format_timestamp',
Continue the code snippet: <|code_start|> class BaseRegistryShowCommand(BaseRegistryCommand, BaseShowCommand): pass class BaseRegistryListCommand(BaseRegistryCommand, BaseListCommand): def get_parser(self, prog_name): parser = super(BaseRegistryListCommand, self) \ .get_parser(prog_name=pr...
api_url = parsed_args.api_url
Given the code snippet: <|code_start|> api_url = parsed_args.api_url region = parsed_args.region if not username: raise ValueError('Missing required argument: username') if not api_key: raise ValueError('Missing required argument: api-key') kwargs = {} if api_url is not None: ...
if i < count:
Predict the next line for this snippet: <|code_start|>class TestUtils(unittest.TestCase): def test_get_enum_as_dict(self): class EnumClass1(object): KEY1 = 0 KEY_TWO_TWO = 1 SOME_KEY_SOME_SOME = 2 result1 = get_enum_as_dict(EnumClass1, friendly_names=False) ...
self.assertDictEqual(result2, expected2)
Given the following code snippet before the placeholder: <|code_start|> config = get_config(app=None, config_path=path1) self.assertEqual(config['username'], 'username1') self.assertEqual(config['api_key'], 'api_key1') self.assertEqual(config['verify_ssl'], True) self.assertEqual...
self.assertEqual(config['username'], 'username_mon')
Predict the next line after this snippet: <|code_start|># the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANT...
self.assertEqual(config['username'], 'username2')
Here is a snippet: <|code_start|># Copyright 2013 Rackspace # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the A...
def state_to_string(value):
Using the snippet: <|code_start|> 'Algorithm' ] STATES = get_enum_as_dict(State, reverse=True) def state_to_string(value): return STATES[value] class Balancer(Model): id = Attribute() name = Attribute() state = Attribute(transform_func=state_to_string) ip = Attribute() port = Attribute...
def __cmp__(self, other):
Continue the code snippet: <|code_start|># Copyright 2013 Rackspace # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You und...
'Algorithm'
Given the following code snippet before the placeholder: <|code_start|>class FakeEntity1(object): key = 'key1' ip = '127.0.0.1' label = 'test label' state = 'unknown1' class FakeEntity2(object): key = 'key2' ip = '127.0.0.1' label = 'label2' state = 'unknown2' class TestModels(unitte...
[
Continue the code snippet: <|code_start|> state = 'unknown2' class TestModels(unittest.TestCase): def test_generate_output(self): en1 = Entity(FakeEntity1()) en2 = Entity(FakeEntity2()) collection = Collection([en1, en2]) result1 = en1.generate_output() expected1 = ( ...
sys.exit(unittest.main())
Given the following code snippet before the placeholder: <|code_start|> state = 'unknown2' class TestModels(unittest.TestCase): def test_generate_output(self): en1 = Entity(FakeEntity1()) en2 = Entity(FakeEntity2()) collection = Collection([en1, en2]) result1 = en1.generate_ou...
sys.exit(unittest.main())
Next line prediction: <|code_start|> class MonitoringCommand(BaseCommand): def get_parser(self, prog_name): parser = super(MonitoringCommand, self).\ get_parser(prog_name=prog_name) parser.add_argument('--auth-url', dest='auth_url') return parser class MonitoringEntityCommand(M...
return parser
Based on the snippet: <|code_start|> parser.add_argument('--marker', dest='marker') return parser class MonitoringEntityListCommand(MonitoringListCommand): def get_parser(self, prog_name): parser = super(MonitoringEntityListCommand, self).\ get_parser(prog_name=prog_name) ...
if parsed_args.username:
Continue the code snippet: <|code_start|> return parser def get_config(): return get_base_config(app='monitoring') def get_client(parsed_args): config = get_config() driver = get_driver(Provider.RACKSPACE) username = config['username'] api_key = config['api_key'] if parsed_args.usern...
options['ex_force_base_url'] = api_url
Using the snippet: <|code_start|># See the License for the specific language governing permissions and # limitations under the License. __all__ = [ 'for_all_regions' ] CA_CERT_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../data/cacert.pem') libcloud.security.C...
parser.add_argument('--balancer-id', dest='balancer_id', required=True)
Next line prediction: <|code_start|> return parser class LoadBalancerBalancerListCommand(LoadBalancerCommand, BaseListCommand): def get_parser(self, prog_name): parser = super(LoadBalancerBalancerListCommand, self).\ get_parser(prog_name=prog_name) parser.add_argument('--balance...
if not username:
Continue the code snippet: <|code_start|> class LoadBalancerBalancerListCommand(LoadBalancerCommand, BaseListCommand): def get_parser(self, prog_name): parser = super(LoadBalancerBalancerListCommand, self).\ get_parser(prog_name=prog_name) parser.add_argument('--balancer-id', dest='bala...
raise ValueError('Missing required argument: username')
Here is a snippet: <|code_start|># distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. __all__ = [ 'for_all_regions' ] ...
parser = super(LoadBalancerBalancerListCommand, self).\
Given the code snippet: <|code_start|>def get_client(parsed_args, driver_kwargs=None): config = get_config() # TODO: regions/uk driver = get_driver(Provider.RACKSPACE_US) username = config['username'] api_key = config['api_key'] if parsed_args.username: username = parsed_args.username ...
options['ex_force_auth_url'] = auth_url
Given the code snippet: <|code_start|># Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or...
self.assertEqual('b', a.b)
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- # Copyright (C) 2013 Yahoo! Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy...
self.assertIs(future.result(), result)
Predict the next line after this snippet: <|code_start|> routing_key = 'routing-key' task_uuid = 'task-uuid' p = self.proxy(reset_master_mock=True) p.publish(msg_mock, routing_key, correlation_id=task_uuid) mock_producer = mock.call.connection.Producer() master_mock_call...
self.master_mock.assert_has_calls(master_calls)
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- # Copyright (C) 2014 Yahoo! Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # ht...
def test_interrupt(self):
Predict the next line for this snippet: <|code_start|>CEO |__Infra | |__Infra.1 |__Mail |__Search |__Search.1 """ self.assertEqual(expected.strip(), root.pformat()) root[-1].add(tree.Node("Search.2")) expected = """ CEO |__Infra | |__Infra.1 |__Mail |__Search |__Search.1 |__Search.2 ...
|__Search.2
Based on the snippet: <|code_start|>class TimingTest(test.TestCase): def test_convert_fail(self): for baddie in ["abc123", "-1", "", object()]: self.assertRaises(ValueError, timing.convert_to_timeout, baddie) def test_convert_noop(self): t = timing.conv...
def test_fail(self):
Based on the snippet: <|code_start|> else: val = self.__get_bool('no' + backend) if val: snap.config.options.target_backends[backend] = False of = self.__get_string('outputformat') sf = self.__get_string('snapfile') ...
configoptions = None
Given the following code snippet before the placeholder: <|code_start|> else: val = self.__get_bool('no' + backend) if val: snap.config.options.target_backends[backend] = False of = self.__get_string('outputformat') sf = se...
configoptions = None
Predict the next line for this snippet: <|code_start|>#!/usr/bin/python # # test/tdltest.py unit test suite for snap.metadata.tdl # # (C) Copyright 2012 Mo Morsi (mo@morsi.org) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, Version 3, # a...
contents = tf.read()
Predict the next line after this snippet: <|code_start|> self.assertEqual('C:\\', OS.get_root('windows')) @unittest.skipUnless(OS.is_windows(), "only relevant for windows") def testWindowsRoot(self): self.assertEqual('C:\\', OS.get_root()) @unittest.skipUnless(OS.is_linux(),...
def testLinuxNullFile(self):
Here is a snippet: <|code_start|> basefile = os.path.join(self.basedir, "foo") f = open(basefile, "w") f.write("foo") f.close OSUtils.chown(self.basedir, uid=100, gid=100) st = os.stat(self.basedir) self.assertEqual(100, st.st_uid) self.assertEqual...
ouid = os.geteuid()
Predict the next line after this snippet: <|code_start|> for target in backends.keys(): backend_classes.append(backends[target].__class__) self.assertEqual('mock', snap.config.options.target_backends['repos']) self.assertEqual('mock', snap.config.options.target_backends['packages']) ...
self.snapbase.restore()
Predict the next line after this snippet: <|code_start|>#!/usr/bin/python # # test/aptbackendtest.py unit test suite for apt snap backends # # (C) Copyright 2011 Mo Morsi (mo@morsi.org) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, Versi...
os.mkdir(self.fs_root)
Given snippet: <|code_start|> class Operation(): def __init__(self, op): if isinstance(op, list) and len(op) == 2: if isinstance(op[0], int): <|code_end|> , continue by predicting the next line. Consider current file imports: from collections import OrderedDict from graphenebase.types import (...
self.opId = op[0]
Continue the code snippet: <|code_start|> else: if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] prefix = kwargs.pop("prefix", default_prefix) meta = "" if "json_metadata" in kwargs and kwargs["json_metadata"]: if isinstance...
else:
Predict the next line after this snippet: <|code_start|> pk_url_kwarg = 'image_key' # def view_full_image(request, image_key): # # li = LeafletImage.objects.filter(pk=image_key) # if li.count() == 1: # li = get_object_or_404(LeafletImage, image_key=image_key) # else: # # Should not do th...
context_instance=RequestContext(request), )
Given snippet: <|code_start|># context_instance=RequestContext(request), ) def view_all_full_images(request, leafletid): leaflet = get_object_or_404(Leaflet, pk=leafletid) images = LeafletImage.objects.filter(leaflet=leaflet) return render_to_response('leaflets/full_all.html'...
"postcode": "leaflets/upload_form/postcode.html",
Here is a snippet: <|code_start|> class ConstituencyViewSet(viewsets.ModelViewSet): queryset = Constituency.objects.all() serializer_class = ConstituencySerializer <|code_end|> . Write the next line using the current file imports: from django.http import HttpResponse from django.contrib.sites.models impo...
class PartyViewSet(viewsets.ModelViewSet):
Next line prediction: <|code_start|>class ConstituencyViewSet(viewsets.ModelViewSet): queryset = Constituency.objects.all() serializer_class = ConstituencySerializer class PartyViewSet(viewsets.ModelViewSet): queryset = Party.objects.all() serializer_class = PartySerializer class LeafletImageViewSet...
d['uploaded_date'] = str(leaflet.date_uploaded)
Predict the next line for this snippet: <|code_start|> class ConstituencyViewSet(viewsets.ModelViewSet): queryset = Constituency.objects.all() serializer_class = ConstituencySerializer class PartyViewSet(viewsets.ModelViewSet): queryset = Party.objects.all() serializer_class = PartySerializer class ...
d['constituency'] = str(d['constituency'])
Predict the next line for this snippet: <|code_start|> domain = Site.objects.get_current().domain leaflets = Leaflet.objects.order_by('-id').all()[0:20] resp = [] for leaflet in leaflets: d = {} d['constituency'] = leaflet.constituency() or 'Unknown' d['constituency'] = str(d['co...
output += "</leaflets>"
Here is a snippet: <|code_start|> named_form_list = [ ('front', FrontPageImageForm), ('postcode', PostcodeForm), # ('back', BackPageImageForm), # ('inside', InsidePageImageForm), ] upload_form_wizzard = LeafletUploadWizzard.as_view(named_form_list, url_name='upload_step', done_step_name='finished...
url(r'^/full/(?P<image_key>.+)/$', ImageView.as_view(), name='full_image'),
Given the following code snippet before the placeholder: <|code_start|> named_form_list = [ ('front', FrontPageImageForm), ('postcode', PostcodeForm), # ('back', BackPageImageForm), # ('inside', InsidePageImageForm), ] upload_form_wizzard = LeafletUploadWizzard.as_view(named_form_list, <|code_end|> ,...
url_name='upload_step', done_step_name='finished')
Predict the next line after this snippet: <|code_start|> b.extend([astate,bstate]) # catch errors elif 'D' in B and 'D' in A: print 'Error: fake bond %s-%s (%s-%s -> %s-%s)' % (a1.name,a2.name,a1.atomtype,a2.atomtype, a1.atomtypeB,a2.atomtypeB) sys....
astate = [1,0,0,0,0]
Next line prediction: <|code_start|> def list_path(path): assert not os.path.isabs(path) abs_path = os.path.join(app.root_path, path) return [ os.path.join(abs_path, f) for f in os.listdir(abs_path) ] def all(): for insight_path in list_path("insights"): try: insight = dict( id...
except GeneratorExit:
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python if __name__ == '__main__': app.run( debug=True <|code_end|> with the help of current file imports: from web import app and context from other files: # Path: web/app.py # def sort(iter, col, dir="ASC"): # def execute(q_str, col=1): # ...
)
Based on the snippet: <|code_start|> class TestDBWrapper(TestCase): def setUp(self): self._old_db_path = os.environ['DATA_DB_PATH'] self.tmp_dir = os.environ['DATA_DB_PATH'] = tempfile.mkdtemp() def tearDown(self): shutil.rmtree(self.tmp_dir) os.environ['DATA_DB_PATH'] = self._old_db_path ...
dbs={},
Predict the next line for this snippet: <|code_start|> ( ConcreteTemplate({'content': '((1)) ((2)) ((3))'}), ConcreteTemplate({'content': '((1)) ((2)) ((3))'}), False ), ( ConcreteTemplate({'content': '((1)) ((2)) ((3))'}), ConcreteTempl...
]
Here is a snippet: <|code_start|> assert TemplateChange(old_template, new_template).has_different_placeholders == should_differ @pytest.mark.parametrize( "old_template, new_template, placeholders_added", [ ( ConcreteTemplate({'content': '((1)) ((2)) ((3))'}), ConcreteTemplate({'...
]
Next line prediction: <|code_start|> def foo(self): raise AttributeError('Something has gone wrong') with pytest.raises(AttributeError) as e: Custom(json_response).foo assert str(e.value) == 'Something has gone wrong' def test_dynamic_properties_are_introspectable(): class Cu...
def test_serialised_model_collection_returns_models_from_list():
Given the following code snippet before the placeholder: <|code_start|> "Can't instantiate abstract class CustomCollection with abstract method model" ) def test_looks_up_from_dict(): class Custom(SerialisedModel): ALLOWED_PROPERTIES = {'foo'} assert Custom({'foo': 'bar'}).foo == ...
{'foo': 'bar'}, # Should still raise an exception
Predict the next line for this snippet: <|code_start|> class TemplateChange(): def __init__(self, old_template, new_template): self.old_placeholders = InsensitiveDict.from_keys(old_template.placeholders) self.new_placeholders = InsensitiveDict.from_keys(new_template.placeholders) @property <...
def has_different_placeholders(self):
Given the following code snippet before the placeholder: <|code_start|> def test_request_id_is_set_on_response(app): request_helper.init_app(app) client = app.test_client() <|code_end|> , predict the next line using imports from the current file: from notifications_utils import request_helper and context in...
with app.app_context():
Predict the next line after this snippet: <|code_start|>#!/usr/bin/env python version_parts = ('major', 'minor', 'patch') parser = argparse.ArgumentParser() parser.add_argument('version_part', choices=version_parts) version_part = parser.parse_args().version_part current_major, current_minor, current_patch = map(i...
'minor': (current_major, current_minor + 1, 0),
Predict the next line after this snippet: <|code_start|> {'placeholder': '<em>without</em>'}, 'string without html', 'string &lt;em&gt;without&lt;/em&gt; html', 'string <em>without</em> html', ), ( 'string ((<em>conditional</em>??<em>placeholder</em>)) html', {}, ...
),
Based on the snippet: <|code_start|> "values", [[], False] ) def test_errors_for_invalid_values(values): with pytest.raises(TypeError): ConcreteTemplate({"content": ''}, values) def test_matches_keys_to_placeholder_names(): template = ConcreteTemplate({"content": "hello ((name))"}) template.v...
"the quick ((colour)) fox",
Given the code snippet: <|code_start|> template.values = {'NAME': 'Chris', 'Town': 'London'} assert template.values == {'name': 'Chris', 'Town': 'London'} assert template.additional_data == {'Town'} template.values = None assert template.missing_data == ['name'] @pytest.mark.parametrize( "temp...
(
Next line prediction: <|code_start|> mocked_put.assert_called_once_with( Body=contents, ServerSideEncryption='AES256', ContentType=content_type, ) def test_s3upload_save_file_to_bucket_with_contenttype(mocker): content_type = 'image/png' mocked = mocker.patch('notifications_util...
region=region,
Here is a snippet: <|code_start|> region=region, bucket_name=bucket, file_location=location, tags={'a': '1/2', 'b': 'x y'}, ) mocked_put = mocked.return_value.Object.return_value.put # make sure tags were a urlencoded query string encoded_tags = mocked_put.call_args[1]['T...
mocked_get = mocked.return_value.Object.return_value.get
Continue the code snippet: <|code_start|> s3upload(filedata=contents, region=region, bucket_name=bucket, file_location=location, content_type=content_type) mocked_put = mocked.return_value.Object.return_value.put mocked_put.assert_called_once_with( ...
bucket_name=bucket,
Based on the snippet: <|code_start|> class FakeService(): id = "1234" @pytest.fixture def app(): flask_app = Flask(__name__) ctx = flask_app.app_context() ctx.push() yield flask_app ctx.pop() @pytest.fixture <|code_end|> , predict the immediate next line with the help of imports: import...
def celery_app(mocker):
Based on the snippet: <|code_start|> @pytest.mark.parametrize('unsafe_string, expected_safe', [ ('name with spaces', 'name.with.spaces'), ('singleword', 'singleword'), ('UPPER CASE', 'upper.case'), ('Service - with dash', 'service.with.dash'), ('lots of spaces', 'lots.of.spaces'), ('name.w...
('trailing-', 'trailing-'),
Predict the next line after this snippet: <|code_start|> @pytest.mark.parametrize('unsafe_string, expected_safe', [ ('name with spaces', 'name.with.spaces'), ('singleword', 'singleword'), ('UPPER CASE', 'upper.case'), ('Service - with dash', 'service.with.dash'), ('lots of spaces', 'lots.of.s...
('UPPER CASE', 'upper-case'),
Given snippet: <|code_start|> @pytest.mark.parametrize('header,secrets,expected', [ ({'X-Custom-Forwarder': 'right_key'}, ['right_key', 'old_key'], (True, 'Key used: 1')), ({'X-Custom-Forwarder': 'right_key'}, ['right_key'], (True, 'Key used: 1')), ({'X-Custom-Forwarder': 'right_key'}, ['right_key', ''],...
(['old_key', 'right_key'], (False, 'Header missing')),
Using the snippet: <|code_start|> @pytest.mark.parametrize('header,secrets,expected', [ ({'X-Custom-Forwarder': 'right_key'}, ['right_key', 'old_key'], (True, 'Key used: 1')), ({'X-Custom-Forwarder': 'right_key'}, ['right_key'], (True, 'Key used: 1')), ({'X-Custom-Forwarder': 'right_key'}, ['right_key', ...
])
Continue the code snippet: <|code_start|> notify_celery, ): super_apply = mocker.patch('celery.Celery.send_task') g.request_id = '1234' notify_celery.send_task( 'some-task', None, # args None, # kwargs headers=None, # other kwargs (task retry set headers to "None") ...
notify_celery.send_task('some-task')
Given the following code snippet before the placeholder: <|code_start|> def test_bytes_to_base64_to_bytes(): b = os.urandom(32) b64 = bytes_to_base64(b) assert base64_to_bytes(b64) == b @pytest.mark.parametrize('url_val', [ 'AAAAAAAAAAAAAAAAAAAAAQ', 'AAAAAAAAAAAAAAAAAAAAAQ=', # even though thi...
])
Predict the next line after this snippet: <|code_start|> assert base64_to_bytes(b64) == b @pytest.mark.parametrize('url_val', [ 'AAAAAAAAAAAAAAAAAAAAAQ', 'AAAAAAAAAAAAAAAAAAAAAQ=', # even though this has invalid padding we put extra =s on the end so this is okay 'AAAAAAAAAAAAAAAAAAAAAQ==', ]) def test...
with pytest.raises(Exception):
Predict the next line for this snippet: <|code_start|> def test_bytes_to_base64_to_bytes(): b = os.urandom(32) b64 = bytes_to_base64(b) assert base64_to_bytes(b64) == b @pytest.mark.parametrize('url_val', [ 'AAAAAAAAAAAAAAAAAAAAAQ', 'AAAAAAAAAAAAAAAAAAAAAQ=', # even though this has invalid pad...
])
Using the snippet: <|code_start|> def test_bytes_to_base64_to_bytes(): b = os.urandom(32) b64 = bytes_to_base64(b) assert base64_to_bytes(b64) == b @pytest.mark.parametrize('url_val', [ 'AAAAAAAAAAAAAAAAAAAAAQ', 'AAAAAAAAAAAAAAAAAAAAAQ=', # even though this has invalid padding we put extra =s ...
])
Here is a snippet: <|code_start|> @pytest.fixture(scope='function') def antivirus(app, mocker): client = AntivirusClient() app.config['ANTIVIRUS_API_HOST'] = 'https://antivirus' app.config['ANTIVIRUS_API_KEY'] = 'test-antivirus-key' <|code_end|> . Write the next line using the current file imports: impo...
client.init_app(app)
Given the following code snippet before the placeholder: <|code_start|> client = AntivirusClient() app.config['ANTIVIRUS_API_HOST'] = 'https://antivirus' app.config['ANTIVIRUS_API_KEY'] = 'test-antivirus-key' client.init_app(app) return client def test_scan_document(antivirus, rmock): document ...
assert excinfo.value.message == 'Antivirus error'
Predict the next line for this snippet: <|code_start|> class Placeholder: def __init__(self, body): # body shouldn’t include leading/trailing brackets, like (( and )) self.body = body.lstrip('(').rstrip(')') @classmethod def from_match(cls, match): return cls(match.group(0)) ...
@property
Predict the next line after this snippet: <|code_start|> class Placeholder: def __init__(self, body): # body shouldn’t include leading/trailing brackets, like (( and )) self.body = body.lstrip('(').rstrip(')') @classmethod def from_match(cls, match): return cls(match.group(0)) ...
def name(self):
Predict the next line after this snippet: <|code_start|> class Placeholder: def __init__(self, body): # body shouldn’t include leading/trailing brackets, like (( and )) self.body = body.lstrip('(').rstrip(')') @classmethod def from_match(cls, match): return cls(match.group(0)) ...
if self.is_conditional():
Next line prediction: <|code_start|>class Placeholder: def __init__(self, body): # body shouldn’t include leading/trailing brackets, like (( and )) self.body = body.lstrip('(').rstrip(')') @classmethod def from_match(cls, match): return cls(match.group(0)) def is_conditional(se...
raise ValueError('{} not conditional'.format(self))
Given snippet: <|code_start|> def test_international_billing_rates_exists(): assert INTERNATIONAL_BILLING_RATES['1']['names'][0] == 'Canada' @pytest.mark.parametrize('country_prefix, values', sorted(INTERNATIONAL_BILLING_RATES.items())) def test_international_billing_rates_are_in_correct_format(country_prefix, ...
def test_country_codes():
Based on the snippet: <|code_start|> def test_international_billing_rates_exists(): assert INTERNATIONAL_BILLING_RATES['1']['names'][0] == 'Canada' @pytest.mark.parametrize('country_prefix, values', sorted(INTERNATIONAL_BILLING_RATES.items())) def test_international_billing_rates_are_in_correct_format(country_p...
assert isinstance(country_prefix, str)
Given the code snippet: <|code_start|> def test_international_billing_rates_exists(): assert INTERNATIONAL_BILLING_RATES['1']['names'][0] == 'Canada' @pytest.mark.parametrize('country_prefix, values', sorted(INTERNATIONAL_BILLING_RATES.items())) <|code_end|> , generate the next line using the imports in this fi...
def test_international_billing_rates_are_in_correct_format(country_prefix, values):
Predict the next line after this snippet: <|code_start|> class AnyStringWith(str): def __eq__(self, other): return self in other def test_should_call_statsd(app, mocker): app.config['NOTIFY_ENVIRONMENT'] = "test" app.config['NOTIFY_APP_NAME'] = "api" app.config['STATSD_HOST'] = "localhost" ...
assert test_function()
Given the following code snippet before the placeholder: <|code_start|> def test_should_return_payload_from_signed_token(): payload = 'email@something.com' token = generate_token(payload, 'secret-key', 'dangerous-salt') token = urllib.parse.unquote(token) assert payload == check_token(token, 'secret-...
pass
Continue the code snippet: <|code_start|> def test_should_return_payload_from_signed_token(): payload = 'email@something.com' token = generate_token(payload, 'secret-key', 'dangerous-salt') token = urllib.parse.unquote(token) assert payload == check_token(token, 'secret-key', 'dangerous-salt', 30) ...
fail('Expected a SignatureExpired exception')
Predict the next line for this snippet: <|code_start|> def _uppercase(value): return value.upper() def _append(value, to_append): return value + to_append def _prepend_with_service_name(value, service_name=None): return '{}: {}'.format(service_name, value) def test_take(): assert 'Service name: H...
_append, '!'
Given snippet: <|code_start|> handlers = logging.get_handlers(app) assert len(handlers) == 1 assert type(handlers[0]) == builtin_logging.StreamHandler assert type(handlers[0].formatter) == logging.CustomLogFormatter assert not (tmpdir / 'foo').exists() def test_get_handlers_sets_up_logging_approp...
dir_contents = tmpdir.listdir()
Given the code snippet: <|code_start|> @pytest.mark.parametrize('input_value', [ 'foo', 100, True, False, None, ]) def test_utc_string_to_aware_gmt_datetime_rejects_bad_input(input_value): with pytest.raises(Exception): utc_string_to_aware_gmt_datetime(input_value) def test_utc_stri...
('2000-06-1T20:01+00:00', '21:01'),