Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Given the following code snippet before the placeholder: <|code_start|> def f(a, b, c, *args): raise NotImplementedError() sig = FunctionSignature(f) with self.assertRaises(UnknownArguments): sig.get_normalized_args((1, 2, 3, 4), dict(d=5)) def test__kwargs(self): ...
with self.assertRaises(InvalidKeywordArgument):
Predict the next line after this snippet: <|code_start|> def _assert_argument_names(self, sig, names): self.assertEquals([arg.name for arg in sig._args], names) def _test_function_signature(self, func, expected_signature, has_varargs=False, has_varkwargs=False ): ...
with self.assertRaises(MissingArguments):
Based on the snippet: <|code_start|> value = inst._cache[self.__name__] except (KeyError, AttributeError): value = self.fget(inst) try: cache = inst._cache except AttributeError: cache = inst._cache = {} cache[self.__name...
@wraps(func)
Using the snippet: <|code_start|> """Decorator that caches a method's return value each time it is called. If called later with the same arguments, the cached value is returned, and not re-evaluated. decorated class must implement inst.init_cache() which creates inst._cache dictionary. ...
return (tuple(args), frozenset(iteritems(kwargs)))
Given the code snippet: <|code_start|> _PYTHON_VERSION = sys.version_info if _PYTHON_VERSION >= (3,): else: if _PYTHON_VERSION >= (3,5): def contextmanager(func): <|code_end|> , generate the next line using the imports in this file: import sys from .decorators import wraps from contextlib import _GeneratorC...
@wraps(func)
Based on the snippet: <|code_start|> def wraps(wrapped): """ a convenience function on top of functools.wraps: - adds the original function to the wrapped function as __wrapped__ attribute.""" def new_decorator(f): returned = functools.wraps(wrapped)(f) returned.__wrapped__ = wrapped ...
monkey_patch(inspect, "getargspec", inspect_getargspec_patch)
Predict the next line after this snippet: <|code_start|> >>> avg.as_version('2.0') == 'Average' True """ def __init__(self, key, list_or_dict=None, default_version=ALL, **kwargs): super(Value, self).__init__(default_version) if isinstance(key, Value): key = str(key) ...
self._values = OrderedDict((_convert(k), values[k]) for k in reversed(sorted(values.keys())))
Here is a snippet: <|code_start|> An Enum class for python. >>> x = Enum(VersionedValue("True",{'1.0': ["TRUE"], '2.0': ["True","yes"]}), VersionedValue("False",{'1.0': ["FALSE"], '2.0': ["False","No"]})) >...
for value in itervalues(self._values):
Given the following code snippet before the placeholder: <|code_start|> class RecursiveGetattrTest(TestCase): def setUp(self): super(RecursiveGetattrTest, self).setUp() self.obj = Object() self.obj.a = Object() self.obj.a.b = Object() self.obj.a.b.value = self.value = Object(...
self.assertIs(recursive_getattr(self.obj, 'a.b.value'),
Next line prediction: <|code_start|> class MethodMapTest(TestCase): def test__method_map(self): class MyObj(object): <|code_end|> . Use current file imports: (import platform from .test_utils import TestCase from infi.pyutils.method_map import MethodMap) and context including class names, function names, ...
METHODS = MethodMap()
Continue the code snippet: <|code_start|> class Predicate(Functor): def __init__(self, func=None): super(Predicate, self).__init__() self._func = func def __call__(self, *args, **kwargs): return self._func(*args, **kwargs) def __repr__(self): return "<Predicate {0!r}>".format...
AlwaysTrue = Predicate(Always(True))
Based on the snippet: <|code_start|> def __init__(self, pred): super(Not, self).__init__() self._pred = pred def __call__(self, *args, **kwargs): return not self._pred(*args, **kwargs) def __repr__(self): return "<not {0!r}>".format(self._pred) class Identity(Predicate): ...
return all(getattr(obj, attr, _MISSING) == value for attr, value in iteritems(self._attributes))
Next line prediction: <|code_start|># -*- coding: utf-8 -*- """ Django TailorDev Biblio Test forms """ from __future__ import unicode_literals def test_text_to_list(): """Test text_to_list utils""" inputs = [ "foo,bar,lol", "foo , bar, lol", "foo\nbar\nlol", "foo,\nbar,\nlol"...
result = text_to_list(input)
Given the code snippet: <|code_start|> "foo,,bar,\nlol", ] expected = ["bar", "foo", "lol"] for input in inputs: result = text_to_list(input) result.sort() assert result == expected class EntryBatchImportFormTests(TestCase): """ Tests for the EntryBatchImportForm ...
form = EntryBatchImportForm(input)
Given snippet: <|code_start|># -*- coding: utf-8 -*- class Command(BaseCommand): help = "Import entries from a BibTex file" def _get_logger(self): logger = logging.getLogger("td_biblio") return logger def add_arguments(self, parser): parser.add_argument("bibtex", help="The path...
loader = BibTeXLoader()
Given snippet: <|code_start|> ) def clean_pmids(self): """Transform raw data in a PMID list""" pmids = text_to_list(self.cleaned_data["pmids"]) for pmid in pmids: pmid_validator(pmid) return pmids def clean_dois(self): """Transform raw data in a DOI list"...
return Author.objects.values_list("id", "last_name")
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- try: except ImportError: @pytest.mark.django_db class PublicationDateFilterTests(TestCase): """Tests for the publication_date filter""" def setUp(self): """Setup a publication database""" # Stand...
EntryFactory(is_partial_publication_date=False)
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*- """ TailorDev Bibliography Test factories. """ @pytest.mark.django_db class FuzzyPagesTestCase(TestCase): def test_simple_call(self): """Test the Fuzzy pages attribute implicit call""" entry = EntryFactory() ...
entry = EntryFactory(pages=FuzzyPages(1, 10))
Given snippet: <|code_start|># -*- coding: utf-8 -*- """ TailorDev Bibliography Test factories. """ @pytest.mark.django_db class FuzzyPagesTestCase(TestCase): def test_simple_call(self): """Test the Fuzzy pages attribute implicit call""" <|code_end|> , continue by predicting the next line. Consider cur...
entry = EntryFactory()
Next line prediction: <|code_start|> self.verticalLayout.setSpacing(1) self.verticalLayout.setObjectName("verticalLayout") self.topListEntryLayout = QtWidgets.QHBoxLayout() self.topListEntryLayout.setSpacing(1) self.topListEntryLayout.setObjectName("topListEntryLayout") sp...
self.entryListWidget = MixListWidget(listEntryDialog)
Continue the code snippet: <|code_start|> font = QtGui.QFont() font.setBold(False) font.setWeight(50) self.actIntervalLabel.setFont(font) self.actIntervalLabel.setAlignment(QtCore.Qt.AlignCenter) self.actIntervalLabel.setObjectName("actIntervalLabel") self.actShort...
self.actTagLineEdit = HoverLineEdit(actionDialog)
Given the following code snippet before the placeholder: <|code_start|># Form implementation generated from reading ui file 'ActionSetup.ui' # # Created by: PyQt5 UI code generator 5.6 # # WARNING! All changes made in this file will be lost! class Ui_actionDialog(object): def setupUi(self, actionDialog): ...
self.actTriggerLineEdit = KeyBindLineEdit(actionDialog)
Next line prediction: <|code_start|> self.actPathLineEdit.setObjectName("actPathLineEdit") self.actShortInputLayout.addWidget(self.actPathLineEdit, 4, 2, 1, 1) self.actTriggerLabel = QtWidgets.QLabel(actionDialog) font = QtGui.QFont() font.setBold(False) font.setWeight(50)...
self.actSelectInputList = KeyListWidget(actionDialog)
Given snippet: <|code_start|># -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'MapProj.ui' # # Created by: PyQt5 UI code generator 5.6 # # WARNING! All changes made in this file will be lost! class Ui_mapProjDialog(object): def setupUi(self, mapProjDialog): mapProjDialog.setOb...
self.epsgLineEdit = HoverLineEdit(mapProjDialog)
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'Configuration.ui' # # Created by: PyQt5 UI code generator 5.6 # # WARNING! All changes made in this file will be lost! class Ui_ConfDialog(object): def setupUi(self, ConfDialog): ...
self.confPrefList = MixListWidget(ConfDialog)
Next line prediction: <|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. class UserViewSet(viewsets.ViewSet...
user = User.objects.all()
Continue the code snippet: <|code_start|># WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. class UserViewSet(viewsets.ViewSet): permission_classes = [AllowAny, ] """ A simple ViewSet t...
serializer = UserSerializer(user, many=True)
Given the code snippet: <|code_start|># License for the specific language governing permissions and limitations # under the License. class UserViewSet(viewsets.ViewSet): permission_classes = [AllowAny, ] """ A simple ViewSet that for listing or retrieving users. user_list = UserViewSet.as_view({ ...
return send_response(request.method, serializer)
Using the snippet: <|code_start|># 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 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for ...
data = Data.objects.all()
Given snippet: <|code_start|> # This API endpoint needs to be modified for enabling directly # upload any kind of data without requiring hard work on frontend def list(self, request): """ Lists all experiments for a particular user --- """ data = Data.objects.all() ...
user=User.objects.get(pk=int(data["user_id"])),
Given the following code snippet before the placeholder: <|code_start|># # Unless required by applicable law or agreed to in writing, software # 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...
serializer = DataSerializer(data, many=True)
Given snippet: <|code_start|># Unless required by applicable law or agreed to in writing, software # 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 limitati...
return send_response(request.method, serializer)
Based on the snippet: <|code_start|># 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 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or...
exp = Experiment.objects.get(pk=self.experiment)
Next line prediction: <|code_start|> for elem in tmp: node = elem.split(":") if len(node) > 1: first_node = node[0] second_node = node[1] else: first_node = node[0] second_node = '' if second_node in ...
comp = Component.objects.get(pk=component_id)
Predict the next line for this snippet: <|code_start|> comp = Component.objects.get(pk=component_id) print "Component_id", component_id, " ", comp.operation_type op = comp.operation_type if op.function_type == 'Create': if op.function_arg == 'Table': ...
classifier = Classifier(
Predict the next line for this 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...
exp = Experiment.objects.get(pk=self.experiment)
Based on the snippet: <|code_start|> self.threadID = thread_id self.name = name self.experiment = experiment self.comp_id = component_id self.result = {} self.max_results = max_results self.cache_results = cache_results print "Submitting topology to storm. ...
comp = Component.objects.get(pk=component_id)
Based on the snippet: <|code_start|># Copyright 2015 Cisco Inc. # # 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 appl...
exp = Workflow.objects.all()
Given snippet: <|code_start|> class WorkFlowViewSet(viewsets.ViewSet): def list(self, request): """ List all workflows for an experiment --- """ exp = Workflow.objects.all() serializer = WorkflowSerializer(exp, many=True) return send_response(request.method,...
exp = Experiment.objects.get(pk=exp_id)
Given the following code snippet before the placeholder: <|code_start|># Copyright 2015 Cisco Inc. # # 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/LICE...
serializer = WorkflowSerializer(exp, many=True)
Given the code snippet: <|code_start|># Copyright 2015 Cisco Inc. # # 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 ap...
return send_response(request.method, serializer)
Predict the next line after this snippet: <|code_start|># Copyright 2015 Cisco Inc. # # 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 # # Unl...
exp = Experiment.objects.all()
Given snippet: <|code_start|># Copyright 2015 Cisco Inc. # # 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 ...
serializer = ExperimentSerializer(exp, many=True)
Using the snippet: <|code_start|># Copyright 2015 Cisco Inc. # # 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 applica...
return send_response(request.method, serializer)
Here is a snippet: <|code_start|> def nonfatal(func, *args): try: func(*args) except Fatal as e: <|code_end|> . Write the next line using the current file imports: import socket import subprocess as ssubprocess from sshuttle.helpers import log, debug1, Fatal, family_to_string, get_env and context fro...
log('error: %s' % e)
Predict the next line for this snippet: <|code_start|> try: func(*args) except Fatal as e: log('error: %s' % e) def ipt_chain_exists(family, table, name): if family == socket.AF_INET6: cmd = 'ip6tables' elif family == socket.AF_INET: cmd = 'iptables' else: ra...
debug1('%s' % ' '.join(argv))
Predict the next line after this snippet: <|code_start|> def nonfatal(func, *args): try: func(*args) <|code_end|> using the current file's imports: import socket import subprocess as ssubprocess from sshuttle.helpers import log, debug1, Fatal, family_to_string, get_env and any relevant context from othe...
except Fatal as e:
Using the snippet: <|code_start|> def nonfatal(func, *args): try: func(*args) except Fatal as e: log('error: %s' % e) def ipt_chain_exists(family, table, name): if family == socket.AF_INET6: cmd = 'ip6tables' elif family == socket.AF_INET: cmd = 'iptables' else: <|...
raise Exception('Unsupported family "%s"' % family_to_string(family))
Given snippet: <|code_start|> def nonfatal(func, *args): try: func(*args) except Fatal as e: log('error: %s' % e) def ipt_chain_exists(family, table, name): if family == socket.AF_INET6: cmd = 'ip6tables' elif family == socket.AF_INET: cmd = 'iptables' else: ...
output = ssubprocess.check_output(argv, env=get_env())
Based on the snippet: <|code_start|> return 0 # still connecting self.wsock.setblocking(False) try: return _nb_clean(os.write, self.wsock.fileno(), buf) except OSError: _, e = sys.exc_info()[:2] if e.errno == errno.EPIPE: debug1('%r...
return b('') # unexpected error... we'll call it EOF
Continue the code snippet: <|code_start|> return rb = self.uread() if rb: self.buf.append(rb) if rb == b(''): # empty string means EOF; None means temporarily empty self.noread() def copy_to(self, outwrap): if self.buf and self.buf[0]: ...
log('--no callback defined-- %r' % self)
Predict the next line for this snippet: <|code_start|> if e.args[0] == errno.EINVAL: pass elif e.args[0] not in (errno.ENOTCONN, errno.ENOTSOCK): raise except AttributeError: pass return 'unknown' _swcount = 0 class SockWrapper: def __init__(self, rsock, w...
debug1('%r: deleting (%d remain)' % (self, _swcount))
Given snippet: <|code_start|> # automatically, so this code won't run. realerr = self.rsock.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR) e = socket.error(realerr, os.strerror(realerr)) debug3('%r: fixed conn...
debug2('%r: done reading' % self)
Here is a snippet: <|code_start|> errno.EHOSTUNREACH, errno.ENETUNREACH, errno.EHOSTDOWN, errno.ENETDOWN, errno.ENETUNREACH, errno.ECONNABORTED, errno.ECONNRESET] def _add(socks, elem): if elem not in socks: socks.append(elem) def _fds(socks): out = [] ...
debug3('%s: err was: %s' % (func.__name__, e))
Given snippet: <|code_start|> try: os.set_blocking(self.wfile.fileno(), False) except AttributeError: # python < 3.5 flags = fcntl.fcntl(self.wfile.fileno(), fcntl.F_GETFL) flags |= os.O_NONBLOCK flags = fcntl.fcntl(self.wfile.fileno(), fcntl.F_...
raise Fatal('other end: %r' % e)
Given snippet: <|code_start|> return hostwatch.hw_main(opt.subnets, opt.auto_hosts) else: # parse_subnetports() is used to create a list of includes # and excludes. It is called once for each parameter and # returns a list of one or more items for each subnet (it ...
family, ip, port = parse_ipport(ip)
Given the code snippet: <|code_start|> if opt.wrap: ssnet.MAX_CHANNEL = opt.wrap if opt.latency_buffer_size: ssnet.LATENCY_BUFFER_SIZE = opt.latency_buffer_size helpers.verbose = opt.verbose try: if opt.firewall: if opt.subnets or opt.subnets_file: par...
nslist = [family_ip_tuple(ns) for ns in opt.ns_hosts]
Predict the next line after this snippet: <|code_start|> def main(): opt = parser.parse_args() if opt.sudoers or opt.sudoers_no_modify: if platform.platform().startswith('OpenBSD'): <|code_end|> using the current file's imports: import re import socket import platform import sshuttle.helpers as help...
log('Automatic sudoers does not work on BSD')
Based on the snippet: <|code_start|> ssyslog.close_stdin() ssyslog.stdout_to_syslog() ssyslog.stderr_to_syslog() return_code = client.main(ipport_v6, ipport_v4, opt.ssh_cmd, remotename,...
except Fatal as e:
Based on the snippet: <|code_start|> "# command as root.\n" def build_config(user_name): content = warning_msg content += template % { 'ca': command_alias, 'dist_packages': path_to_dist_packages, 'py': sys.executable, 'path': path_to_sshuttle, 'user_name': ...
log('Failed updating sudoers file.')
Next line prediction: <|code_start|> def build_config(user_name): content = warning_msg content += template % { 'ca': command_alias, 'dist_packages': path_to_dist_packages, 'py': sys.executable, 'path': path_to_sshuttle, 'user_name': user_name, } return content ...
debug1(streamdata)
Given snippet: <|code_start|>"""When sshuttle is run via a systemd service file, we can communicate to systemd about the status of the sshuttle process. In particular, we can send READY status to tell systemd that sshuttle has completed startup and send STOPPING to indicate that sshuttle is beginning shutdown. For det...
debug1("Error creating socket to notify systemd: %s" % e)
Given the code snippet: <|code_start|> if password is not None: os.environ['SSHPASS'] = str(password) argv = (["sshpass", "-e"] + sshl + portl + [rhost, '--', pycmd]) else: argv = (sshl + portl + ...
debug2('executing: %r' % argv)
Given snippet: <|code_start|> # # Specifying the exact python program to run with --python # avoids many of the issues above. However, if # you have a restricted shell on remote, you may only be # able to run python if it is in your PATH (and you can't ...
abs_path = which(argv[0])
Continue the code snippet: <|code_start|> # avoids many of the issues above. However, if # you have a restricted shell on remote, you may only be # able to run python if it is in your PATH (and you can't # run programs specified with an absolute path). In that ...
raise Fatal("Failed to find '%s' in path %s" % (argv[0], get_path()))
Predict the next line after this snippet: <|code_start|> # avoids many of the issues above. However, if # you have a restricted shell on remote, you may only be # able to run python if it is in your PATH (and you can't # run programs specified with an absolute path). In th...
raise Fatal("Failed to find '%s' in path %s" % (argv[0], get_path()))
Predict the next line for this snippet: <|code_start|> POLL_TIME = 60 * 15 NETSTAT_POLL_TIME = 30 CACHEFILE = os.path.expanduser('~/.sshuttle.hosts') # Have we already failed to write CACHEFILE? CACHE_WRITE_FAILED = False hostnames = {} queue = {} try: null = open(os.devnull, 'wb') except IOError: _, e = sys...
log('warning: %s' % e)
Continue the code snippet: <|code_start|> % CACHEFILE) return for line in f: words = line.strip().split(',') if len(words) == 2: (name, ip) = words name = re.sub(r'[^-\w\.]', '-', name).strip() # Remove characters that shouldn't be in IP...
debug1('Found: %s: %s' % (name, ip))
Predict the next line after this snippet: <|code_start|> ip = re.sub(r'[^0-9.]', '', ip).strip() if name and ip: found_host(name, ip) def found_host(name, ip): """The provided name maps to the given IP. Add the host to the hostnames list, send the host to the sshuttle...
debug2(' > Reading %s on remote host' % filename)
Predict the next line for this snippet: <|code_start|> hostname = re.sub(r'\..*', '', name) hostname = re.sub(r'[^-\w\.]', '_', hostname) if (ip.startswith('127.') or ip.startswith('255.') or hostname == 'localhost'): return if hostname != name: found_host(hostname, ip) ...
debug3('< %s %r' % (ip, names))
Next line prediction: <|code_start|>def _check_revdns(ip): """Use reverse DNS to try to get hostnames from an IP addresses.""" debug2(' > rev: %s' % ip) try: r = socket.gethostbyaddr(ip) debug3('< %s' % r[0]) check_host(r[0]) found_host(r[0], ip) except (OSError, socke...
env=get_env())
Here is a snippet: <|code_start|> Non-existing profiles shouldn't be found :param sqlalchemy.orm.session.Session dbsession: pytest fixture for database session :param list(str) testdata: pytest fixture listing test data tokens. """ assert '1ced@4c41.a936' not in testdata assert profiles.Profiles....
group1 = groups.Groups(name='dfe5cf8f-1da7-4b70-aefb-8236cd894c5d')
Predict the next line for this snippet: <|code_start|> :param sqlalchemy.orm.session.Session dbsession: pytest fixture for database session :param list(str) testdata: pytest fixture listing test data tokens. """ # Include testdata so we know there are at least some records in table to search assert p...
login = logins.Logins(password='104d4cec-9425-4e37-9de2-242c6d772eea')
Predict the next line for this snippet: <|code_start|> :param sqlalchemy.orm.session.Session dbsession: pytest fixture for database session :param list(str) testdata: pytest fixture listing test data tokens. """ assert '1ced@4c41.a936' not in testdata assert profiles.Profiles.get_by_email('1ced@4c41....
membership1 = memberships.Memberships(group=group1)
Predict the next line after this snippet: <|code_start|>""" Tests for the Profiles Model """ from __future__ import (absolute_import, division, print_function, unicode_literals) try: except ImportError: print("WARNING: Cannot Load builtins for py3 compatibility.", file=sys.stderr) warnings.simplefilter("error"...
profile = profiles.Profiles(full_name=record['full_name'], email=record['email'])
Next line prediction: <|code_start|> """ Should convert Class Names to Database Table names. """ test_strings = { 'test': 'test', 'Test': 'test', 'TEST': 'test', # https://stackoverflow.com/a/1176023 'CamelCase': 'camel_case', 'CamelCamelCase': 'camel_camel_case', ...
assert utilities.camel_to_delimiter_separated(camel) == snake
Predict the next line for this snippet: <|code_start|>""" Tests for our customized marshmallow Schema """ from __future__ import (absolute_import, division, print_function, unicode_literals) try: except ImportError: print("WARNING: Cannot Load builtins for py3 compatibility.", file=sys.stderr) warnings.simplef...
class FakeRelation(bases.BaseModel):
Here is a snippet: <|code_start|>""" Tests for the Base Model """ from __future__ import (absolute_import, division, print_function, unicode_literals) try: except ImportError: print("WARNING: Cannot Load builtins for py3 compatibility.", file=sys.stderr) warnings.simplefilter("error") # Make All warnings erro...
class DummyBase(bases.Base): # pylint: disable=too-few-public-methods
Based on the snippet: <|code_start|>""" Tests for Relationship endpoints. """ from __future__ import (absolute_import, division, print_function, unicode_literals) try: except ImportError: print("WARNING: Cannot Load builtins for py3 compatibility.", file=sys.stderr) warnings.simplefilter("error") # Make All w...
class Departments(bases.BaseModel):
Given the code snippet: <|code_start|> Remove the parent relationship of a Department. :param sqlalchemy.orm.session.Session dbsession: pytest fixture for database session :param list(str) testdata: pytest fixture listing test data tokens. """ resource = ParentRelationship() response = resource.g...
with pytest.raises(Conflict):
Given the code snippet: <|code_start|> :param sqlalchemy.orm.session.Session dbsession: pytest fixture for database session :param list(str) testdata: pytest fixture listing test data tokens. """ resource = ChildrenRelationship() response = resource.get(22) # Just above this section is an example...
with pytest.raises(NotFound):
Given the code snippet: <|code_start|>""" Tests for Related model endpoints. """ from __future__ import (absolute_import, division, print_function, unicode_literals) try: except ImportError: print("WARNING: Cannot Load builtins for py3 compatibility.", file=sys.stderr) warnings.simplefilter("error") # Make Al...
class Persons(bases.BaseModel):
Given the following code snippet before the placeholder: <|code_start|> response = resource.get(20) assert response == {'data': [{'attributes': {'name': 'Impossible Stand'}, 'id': '21', 'links': {'self': '/persons/21'}, ...
with pytest.raises(NotFound):
Given snippet: <|code_start|>""" Tests for our customized marshmallow-sqlalchemy converter to support JSONAPI Relationship fields. """ from __future__ import (absolute_import, division, print_function, unicode_literals) try: except ImportError: print("WARNING: Cannot Load builtins for py3 compatibility.", file=sys....
class Nodes(bases.BaseModel):
Using the snippet: <|code_start|> class ModelConverter(marshmallow_sqlalchemy.ModelConverter): """ Customize SQLAlchemy Model Converter to use JSON API Relationships. """ # property2field will convert the Relationship to a List field if the prop.direction.name in # this mapping returns True. Hack to work...
kwargs['type_'] = utilities.camel_to_delimiter_separated(prop.mapper.class_.__name__,
Next line prediction: <|code_start|>""" Customized Marshmallow-SQLAlchemy ModelConverter to combine Related and Relationship fields. """ from __future__ import (absolute_import, division, print_function, unicode_literals) try: except ImportError: print("WARNING: Cannot Load builtins for py3 compatibility.", file=sy...
return Relationship
Given the following code snippet before the placeholder: <|code_start|>""" Configuration for py.tests. Does things like setup the database and flask app for individual tests. https://gist.github.com/alexmic/7857543 """ warnings.simplefilter("error") # Make All warnings errors while testing. # Setup Stream logging ...
log.init_logging()
Given the code snippet: <|code_start|>""" from __future__ import (absolute_import, division, print_function, unicode_literals) try: except ImportError: print("WARNING: Cannot Load builtins for py3 compatibility.", file=sys.stderr) warnings.simplefilter("error") # Make All warnings errors while testing. @pyte...
token = autht.AuthenticationTokens(login=login)
Continue the code snippet: <|code_start|>Tests for Authentication Tokens """ from __future__ import (absolute_import, division, print_function, unicode_literals) try: except ImportError: print("WARNING: Cannot Load builtins for py3 compatibility.", file=sys.stderr) warnings.simplefilter("error") # Make All wa...
login = logins.Logins(password=record['password'], profile=profile)
Predict the next line after this snippet: <|code_start|>""" Tests for Authentication Tokens """ from __future__ import (absolute_import, division, print_function, unicode_literals) try: except ImportError: print("WARNING: Cannot Load builtins for py3 compatibility.", file=sys.stderr) warnings.simplefilter("err...
profile = profiles.Profiles(full_name=record['full_name'], email=record['email'])
Predict the next line after this snippet: <|code_start|>""" from __future__ import (absolute_import, division, print_function, unicode_literals) try: except ImportError: print("WARNING: Cannot Load builtins for py3 compatibility.", file=sys.stderr) warnings.simplefilter("error") # Make All warnings errors whi...
token = fpt.ForgotPasswordTokens(login=login)
Continue the code snippet: <|code_start|>Tests for Forgot Password Tokens """ from __future__ import (absolute_import, division, print_function, unicode_literals) try: except ImportError: print("WARNING: Cannot Load builtins for py3 compatibility.", file=sys.stderr) warnings.simplefilter("error") # Make All w...
login = logins.Logins(password=record['password'], profile=profile)
Next line prediction: <|code_start|>""" Tests for Forgot Password Tokens """ from __future__ import (absolute_import, division, print_function, unicode_literals) try: except ImportError: print("WARNING: Cannot Load builtins for py3 compatibility.", file=sys.stderr) warnings.simplefilter("error") # Make All wa...
profile = profiles.Profiles(full_name=record['full_name'], email=record['email'])
Given snippet: <|code_start|>""" Tests for the Base API Resource class """ from __future__ import (absolute_import, division, print_function, unicode_literals) try: except ImportError: print("WARNING: Cannot Load builtins for py3 compatibility.", file=sys.stderr) warnings.simplefilter("error") # Make All warn...
class OkModel(bases.BaseModel):
Using the snippet: <|code_start|>""" Tests for the Base API Resource class """ from __future__ import (absolute_import, division, print_function, unicode_literals) try: except ImportError: print("WARNING: Cannot Load builtins for py3 compatibility.", file=sys.stderr) warnings.simplefilter("error") # Make All ...
resource.JsonApiResource()
Given snippet: <|code_start|>""" Tests for the API ResourceList class """ from __future__ import (absolute_import, division, print_function, unicode_literals) try: except ImportError: print("WARNING: Cannot Load builtins for py3 compatibility.", file=sys.stderr) warnings.simplefilter("error") # Make All warni...
class Batteries(bases.BaseModel):
Given the code snippet: <|code_start|> :param sqlalchemy.orm.session.Session dbsession: pytest fixture for database session """ resource = BatteriesResource() # Need to create a flask app and context so post can generate the URL for new model. test_app = flask.Flask(__name__) test_app.add_url_rul...
with pytest.raises(Forbidden) as excinfo:
Based on the snippet: <|code_start|>""" Tests for the database module """ from __future__ import (absolute_import, division, print_function, unicode_literals) try: except ImportError: print("WARNING: Cannot Load builtins for py3 compatibility.", file=sys.stderr) warnings.simplefilter("error") # Make All warni...
assert db.ENV == 'dev'
Continue the code snippet: <|code_start|>""" Tests for the Logins Model """ from __future__ import (absolute_import, division, print_function, unicode_literals) try: except ImportError: print("WARNING: Cannot Load builtins for py3 compatibility.", file=sys.stderr) warnings.simplefilter("error") # Make All war...
login = logins.Logins(password=record['password'], profile=profile)
Based on the snippet: <|code_start|>""" Tests for the Logins Model """ from __future__ import (absolute_import, division, print_function, unicode_literals) try: except ImportError: print("WARNING: Cannot Load builtins for py3 compatibility.", file=sys.stderr) warnings.simplefilter("error") # Make All warnings...
profile = profiles.Profiles(full_name=record['full_name'], email=record['email'])