Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Using the snippet: <|code_start|> @pytest.mark.django_db def test_update_pet(client, api_urls): pet1 = Pet.objects.create(name='henlo') payload = {'name': 'worl', 'tag': 'bunner'} resp = client.patch( f'/api/pets/{pet1.id}', json.dumps(payload), content_type='application/json' ) ...
assert isinstance(ei.value.errors['pet'], InvalidBodyFormat)
Given the following code snippet before the placeholder: <|code_start|> @pytest.mark.django_db @pytest.mark.parametrize('with_tag', (False, True)) def test_post_pet(client, api_urls, with_tag): payload = { 'name': get_random_string(15), } if with_tag: payload['tag'] = get_random_string(15) ...
pet1 = Pet.objects.create(name='smolboye', tag='pupper')
Using the snippet: <|code_start|># `urlconf_map` is a map of dynamically generated URLconf modules # that don't actually exist on disk, and this fixture ensures all # tests in this module which request the `api_urls` fixture (defined below) # actually get parametrized to include all versions in the map. def pytest_ge...
assert get_data_from_response(client.get('/api/pets')) == []
Next line prediction: <|code_start|> try: # Django 2 except: # pragma: no cover # Django 1.11 # There's some moderate Py.test and Python magic going on here. # `urlconf_map` is a map of dynamically generated URLconf modules # that don't actually exist on disk, and this fixture ensures all # tests in this m...
module_names = [m.__name__ for m in urlconf_map.values()]
Predict the next line for this snippet: <|code_start|> required: - lat - long properties: lat: type: number long: type: number ''') def test_complex_parameter(): coords_obj = {'lat': 8, '...
with pytest.raises(ErroneousParameters) as ei:
Predict the next line after this snippet: <|code_start|>paths: /complex-parameter: get: parameters: - in: query name: coordinates required: true content: application/json: schema: type: object required: - lat ...
params = read_parameters(request)
Given the following code snippet before the placeholder: <|code_start|> doc = APIDefinition.from_yaml(''' openapi: 3.0.0 paths: /complex-parameter: get: parameters: - in: query name: coordinates required: true content: application/json: schema: ...
request = make_request_for_operation(
Continue the code snippet: <|code_start|> class PathView(View): router = None # Filled in by subclasses path = None # Filled in by subclasses def dispatch(self, request, **kwargs): try: operation = self.path.get_operation(request.method) except InvalidOperation: ...
request.api_info = APIInfo(
Using the snippet: <|code_start|> class PathView(View): router = None # Filled in by subclasses path = None # Filled in by subclasses def dispatch(self, request, **kwargs): try: operation = self.path.get_operation(request.method) except InvalidOperation: return s...
except ExceptionalResponse as er:
Here is a snippet: <|code_start|> class PathView(View): router = None # Filled in by subclasses path = None # Filled in by subclasses def dispatch(self, request, **kwargs): try: operation = self.path.get_operation(request.method) <|code_end|> . Write the next line using the current ...
except InvalidOperation:
Here is a snippet: <|code_start|> class PathView(View): router = None # Filled in by subclasses path = None # Filled in by subclasses def dispatch(self, request, **kwargs): try: operation = self.path.get_operation(request.method) except InvalidOperation: return s...
in read_parameters(request, kwargs, capture_errors=True).items()
Given the following code snippet before the placeholder: <|code_start|> class PathView(View): router = None # Filled in by subclasses path = None # Filled in by subclasses def dispatch(self, request, **kwargs): try: operation = self.path.get_operation(request.method) except ...
snake_case(name): value
Using the snippet: <|code_start|> def cast(self, api, value): # pragma: no cover raise NotImplementedError('Subclasses must implement cast') def get_value(self, request, view_kwargs): # pragma: no cover """ :type request: WSGIRequest :type view_kwargs: dict """ ...
raise InvalidParameterDefinition(f'unsupported `in` value {self.location!r} in {self!r}') # pragma: no cover
Predict the next line for this snippet: <|code_start|> lil_bub = {'name': 'Lil Bub', 'petType': 'Cat', 'huntingSkill': 'lazy'} hachiko = {'name': 'Hachiko', 'petType': 'Dog', 'packSize': 83} @doc_versions def test_path_refs(doc_version): router = get_router(f'{doc_version}/path-refs.yaml') assert router.get...
request.api_info = APIInfo(router.get_path('/cat').get_operation('post'))
Continue the code snippet: <|code_start|> lil_bub = {'name': 'Lil Bub', 'petType': 'Cat', 'huntingSkill': 'lazy'} hachiko = {'name': 'Hachiko', 'petType': 'Dog', 'packSize': 83} @doc_versions def test_path_refs(doc_version): router = get_router(f'{doc_version}/path-refs.yaml') assert router.get_path('/b').m...
params = read_parameters(request, {})
Given snippet: <|code_start|> lil_bub = {'name': 'Lil Bub', 'petType': 'Cat', 'huntingSkill': 'lazy'} hachiko = {'name': 'Hachiko', 'petType': 'Dog', 'packSize': 83} @doc_versions def test_path_refs(doc_version): <|code_end|> , continue by predicting the next line. Consider current file imports: import json import...
router = get_router(f'{doc_version}/path-refs.yaml')
Predict the next line after this snippet: <|code_start|>""" Class-based implementation of the pet resource. """ class PetHandler(CRUDModelHandler): model = Pet queryset = Pet.objects.all() <|code_end|> using the current file's imports: from functools import reduce from django.db.models import Q from lepo...
schema_class = PetSchema
Here is a snippet: <|code_start|> :rtype: APIDefinition """ with open(filename) as infp: if filename.endswith('.yaml') or filename.endswith('.yml'): data = yaml.safe_load(infp) else: data = json.load(infp) return cls.from_data(data) ...
operation_class = OpenAPI3Operation
Given the following code snippet before the placeholder: <|code_start|> If PyYAML is installed, YAML files are supported. JSON files are always supported. :param filename: The filename to read. :rtype: APIDefinition """ with open(filename) as infp: if filenam...
operation_class = Swagger2Operation
Given snippet: <|code_start|> Iterate over all Path objects declared by the API. :rtype: Iterable[lepo.path.Path] """ for path_name in self.get_path_names(): yield self.get_path(path_name) @classmethod def from_file(cls, filename): """ Construct an AP...
if version == OPENAPI_3:
Predict the next line after this snippet: <|code_start|> def get_paths(self): """ Iterate over all Path objects declared by the API. :rtype: Iterable[lepo.path.Path] """ for path_name in self.get_path_names(): yield self.get_path(path_name) @classmethod d...
if version == SWAGGER_2:
Predict the next line for this snippet: <|code_start|> def get_paths(self): """ Iterate over all Path objects declared by the API. :rtype: Iterable[lepo.path.Path] """ for path_name in self.get_path_names(): yield self.get_path(path_name) @classmethod de...
version = parse_version(data)
Given the following code snippet before the placeholder: <|code_start|> class APIDefinition: version = None path_class = Path operation_class = None def __init__(self, doc): """ Instantiate a new Lepo router. :param doc: The OpenAPI definition document. :type doc: dic...
return maybe_resolve(self.doc['paths'][path], self.resolve_reference)
Using the snippet: <|code_start|> routers = pytest.mark.parametrize('router', [ get_router(f'{doc_version}/parameter-test.yaml') for doc_version in DOC_VERSIONS ], ids=DOC_VERSIONS) def test_parameter_validation(): with pytest.raises(ValidationError) as ei: cast_parameter_value( Sw...
request.api_info = APIInfo(router.get_path('/upload').get_operation('post'))
Continue the code snippet: <|code_start|> routers = pytest.mark.parametrize('router', [ get_router(f'{doc_version}/parameter-test.yaml') for doc_version in DOC_VERSIONS ], ids=DOC_VERSIONS) def test_parameter_validation(): with pytest.raises(ValidationError) as ei: cast_parameter_value( <|cod...
Swagger2APIDefinition({}),
Based on the snippet: <|code_start|> get_router(f'{doc_version}/parameter-test.yaml') for doc_version in DOC_VERSIONS ], ids=DOC_VERSIONS) def test_parameter_validation(): with pytest.raises(ValidationError) as ei: cast_parameter_value( Swagger2APIDefinition({}), { ...
if OpenAPI3BodyParameter.name in parameters: # Peel into the body parameter
Given the code snippet: <|code_start|> request = rf.post('/upload', { 'file': ContentFile(b'foo', name='foo.txt'), }) request.api_info = APIInfo(router.get_path('/upload').get_operation('post')) parameters = read_parameters(request) if OpenAPI3BodyParameter.name in parameters: # Peel into th...
with pytest.raises(ErroneousParameters) as ei:
Predict the next line after this snippet: <|code_start|> }) request.api_info = APIInfo(router.get_path('/upload').get_operation('post')) parameters = read_parameters(request) if OpenAPI3BodyParameter.name in parameters: # Peel into the body parameter parameters = parameters[OpenAPI3BodyParameter...
assert isinstance(ei.value.errors['greetee'], MissingParameter)
Continue the code snippet: <|code_start|>routers = pytest.mark.parametrize('router', [ get_router(f'{doc_version}/parameter-test.yaml') for doc_version in DOC_VERSIONS ], ids=DOC_VERSIONS) def test_parameter_validation(): with pytest.raises(ValidationError) as ei: cast_parameter_value( ...
parameters = read_parameters(request)
Given the code snippet: <|code_start|> routers = pytest.mark.parametrize('router', [ get_router(f'{doc_version}/parameter-test.yaml') for doc_version <|code_end|> , generate the next line using the imports in this file: import pytest from django.core.exceptions import ImproperlyConfigured from django.core.fil...
in DOC_VERSIONS
Given snippet: <|code_start|> routers = pytest.mark.parametrize('router', [ get_router(f'{doc_version}/parameter-test.yaml') for doc_version in DOC_VERSIONS ], ids=DOC_VERSIONS) def test_parameter_validation(): with pytest.raises(ValidationError) as ei: <|code_end|> , continue by predicting the next ...
cast_parameter_value(
Given snippet: <|code_start|> style: label explode: true schema: type: array items: type: string - name: thing in: path schema: type: string /object/{thing}/data{format}: get: parameters: - nam...
params = read_parameters(request, {
Given snippet: <|code_start|> in: path style: label explode: true schema: type: array items: type: string - name: thing in: path schema: type: string /object/{thing}/data{format}: get: parame...
request = make_request_for_operation(doc.get_path('/single/{thing}/data{format}').get_operation('get'))
Given the code snippet: <|code_start|> @doc_versions def test_validator(doc_version): router = get_router(f'{doc_version}/schema-refs.yaml') with pytest.raises(RouterValidationError) as ei: validate_router(router) assert len(ei.value.errors) == 2 @doc_versions def test_header_underscore(doc_vers...
assert any(isinstance(e[1], InvalidParameterDefinition) for e in errors)
Given the following code snippet before the placeholder: <|code_start|> @doc_versions def test_validator(doc_version): router = get_router(f'{doc_version}/schema-refs.yaml') <|code_end|> , predict the next line using imports from the current file: import pytest from lepo.excs import InvalidParameterDefinition, R...
with pytest.raises(RouterValidationError) as ei:
Continue the code snippet: <|code_start|> @doc_versions def test_validator(doc_version): router = get_router(f'{doc_version}/schema-refs.yaml') with pytest.raises(RouterValidationError) as ei: <|code_end|> . Use current file imports: import pytest from lepo.excs import InvalidParameterDefinition, RouterValid...
validate_router(router)
Based on the snippet: <|code_start|> DATA_EXAMPLES = [ {'spec': {'type': 'integer'}, 'input': '5041211', 'output': 5041211}, {'spec': {'format': 'long'}, 'input': '88888888888888888888888', 'output': 88888888888888888888888}, {'spec': {'format': 'float'}, 'input': '-6.3', 'output': -6.3}, {'spec': {'f...
parsed = cast_primitive_value(type, format, case['input'])
Here is a snippet: <|code_start|> {'type': 'array', 'collectionFormat': 'ssv', 'items': {'type': 'string'}}, None, 'what it do', ['what', 'it', 'do'], ), Case( { 'type': 'array', 'collectionFormat': 'pipes', 'items': { 't...
assert cast_parameter_value(apidoc, schema, case.input) == case.expected
Here is a snippet: <|code_start|> Case( {'type': 'array', 'collectionFormat': 'tsv', 'items': {'type': 'boolean'}}, None, # TSV does not exist in OpenAPI 3 'true\ttrue\tfalse', [True, True, False], ), Case( {'type': 'array', 'collectionFormat': 'ssv', 'items': {'type'...
@doc_versions
Predict the next line for this snippet: <|code_start|> Case( {'type': 'array', 'collectionFormat': 'ssv', 'items': {'type': 'string'}}, None, 'what it do', ['what', 'it', 'do'], ), Case( { 'type': 'array', 'collectionFormat': 'pipes', ...
apidoc = get_apidoc_from_version(doc_version)
Using the snippet: <|code_start|> COLLECTION_FORMAT_SPLITTERS = { 'csv': comma_split, 'ssv': space_split, 'tsv': tab_split, 'pipes': pipe_split, } OPENAPI_JSONSCHEMA_VALIDATION_KEYS = ( 'maximum', 'exclusiveMaximum', 'minimum', 'exclusiveMinimum', 'maxLength', 'minLength', 'pattern', ...
class Swagger2BaseParameter(BaseParameter):
Continue the code snippet: <|code_start|> COLLECTION_FORMAT_SPLITTERS = { 'csv': comma_split, 'ssv': space_split, 'tsv': tab_split, <|code_end|> . Use current file imports: import jsonschema from lepo.apidef.parameter.base import NO_VALUE, BaseParameter, BaseTopParameter from lepo.apidef.parameter.utils i...
'pipes': pipe_split,
Given the code snippet: <|code_start|> COLLECTION_FORMAT_SPLITTERS = { 'csv': comma_split, 'ssv': space_split, <|code_end|> , generate the next line using the imports in this file: import jsonschema from lepo.apidef.parameter.base import NO_VALUE, BaseParameter, BaseTopParameter from lepo.apidef.parameter.uti...
'tsv': tab_split,
Continue the code snippet: <|code_start|> CASCADE_DOC = """ swagger: "2.0" consumes: - application/json produces: - application/x-happiness paths: /cows: consumes: - application/x-grass produces: - application/x-moo post: operationId: tip delete: operationId: remoove pro...
router = APIDefinition.from_data(yaml.safe_load(CASCADE_DOC))
Here is a snippet: <|code_start|> def validate_router(router): errors = defaultdict(list) for path in router.get_paths(): for operation in path.get_operations(): # Check the handler exists. try: router.get_handler(operation.id) except MissingHandler ...
ipd = InvalidParameterDefinition(
Given snippet: <|code_start|> def validate_router(router): errors = defaultdict(list) for path in router.get_paths(): for operation in path.get_operations(): # Check the handler exists. try: router.get_handler(operation.id) <|code_end|> , continue by predicting ...
except MissingHandler as e:
Given the following code snippet before the placeholder: <|code_start|> def validate_router(router): errors = defaultdict(list) for path in router.get_paths(): for operation in path.get_operations(): # Check the handler exists. try: router.get_handler(operation....
raise RouterValidationError(errors)
Predict the next line for this snippet: <|code_start|> JSONIFY_DOC = """ swagger: "2.0" consumes: - text/plain produces: - application/json paths: /jsonify: post: parameters: - name: text in: body """ # TODO: add OpenAPI 3 version of this test def test_text_body_type(rf): a...
request.api_info = APIInfo(operation=operation)
Based on the snippet: <|code_start|> JSONIFY_DOC = """ swagger: "2.0" consumes: - text/plain produces: - application/json paths: /jsonify: post: parameters: - name: text in: body """ # TODO: add OpenAPI 3 version of this test def test_text_body_type(rf): <|code_end|> , predict ...
apidoc = APIDefinition.from_data(yaml.safe_load(JSONIFY_DOC))
Next line prediction: <|code_start|> JSONIFY_DOC = """ swagger: "2.0" consumes: - text/plain produces: - application/json paths: /jsonify: post: parameters: - name: text in: body """ # TODO: add OpenAPI 3 version of this test def test_text_body_type(rf): apidoc = APIDefinit...
params = read_parameters(request, {})
Given snippet: <|code_start|> def greet(request, greeting, greetee): raise ExceptionalResponse(HttpResponse('oh no', status=400)) @doc_versions def test_exceptional_response(rf, doc_version): <|code_end|> , continue by predicting the next line. Consider current file imports: from django.http.response import Ht...
router = get_router(f'{doc_version}/parameter-test.yaml')
Given the following code snippet before the placeholder: <|code_start|> :type path: str :type mapping: dict """ self.api = api self.path = path self.mapping = mapping self.regex = self._build_regex() self.name = self._build_view_name() def get_view_cla...
raise InvalidOperation(f'Path {self.path} does not support method {method.upper()}')
Here is a snippet: <|code_start|> PATH_PLACEHOLDER_REGEX = r'\{(.+?)\}' # As defined in the documentation for Path Items: METHODS = {'get', 'put', 'post', 'delete', 'options', 'head', 'patch'} class Path: def __init__(self, api, path, mapping): """ :type api: lepo.apidef.APIDefinition :t...
return type(f'{self.name.title()}View', (PathView,), {
Here is a snippet: <|code_start|>try: except ImportError: def root_view(request): return HttpResponse('API root') class Router: def __init__(self, api): """ Instantiate a new Lepo router. :param api: An APIDefinition object :type api: APIDefinition """ <|code_end...
assert isinstance(api, APIDefinition)
Based on the snippet: <|code_start|> regex = regex.rstrip('$') if not regex.endswith('/'): regex += '/' regex += '?$' view = decorate(path.get_view_class(router=self).as_view()) urls.append(re_path(regex, view, name=name_template...
raise MissingHandler(
Here is a snippet: <|code_start|> urls = [] for path in self.api.get_paths(): regex = path.regex if optional_trailing_slash: regex = regex.rstrip('$') if not regex.endswith('/'): regex += '/' regex += '?$' ...
or self.handlers.get(snake_case(operation_id))
Next line prediction: <|code_start|> DEFAULT_TEMPLATE = 'fedora' DEFAULT_PYTHON_VERSIONS = { 'fedora': ['3'], 'epel7': ['2', '3'], 'epel6': ['2'], 'mageia': ['3'], 'pld': ['2', '3'] } DEFAULT_PYTHON_VERSION = DEFAULT_PYTHON_VERSIONS[DEFAULT_TEMPLATE][0] DEFAULT_PKG_SOURCE = 'pypi' DEFAULT_METADATA_S...
DEFAULT_PKG_SAVE_PATH = utils.get_default_save_path()
Next line prediction: <|code_start|> def __sub__(self, other): ''' Makes differance of DirsContents objects attributes ''' if any([self.bindir is None, self.lib_sitepackages is None, other.bindir is None, other.lib_sitepackages is None]): raise ValueError(...
raise VirtualenvFailException('Failed to create virtualenv')
Given snippet: <|code_start|> def fill(self, path): ''' Scans content of directories ''' self.bindir = set(os.listdir(path + 'bin/')) self.lib_sitepackages = set(os.listdir(glob.glob( path + 'lib/python*.*/site-packages/')[0])) def __sub__(self, other): ...
base_python_version = DEFAULT_PYTHON_VERSION
Given the code snippet: <|code_start|> def install_package_to_venv(self): ''' Installs package given as first argument to virtualenv without dependencies ''' try: self.env.install((self.name,), force=True, options=["--no-deps"]) ...
[p for p in site_packages if not p.endswith(MODULE_SUFFIXES)])
Predict the next line after this snippet: <|code_start|> def close(self): if self.handle: self.handle.close() def __enter__(self): return self.open() def __exit__(self, type, value, traceback): # TODO: handle exceptions here self.close() @property def extracto...
@utils.memoize_by_args
Based on the snippet: <|code_start|> tests_dir = os.path.split(os.path.abspath(__file__))[0] class TestMetadataExtractor(object): td_dir = '{0}/test_data/'.format(tests_dir) def setup_method(self, method): # create fresh extractors for every test <|code_end|> , predict the immediate next line wit...
self.nc = NameConvertor('fedora')
Next line prediction: <|code_start|> logger = logging.getLogger(__name__) def dependency_to_rpm(dep, runtime, use_rich_deps=True): """Converts a dependency got by pkg_resources.Requirement.parse() to RPM format. Args: dep - a dependency retrieved by pkg_resources.Requirement.parse() runt...
converted = convert_requirement(dep, use_rich_deps)
Predict the next line after this snippet: <|code_start|> [['Requires', 'pyp2rpm', '{name} >= 0.9.3.1'], ['Requires', 'pyp2rpm', '{name} < 0.9.4'] ] ), ('docutils>=0.3,<1,!=0.5', True, True, [['Requires', 'docutils', '({name} >= 0.3 with {name} < 1~~ with (...
rpm_deps = dependency_to_rpm(R.parse(d), r, rich)
Given the following code snippet before the placeholder: <|code_start|> description = """Convert Python packages to RPM SPECFILES. The packages can be downloaded from PyPI and the produced SPEC is in line with Fedora Packaging Guidelines or Mageia Python Policy. Users can provide their own templates for rendering t...
version=version,
Based on the snippet: <|code_start|> def teardown_method(self, method): shutil.rmtree(self.temp_dir) @pytest.mark.webtest def test_srpm(self): res = self.env.run('{0} Jinja2 -v2.8 --srpm'.format(self.exe), expect_stderr=True) assert res.returncode == 0 @p...
flexmock(Convertor).should_receive('__init__').and_return(None)
Next line prediction: <|code_start|> nc = '_dnfnc' if dnf is not None else '_nc' variant = expected.format(nc) with open(self.td_dir + variant) as fi: self.spec_content = fi.read() res = self.env.run('{0} {1} {2}'.format(self.exe, package, options), ...
@pytest.mark.skipif(SclConvertor is None, reason="spec2scl not installed")
Predict the next line for this snippet: <|code_start|> 'skip_functions': [''], 'no_deps_convert': False, 'list_file': None, 'meta_spec': None } flexmock(Convertor).should_receive('__init__').and_return(None) flexmock(Convertor).should_receive('conve...
main(args=['foo_package', '--sclize'] + options)
Given snippet: <|code_start|> (['--list-file=file_name'], {'list_file': 'file_name'}), ]) def test_scl_convertor_args_correctly_passed(self, options, expected_options, capsys): """Test that pyp2rpm command passes correct options to SCL conv...
converted = convert_to_scl(self.test_spec, self.default_options)
Predict the next line for this snippet: <|code_start|> logger = logging.getLogger(__name__) def get_deps_names(runtime_deps_list): ''' data['runtime_deps'] has format: [['Requires', 'name', '{name} >= version'], ...] this function creates list of lowercase deps names ''' return [x[1].lower() ...
credit_line = '# Created by pyp2rpm-{0}'.format(version.version)
Given snippet: <|code_start|> object.__setattr__(self, 'data', {}) self.data['local_file'] = local_file self.data['name'] = name self.data['srcname'] = srcname self.data['pkg_name'] = pkg_name self.data['version'] = version self.data['python_versions'] = [] ...
if name == 'summary' and isinstance(value, utils.str_classes):
Based on the snippet: <|code_start|> class TestPackageData(object): @pytest.mark.parametrize(('s', 'expected'), [ ('Spam.', 'Spam'), ('Spam', 'Spam'), ]) def test_summary_with_dot(self, s, expected): <|code_end|> , predict the immediate next line with the help of imports: import pytest f...
pd = PackageData('spam', 'spam', 'python-spam', 'spam')
Continue the code snippet: <|code_start|># -*- encoding: utf-8 -*- class TestRerun(object): def setup_method(self, test_method): self.patcher = patch('thefuck.output_readers.rerun.Process') process_mock = self.patcher.start() self.proc_mock = process_mock.return_value = Mock() def t...
assert rerun.get_output('', '') is None
Given the following code snippet before the placeholder: <|code_start|> @pytest.mark.parametrize('called, command, output', [ ('git co', 'git checkout', "19:22:36.299340 git.c:282 trace: alias expansion: co => 'checkout'"), ('git com file', 'git commit --verbose file', "19:23:25.470911 git.c:282 trace...
@git_support
Using the snippet: <|code_start|> @pytest.mark.parametrize('called, command, output', [ ('git co', 'git checkout', "19:22:36.299340 git.c:282 trace: alias expansion: co => 'checkout'"), ('git com file', 'git commit --verbose file', "19:23:25.470911 git.c:282 trace: alias expansion: com => 'commit' '--...
assert fn(Command(called, output)) == command
Given snippet: <|code_start|> @pytest.fixture def output(branch_name): if not branch_name: return '' return '''fatal: The current branch {} has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin {} '''.format(branch_name, branch_name) ...
assert match(Command(script, output))
Predict the next line after this snippet: <|code_start|> @pytest.fixture def module_error_output(filename, module_name): return """Traceback (most recent call last): File "{0}", line 1, in <module> import {1} ModuleNotFoundError: No module named '{1}'""".format( filename, module_name ) @pytest...
Command("python hello_world.py", "Hello World"),
Given the following code snippet before the placeholder: <|code_start|>Additional help topics: \tbuildconstraint build constraints \tbuildmode build modes \tc calling between Go and C \tcache build and test caching \tenvironment environment variables \tfiletype file types \tgo....
assert match(Command('go bulid', build_misspelled_output))
Predict the next line for this snippet: <|code_start|>\tgopath GOPATH environment variable \tgopath-get legacy GOPATH go get \tgoproxy module proxy protocol \timportpath import path syntax \tmodules modules, module versions, and more \tmodule-get module-aware go get \tmodule-auth...
assert get_new_command(Command('go bulid', build_misspelled_output)) == 'go build'
Next line prediction: <|code_start|>Additional help topics: \tbuildconstraint build constraints \tbuildmode build modes \tc calling between Go and C \tcache build and test caching \tenvironment environment variables \tfiletype file types \tgo.mod the go.mod file \tgopa...
assert match(Command('go bulid', build_misspelled_output))
Given the code snippet: <|code_start|> '\n' '\n' ) @pytest.fixture def composer_not_command_one_of_this(): # that weird spacing is part of the actual command output return ( '\n' '\n' ' \n' ' [InvalidArgumentException] ...
assert match(Command('composer udpate',
Predict the next line for this snippet: <|code_start|> @pytest.fixture def output(): return "error: Cannot delete branch 'foo' checked out at '/bar/foo'" @pytest.mark.parametrize("script", ["git branch -d foo", "git branch -D foo"]) def test_match(script, output): <|code_end|> with the help of current file impo...
assert match(Command(script, output))
Given snippet: <|code_start|> @pytest.fixture def output(): return "error: Cannot delete branch 'foo' checked out at '/bar/foo'" @pytest.mark.parametrize("script", ["git branch -d foo", "git branch -D foo"]) def test_match(script, output): assert match(Command(script, output)) @pytest.mark.parametrize("scr...
assert get_new_command(Command(script, output)) == new_command
Based on the snippet: <|code_start|> @pytest.fixture def output(): return "error: Cannot delete branch 'foo' checked out at '/bar/foo'" @pytest.mark.parametrize("script", ["git branch -d foo", "git branch -D foo"]) def test_match(script, output): <|code_end|> , predict the immediate next line with the help of im...
assert match(Command(script, output))
Next line prediction: <|code_start|> @pytest.fixture def load_source(mocker): return mocker.patch('thefuck.conf.load_source') def test_settings_defaults(load_source, settings): load_source.return_value = object() settings.init() <|code_end|> . Use current file imports: (import pytest import six import o...
for key, val in const.DEFAULT_SETTINGS.items():
Given the following code snippet before the placeholder: <|code_start|> def get_loaded_rules(rules_paths): """Yields all available rules. :type rules_paths: [Path] :rtype: Iterable[Rule] """ for path in rules_paths: if path.name != '__init__.py': rule = Rule.from_path(path) ...
yield settings.user_dir.joinpath('rules')
Given the code snippet: <|code_start|> def get_loaded_rules(rules_paths): """Yields all available rules. :type rules_paths: [Path] :rtype: Iterable[Rule] """ for path in rules_paths: if path.name != '__init__.py': <|code_end|> , generate the next line using the imports in this file: impo...
rule = Rule.from_path(path)
Given snippet: <|code_start|> def test_match(): assert match(Command('cs', 'cs: command not found')) assert match(Command('cs /etc/', 'cs: command not found')) def test_get_new_command(): <|code_end|> , continue by predicting the next line. Consider current file imports: from thefuck.rules.cd_cs import matc...
assert get_new_command(Command('cs /etc/', 'cs: command not found')) == 'cd /etc/'
Based on the snippet: <|code_start|> aliases = {} proc = Popen(['fish', '-ic', 'alias'], stdout=PIPE, stderr=DEVNULL) alias_out = proc.stdout.read().decode('utf-8').strip() if not alias_out: return aliases for alias in alias_out.split('\n'): for separator in (' ', '='): sp...
if settings.alter_history:
Based on the snippet: <|code_start|> aliases[name] = value return aliases class Fish(Generic): friendly_name = 'Fish Shell' def _get_overridden_aliases(self): overridden = os.environ.get('THEFUCK_OVERRIDDEN_ALIASES', os.environ.get('TF_OVERRIDDEN_ALI...
'end').format(alias_name, alter_history, ARGUMENT_PLACEHOLDER)
Predict the next line for this snippet: <|code_start|> self.requires_output = requires_output def __eq__(self, other): if isinstance(other, Rule): return ((self.name, self.match, self.get_new_command, self.enabled_by_default, self.side_effect, se...
if name in settings.exclude_rules:
Given the following code snippet before the placeholder: <|code_start|> other.priority, other.requires_output)) else: return False def __repr__(self): return 'Rule(name={}, match={}, get_new_command={}, ' \ 'enabled_by_default={}, side_effect={}, ' ...
priority = getattr(rule_module, 'priority', DEFAULT_PRIORITY)
Predict the next line after this snippet: <|code_start|> """ name = path.name[:-3] if name in settings.exclude_rules: logs.debug(u'Ignoring excluded rule: {}'.format(name)) return with logs.debug_time(u'Importing rule: {};'.format(name)): try: ...
and ALL_ENABLED in settings.rules
Given snippet: <|code_start|> @pytest.fixture def mistype_response(): return """ CommandNotFoundError: No command 'conda lst'. Did you mean 'conda list'? """ def test_match(mistype_response): <|code_end|> , continue by predicting the next line. Consider current file imports: import pytest from thefuck.ru...
assert match(Command('conda lst', mistype_response))
Given the code snippet: <|code_start|> @pytest.mark.parametrize( "script, output", [ ('git commit -m "test"', "no changes added to commit"), ("git commit", "no changes added to commit"), ], ) def test_match(output, script): <|code_end|> , generate the next line using the imports in this fil...
assert match(Command(script, output))
Next line prediction: <|code_start|> [ ('git commit -m "test"', "no changes added to commit"), ("git commit", "no changes added to commit"), ], ) def test_match(output, script): assert match(Command(script, output)) @pytest.mark.parametrize( "script, output", [ ('git commit ...
assert get_new_command(Command(script, "")) == new_command
Given the code snippet: <|code_start|> @pytest.mark.parametrize( "script, output", [ ('git commit -m "test"', "no changes added to commit"), ("git commit", "no changes added to commit"), ], ) def test_match(output, script): <|code_end|> , generate the next line using the imports in this fil...
assert match(Command(script, output))
Next line prediction: <|code_start|> output = 'merge: local - not something we can merge\n\n' \ 'Did you mean this?\n\tremote/local' def test_match(): <|code_end|> . Use current file imports: (import pytest from thefuck.rules.git_merge import match, get_new_command from thefuck.types import Command) and c...
assert match(Command('git merge test', output))
Given the following code snippet before the placeholder: <|code_start|> def test_and_(self, shell): assert shell.and_('foo', 'bar') == 'foo; and bar' def test_or_(self, shell): assert shell.or_('foo', 'bar') == 'foo; or bar' def test_get_aliases(self, shell): assert shell.get_alias...
assert ARGUMENT_PLACEHOLDER in shell.app_alias('fuck')
Given the following code snippet before the placeholder: <|code_start|> @pytest.fixture def output(branch_name): if not branch_name: return "" output_str = u"error: pathspec '{}' did not match any file(s) known to git" return output_str.format(branch_name) @pytest.mark.parametrize( "script, b...
assert match(Command(script, output))