repo_id
stringclasses
409 values
prefix
large_stringlengths
34
36.3k
target
large_stringlengths
1
498
assertion_type
stringclasses
31 values
difficulty
stringclasses
8 values
test_file
stringlengths
10
121
test_function
stringlengths
1
104
test_class
stringlengths
0
51
lineno
int32
2
11.3k
commit_idx
int32
bottlepy/bottle
import unittest import sys import itertools import bottle from bottle import request, tob, touni, json_dumps, HTTPError, parse_date, CookieError from . import tools import wsgiref.util import base64 from bottle import BaseRequest, BaseResponse, LocalRequest class TestRequest(unittest.TestCase): def _test_chunk...
ips)
self.assertEqual
variable
test/test_environ.py
test_remote_route
TestRequest
435
null
bottlepy/bottle
import unittest from bottle import FormsDict, touni, tob class TestFormsDict(unittest.TestCase): def test_attr_missing(self): """ FomsDict.attribute returs u'' on missing keys. """ d = FormsDict() self.assertEqual('',
d.missing)
self.assertEqual
complex_expr
test/test_formsdict.py
test_attr_missing
TestFormsDict
17
null
bottlepy/bottle
import sys import unittest from bottle import static_file, request, response, parse_date, parse_range_header, Bottle, tob import bottle import wsgiref.util import os import tempfile import time basename = os.path.basename(__file__) root = os.path.dirname(__file__) basename2 = os.path.basename(bottle.__file__) root2 =...
f.status_code)
self.assertEqual
complex_expr
test/test_sendfile.py
test_invalid
TestSendFile
64
null
bottlepy/bottle
import unittest import sys, os import bottle class TestImportHooks(unittest.TestCase): def make_module(self, name, **args): mod = sys.modules.setdefault(name, bottle.new_module(name)) mod.__file__ = '<virtual %s>' % name mod.__dict__.update(**args) return mod def test_ext_isfi...
os.path.isfile(ext.__file__))
self.assertTrue
func_call
test/test_importhook.py
test_ext_isfile
TestImportHooks
40
null
bottlepy/bottle
import unittest import base64 import sys, os.path, tempfile from io import BytesIO import bottle class BaseMultipartTest(unittest.TestCase): def setUp(self): self.reset() def reset(self): self.data = BytesIO() self.parts = None def write(self, *lines): for line in lines: ...
filename)
self.assertEqual
variable
test/test_multipart.py
assertFile
BaseMultipartTest
33
null
bottlepy/bottle
from __future__ import with_statement import bottle from .tools import ServerTestBase, chdir from bottle import tob, touni, HTTPResponse class TestWsgi(ServerTestBase): def get204(self): """ 204 responses must not return some entity headers """ bad = ('content-length', 'content-type') for ...
'b=b' in c)
self.assertTrue
string_literal
test/test_wsgi.py
test_cookie
TestWsgi
170
null
bottlepy/bottle
import sys import unittest from bottle import static_file, request, response, parse_date, parse_range_header, Bottle, tob import bottle import wsgiref.util import os import tempfile import time basename = os.path.basename(__file__) root = os.path.dirname(__file__) basename2 = os.path.basename(bottle.__file__) root2 =...
parse_date('Bad 123'))
self.assertEqual
func_call
test/test_sendfile.py
test_bad
TestDateParser
44
null
bottlepy/bottle
import unittest import sys import itertools import bottle from bottle import request, tob, touni, json_dumps, HTTPError, parse_date, CookieError from . import tools import wsgiref.util import base64 from bottle import BaseRequest, BaseResponse, LocalRequest class TestRequest(unittest.TestCase): def _test_chunk...
[])
self.assertEqual
collection
test/test_environ.py
test_remote_route
TestRequest
433
null
bottlepy/bottle
import unittest import base64 import sys, os.path, tempfile from io import BytesIO import bottle class TestMultipartParser(BaseMultipartTest): def assertIterline(self, data, *expected, **options): self.assertEqual( list(bottle._MultipartParser(BytesIO(bottle.tob(data)), 'foo', **options)._lin...
partial)
self.assertEqual
variable
test/test_multipart.py
test_fuzzy_lineiter
TestMultipartParser
101
null
bottlepy/bottle
import unittest import bottle import warnings class TestRouter(unittest.TestCase): CGI = False def setUp(self): self.r = bottle.Router() def add(self, path, target, method='GET', **ka): with warnings.catch_warnings() as r: warnings.simplefilter("ignore") self.r.add...
Exception)
self.assertRaises
variable
test/test_router.py
testErrorInPattern
TestRouter
97
null
bottlepy/bottle
import unittest from bottle import FormsDict, touni, tob class TestFormsDict(unittest.TestCase): def test_attr_access(self): """ FomsDict.attribute returs string values as unicode. """ d = FormsDict(py3='瓶') self.assertEqual('瓶', d.
d.py3)
self.assertEqual
complex_expr
test/test_formsdict.py
test_attr_access
TestFormsDict
11
null
bottlepy/bottle
import unittest import sys import itertools import bottle from bottle import request, tob, touni, json_dumps, HTTPError, parse_date, CookieError from . import tools import wsgiref.util import base64 from bottle import BaseRequest, BaseResponse, LocalRequest class TestRequest(unittest.TestCase): def _test_chunk...
test)
self.assertEqual
variable
test/test_environ.py
test_json_valid
TestRequest
392
null
bottlepy/bottle
import unittest from bottle import Jinja2Template, jinja2_template, jinja2_view, touni from .tools import warn, chdir class TestJinja2Template(unittest.TestCase): def test_template_shortcut(self): result = jinja2_template('start {{var}} end', var='middle') self.assertEqual(touni('start middle end...
result)
self.assertEqual
variable
test/test_jinja2.py
test_template_shortcut
TestJinja2Template
59
null
bottlepy/bottle
import unittest from bottle import MultiDict, HeaderDict class TestMultiDict(unittest.TestCase): def test_isadict(self): """ MultiDict should behaves like a normal dict """ d, m = dict(a=5), MultiDict(a=5) d['key'], m['key'] = 'value', 'value' d['k2'], m['k2'] = 'v1', 'v1' d...
len(m))
self.assertEqual
func_call
test/test_mdict.py
test_isadict
TestMultiDict
19
null
bottlepy/bottle
import os.path import sys import unittest from bottle import ResourceManager class TestResourceManager(unittest.TestCase): def test_open(self): rm = ResourceManager() rm.add_path(__file__) fp = rm.open(__file__) self.assertEqual(fp.read(),
open(__file__).read())
self.assertEqual
func_call
test/test_resources.py
test_open
TestResourceManager
97
null
bottlepy/bottle
import unittest import sys, os.path import bottle from bottle import FileUpload, BytesIO, tob import tempfile class TestFileUpload(unittest.TestCase): def assertFilename(self, bad, good): fu = FileUpload(None, None, bad) self.assertEqual(fu.filename, good) def test_save_buffer(self): ...
buff.read())
self.assertEqual
func_call
test/test_fileupload.py
test_save_buffer
TestFileUpload
48
null
bottlepy/bottle
import functools import unittest import bottle from .tools import api from bottle import _re_flatten class TestRoute(unittest.TestCase): @api('0.12') def test_callback_inspection(self): def x(a, b): pass def d(f): @functools.wraps(f) def w(): return f() ...
set(['a', 'b']))
self.assertEqual
func_call
test/test_route.py
test_callback_inspection
TestRoute
30
null
bottlepy/bottle
from __future__ import with_statement import unittest from bottle import SimpleTemplate, TemplateError, view, template, touni, tob, html_quote import re, os import traceback from .tools import chdir class TestSimpleTemplate(unittest.TestCase): def assertRenders(self, tpl, to, *args, **vars): if isinstance(...
test())
self.assertEqual
func_call
test/test_stpl.py
test_view_decorator
TestSimpleTemplate
213
null
bottlepy/bottle
import unittest import base64 import sys, os.path, tempfile from io import BytesIO import bottle class TestMultipartParser(BaseMultipartTest): def assertIterline(self, data, *expected, **options): self.assertEqual( list(bottle._MultipartParser(BytesIO(bottle.tob(data)), 'foo', **options)._lin...
'random.png')
self.assertEqual
string_literal
test/test_multipart.py
test_multiline_header
TestMultipartParser
170
null
bottlepy/bottle
import unittest import base64 import sys, os.path, tempfile from io import BytesIO import bottle class BaseMultipartTest(unittest.TestCase): def setUp(self): self.reset() def reset(self): self.data = BytesIO() self.parts = None def write(self, *lines): for line in lines: ...
bottle.tob(data))
self.assertEqual
func_call
test/test_multipart.py
assertFile
BaseMultipartTest
35
null
bottlepy/bottle
import os import tempfile import unittest from bottle import ConfigDict class TestConfDict(unittest.TestCase): def test_write(self): c = ConfigDict() c['key'] = 'value' self.assertEqual(c['key'], 'value') self.assertTrue('key' in c) c['key'] = 'value2' self.assertE...
'value2')
self.assertEqual
string_literal
test/test_config.py
test_write
TestConfDict
37
null
bottlepy/bottle
from __future__ import with_statement import bottle from .tools import ServerTestBase, chdir from bottle import tob, touni, HTTPResponse class TestDecorators(ServerTestBase): def test_autoroute(self): app = bottle.Bottle() def a(): pass def b(x): pass def c(x, y): pass def ...
list(bottle.yieldroutes(d)))
self.assertEqual
func_call
test/test_wsgi.py
test_autoroute
TestDecorators
516
null
bottlepy/bottle
import os import tempfile import unittest from bottle import ConfigDict class TestConfDict(unittest.TestCase): def test_isadict(self): """ ConfigDict should behaves like a normal dict. """ # It is a dict-subclass, so this kind of pointless, but it doen't hurt. d, m = dict(), ConfigDict() ...
len(m))
self.assertEqual
func_call
test/test_config.py
test_isadict
TestConfDict
21
null
bottlepy/bottle
import unittest import bottle import warnings class TestRouter(unittest.TestCase): CGI = False def setUp(self): self.r = bottle.Router() def add(self, path, target, method='GET', **ka): with warnings.catch_warnings() as r: warnings.simplefilter("ignore") self.r.add...
urlargs)
self.assertEqual
variable
test/test_router.py
assertMatches
TestRouter
29
null
bottlepy/bottle
import unittest from bottle import Jinja2Template, jinja2_template, jinja2_view, touni from .tools import warn, chdir class TestJinja2Template(unittest.TestCase): def test_notfound(self): """ Templates: Unavailable templates""" self.assertRaises(
Exception)
self.assertRaises
variable
test/test_jinja2.py
test_notfound
TestJinja2Template
29
null
bottlepy/bottle
import unittest import bottle import warnings class TestRouter(unittest.TestCase): CGI = False def setUp(self): self.r = bottle.Router() def add(self, path, target, method='GET', **ka): with warnings.catch_warnings() as r: warnings.simplefilter("ignore") self.r.add...
'bar')
self.assertEqual
string_literal
test/test_router.py
test_dynamic_before_static_any
TestRouter
141
null
bottlepy/bottle
from __future__ import with_statement import os import bottle import sys import unittest import wsgiref import wsgiref.util import wsgiref.validate import warnings import mimetypes import uuid from bottle import tob, BytesIO def warn(msg): sys.stderr.write('WARNING: %s\n' % msg.strip()) def tobs(data): '''...
self.urlopen(route, **kargs)['header'].get(name, None))
self.assertTrue
func_call
test/tools.py
assertHeaderAny
ServerTestBase
145
null
bottlepy/bottle
import unittest from . import tools from bottle import HTTPResponse, HTTPError, json_dumps def my_decorator(func): def wrapper(*a, **ka): return list(func(*a, **ka))[-1] class TestPluginManagement(tools.ServerTestBase): def verify_installed(self, plugin, otype, **config): self.assertEqual(ty...
plugin not in self.app.plugins)
self.assertTrue
complex_expr
test/test_plugins.py
test_uninstall_by_instance
TestPluginManagement
57
null
bottlepy/bottle
import unittest import sys, os import bottle class TestImportHooks(unittest.TestCase): def make_module(self, name, **args): mod = sys.modules.setdefault(name, bottle.new_module(name)) mod.__file__ = '<virtual %s>' % name mod.__dict__.update(**args) return mod def test_data_imp...
'value')
self.assertEqual
string_literal
test/test_importhook.py
test_data_import
TestImportHooks
27
null
bottlepy/bottle
import os.path import sys import unittest from bottle import ResourceManager class TestResourceManager(unittest.TestCase): def test_path_order(self): rm = ResourceManager() rm.add_path('/middle/') rm.add_path('/first/', index=0) rm.add_path('/last/') if sys.platform == 'wi...
['/first/', '/middle/', '/last/'])
self.assertEqual
collection
test/test_resources.py
test_path_order
TestResourceManager
83
null
bottlepy/bottle
import sys import unittest from bottle import static_file, request, response, parse_date, parse_range_header, Bottle, tob import bottle import wsgiref.util import os import tempfile import time basename = os.path.basename(__file__) root = os.path.dirname(__file__) basename2 = os.path.basename(bottle.__file__) root2 =...
res.status_code)
self.assertEqual
complex_expr
test/test_sendfile.py
test_ims
TestSendFile
107
null
bottlepy/bottle
import unittest import base64 import sys, os.path, tempfile from io import BytesIO import bottle class BaseMultipartTest(unittest.TestCase): def setUp(self): self.reset() def reset(self): self.data = BytesIO() self.parts = None def write(self, *lines): for line in lines: ...
ctype)
self.assertEqual
variable
test/test_multipart.py
assertFile
BaseMultipartTest
34
null
bottlepy/bottle
import unittest import bottle import threading def run_thread(func): t = threading.Thread(target=func) t.start() t.join() class TestThreadLocals(unittest.TestCase): def test_response(self): def run(): bottle.response.bind() bottle.response.content_type='test/thread' ...
'test/main')
self.assertEqual
string_literal
test/test_contextlocals.py
test_response
TestThreadLocals
39
null
bottlepy/bottle
import unittest from bottle import Jinja2Template, jinja2_template, jinja2_view, touni from .tools import warn, chdir class TestJinja2Template(unittest.TestCase): def test_custom_tests(self): """Templates: jinja2 custom tests """ from bottle import jinja2_template as template TEMPL = touni...
t.render(var=2))
self.assertEqual
func_call
test/test_jinja2.py
test_custom_tests
TestJinja2Template
54
null
bottlepy/bottle
import unittest from bottle import _parse_http_header class TestHttpUtils(unittest.TestCase): def test_accept_header(self): self.ass
[('text/xml', {}), ('text/whitespace', {}), ('application/params', {'param': 'value', 'ws': 'lots', 'quote': 'mid"quote'}), ('more"quotes"', {}), ('I\'m in space!!!', {})])
self.assertEqual
collection
test/test_html_helper.py
test_accept_header
TestHttpUtils
11
null
bottlepy/bottle
import unittest import sys import itertools import bottle from bottle import request, tob, touni, json_dumps, HTTPError, parse_date, CookieError from . import tools import wsgiref.util import base64 from bottle import BaseRequest, BaseResponse, LocalRequest class TestResponse(unittest.TestCase): def test_set_s...
200)
self.assertEqual
numeric_literal
test/test_environ.py
test_set_status
TestResponse
517
null
bottlepy/bottle
import unittest import bottle import warnings class TestRouter(unittest.TestCase): CGI = False def setUp(self): self.r = bottle.Router() def add(self, path, target, method='GET', **ka): with warnings.catch_warnings() as r: warnings.simplefilter("ignore") self.r.add...
str(n-1))
self.assertEqual
func_call
test/test_router.py
test_lots_of_routes
TestRouter
162
null
bottlepy/bottle
import sys import unittest from bottle import static_file, request, response, parse_date, parse_range_header, Bottle, tob import bottle import wsgiref.util import os import tempfile import time basename = os.path.basename(__file__) root = os.path.dirname(__file__) basename2 = os.path.basename(bottle.__file__) root2 =...
f.headers['Content-Type'])
self.assertEqual
complex_expr
test/test_sendfile.py
test_mime
TestSendFile
85
null
bottlepy/bottle
import os import tempfile import unittest from bottle import ConfigDict class TestConfDict(unittest.TestCase): def test_load_dict(self): c = ConfigDict() d = dict(a=dict(b=dict(foo=5, bar=6), baz=7)) c.load_dict(d) self.assertEqual(c['a.b.foo'], 5) self.assertEqual(c['a.b.b...
c[key])
self.assertEqual
complex_expr
test/test_config.py
test_load_dict
TestConfDict
82
null
bottlepy/bottle
from __future__ import with_statement import bottle from .tools import ServerTestBase, chdir from bottle import tob, touni, HTTPResponse class TestWsgi(ServerTestBase): def get204(self): """ 204 responses must not return some entity headers """ bad = ('content-length', 'content-type') for ...
h.lower() in bad)
self.assertFalse
func_call
test/test_wsgi.py
get204
TestWsgi
59
null
bottlepy/bottle
import unittest import bottle import warnings class TestRouter(unittest.TestCase): CGI = False def setUp(self): self.r = bottle.Router() def add(self, path, target, method='GET', **ka): with warnings.catch_warnings() as r: warnings.simplefilter("ignore") self.r.add...
bottle.HTTPError)
self.assertRaises
complex_expr
test/test_router.py
testBasic
TestRouter
41
null
bottlepy/bottle
import unittest from . import tools from bottle import HTTPResponse, HTTPError, json_dumps def my_decorator(func): def wrapper(*a, **ka): return list(func(*a, **ka))[-1] class TestPluginManagement(tools.ServerTestBase): def verify_installed(self, plugin, otype, **config): self.assertEqual(ty...
installed)
self.assertEqual
variable
test/test_plugins.py
test_install_plugin
TestPluginManagement
42
null
bottlepy/bottle
import bottle from .tools import ServerTestBase, api from bottle import response class TestAppMounting(ServerTestBase): def setUp(self): ServerTestBase.setUp(self) self.subapp = bottle.Bottle() @self.subapp.route('/') @self.subapp.route('/test/<test>') def test(test='foo'):...
list(sorted(c.split(', '))))
self.assertEqual
func_call
test/test_mount.py
test_mount_cookie
TestAppMounting
88
null
bottlepy/bottle
import os import tempfile import unittest from bottle import ConfigDict class TestConfDict(unittest.TestCase): def test_isadict(self): """ ConfigDict should behaves like a normal dict. """ # It is a dict-subclass, so this kind of pointless, but it doen't hurt. d, m = dict(), ConfigDict() ...
KeyError)
self.assertRaises
variable
test/test_config.py
test_isadict
TestConfDict
24
null
bottlepy/bottle
import sys import unittest from bottle import static_file, request, response, parse_date, parse_range_header, Bottle, tob import bottle import wsgiref.util import os import tempfile import time basename = os.path.basename(__file__) root = os.path.dirname(__file__) basename2 = os.path.basename(bottle.__file__) root2 =...
headers)
self.assertEqual
variable
test/test_sendfile.py
test_custom_headers
TestSendFile
173
null
bottlepy/bottle
import unittest from bottle import MultiDict, HeaderDict class TestMultiDict(unittest.TestCase): def test_isadict(self): """ MultiDict should behaves like a normal dict """ d, m = dict(a=5), MultiDict(a=5) d['key'], m['key'] = 'value', 'value' d['k2'], m['k2'] = 'v1', 'v1' d...
m.get('key'))
self.assertEqual
func_call
test/test_mdict.py
test_isadict
TestMultiDict
15
null
bottlepy/bottle
import sys import unittest from bottle import static_file, request, response, parse_date, parse_range_header, Bottle, tob import bottle import wsgiref.util import os import tempfile import time basename = os.path.basename(__file__) root = os.path.dirname(__file__) basename2 = os.path.basename(bottle.__file__) root2 =...
r('bytes=10-'))
self.assertEqual
func_call
test/test_sendfile.py
test_range_parser
TestSendFile
161
null
bottlepy/bottle
import unittest import bottle from bottle import tob, touni from .tools import api class TestSignedCookies(unittest.TestCase): def setUp(self): self.data = touni('υηι¢σ∂є') self.secret = tob('secret') bottle.app.push() bottle.response.bind() def tear_down(self): bottle...
result)
self.assertEqual
variable
test/test_securecookies.py
testValid
TestSignedCookies
34
null
bottlepy/bottle
from __future__ import with_statement import unittest from bottle import SimpleTemplate, TemplateError, view, template, touni, tob, html_quote import re, os import traceback from .tools import chdir class TestSimpleTemplate(unittest.TestCase): def assertRenders(self, tpl, to, *args, **vars): if isinstance(...
SyntaxError)
self.assertRaises
variable
test/test_stpl.py
test_error
TestSimpleTemplate
186
null
bottlepy/bottle
from __future__ import with_statement import bottle from .tools import ServerTestBase, chdir from bottle import tob, touni, HTTPResponse class TestDecorators(ServerTestBase): def test_autoroute(self): app = bottle.Bottle() def a(): pass def b(x): pass def c(x, y): pass def ...
list(bottle.yieldroutes(c)))
self.assertEqual
func_call
test/test_wsgi.py
test_autoroute
TestDecorators
515
null
bottlepy/bottle
import unittest import sys import itertools import bottle from bottle import request, tob, touni, json_dumps, HTTPError, parse_date, CookieError from . import tools import wsgiref.util import base64 from bottle import BaseRequest, BaseResponse, LocalRequest class TestRequest(unittest.TestCase): def _test_chunk...
x)
self.assertEqual
variable
test/test_environ.py
test_multipart
TestRequest
343
null
bottlepy/bottle
import unittest import sys import itertools import bottle from bottle import request, tob, touni, json_dumps, HTTPError, parse_date, CookieError from . import tools import wsgiref.util import base64 from bottle import BaseRequest, BaseResponse, LocalRequest class TestRequest(unittest.TestCase): def test_app_pr...
5)
self.assertEqual
numeric_literal
test/test_environ.py
test_app_property
TestRequest
25
null
bottlepy/bottle
import unittest import sys, os.path import bottle from bottle import FileUpload, BytesIO, tob import tempfile class TestFileUpload(unittest.TestCase): def test_content_type(self): fu = FileUpload(None, None, None, {"Content-type": "text/plain"}) self.assertEqual(fu.content_type,
'text/plain')
self.assertEqual
string_literal
test/test_fileupload.py
test_content_type
TestFileUpload
19
null
bottlepy/bottle
import os import tempfile import unittest from bottle import ConfigDict class TestConfDict(unittest.TestCase): def test_load_dict(self): c = ConfigDict() d = dict(a=dict(b=dict(foo=5, bar=6), baz=7)) c.load_dict(d) self.assertEqual(c['a.b.foo'], 5) self.assertEqual(c['a.b.b...
7)
self.assertEqual
numeric_literal
test/test_config.py
test_load_dict
TestConfDict
74
null
bottlepy/bottle
from __future__ import with_statement import os import bottle import sys import unittest import wsgiref import wsgiref.util import wsgiref.validate import warnings import mimetypes import uuid from bottle import tob, BytesIO def warn(msg): sys.stderr.write('WARNING: %s\n' % msg.strip()) def tobs(data): '''...
self.urlopen(route, **kargs)['code'])
self.assertEqual
func_call
test/tools.py
assertStatus
ServerTestBase
131
null
bottlepy/bottle
import os.path import sys import unittest from bottle import ResourceManager class TestResourceManager(unittest.TestCase): def test_get(self): rm = ResourceManager() rm.add_path('/first/') rm.add_path(__file__) rm.add_path('/last/') self.assertEqual(None,
rm.lookup('notexist.txt'))
self.assertEqual
func_call
test/test_resources.py
test_get
TestResourceManager
90
null
bottlepy/bottle
from __future__ import with_statement import unittest from bottle import SimpleTemplate, TemplateError, view, template, touni, tob, html_quote import re, os import traceback from .tools import chdir class TestSimpleTemplate(unittest.TestCase): def assertRenders(self, tpl, to, *args, **vars): if isinstance(...
t.code.splitlines()[0])
self.assertNotEqual
func_call
test/test_stpl.py
test_commentonly
TestSimpleTemplate
203
null
bottlepy/bottle
import unittest from bottle import Bottle class TestApplicationObject(unittest.TestCase): def test_setattr(self): """ Attributed can be assigned, but only once. """ app = Bottle() app.test = 5 self.assertEqual(5,
app.test)
self.assertEqual
complex_expr
test/test_app.py
test_setattr
TestApplicationObject
16
null
bottlepy/bottle
import functools import unittest import bottle from .tools import api from bottle import _re_flatten class TestRoute(unittest.TestCase): def test_unwrap_wrapped(self): import functools def func(): pass @functools.wraps(func) def wrapped(): return func() route =...
func)
self.assertEqual
variable
test/test_route.py
test_unwrap_wrapped
TestRoute
80
null
bottlepy/bottle
import sys import unittest from bottle import static_file, request, response, parse_date, parse_range_header, Bottle, tob import bottle import wsgiref.util import os import tempfile import time basename = os.path.basename(__file__) root = os.path.dirname(__file__) basename2 = os.path.basename(bottle.__file__) root2 =...
out.body.read())
self.assertEqual
func_call
test/test_sendfile.py
test_valid
TestSendFile
58
null
bottlepy/bottle
import os.path import sys import unittest from bottle import ResourceManager class TestResourceManager(unittest.TestCase): def test_root_path(self): if sys.platform == 'win32': expected = ['C:\\foo\\bar\\baz\\'] else: expected = ['/foo/bar/baz/'] for test in TEST_P...
expected)
self.assertEqual
variable
test/test_resources.py
test_root_path
TestResourceManager
67
null
bottlepy/bottle
import functools import unittest import bottle from .tools import api from bottle import _re_flatten class TestReFlatten(unittest.TestCase): def test_re_flatten(self): self.assertEqual(_re_flatten(r"(?:aaa)(_bbb)"), '(?:aaa)(?:_bbb)') self.assertEqual(_re_flatten(r"(aaa)(_bbb)"), '(?:aaa)(?:_bbb)'...
'aaa(?:_bbb)')
self.assertEqual
string_literal
test/test_route.py
test_re_flatten
TestReFlatten
14
null
bottlepy/bottle
import os import tempfile import unittest from bottle import ConfigDict class TestConfDict(unittest.TestCase): def test_overlay(self): source = ConfigDict() source['key'] = 'source' intermediate = source._make_overlay() overlay = intermediate._make_overlay() # Overlay cont...
'source')
self.assertEqual
string_literal
test/test_config.py
test_overlay
TestConfDict
103
null
bottlepy/bottle
import unittest from . import tools from bottle import HTTPResponse, HTTPError, json_dumps def my_decorator(func): def wrapper(*a, **ka): return list(func(*a, **ka))[-1] class TestPluginAPI(tools.ServerTestBase): def setUp(self): super(TestPluginAPI, self).setUp() @self.app.route('/'...
getattr(plugin2, 'closed', False))
self.assertTrue
func_call
test/test_plugins.py
test_close
TestPluginAPI
221
null
bottlepy/bottle
from __future__ import with_statement import bottle from .tools import ServerTestBase, chdir from bottle import tob, touni, HTTPResponse class TestRouteDecorator(ServerTestBase): def test_name(self): @bottle.route(name='foo') def test(x=5): return 'ok' self.assertEqual('/test/6',
bottle.url('foo', x=6))
self.assertEqual
func_call
test/test_wsgi.py
test_name
TestRouteDecorator
444
null
bottlepy/bottle
import unittest import sys import itertools import bottle from bottle import request, tob, touni, json_dumps, HTTPError, parse_date, CookieError from . import tools import wsgiref.util import base64 from bottle import BaseRequest, BaseResponse, LocalRequest class TestRequest(unittest.TestCase): def test_dict_a...
v)
self.assertEqual
variable
test/test_environ.py
test_dict_access
TestRequest
118
null
bottlepy/bottle
import unittest import base64 import sys, os.path, tempfile from io import BytesIO import bottle class TestBrokenMultipart(BaseMultipartTest): def assertMPError(self, **ka): self.assertRaises(bottle.MultipartError, self.parse, **ka) def test_preamble_before_start_boundary(self): parts = self...
'image/png')
self.assertEqual
string_literal
test/test_multipart.py
test_preamble_before_start_boundary
TestBrokenMultipart
222
null
bottlepy/bottle
import unittest from bottle import MultiDict, HeaderDict class TestMultiDict(unittest.TestCase): def test_isadict(self): """ MultiDict should behaves like a normal dict """ d, m = dict(a=5), MultiDict(a=5) d['key'], m['key'] = 'value', 'value' d['k2'], m['k2'] = 'v1', 'v1' d...
'cay' in m)
self.assertEqual
string_literal
test/test_mdict.py
test_isadict
TestMultiDict
21
null
bottlepy/bottle
from __future__ import with_statement import bottle from .tools import ServerTestBase, chdir from bottle import tob, touni, HTTPResponse class TestAppShortcuts(ServerTestBase): def setUp(self): ServerTestBase.setUp(self) def testWithStatement(self): default = bottle.default_app() inner...
bottle.default_app())
self.assertEqual
func_call
test/test_wsgi.py
testWithStatement
TestAppShortcuts
528
null
bottlepy/bottle
import unittest from . import tools from bottle import HTTPResponse, HTTPError, json_dumps def my_decorator(func): def wrapper(*a, **ka): return list(func(*a, **ka))[-1] class TestPluginManagement(tools.ServerTestBase): def verify_installed(self, plugin, otype, **config): self.assertEqual(ty...
TypeError)
self.assertRaises
variable
test/test_plugins.py
test_install_non_plugin
TestPluginManagement
51
null
bottlepy/bottle
import os import tempfile import unittest from bottle import ConfigDict class TestConfDict(unittest.TestCase): def test_load_dict(self): c = ConfigDict() d = dict(a=dict(b=dict(foo=5, bar=6), baz=7)) c.load_dict(d) self.assertEqual(c['a.b.foo'],
5)
self.assertEqual
numeric_literal
test/test_config.py
test_load_dict
TestConfDict
72
null
bottlepy/bottle
import functools import unittest import bottle from .tools import api from bottle import _re_flatten class TestReFlatten(unittest.TestCase): def test_re_flatten(self): self.assertEqual(_re_flatten(r"(?:aaa)(_bbb)"), '(?:aaa)(?:_bbb)') self.assertEqual(_re_flatten(r"(aaa)(_bbb)"), '(?:aaa)(?:_bbb)'...
'aaa_bbb')
self.assertEqual
string_literal
test/test_route.py
test_re_flatten
TestReFlatten
15
null
bottlepy/bottle
import unittest import bottle import warnings class TestRouter(unittest.TestCase): CGI = False def setUp(self): self.r = bottle.Router() def add(self, path, target, method='GET', **ka): with warnings.catch_warnings() as r: warnings.simplefilter("ignore") self.r.add...
target)
self.assertEqual
variable
test/test_router.py
assertMatches
TestRouter
28
null
bottlepy/bottle
import unittest from bottle import Jinja2Template, jinja2_template, jinja2_view, touni from .tools import warn, chdir class TestJinja2Template(unittest.TestCase): def test_custom_filters(self): """Templates: jinja2 custom filters """ from bottle import jinja2_template as template settings ...
t.render(var="var"))
self.assertEqual
func_call
test/test_jinja2.py
test_custom_filters
TestJinja2Template
46
null
bottlepy/bottle
import unittest import sys, os.path import bottle from bottle import FileUpload, BytesIO, tob import tempfile class TestFileUpload(unittest.TestCase): def test_name(self): self.assertEqual(FileUpload(None, 'abc', None).name,
'abc')
self.assertEqual
string_literal
test/test_fileupload.py
test_name
TestFileUpload
12
null
bottlepy/bottle
import sys import unittest from bottle import static_file, request, response, parse_date, parse_range_header, Bottle, tob import bottle import wsgiref.util import os import tempfile import time basename = os.path.basename(__file__) root = os.path.dirname(__file__) basename2 = os.path.basename(bottle.__file__) root2 =...
f.body.read())
self.assertEqual
func_call
test/test_sendfile.py
test_download
TestSendFile
147
null
bottlepy/bottle
import unittest import base64 import sys, os.path, tempfile from io import BytesIO import bottle class BaseMultipartTest(unittest.TestCase): def setUp(self): self.reset() def reset(self): self.data = BytesIO() self.parts = None def write(self, *lines): for line in lines: ...
data)
self.assertEqual
variable
test/test_multipart.py
assertForm
BaseMultipartTest
46
null
matthewwardrop/formulaic
import pytest from formulaic.errors import FormulaSyntaxError from formulaic.parser.types import Token from formulaic.parser.utils import ( exc_for_token, insert_tokens_after, merge_operator_tokens, replace_tokens, ) def tokens(): return [ Token("1", kind=Token.Kind.VALUE), Token("...
["++-"]
assert
collection
tests/parser/test_utils.py
test_merge_operator_tokens
104
null
matthewwardrop/formulaic
import re import numpy import pytest from formulaic.errors import FormulaSyntaxError from formulaic.utils.constraints import LinearConstraintParser, LinearConstraints class TestLinearConstraintParser: COLUMNS = list("abcd") TEST_CASES = { "a": ([[1, 0, 0, 0]], [0]), "a + 3 * (a + b - b) / 3 ...
(0, 4)
assert
collection
tests/utils/test_constraints.py
test_empty
TestLinearConstraintParser
244
null
matthewwardrop/formulaic
import pickle import re from io import BytesIO import numpy import pandas import pytest import scipy.sparse as spsparse from formulaic import ModelMatrices from formulaic.errors import ( FactorEncodingError, FactorEvaluationError, FormulaMaterializationError, ) from formulaic.materializers import PandasMa...
(3, 2)
assert
collection
tests/materializers/test_pandas.py
test_no_levels_encoding
TestPandasMaterializer
473
null
matthewwardrop/formulaic
import pickle import re from io import BytesIO import pytest from formulaic.utils.structured import Structured class TestStructured: def test_access_structure(self): s = Structured("Hello", key="asd") assert s.root == "Hello" assert s[None] == "Hello" assert s.key == "asd" ...
"1"
assert
string_literal
tests/parser/types/test_structured.py
test_access_structure
TestStructured
35
null
matthewwardrop/formulaic
import numpy import pandas as pd import pytest import scipy.sparse as spsparse from formulaic import model_matrix from formulaic.materializers import FactorValues from formulaic.transforms.hashed import hashed def _compare_factor_values(a, b, comp=lambda x, y: numpy.allclose(x, y)): assert type(a) is type(b) ...
(3, levels + 1)
assert
collection
tests/transforms/test_hashed.py
test_usage_in_model_matrix
59
null
matthewwardrop/formulaic
import pytest from formulaic.parser.types import FormulaParser FORMULA_TO_TOKENS = { "": [], " ": [], " \n": [], "1": ["1"], "a": ["a"], "a ~ b": ["a", "~", "b"], "a ~": ["a", "~"], "~ 1 + a": ["~", "1", "+", "a"], "0": ["0"], "0 ~": ["0", "~"], } PARSER = FormulaParser(operat...
tokens
assert
variable
tests/parser/types/test_formula_parser.py
test_get_tokens
TestFormulaParser
30
null
matthewwardrop/formulaic
import re import numpy import pytest from formulaic.errors import FormulaSyntaxError from formulaic.utils.constraints import LinearConstraintParser, LinearConstraints class TestLinearConstraintParser: COLUMNS = list("abcd") TEST_CASES = { "a": ([[1, 0, 0, 0]], [0]), "a + 3 * (a + b - b) / 3 ...
(0,)
assert
collection
tests/utils/test_constraints.py
test_empty
TestLinearConstraintParser
245
null
matthewwardrop/formulaic
import re import narwhals.stable.v1 as nw import numpy import pandas import pytest import scipy.sparse as spsparse from formulaic import model_matrix from formulaic.materializers import NarwhalsMaterializer NARWHALS_TESTS = { "a": (["Intercept", "a"], ["Intercept", "a"]), "A": ( ["Intercept", "A[T.b]...
(3, 5)
assert
collection
tests/materializers/test_narwhals.py
test_na_handling
TestNarwhalsMaterializer
125
null
matthewwardrop/formulaic
import json import os import numpy import numpy as np import pandas import pandas as pd import pytest from formulaic import model_matrix from formulaic.transforms.cubic_spline import ( ExtrapolationError, _get_all_sorted_knots, _map_cyclic, cubic_spline, cyclic_cubic_spline, natural_cubic_spli...
[0, 10])
assert_*
collection
tests/transforms/test_cubic_spline.py
test_get_all_sorted_knots
86
null
matthewwardrop/formulaic
import pytest from formulaic.materializers.types import ScopedFactor from formulaic.parser.types import Factor class TestScopedFactor: def scoped_factor(self): return ScopedFactor(Factor("a")) def scoped_factor_reduced(self): return ScopedFactor(Factor("a"), reduced=True) def test_hash(...
hash("a-")
assert
func_call
tests/materializers/types/test_scoped_factor.py
test_hash
TestScopedFactor
22
null
matthewwardrop/formulaic
import pickle import re from io import BytesIO import pytest from formulaic.utils.structured import Structured class TestStructured: def test__simplify(self): o = object() assert Structured(o)._simplify() is o assert Structured(Structured(o))._simplify() is o assert Structured(o,...
{"a": 1}
assert
collection
tests/parser/types/test_structured.py
test__simplify
TestStructured
119
null
matthewwardrop/formulaic
import re import narwhals.stable.v1 as nw import numpy import pandas import pytest import scipy.sparse as spsparse from formulaic import model_matrix from formulaic.materializers import NarwhalsMaterializer NARWHALS_TESTS = { "a": (["Intercept", "a"], ["Intercept", "a"]), "A": ( ["Intercept", "A[T.b]...
tests[0]
assert
complex_expr
tests/materializers/test_narwhals.py
test_get_model_matrix
TestNarwhalsMaterializer
83
null
matthewwardrop/formulaic
import re from pyexpat import model import numpy import pandas import pytest import scipy.sparse from formulaic import Formula, ModelMatrices, ModelMatrix, ModelSpec, ModelSpecs from formulaic.materializers.base import FormulaMaterializerMeta from formulaic.materializers.pandas import PandasMaterializer from formulai...
True
assert
bool_literal
tests/test_model_spec.py
test_attributes
TestModelSpec
56
null
matthewwardrop/formulaic
import pytest from formulaic.parser.types import Factor, Term from formulaic.parser.types.ordered_set import OrderedSet class TestTerm: def term1(self): return Term([Factor("c"), Factor("b")]) def term2(self): return Term([Factor("c"), Factor("d")]) def term3(self): return Term(...
0
assert
numeric_literal
tests/parser/types/test_term.py
test_degree
TestTerm
50
null
matthewwardrop/formulaic
import pickle import re from io import BytesIO import pandas import pytest from formulaic import Formula, SimpleFormula, StructuredFormula from formulaic.errors import FormulaInvalidError, FormulaMaterializerInvalidError from formulaic.parser.types.factor import Factor from formulaic.parser.types.term import Term fro...
["a:b"]
assert
collection
tests/test_formula.py
test_constructor
TestSimpleFormula
277
null
matthewwardrop/formulaic
import re import pandas import pyarrow import pytest from formulaic.errors import FactorEncodingError, FormulaMaterializerNotFoundError from formulaic.materializers.base import FormulaMaterializer from formulaic.materializers.narwhals import NarwhalsMaterializer from formulaic.materializers.pandas import PandasMateri...
[1, 2, 3, 4]
assert
collection
tests/materializers/test_base.py
test__flatten_encoded_evaled_factor
TestFormulaMaterializer
140
null
matthewwardrop/formulaic
import re import pandas import pyarrow import pytest from formulaic.errors import FactorEncodingError, FormulaMaterializerNotFoundError from formulaic.materializers.base import FormulaMaterializer from formulaic.materializers.narwhals import NarwhalsMaterializer from formulaic.materializers.pandas import PandasMateri...
1
assert
numeric_literal
tests/materializers/test_base.py
test__enforce_structure
TestFormulaMaterializer
148
null
matthewwardrop/formulaic
import pytest from formulaic.parser.types import Factor class TestFactor: def factor_unknown(self): return Factor("unknown") def factor_literal(self): return Factor('"string"', kind="literal") def factor_lookup(self): return Factor("a", kind="lookup") def test_equality(self...
Factor("a", eval_method="lookup")
assert
func_call
tests/parser/types/test_factor.py
test_equality
TestFactor
30
null
matthewwardrop/formulaic
import pickle import re from io import BytesIO from xml.etree.ElementInclude import include import pytest from formulaic.errors import FormulaParsingError, FormulaSyntaxError from formulaic.parser import DefaultFormulaParser, DefaultOperatorResolver from formulaic.parser.types import Token from formulaic.parser.types...
terms
assert
variable
tests/parser/test_parser.py
test_to_terms
TestFormulaParser
170
null
matthewwardrop/formulaic
from formulaic.parser.types import OrderedSet def test_ordered_set(): assert OrderedSet() == OrderedSet() assert len(OrderedSet()) == 0 assert list(OrderedSet(["a", "a", "z", "b"])) ==
["a", "z", "b"]
assert
collection
tests/parser/types/test_ordered_set.py
test_ordered_set
8
null
matthewwardrop/formulaic
import pytest from formulaic.materializers.types import ScopedFactor from formulaic.parser.types import Factor class TestScopedFactor: def scoped_factor(self): return ScopedFactor(Factor("a")) def scoped_factor_reduced(self): return ScopedFactor(Factor("a"), reduced=True) def test_sort(...
ScopedFactor(Factor("b"))
assert
func_call
tests/materializers/types/test_scoped_factor.py
test_sort
TestScopedFactor
31
null
matthewwardrop/formulaic
import re from pyexpat import model import numpy import pandas import pytest import scipy.sparse from formulaic import Formula, ModelMatrices, ModelMatrix, ModelSpec, ModelSpecs from formulaic.materializers.base import FormulaMaterializerMeta from formulaic.materializers.pandas import PandasMaterializer from formulai...
s
assert
variable
tests/test_model_spec.py
test_get_slice
TestModelSpec
135
null
matthewwardrop/formulaic
import copy from formulaic.utils.sentinels import MISSING, UNSET, Sentinel def test_missing(): assert MISSING is Sentinel.MISSING assert UNSET is Sentinel.UNSET assert MISSING is not UNSET assert bool(MISSING) is False assert repr(MISSING) == "MISSING" assert copy.copy(MISSING) is
MISSING
assert
variable
tests/utils/test_sentinels.py
test_missing
12
null