Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Based on the snippet: <|code_start|>from __future__ import annotations
# Input, expected return value, expected output
TESTS = (
(b'foo\n', 0, b'foo\n'),
(b'', 0, b''),
(b'\n\n', 1, b''),
(b'\n\n\n\n', 1, b''),
(b'foo', 1, b'foo\n'),
(b'foo\n\n\n', 1, b'foo\n'),
(b'\xe2\x98\x83', 1, b'\... | (b'foo\r\r\r\r', 1, b'foo\r'), |
Based on the snippet: <|code_start|>from __future__ import annotations
# Input, expected return value, expected output
TESTS = (
(b'foo\n', 0, b'foo\n'),
<|code_end|>
, predict the immediate next line with the help of imports:
import io
import pytest
from pre_commit_hooks.end_of_file_fixer import fix_file
fro... | (b'', 0, b''), |
Given snippet: <|code_start|>from __future__ import annotations
@pytest.mark.parametrize(
('filename', 'expected_retval'), (
('bad_yaml.notyaml', 1),
('ok_yaml.yaml', 0),
),
)
def test_main(filename, expected_retval):
ret = main([get_resource_path(filename)])
assert ret == expected_r... | f.write('[') |
Based on the snippet: <|code_start|>from __future__ import annotations
def test_raises_on_error():
with pytest.raises(CalledProcessError):
cmd_output('sh', '-c', 'exit 1')
def test_output():
ret = cmd_output('sh', '-c', 'echo hi')
assert ret == 'hi\n'
@pytest.mark.parametrize('out', ('\0f1\0... | @pytest.mark.parametrize('out', ('\0\0', '\0', '')) |
Given the code snippet: <|code_start|>from __future__ import annotations
def test_raises_on_error():
with pytest.raises(CalledProcessError):
cmd_output('sh', '-c', 'exit 1')
def test_output():
ret = cmd_output('sh', '-c', 'echo hi')
assert ret == 'hi\n'
<|code_end|>
, generate the next line ... | @pytest.mark.parametrize('out', ('\0f1\0f2\0', '\0f1\0f2', 'f1\0f2\0')) |
Here is a snippet: <|code_start|>from __future__ import annotations
def test_raises_on_error():
with pytest.raises(CalledProcessError):
cmd_output('sh', '-c', 'exit 1')
def test_output():
ret = cmd_output('sh', '-c', 'echo hi')
assert ret == 'hi\n'
@pytest.mark.parametrize('out', ('\0f1\0f2\... | def test_check_zsplits_str_correctly(out): |
Predict the next line for this snippet: <|code_start|> assert ret == expected_retval
@pytest.mark.parametrize(
('filename', 'expected_retval'), (
('not_pretty_formatted_json.json', 1),
('unsorted_pretty_formatted_json.json', 0),
('non_ascii_pretty_formatted_json.json', 1),
('pre... | def test_non_ascii_main(): |
Given the following code snippet before the placeholder: <|code_start|>
def test_top_sorted_get_pretty_format():
ret = main((
'--top-keys=01-alist,alist', get_resource_path('top_sorted_json.json'),
))
assert ret == 0
def test_badfile_main():
ret = main([get_resource_path('ok_yaml.yaml')])
... | + 34, |
Predict the next line for this snippet: <|code_start|> ret = main([str(srcfile)])
assert ret == 0
def test_orderfile_get_pretty_format():
ret = main((
'--top-keys=alist', get_resource_path('pretty_formatted_json.json'),
))
assert ret == 0
def test_not_orderfile_get_pretty_format():
re... | def test_diffing_output(capsys): |
Based on the snippet: <|code_start|>from __future__ import annotations
# Input, expected return value
TESTS = (
(b'-----BEGIN RSA PRIVATE KEY-----', 1),
<|code_end|>
, predict the immediate next line with the help of imports:
import pytest
from pre_commit_hooks.detect_private_key import main
and context (class... | (b'-----BEGIN DSA PRIVATE KEY-----', 1), |
Using the snippet: <|code_start|>RETVAL_BAD = 1
TEST_SORTS = [
(
['c: true', '', 'b: 42', 'a: 19'],
['b: 42', 'a: 19', '', 'c: true'],
RETVAL_BAD,
),
(
['# i am', '# a header', '', 'c: true', '', 'b: 42', 'a: 19'],
['# i am', '# a header', '', 'b: 42', 'a: 19', '', '... | file_path = os.path.join(str(tmpdir), 'foo.yaml') |
Based on the snippet: <|code_start|> assert [line.rstrip() for line in f.readlines()] == good_lines
def test_parse_header():
lines = ['# some header', '# is here', '', 'this is not a header']
assert parse_block(lines, header=True) == ['# some header', '# is here']
assert lines == ['', 'this is not ... | def test_parse_blocks(): |
Given the following code snippet before the placeholder: <|code_start|>from __future__ import annotations
RETVAL_GOOD = 0
RETVAL_BAD = 1
TEST_SORTS = [
(
['c: true', '', 'b: 42', 'a: 19'],
['b: 42', 'a: 19', '', 'c: true'],
RETVAL_BAD,
),
(
['# i am', '# a header', '', '... | ), |
Given the following code snippet before the placeholder: <|code_start|> ['# i am', '# a header', '', 'already: sorted', '', 'yup: i am'],
RETVAL_GOOD,
),
(
['# i am', '# a header'],
['# i am', '# a header'],
RETVAL_GOOD,
),
]
@pytest.mark.parametrize('bad_lines,good... | lines = ['this is not a header'] |
Here is a snippet: <|code_start|>from __future__ import annotations
BUILTIN_CONSTRUCTORS = '''\
import builtins
c1 = complex()
<|code_end|>
. Write the next line using the current file imports:
import ast
import pytest
from pre_commit_hooks.check_builtin_literals import Call
from pre_commit_hooks.check_builtin_li... | d1 = dict() |
Using the snippet: <|code_start|>from __future__ import annotations
BUILTIN_CONSTRUCTORS = '''\
import builtins
c1 = complex()
d1 = dict()
f1 = float()
i1 = int()
<|code_end|>
, determine the next line of code. You have imports:
import ast
import pytest
from pre_commit_hooks.check_builtin_literals import Call
fro... | l1 = list() |
Given the following code snippet before the placeholder: <|code_start|> ('input_str', 'output'),
(
(
b'import httplib\n',
b'# -*- coding: utf-8 -*-\n'
b'import httplib\n',
),
(
b'#!/usr/bin/env python\n'
b'x = 1\n',
b... | (b'# -*- coding: utf-8 -*-\n', b''), |
Continue the code snippet: <|code_start|>@pytest.mark.parametrize(
('input_str', 'output'),
(
(
b'import httplib\n',
b'# -*- coding: utf-8 -*-\n'
b'import httplib\n',
),
(
b'#!/usr/bin/env python\n'
b'x = 1\n',
b'#!/... | (b'#coding: utf-8\n', b''), |
Here is a snippet: <|code_start|>)
def test_not_ok_inputs(input_str, output):
bytesio = io.BytesIO(input_str)
assert fix_encoding_pragma(bytesio) == 1
bytesio.seek(0)
assert bytesio.read() == output
def test_ok_input_alternate_pragma():
input_s = b'# coding: utf-8\nx = 1\n'
bytesio = io.BytesI... | ('# coding: utf-8\n', b'# coding: utf-8'), |
Predict the next line for this snippet: <|code_start|>from __future__ import annotations
@pytest.fixture
def git_dir_with_git_dir(tmpdir):
with tmpdir.as_cwd():
subprocess.check_call(('git', 'init', '.'))
git_commit('--allow-empty', '-m', 'init')
subprocess.check_call(('git', 'init', 'f... | out, _ = capsys.readouterr() |
Predict the next line for this snippet: <|code_start|> # Sneaky submodule add (that doesn't show up in .gitmodules)
('git', 'add', 'foo'),
),
)
def test_main_new_submodule(git_dir_with_git_dir, capsys, cmd):
subprocess.check_call(cmd)
assert main(('random_non-related_file',)) == 0
assert ... | subprocess.check_call(('git', 'add', 'test.py')) |
Given snippet: <|code_start|>from __future__ import annotations
def test_failure(tmpdir):
f = tmpdir.join('f.txt')
f.write_text('ohai', encoding='utf-8-sig')
assert check_byte_order_marker.main((str(f),)) == 1
def test_success(tmpdir):
<|code_end|>
, continue by predicting the next line. Consider curre... | f = tmpdir.join('f.txt') |
Given snippet: <|code_start|>
CONFLICT_PATTERNS = [
b'<<<<<<< ',
b'======= ',
b'=======\n',
b'>>>>>>> ',
]
def is_in_merge() -> bool:
git_dir = cmd_output('git', 'rev-parse', '--git-dir').rstrip()
return (
os.path.exists(os.path.join(git_dir, 'MERGE_MSG')) and
(
os.... | retcode = 0 |
Given the code snippet: <|code_start|>from __future__ import annotations
def test_no_breakpoints():
visitor = DebugStatementParser()
visitor.visit(ast.parse('import os\nfrom foo import bar\n'))
assert visitor.breakpoints == []
def test_finds_debug_import_attribute_access():
visitor = DebugStatemen... | visitor.visit(ast.parse('breakpoint()')) |
Based on the snippet: <|code_start|>
def test_finds_debug_import_from_import():
visitor = DebugStatementParser()
visitor.visit(ast.parse('from pudb import set_trace; set_trace()'))
assert visitor.breakpoints == [Debug(1, 0, 'pudb', 'imported')]
def test_finds_breakpoint():
visitor = DebugStatementPars... | def test_non_utf8_file(tmpdir): |
Given the code snippet: <|code_start|>from __future__ import annotations
def test_no_breakpoints():
visitor = DebugStatementParser()
visitor.visit(ast.parse('import os\nfrom foo import bar\n'))
assert visitor.breakpoints == []
def test_finds_debug_import_attribute_access():
visitor = DebugStatemen... | def test_finds_breakpoint(): |
Given snippet: <|code_start|>def test_finds_debug_import_attribute_access():
visitor = DebugStatementParser()
visitor.visit(ast.parse('import ipdb; ipdb.set_trace()'))
assert visitor.breakpoints == [Debug(1, 0, 'ipdb', 'imported')]
def test_finds_debug_import_from_import():
visitor = DebugStatementPar... | def test_syntaxerror_file(): |
Predict the next line after this snippet: <|code_start|>from __future__ import annotations
def test_failing_file():
ret = main([get_resource_path('cannot_parse_ast.notpy')])
assert ret == 1
<|code_end|>
using the current file's imports:
from pre_commit_hooks.check_ast import main
from testing.util import... | def test_passing_file(): |
Using the snippet: <|code_start|>from __future__ import annotations
def is_on_branch(
protected: AbstractSet[str],
patterns: AbstractSet[str] = frozenset(),
) -> bool:
try:
ref_name = cmd_output('git', 'symbolic-ref', 'HEAD')
except CalledProcessError:
return False
chunks... | '-p', '--pattern', action='append', |
Based on the snippet: <|code_start|>from __future__ import annotations
def is_on_branch(
protected: AbstractSet[str],
patterns: AbstractSet[str] = frozenset(),
) -> bool:
try:
ref_name = cmd_output('git', 'symbolic-ref', 'HEAD')
except CalledProcessError:
return False
chu... | 'regex pattern for branch name to disallow commits to, ' |
Predict the next line for this snippet: <|code_start|>from __future__ import annotations
def test_nothing_added(temp_git_dir):
with temp_git_dir.as_cwd():
assert find_large_added_files(['f.py'], 0) == 0
def test_adding_something(temp_git_dir):
with temp_git_dir.as_cwd():
<|code_end|>
with the he... | temp_git_dir.join('f.py').write("print('hello world')") |
Based on the snippet: <|code_start|> assert main(('--maxkb', '9', 'f.py')) == 0
@xfailif_no_gitlfs
def test_moves_with_gitlfs(temp_git_dir): # pragma: no cover
with temp_git_dir.as_cwd():
cmd_output('git', 'lfs', 'install', '--local')
cmd_output('git', 'lfs', 'track', 'a.bin', 'b.bin')
... | with temp_git_dir.as_cwd(): |
Given snippet: <|code_start|>
def test_added_file_not_in_pre_commits_list(temp_git_dir):
with temp_git_dir.as_cwd():
temp_git_dir.join('f.py').write("print('hello world')")
cmd_output('git', 'add', 'f.py')
# Should pass even with a size of 0
assert find_large_added_files(['g.py'], ... | not has_gitlfs(), reason='This test requires git-lfs', |
Predict the next line after this snippet: <|code_start|>from __future__ import annotations
def test_nothing_added(temp_git_dir):
with temp_git_dir.as_cwd():
assert find_large_added_files(['f.py'], 0) == 0
def test_adding_something(temp_git_dir):
<|code_end|>
using the current file's imports:
import... | with temp_git_dir.as_cwd(): |
Based on the snippet: <|code_start|>from __future__ import annotations
def test_always_fails():
with pytest.raises(SystemExit) as excinfo:
main((
'autopep8-wrapper', 'autopep8',
'https://github.com/pre-commit/mirrors-autopep8',
'--foo', 'bar',
))
msg, = ex... | 'use `autopep8` from https://github.com/pre-commit/mirrors-autopep8' |
Predict the next line after this snippet: <|code_start|>
skip_win32 = pytest.mark.skipif(
sys.platform == 'win32',
reason="non-git checks aren't relevant on windows",
)
@skip_win32 # pragma: win32 no cover
@pytest.mark.parametrize(
'content', (
b'#!/bin/bash\nhello world\n',
b'#!/usr/bin/... | ), |
Predict the next line for this snippet: <|code_start|>
def test_check_git_filemode_passing(tmpdir):
with tmpdir.as_cwd():
cmd_output('git', 'init', '.')
f = tmpdir.join('f')
f.write('#!/usr/bin/env bash')
f_path = str(f)
cmd_output('chmod', '+x', f_path)
cmd_output(... | with tmpdir.as_cwd(): |
Continue the code snippet: <|code_start|> b'#!/usr/bin/env python3.6',
b'#!python',
'#!☃'.encode(),
),
)
def test_has_shebang(content, tmpdir):
path = tmpdir.join('path')
path.write(content, 'wb')
assert main((str(path),)) == 0
@skip_win32 # pragma: win32 no cover
@pytest.mark.... | with tmpdir.as_cwd(): |
Predict the next line after this snippet: <|code_start|> for line in zsplit(
cmd_output('git', 'status', '--porcelain=v2', '-z', '--', *files),
):
splitted = line.split(' ')
if splitted and splitted[0] == ORDINARY_CHANGED_ENTRIES_MARKER:
# https://git-scm.com/docs/git-status#_... | SIZE_CMD = ('git', 'cat-file', '-s') |
Given snippet: <|code_start|>from __future__ import annotations
@pytest.mark.parametrize(
('input_s', 'argv', 'expected_retval', 'output'),
(
(b'', [], FAIL, b'\n'),
(b'lonesome\n', [], PASS, b'lonesome\n'),
(b'missing_newline', [], FAIL, b'missing_newline\n'),
(b'newline\nmi... | [], |
Predict the next line for this snippet: <|code_start|> ['--unique'],
PASS,
b'Fie\nFoe\nfee\nfum\n',
),
(
b'Fie\nFie\nFoe\nfee\nfum\n',
['--unique'],
FAIL,
b'Fie\nFoe\nfee\nfum\n',
),
(
b'fee\nF... | assert path.read_binary() == output |
Here is a snippet: <|code_start|> (
(b'', [], FAIL, b'\n'),
(b'lonesome\n', [], PASS, b'lonesome\n'),
(b'missing_newline', [], FAIL, b'missing_newline\n'),
(b'newline\nmissing', [], FAIL, b'missing\nnewline\n'),
(b'missing\nnewline', [], FAIL, b'missing\nnewline\n'),
(... | b'fee\nFie\nFoe\nfum\n', |
Here is a snippet: <|code_start|>from __future__ import annotations
@pytest.mark.parametrize(
('filename', 'expected_retval'), (
('bad_xml.notxml', 1),
('ok_xml.xml', 0),
),
<|code_end|>
. Write the next line using the current file imports:
import pytest
from pre_commit_hooks.check_xml impo... | ) |
Continue the code snippet: <|code_start|>from __future__ import annotations
@pytest.mark.parametrize(
('filename', 'expected_retval'), (
<|code_end|>
. Use current file imports:
import pytest
from pre_commit_hooks.check_xml import main
from testing.util import get_resource_path
and context (classes, functions... | ('bad_xml.notxml', 1), |
Using the snippet: <|code_start|>from __future__ import annotations
def test_other_branch(temp_git_dir):
with temp_git_dir.as_cwd():
cmd_output('git', 'checkout', '-b', 'anotherbranch')
assert is_on_branch({'master'}) is False
def test_multi_branch(temp_git_dir):
with temp_git_dir.as_cwd()... | def test_multi_branch_fail(temp_git_dir): |
Continue the code snippet: <|code_start|>from __future__ import annotations
def test_other_branch(temp_git_dir):
with temp_git_dir.as_cwd():
cmd_output('git', 'checkout', '-b', 'anotherbranch')
assert is_on_branch({'master'}) is False
def test_multi_branch(temp_git_dir):
with temp_git_dir.... | with temp_git_dir.as_cwd(): |
Given snippet: <|code_start|>from __future__ import annotations
@pytest.mark.parametrize(
('env_vars', 'values'),
(
({}, set()),
({'AWS_PLACEHOLDER_KEY': '/foo'}, set()),
({'AWS_CONFIG_FILE': '/foo'}, {'/foo'}),
({'AWS_CREDENTIAL_FILE': '/foo'}, {'/foo'}),
({'AWS_SHA... | ({'AWS_PLACEHOLDER_KEY': '/foo', 'AWS_CONFIG_FILE': '/bar'}, {'/bar'}), |
Predict the next line for this snippet: <|code_start|> {
'AWS_PLACEHOLDER_KEY': '/foo', 'AWS_CONFIG_FILE': '/bar',
'AWS_CREDENTIAL_FILE': '/baz',
},
{'/bar', '/baz'},
),
(
{
'AWS_CONFIG_FILE': '/foo', 'AWS_CRE... | ( |
Continue the code snippet: <|code_start|>from __future__ import annotations
@pytest.mark.parametrize(
('env_vars', 'values'),
(
({}, set()),
({'AWS_PLACEHOLDER_KEY': '/foo'}, set()),
({'AWS_CONFIG_FILE': '/foo'}, {'/foo'}),
({'AWS_CREDENTIAL_FILE': '/foo'}, {'/foo'}),
... | ({'BOTO_CONFIG': '/foo'}, {'/foo'}), |
Given the following code snippet before the placeholder: <|code_start|> ({}, set()),
({'AWS_PLACEHOLDER_KEY': '/foo'}, set()),
({'AWS_CONFIG_FILE': '/foo'}, {'/foo'}),
({'AWS_CREDENTIAL_FILE': '/foo'}, {'/foo'}),
({'AWS_SHARED_CREDENTIALS_FILE': '/foo'}, {'/foo'}),
({'BOTO... | ( |
Given snippet: <|code_start|>from __future__ import annotations
@pytest.mark.parametrize(
('env_vars', 'values'),
(
({}, set()),
({'AWS_PLACEHOLDER_KEY': '/foo'}, set()),
({'AWS_CONFIG_FILE': '/foo'}, {'/foo'}),
({'AWS_CREDENTIAL_FILE': '/foo'}, {'/foo'}),
({'AWS_SHA... | { |
Predict the next line for this snippet: <|code_start|>def test_ok_no_newline_end_of_file(tmpdir):
filename = tmpdir.join('f')
filename.write_binary(b'foo\nbar')
ret = main((str(filename),))
assert filename.read_binary() == b'foo\nbar'
assert ret == 0
def test_ok_with_dos_line_endings(tmpdir):
... | 'bar\n' |
Given the following code snippet before the placeholder: <|code_start|> for filename in set(relevant_files):
if filename.lower() in lowercase_relevant_files:
lowercase_relevant_files.remove(filename.lower())
else:
conflicts.add(filename.lower())
if conflicts:
conf... | if __name__ == '__main__': |
Next line prediction: <|code_start|>from __future__ import annotations
def test_trivial(tmpdir):
f = tmpdir.join('f.txt').ensure()
assert not main((str(f),))
def test_passing(tmpdir):
f = tmpdir.join('f.txt')
f.write_binary(
# permalinks are ok
b'https://github.com/asottile/test/blo... | b'https://example.com/asottile/test/blob/master/foo#L1\n' |
Given the code snippet: <|code_start|> b'c-a>=1;python_version>="3.6"\n'
b'd>2\n'
b'e>=2\n'
b'f<=2\n'
b'g<2\n',
),
(b'ocflib\nDjango\nPyMySQL\n', FAIL, b'Django\nocflib\nPyMySQL\n'),
(
b'-e git+ssh://git_url@tag#egg=ocflib\nD... | b' --hash=sha256:abcd\n', |
Using the snippet: <|code_start|> (
b'#comment1\nbar\n#comment2\nfoo\n',
PASS,
b'#comment1\nbar\n#comment2\nfoo\n',
),
(b'#comment\n\nfoo\nbar\n', FAIL, b'#comment\n\nbar\nfoo\n'),
(b'#comment\n\nbar\nfoo\n', PASS, b'#comment\n\nbar\nfoo\n'),
(
... | b'd>2\n' |
Predict the next line for this snippet: <|code_start|> (b'foo\n# comment at end\n', PASS, b'foo\n# comment at end\n'),
(b'foo\nbar\n', FAIL, b'bar\nfoo\n'),
(b'bar\nfoo\n', PASS, b'bar\nfoo\n'),
(b'a\nc\nb\n', FAIL, b'a\nb\nc\n'),
(b'a\nc\nb', FAIL, b'a\nb\nc\n'),
(b'a\nb\... | ( |
Here is a snippet: <|code_start|> (b'a\nc\nb', FAIL, b'a\nb\nc\n'),
(b'a\nb\nc', FAIL, b'a\nb\nc\n'),
(
b'#comment1\nfoo\n#comment2\nbar\n',
FAIL,
b'#comment2\nbar\n#comment1\nfoo\n',
),
(
b'#comment1\nbar\n#comment2\nfoo\n',
... | ), |
Using the snippet: <|code_start|>from __future__ import annotations
def test_readme_contains_all_hooks():
with open('README.md', encoding='UTF-8') as f:
readme_contents = f.read()
with open('.pre-commit-hooks.yaml', encoding='UTF-8') as f:
hooks = yaml.load(f)
<|code_end|>
, determine the nex... | for hook in hooks: |
Here is a snippet: <|code_start|>from __future__ import annotations
def test_main_all_pass():
ret = main(['foo_test.py', 'bar_test.py'])
assert ret == 0
def test_main_one_fails():
ret = main(['not_test_ending.py', 'foo_test.py'])
assert ret == 1
def test_regex():
assert main(('foo_test_py',))... | def test_main_django_all_pass(): |
Given snippet: <|code_start|> ('--fix=crlf', b'foo\r\nbar\r\nbaz\r\n'),
# --fix=lf with lf endings
('--fix=lf', b'foo\nbar\nbaz\n'),
),
)
def test_line_endings_ok(fix_option, input_s, tmpdir, capsys):
path = tmpdir.join('input.txt')
path.write_binary(input_s)
ret = main((fix_optio... | path.write_binary(b'foo\r\nbar\rbaz\n') |
Predict the next line after this snippet: <|code_start|> # Commit in clone and pull without committing
with repo2.as_cwd():
repo2_f2.write('child\n')
cmd_output('git', 'add', '.')
git_commit('-m', 'clone commit2')
cmd_output('git', 'pull', '--no-commit', '--no-rebase')
# W... | f1_is_a_conflict_file.join('f1').write_binary(contents) |
Given the code snippet: <|code_start|>@pytest.fixture
def repository_pending_merge(tmpdir):
# Make a (non-conflicting) merge
repo1 = tmpdir.join('repo1')
repo1_f1 = repo1.join('f1')
repo2 = tmpdir.join('repo2')
repo2_f1 = repo2.join('f1')
repo2_f2 = repo2.join('f2')
cmd_output('git', 'init',... | assert os.path.exists(os.path.join('.git', 'MERGE_HEAD')) |
Using the snippet: <|code_start|> repo1_f1 = repo1.join('f1')
repo2 = tmpdir.join('repo2')
repo2_f1 = repo2.join('f1')
repo2_f2 = repo2.join('f2')
cmd_output('git', 'init', str(repo1))
with repo1.as_cwd():
repo1_f1.ensure()
cmd_output('git', 'add', '.')
git_commit('-m', 'c... | @pytest.mark.usefixtures('f1_is_a_conflict_file') |
Next line prediction: <|code_start|> # Commit in master
with repo1.as_cwd():
repo1_f1.write('parent\n')
git_commit('-am', 'master commit2')
# Commit in clone and pull
with repo2.as_cwd():
repo2_f1.write('child\n')
git_commit('-am', 'clone commit2')
cmd_output('git... | 'parent\n' |
Predict the next line for this snippet: <|code_start|> fname = test_images / "test_000_.SPE"
fr1 = np.zeros((32, 32), np.uint16)
fr2 = np.ones_like(fr1)
# Test imread
im = imageio.imread(fname)
ims = imageio.mimread(fname)
np.testing.assert_equal(im, fr1)
np.testing.assert_equal(ims, [... | {"top_left": [238, 187], "bottom_right": [269, 218], "bin": [1, 1]} |
Given the code snippet: <|code_start|>
User = get_user_model()
@override_settings(AUTH_USER_MODEL='tests.VerifyEmailUser')
class TestVerifyAccountView(APIRequestTestCase):
view_class = views.VerifyAccountViewMixin
<|code_end|>
, generate the next line using the imports in this file:
import mock
from django.con... | @classmethod |
Based on the snippet: <|code_start|>
User = get_user_model()
@override_settings(AUTH_USER_MODEL='tests.VerifyEmailUser')
class TestVerifyAccountView(APIRequestTestCase):
view_class = views.VerifyAccountViewMixin
@classmethod
def setUpTestData(cls):
cls.request = mock.MagicMock
cls.view_i... | def test_verify_token_allowed(self): |
Continue the code snippet: <|code_start|>
class UserFactory(factory.DjangoModelFactory):
name = factory.Sequence('Test User {}'.format)
email = factory.Sequence('email{}@example.com'.format)
is_active = True
class Meta:
model = get_user_model()
@factory.post_generation
def password(... | email_verified = False |
Next line prediction: <|code_start|>
class UserFactory(factory.DjangoModelFactory):
name = factory.Sequence('Test User {}'.format)
email = factory.Sequence('email{}@example.com'.format)
is_active = True
class Meta:
model = get_user_model()
@factory.post_generation
def password(self,... | email_verified = False |
Here is a snippet: <|code_start|> def test_invalid_token(self):
data = QueryDict('', mutable=True)
data.update({'token': 'WOOT'})
request = mock.Mock(data=data)
response = FormTokenAuthentication().authenticate(request)
self.assertIsNone(response)
def test_valid_token(sel... | ) |
Based on the snippet: <|code_start|>
class TestFormTokenAuthentication(TestCase):
def test_no_token(self):
request = mock.Mock(data=QueryDict(''))
response = FormTokenAuthentication().authenticate(request)
self.assertIsNone(response)
<|code_end|>
, predict the immediate next line with th... | def test_invalid_token(self): |
Predict the next line after this snippet: <|code_start|> response = FormTokenAuthentication().authenticate(request)
self.assertIsNone(response)
def test_invalid_token(self):
data = QueryDict('', mutable=True)
data.update({'token': 'WOOT'})
request = mock.Mock(data=data)
... | key=self.key, |
Using the snippet: <|code_start|>
class TestFormTokenAuthentication(TestCase):
def test_no_token(self):
request = mock.Mock(data=QueryDict(''))
response = FormTokenAuthentication().authenticate(request)
self.assertIsNone(response)
def test_invalid_token(self):
data = QueryDic... | def test_valid_token(self): |
Given snippet: <|code_start|>
class TestAuthToken(utils.APIRequestTestCase):
model = AuthToken
def test_fields(self):
fields = {field.name for field in self.model._meta.get_fields()}
expected = (
# Inherited from subclassed model
'key',
<|code_end|>
, continue by predi... | 'user', |
Next line prediction: <|code_start|>
class TestAuthToken(utils.APIRequestTestCase):
model = AuthToken
def test_fields(self):
fields = {field.name for field in self.model._meta.get_fields()}
expected = (
# Inherited from subclassed model
'key',
<|code_end|>
. Use curren... | 'user', |
Predict the next line for this snippet: <|code_start|>
class TestAuthToken(utils.APIRequestTestCase):
model = AuthToken
def test_fields(self):
fields = {field.name for field in self.model._meta.get_fields()}
expected = (
# Inherited from subclassed model
'key',
... | 'created', |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
class PasswordsTest(TestCase):
too_simple = (
'Password must have at least ' +
'one upper case letter, one lower case letter, and one number.'
)
too_fancy = (
'Password only accepts the following sym... | with self.assertRaises(ValidationError) as error: |
Based on the snippet: <|code_start|>
class VerifyUserAdminTest(TestCase):
def setUp(self):
self.site = AdminSite()
def test_create_fieldsets(self):
expected_fieldsets = (
(None, {
<|code_end|>
, predict the immediate next line with the help of imports:
from django.contrib.admin.s... | 'classes': ('wide',), |
Given the following code snippet before the placeholder: <|code_start|>
class VerifyUserAdminTest(TestCase):
def setUp(self):
self.site = AdminSite()
def test_create_fieldsets(self):
expected_fieldsets = (
(None, {
'classes': ('wide',),
'fields': ('e... | 'user_permissions', |
Here is a snippet: <|code_start|>
def test_create_fieldsets(self):
expected_fieldsets = (
(None, {
'classes': ('wide',),
'fields': ('email', 'password1', 'password2'),
}),
)
verify_user_admin = VerifyUserAdmin(User, self.site)
... | }), |
Given snippet: <|code_start|>
class TestRemoveExpiredTokensManagementCommand(utils.APIRequestTestCase):
def setUp(self):
self.command = remove_expired_tokens.Command()
self.command.stdout = mock.MagicMock()
<|code_end|>
, continue by predicting the next line. Consider current file imports:
impo... | def test_no_tokens_removed(self): |
Given snippet: <|code_start|>
class TestRemoveExpiredTokensManagementCommand(utils.APIRequestTestCase):
def setUp(self):
self.command = remove_expired_tokens.Command()
<|code_end|>
, continue by predicting the next line. Consider current file imports:
import datetime
import mock
from django.test.utils i... | self.command.stdout = mock.MagicMock() |
Given the code snippet: <|code_start|>
class TestRemoveExpiredTokensManagementCommand(utils.APIRequestTestCase):
def setUp(self):
self.command = remove_expired_tokens.Command()
self.command.stdout = mock.MagicMock()
<|code_end|>
, generate the next line using the imports in this file:
import da... | def test_no_tokens_removed(self): |
Next line prediction: <|code_start|>
class TestRemoveExpiredTokensManagementCommand(utils.APIRequestTestCase):
def setUp(self):
self.command = remove_expired_tokens.Command()
self.command.stdout = mock.MagicMock()
<|code_end|>
. Use current file imports:
(import datetime
import mock
from django... | def test_no_tokens_removed(self): |
Given the code snippet: <|code_start|>
class User(AvatarMixin, VerifyEmailMixin, PermissionsMixin, AbstractBaseUser):
pass
class BasicUser(BasicUserFieldsMixin, AbstractBaseUser):
pass
class VerifyEmailUser(VerifyEmailMixin, AbstractBaseUser):
<|code_end|>
, generate the next line using the imports in th... | pass |
Predict the next line after this snippet: <|code_start|>
class User(AvatarMixin, VerifyEmailMixin, PermissionsMixin, AbstractBaseUser):
pass
class BasicUser(BasicUserFieldsMixin, AbstractBaseUser):
pass
class VerifyEmailUser(VerifyEmailMixin, AbstractBaseUser):
<|code_end|>
using the current file's impo... | pass |
Given snippet: <|code_start|>
class User(AvatarMixin, VerifyEmailMixin, PermissionsMixin, AbstractBaseUser):
pass
class BasicUser(BasicUserFieldsMixin, AbstractBaseUser):
pass
class VerifyEmailUser(VerifyEmailMixin, AbstractBaseUser):
<|code_end|>
, continue by predicting the next line. Consider current ... | pass |
Using the snippet: <|code_start|>
class User(AvatarMixin, VerifyEmailMixin, PermissionsMixin, AbstractBaseUser):
pass
class BasicUser(BasicUserFieldsMixin, AbstractBaseUser):
<|code_end|>
, determine the next line of code. You have imports:
from django.contrib.auth.models import AbstractBaseUser, PermissionsM... | pass |
Predict the next line after this snippet: <|code_start|>
class User(AvatarMixin, VerifyEmailMixin, PermissionsMixin, AbstractBaseUser):
pass
class BasicUser(BasicUserFieldsMixin, AbstractBaseUser):
pass
class VerifyEmailUser(VerifyEmailMixin, AbstractBaseUser):
<|code_end|>
using the current file's impo... | pass |
Continue the code snippet: <|code_start|>
class User(AvatarMixin, VerifyEmailMixin, PermissionsMixin, AbstractBaseUser):
pass
class BasicUser(BasicUserFieldsMixin, AbstractBaseUser):
pass
class VerifyEmailUser(VerifyEmailMixin, AbstractBaseUser):
<|code_end|>
. Use current file imports:
from django.cont... | pass |
Next line prediction: <|code_start|>
class User(AvatarMixin, VerifyEmailMixin, PermissionsMixin, AbstractBaseUser):
pass
class BasicUser(BasicUserFieldsMixin, AbstractBaseUser):
<|code_end|>
. Use current file imports:
(from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin
from django.db i... | pass |
Continue the code snippet: <|code_start|>
@override_settings(AUTH_USER_MODEL='tests.VerifyEmailUser')
class TestVerifyUserEmailView(RequestTestCase):
view_class = views.VerifyUserEmailView
<|code_end|>
. Use current file imports:
from django.test import override_settings
from user_management.models.tests.facto... | def test_get(self): |
Based on the snippet: <|code_start|>
@override_settings(AUTH_USER_MODEL='tests.VerifyEmailUser')
class TestVerifyUserEmailView(RequestTestCase):
view_class = views.VerifyUserEmailView
<|code_end|>
, predict the immediate next line with the help of imports:
from django.test import override_settings
from user_ma... | def test_get(self): |
Predict the next line for this snippet: <|code_start|>
@override_settings(AUTH_USER_MODEL='tests.VerifyEmailUser')
class TestVerifyUserEmailView(RequestTestCase):
view_class = views.VerifyUserEmailView
<|code_end|>
with the help of current file imports:
from django.test import override_settings
from user_mana... | def test_get(self): |
Next line prediction: <|code_start|>
User = get_user_model()
TEST_SERVER = 'http://testserver'
SEND_METHOD = 'user_management.utils.notifications.incuna_mail.send'
EMAIL_CONTEXT = 'user_management.utils.notifications.password_reset_email_context'
REGISTRATION_SERIALIZER_META_MODEL = (
'user_management.api.seriali... | cache.clear() |
Given the code snippet: <|code_start|>
User = get_user_model()
TEST_SERVER = 'http://testserver'
SEND_METHOD = 'user_management.utils.notifications.incuna_mail.send'
<|code_end|>
, generate the next line using the imports in this file:
import datetime
import re
from collections import OrderedDict
from django.contrib... | EMAIL_CONTEXT = 'user_management.utils.notifications.password_reset_email_context' |
Given the code snippet: <|code_start|>
User = get_user_model()
TEST_SERVER = 'http://testserver'
SEND_METHOD = 'user_management.utils.notifications.incuna_mail.send'
EMAIL_CONTEXT = 'user_management.utils.notifications.password_reset_email_context'
REGISTRATION_SERIALIZER_META_MODEL = (
'user_management.api.seria... | self.data = {'username': self.username, 'password': self.password} |
Using the snippet: <|code_start|>
User = get_user_model()
TEST_SERVER = 'http://testserver'
SEND_METHOD = 'user_management.utils.notifications.incuna_mail.send'
EMAIL_CONTEXT = 'user_management.utils.notifications.password_reset_email_context'
REGISTRATION_SERIALIZER_META_MODEL = (
'user_management.api.serializer... | cache.clear() |
Given snippet: <|code_start|>
User = get_user_model()
TEST_SERVER = 'http://testserver'
SEND_METHOD = 'user_management.utils.notifications.incuna_mail.send'
EMAIL_CONTEXT = 'user_management.utils.notifications.password_reset_email_context'
REGISTRATION_SERIALIZER_META_MODEL = (
'user_management.api.serializers.Re... | def tearDown(self): |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.