Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
mark_all_messages_as_read
()
We want to keep these two flags intact after we create messages: has_alert_word is_private But we will mark all messages as read to save a step for users.
We want to keep these two flags intact after we create messages:
def mark_all_messages_as_read() -> None: """ We want to keep these two flags intact after we create messages: has_alert_word is_private But we will mark all messages as read to save a step for users. """ # Mark all messages as read UserMessage.objects.all().update( ...
[ "def", "mark_all_messages_as_read", "(", ")", "->", "None", ":", "# Mark all messages as read", "UserMessage", ".", "objects", ".", "all", "(", ")", ".", "update", "(", "flags", "=", "F", "(", "\"flags\"", ")", ".", "bitor", "(", "UserMessage", ".", "flags",...
[ 888, 0 ]
[ 901, 5 ]
python
en
['en', 'error', 'th']
False
deconstructible
(*args, path=None)
Class decorator that allows the decorated class to be serialized by the migrations subsystem. The `path` kwarg specifies the import path.
Class decorator that allows the decorated class to be serialized by the migrations subsystem.
def deconstructible(*args, path=None): """ Class decorator that allows the decorated class to be serialized by the migrations subsystem. The `path` kwarg specifies the import path. """ def decorator(klass): def __new__(cls, *args, **kwargs): # We capture the arguments to mak...
[ "def", "deconstructible", "(", "*", "args", ",", "path", "=", "None", ")", ":", "def", "decorator", "(", "klass", ")", ":", "def", "__new__", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# We capture the arguments to make returning the...
[ 5, 0 ]
[ 54, 27 ]
python
en
['en', 'error', 'th']
False
spawn
(cmd, search_path=1, verbose=0, dry_run=0)
Run another program, specified as a command list 'cmd', in a new process. 'cmd' is just the argument list for the new process, ie. cmd[0] is the program to run and cmd[1:] are the rest of its arguments. There is no way to run a program with a name different from that of its executable. If 'search_...
Run another program, specified as a command list 'cmd', in a new process.
def spawn(cmd, search_path=1, verbose=0, dry_run=0): """Run another program, specified as a command list 'cmd', in a new process. 'cmd' is just the argument list for the new process, ie. cmd[0] is the program to run and cmd[1:] are the rest of its arguments. There is no way to run a program with a name...
[ "def", "spawn", "(", "cmd", ",", "search_path", "=", "1", ",", "verbose", "=", "0", ",", "dry_run", "=", "0", ")", ":", "# cmd is documented as a list, but just in case some code passes a tuple", "# in, protect our %-formatting code against horrible death", "cmd", "=", "l...
[ 22, 0 ]
[ 81, 70 ]
python
en
['en', 'en', 'en']
True
find_executable
(executable, path=None)
Tries to find 'executable' in the directories listed in 'path'. A string listing directories separated by 'os.pathsep'; defaults to os.environ['PATH']. Returns the complete filename or None if not found.
Tries to find 'executable' in the directories listed in 'path'.
def find_executable(executable, path=None): """Tries to find 'executable' in the directories listed in 'path'. A string listing directories separated by 'os.pathsep'; defaults to os.environ['PATH']. Returns the complete filename or None if not found. """ _, ext = os.path.splitext(executable) i...
[ "def", "find_executable", "(", "executable", ",", "path", "=", "None", ")", ":", "_", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "executable", ")", "if", "(", "sys", ".", "platform", "==", "'win32'", ")", "and", "(", "ext", "!=", "'....
[ 84, 0 ]
[ 118, 15 ]
python
en
['en', 'en', 'en']
True
TypingValidateOperatorTest.test_missing_parameter
(self)
Sending typing notification without op parameter fails
Sending typing notification without op parameter fails
def test_missing_parameter(self) -> None: """ Sending typing notification without op parameter fails """ sender = self.example_user("hamlet") params = dict( to=orjson.dumps([sender.id]).decode(), ) result = self.api_post(sender, "/api/v1/typing", param...
[ "def", "test_missing_parameter", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "params", "=", "dict", "(", "to", "=", "orjson", ".", "dumps", "(", "[", "sender", ".", "id", "]", ")", ".", "de...
[ 10, 4 ]
[ 19, 63 ]
python
en
['en', 'error', 'th']
False
TypingValidateOperatorTest.test_invalid_parameter
(self)
Sending typing notification with invalid value for op parameter fails
Sending typing notification with invalid value for op parameter fails
def test_invalid_parameter(self) -> None: """ Sending typing notification with invalid value for op parameter fails """ sender = self.example_user("hamlet") params = dict( to=orjson.dumps([sender.id]).decode(), op="foo", ) result = self.api...
[ "def", "test_invalid_parameter", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "params", "=", "dict", "(", "to", "=", "orjson", ".", "dumps", "(", "[", "sender", ".", "id", "]", ")", ".", "de...
[ 21, 4 ]
[ 31, 52 ]
python
en
['en', 'error', 'th']
False
TypingValidateUsersTest.test_empty_array
(self)
Sending typing notification without recipient fails
Sending typing notification without recipient fails
def test_empty_array(self) -> None: """ Sending typing notification without recipient fails """ sender = self.example_user("hamlet") result = self.api_post(sender, "/api/v1/typing", {"op": "start", "to": "[]"}) self.assert_json_error(result, "Missing parameter: 'to' (reci...
[ "def", "test_empty_array", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "result", "=", "self", ".", "api_post", "(", "sender", ",", "\"/api/v1/typing\"", ",", "{", "\"op\"", ":", "\"start\"", ",",...
[ 47, 4 ]
[ 53, 77 ]
python
en
['en', 'error', 'th']
False
TypingValidateUsersTest.test_missing_recipient
(self)
Sending typing notification without recipient fails
Sending typing notification without recipient fails
def test_missing_recipient(self) -> None: """ Sending typing notification without recipient fails """ sender = self.example_user("hamlet") result = self.api_post(sender, "/api/v1/typing", {"op": "start"}) self.assert_json_error(result, "Missing 'to' argument")
[ "def", "test_missing_recipient", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "result", "=", "self", ".", "api_post", "(", "sender", ",", "\"/api/v1/typing\"", ",", "{", "\"op\"", ":", "\"start\"", ...
[ 55, 4 ]
[ 61, 63 ]
python
en
['en', 'error', 'th']
False
TypingValidateUsersTest.test_argument_to_is_not_valid_json
(self)
Sending typing notification to invalid recipient fails
Sending typing notification to invalid recipient fails
def test_argument_to_is_not_valid_json(self) -> None: """ Sending typing notification to invalid recipient fails """ sender = self.example_user("hamlet") invalid = "bad email" result = self.api_post(sender, "/api/v1/typing", {"op": "start", "to": invalid}) self.as...
[ "def", "test_argument_to_is_not_valid_json", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "invalid", "=", "\"bad email\"", "result", "=", "self", ".", "api_post", "(", "sender", ",", "\"/api/v1/typing\"...
[ 63, 4 ]
[ 70, 74 ]
python
en
['en', 'error', 'th']
False
TypingValidateUsersTest.test_bogus_user_id
(self)
Sending typing notification to invalid recipient fails
Sending typing notification to invalid recipient fails
def test_bogus_user_id(self) -> None: """ Sending typing notification to invalid recipient fails """ sender = self.example_user("hamlet") invalid = "[9999999]" result = self.api_post(sender, "/api/v1/typing", {"op": "start", "to": invalid}) self.assert_json_error(...
[ "def", "test_bogus_user_id", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "invalid", "=", "\"[9999999]\"", "result", "=", "self", ".", "api_post", "(", "sender", ",", "\"/api/v1/typing\"", ",", "{",...
[ 72, 4 ]
[ 79, 65 ]
python
en
['en', 'error', 'th']
False
TypingHappyPathTest.test_start_to_self
(self)
Sending typing notification to yourself (using user IDs) is successful.
Sending typing notification to yourself (using user IDs) is successful.
def test_start_to_self(self) -> None: """ Sending typing notification to yourself (using user IDs) is successful. """ user = self.example_user("hamlet") email = user.email expected_recipient_emails = {email} expected_recipient_ids = {user.id} event...
[ "def", "test_start_to_self", "(", "self", ")", "->", "None", ":", "user", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "email", "=", "user", ".", "email", "expected_recipient_emails", "=", "{", "email", "}", "expected_recipient_ids", "=", "{", "...
[ 157, 4 ]
[ 189, 46 ]
python
en
['en', 'error', 'th']
False
TypingHappyPathTest.test_start_to_another_user
(self)
Sending typing notification to another user is successful.
Sending typing notification to another user is successful.
def test_start_to_another_user(self) -> None: """ Sending typing notification to another user is successful. """ sender = self.example_user("hamlet") recipient = self.example_user("othello") expected_recipients = {sender, recipient} expected_recipient_emai...
[ "def", "test_start_to_another_user", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "recipient", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "expected_recipients", "=", "{", "sender", ","...
[ 191, 4 ]
[ 224, 46 ]
python
en
['en', 'error', 'th']
False
TypingHappyPathTest.test_stop_to_self
(self)
Sending stopped typing notification to yourself is successful.
Sending stopped typing notification to yourself is successful.
def test_stop_to_self(self) -> None: """ Sending stopped typing notification to yourself is successful. """ user = self.example_user("hamlet") email = user.email expected_recipient_emails = {email} expected_recipient_ids = {user.id} events: List[M...
[ "def", "test_stop_to_self", "(", "self", ")", "->", "None", ":", "user", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "email", "=", "user", ".", "email", "expected_recipient_emails", "=", "{", "email", "}", "expected_recipient_ids", "=", "{", "u...
[ 226, 4 ]
[ 257, 45 ]
python
en
['en', 'error', 'th']
False
TypingHappyPathTest.test_stop_to_another_user
(self)
Sending stopped typing notification to another user is successful.
Sending stopped typing notification to another user is successful.
def test_stop_to_another_user(self) -> None: """ Sending stopped typing notification to another user is successful. """ sender = self.example_user("hamlet") recipient = self.example_user("othello") expected_recipients = {sender, recipient} expected_recipie...
[ "def", "test_stop_to_another_user", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "recipient", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "expected_recipients", "=", "{", "sender", ",",...
[ 259, 4 ]
[ 291, 45 ]
python
en
['en', 'error', 'th']
False
static
(prefix, view=serve, **kwargs)
Helper function to return a URL pattern for serving files in debug mode. from django.conf import settings from django.conf.urls.static import static urlpatterns = [ # ... the rest of your URLconf goes here ... ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Helper function to return a URL pattern for serving files in debug mode.
def static(prefix, view=serve, **kwargs): """ Helper function to return a URL pattern for serving files in debug mode. from django.conf import settings from django.conf.urls.static import static urlpatterns = [ # ... the rest of your URLconf goes here ... ] + static(settings.MEDIA_URL,...
[ "def", "static", "(", "prefix", ",", "view", "=", "serve", ",", "*", "*", "kwargs", ")", ":", "# No-op if not in debug mode or an non-local prefix", "if", "not", "settings", ".", "DEBUG", "or", "(", "prefix", "and", "'://'", "in", "prefix", ")", ":", "return...
[ 8, 0 ]
[ 27, 5 ]
python
en
['en', 'error', 'th']
False
auto_decode
(data)
Check a bytes string for a BOM to correctly detect the encoding Fallback to locale.getpreferredencoding(False) like open() on Python3
Check a bytes string for a BOM to correctly detect the encoding
def auto_decode(data): # type: (bytes) -> Text """Check a bytes string for a BOM to correctly detect the encoding Fallback to locale.getpreferredencoding(False) like open() on Python3""" for bom, encoding in BOMS: if data.startswith(bom): return data[len(bom):].decode(encoding) ...
[ "def", "auto_decode", "(", "data", ")", ":", "# type: (bytes) -> Text", "for", "bom", ",", "encoding", "in", "BOMS", ":", "if", "data", ".", "startswith", "(", "bom", ")", ":", "return", "data", "[", "len", "(", "bom", ")", ":", "]", ".", "decode", "...
[ 26, 0 ]
[ 41, 5 ]
python
en
['en', 'en', 'en']
True
_zipdir
(path, zf)
Zip all the files in a directory in a determinisitc order along with a constant timestamp
Zip all the files in a directory in a determinisitc order along with a constant timestamp
def _zipdir(path, zf): """ Zip all the files in a directory in a determinisitc order along with a constant timestamp """ files_to_add = [] for root, dirs, files in os.walk(path): for file in files: abspath = os.path.join(root, file) relpath = os.path.relpath(abspath, ...
[ "def", "_zipdir", "(", "path", ",", "zf", ")", ":", "files_to_add", "=", "[", "]", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "path", ")", ":", "for", "file", "in", "files", ":", "abspath", "=", "os", ".", "path", "...
[ 31, 0 ]
[ 51, 42 ]
python
en
['en', 'error', 'th']
False
_get_default_args
(f)
get the default args of a functon `f` as a map from an arg name to a default value
get the default args of a functon `f` as a map from an arg name to a default value
def _get_default_args(f): """ get the default args of a functon `f` as a map from an arg name to a default value """ if hasattr(f, "neuropod_default_args"): return f.neuropod_default_args argspec = inspect.getargspec(f) if argspec.defaults: # Generate tuples of (arg, default_va...
[ "def", "_get_default_args", "(", "f", ")", ":", "if", "hasattr", "(", "f", ",", "\"neuropod_default_args\"", ")", ":", "return", "f", ".", "neuropod_default_args", "argspec", "=", "inspect", ".", "getargspec", "(", "f", ")", "if", "argspec", ".", "defaults",...
[ 205, 0 ]
[ 221, 13 ]
python
en
['en', 'error', 'th']
False
_generate_default_arg_map
(f_list)
Given a list of functions, generates a map from an arg name to a default value Note: later functions take priority
Given a list of functions, generates a map from an arg name to a default value
def _generate_default_arg_map(f_list): """ Given a list of functions, generates a map from an arg name to a default value Note: later functions take priority """ default_args = {} for f in f_list: default_args.update(_get_default_args(f)) return default_args
[ "def", "_generate_default_arg_map", "(", "f_list", ")", ":", "default_args", "=", "{", "}", "for", "f", "in", "f_list", ":", "default_args", ".", "update", "(", "_get_default_args", "(", "f", ")", ")", "return", "default_args" ]
[ 224, 0 ]
[ 234, 23 ]
python
en
['en', 'error', 'th']
False
FormMixin.get_initial
(self)
Returns the initial data to use for forms on this view.
Returns the initial data to use for forms on this view.
def get_initial(self): """ Returns the initial data to use for forms on this view. """ return self.initial.copy()
[ "def", "get_initial", "(", "self", ")", ":", "return", "self", ".", "initial", ".", "copy", "(", ")" ]
[ 19, 4 ]
[ 23, 34 ]
python
en
['en', 'error', 'th']
False
FormMixin.get_prefix
(self)
Returns the prefix to use for forms on this view
Returns the prefix to use for forms on this view
def get_prefix(self): """ Returns the prefix to use for forms on this view """ return self.prefix
[ "def", "get_prefix", "(", "self", ")", ":", "return", "self", ".", "prefix" ]
[ 25, 4 ]
[ 29, 26 ]
python
en
['en', 'error', 'th']
False
FormMixin.get_form_class
(self)
Returns the form class to use in this view
Returns the form class to use in this view
def get_form_class(self): """ Returns the form class to use in this view """ return self.form_class
[ "def", "get_form_class", "(", "self", ")", ":", "return", "self", ".", "form_class" ]
[ 31, 4 ]
[ 35, 30 ]
python
en
['en', 'error', 'th']
False
FormMixin.get_form
(self, form_class)
Returns an instance of the form to be used in this view.
Returns an instance of the form to be used in this view.
def get_form(self, form_class): """ Returns an instance of the form to be used in this view. """ return form_class(**self.get_form_kwargs())
[ "def", "get_form", "(", "self", ",", "form_class", ")", ":", "return", "form_class", "(", "*", "*", "self", ".", "get_form_kwargs", "(", ")", ")" ]
[ 37, 4 ]
[ 41, 51 ]
python
en
['en', 'error', 'th']
False
FormMixin.get_form_kwargs
(self)
Returns the keyword arguments for instantiating the form.
Returns the keyword arguments for instantiating the form.
def get_form_kwargs(self): """ Returns the keyword arguments for instantiating the form. """ kwargs = { 'initial': self.get_initial(), 'prefix': self.get_prefix(), } if self.request.method in ('POST', 'PUT'): kwargs.update({ ...
[ "def", "get_form_kwargs", "(", "self", ")", ":", "kwargs", "=", "{", "'initial'", ":", "self", ".", "get_initial", "(", ")", ",", "'prefix'", ":", "self", ".", "get_prefix", "(", ")", ",", "}", "if", "self", ".", "request", ".", "method", "in", "(", ...
[ 43, 4 ]
[ 57, 21 ]
python
en
['en', 'error', 'th']
False
FormMixin.get_success_url
(self)
Returns the supplied success URL.
Returns the supplied success URL.
def get_success_url(self): """ Returns the supplied success URL. """ if self.success_url: # Forcing possible reverse_lazy evaluation url = force_text(self.success_url) else: raise ImproperlyConfigured( "No URL to redirect to. Pr...
[ "def", "get_success_url", "(", "self", ")", ":", "if", "self", ".", "success_url", ":", "# Forcing possible reverse_lazy evaluation", "url", "=", "force_text", "(", "self", ".", "success_url", ")", "else", ":", "raise", "ImproperlyConfigured", "(", "\"No URL to redi...
[ 59, 4 ]
[ 69, 18 ]
python
en
['en', 'error', 'th']
False
FormMixin.form_valid
(self, form)
If the form is valid, redirect to the supplied URL.
If the form is valid, redirect to the supplied URL.
def form_valid(self, form): """ If the form is valid, redirect to the supplied URL. """ return HttpResponseRedirect(self.get_success_url())
[ "def", "form_valid", "(", "self", ",", "form", ")", ":", "return", "HttpResponseRedirect", "(", "self", ".", "get_success_url", "(", ")", ")" ]
[ 71, 4 ]
[ 75, 59 ]
python
en
['en', 'error', 'th']
False
FormMixin.form_invalid
(self, form)
If the form is invalid, re-render the context data with the data-filled form and errors.
If the form is invalid, re-render the context data with the data-filled form and errors.
def form_invalid(self, form): """ If the form is invalid, re-render the context data with the data-filled form and errors. """ return self.render_to_response(self.get_context_data(form=form))
[ "def", "form_invalid", "(", "self", ",", "form", ")", ":", "return", "self", ".", "render_to_response", "(", "self", ".", "get_context_data", "(", "form", "=", "form", ")", ")" ]
[ 77, 4 ]
[ 82, 72 ]
python
en
['en', 'error', 'th']
False
ModelFormMixin.get_form_class
(self)
Returns the form class to use in this view.
Returns the form class to use in this view.
def get_form_class(self): """ Returns the form class to use in this view. """ if self.form_class: return self.form_class else: if self.model is not None: # If a model has been explicitly provided, use it model = self.model ...
[ "def", "get_form_class", "(", "self", ")", ":", "if", "self", ".", "form_class", ":", "return", "self", ".", "form_class", "else", ":", "if", "self", ".", "model", "is", "not", "None", ":", "# If a model has been explicitly provided, use it", "model", "=", "se...
[ 91, 4 ]
[ 116, 75 ]
python
en
['en', 'error', 'th']
False
ModelFormMixin.get_form_kwargs
(self)
Returns the keyword arguments for instantiating the form.
Returns the keyword arguments for instantiating the form.
def get_form_kwargs(self): """ Returns the keyword arguments for instantiating the form. """ kwargs = super(ModelFormMixin, self).get_form_kwargs() if hasattr(self, 'object'): kwargs.update({'instance': self.object}) return kwargs
[ "def", "get_form_kwargs", "(", "self", ")", ":", "kwargs", "=", "super", "(", "ModelFormMixin", ",", "self", ")", ".", "get_form_kwargs", "(", ")", "if", "hasattr", "(", "self", ",", "'object'", ")", ":", "kwargs", ".", "update", "(", "{", "'instance'", ...
[ 118, 4 ]
[ 125, 21 ]
python
en
['en', 'error', 'th']
False
ModelFormMixin.get_success_url
(self)
Returns the supplied URL.
Returns the supplied URL.
def get_success_url(self): """ Returns the supplied URL. """ if self.success_url: url = self.success_url % self.object.__dict__ else: try: url = self.object.get_absolute_url() except AttributeError: raise Imprope...
[ "def", "get_success_url", "(", "self", ")", ":", "if", "self", ".", "success_url", ":", "url", "=", "self", ".", "success_url", "%", "self", ".", "object", ".", "__dict__", "else", ":", "try", ":", "url", "=", "self", ".", "object", ".", "get_absolute_...
[ 127, 4 ]
[ 140, 18 ]
python
en
['en', 'error', 'th']
False
ModelFormMixin.form_valid
(self, form)
If the form is valid, save the associated model.
If the form is valid, save the associated model.
def form_valid(self, form): """ If the form is valid, save the associated model. """ self.object = form.save() return super(ModelFormMixin, self).form_valid(form)
[ "def", "form_valid", "(", "self", ",", "form", ")", ":", "self", ".", "object", "=", "form", ".", "save", "(", ")", "return", "super", "(", "ModelFormMixin", ",", "self", ")", ".", "form_valid", "(", "form", ")" ]
[ 142, 4 ]
[ 147, 59 ]
python
en
['en', 'error', 'th']
False
ProcessFormView.get
(self, request, *args, **kwargs)
Handles GET requests and instantiates a blank version of the form.
Handles GET requests and instantiates a blank version of the form.
def get(self, request, *args, **kwargs): """ Handles GET requests and instantiates a blank version of the form. """ form_class = self.get_form_class() form = self.get_form(form_class) return self.render_to_response(self.get_context_data(form=form))
[ "def", "get", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "form_class", "=", "self", ".", "get_form_class", "(", ")", "form", "=", "self", ".", "get_form", "(", "form_class", ")", "return", "self", ".", "render_t...
[ 154, 4 ]
[ 160, 72 ]
python
en
['en', 'error', 'th']
False
ProcessFormView.post
(self, request, *args, **kwargs)
Handles POST requests, instantiating a form instance with the passed POST variables and then checked for validity.
Handles POST requests, instantiating a form instance with the passed POST variables and then checked for validity.
def post(self, request, *args, **kwargs): """ Handles POST requests, instantiating a form instance with the passed POST variables and then checked for validity. """ form_class = self.get_form_class() form = self.get_form(form_class) if form.is_valid(): ...
[ "def", "post", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "form_class", "=", "self", ".", "get_form_class", "(", ")", "form", "=", "self", ".", "get_form", "(", "form_class", ")", "if", "form", ".", "is_valid", ...
[ 162, 4 ]
[ 172, 42 ]
python
en
['en', 'error', 'th']
False
DeletionMixin.delete
(self, request, *args, **kwargs)
Calls the delete() method on the fetched object and then redirects to the success URL.
Calls the delete() method on the fetched object and then redirects to the success URL.
def delete(self, request, *args, **kwargs): """ Calls the delete() method on the fetched object and then redirects to the success URL. """ self.object = self.get_object() success_url = self.get_success_url() self.object.delete() return HttpResponseRedirect...
[ "def", "delete", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "object", "=", "self", ".", "get_object", "(", ")", "success_url", "=", "self", ".", "get_success_url", "(", ")", "self", ".", "object", ...
[ 244, 4 ]
[ 252, 48 ]
python
en
['en', 'error', 'th']
False
get_perm
(Model, perm)
Return the permission object, for the Model
Return the permission object, for the Model
def get_perm(Model, perm): """Return the permission object, for the Model""" ct = ContentType.objects.get_for_model(Model) return Permission.objects.get(content_type=ct, codename=perm)
[ "def", "get_perm", "(", "Model", ",", "perm", ")", ":", "ct", "=", "ContentType", ".", "objects", ".", "get_for_model", "(", "Model", ")", "return", "Permission", ".", "objects", ".", "get", "(", "content_type", "=", "ct", ",", "codename", "=", "perm", ...
[ 1034, 0 ]
[ 1037, 65 ]
python
en
['en', 'en', 'en']
True
test_unicode_edit
(self)
A test to ensure that POST on edit_view handles non-ASCII characters.
A test to ensure that POST on edit_view handles non-ASCII characters.
def test_unicode_edit(self): """ A test to ensure that POST on edit_view handles non-ASCII characters. """ post_data = { "name": "Test lærdommer", # inline data "chapter_set-TOTAL_FORMS": "6", "chapter_set-INITIAL_FORMS": "3", "...
[ "def", "test_unicode_edit", "(", "self", ")", ":", "post_data", "=", "{", "\"name\"", ":", "\"Test lærdommer\",", "", "# inline data", "\"chapter_set-TOTAL_FORMS\"", ":", "\"6\"", ",", "\"chapter_set-INITIAL_FORMS\"", ":", "\"3\"", ",", "\"chapter_set-MAX_NUM_FORMS\"", ...
[ 1995, 4 ]
[ 2026, 51 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_trailing_slash_required
(self)
If you leave off the trailing slash, app should redirect and add it.
If you leave off the trailing slash, app should redirect and add it.
def test_trailing_slash_required(self): """ If you leave off the trailing slash, app should redirect and add it. """ response = self.client.get('/test_admin/%s/admin_views/article/add' % self.urlbit) self.assertRedirects(response, '/test_admin/%s/admin_views/article/a...
[ "def", "test_trailing_slash_required", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "'/test_admin/%s/admin_views/article/add'", "%", "self", ".", "urlbit", ")", "self", ".", "assertRedirects", "(", "response", ",", "'/test_admin/...
[ 97, 4 ]
[ 104, 28 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_admin_static_template_tag
(self)
Test that admin_static.static is pointing to the collectstatic version (as django.contrib.collectstatic is in installed apps).
Test that admin_static.static is pointing to the collectstatic version (as django.contrib.collectstatic is in installed apps).
def test_admin_static_template_tag(self): """ Test that admin_static.static is pointing to the collectstatic version (as django.contrib.collectstatic is in installed apps). """ old_url = staticfiles_storage.base_url staticfiles_storage.base_url = '/test/' try: ...
[ "def", "test_admin_static_template_tag", "(", "self", ")", ":", "old_url", "=", "staticfiles_storage", ".", "base_url", "staticfiles_storage", ".", "base_url", "=", "'/test/'", "try", ":", "self", ".", "assertEqual", "(", "static", "(", "'path'", ")", ",", "'/te...
[ 106, 4 ]
[ 116, 50 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_basic_add_GET
(self)
A smoke test to ensure GET on the add_view works.
A smoke test to ensure GET on the add_view works.
def test_basic_add_GET(self): """ A smoke test to ensure GET on the add_view works. """ response = self.client.get('/test_admin/%s/admin_views/section/add/' % self.urlbit) self.assertIsInstance(response, TemplateResponse) self.assertEqual(response.status_code, 200)
[ "def", "test_basic_add_GET", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "'/test_admin/%s/admin_views/section/add/'", "%", "self", ".", "urlbit", ")", "self", ".", "assertIsInstance", "(", "response", ",", "TemplateResponse", ...
[ 118, 4 ]
[ 124, 51 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_basic_edit_GET
(self)
A smoke test to ensure GET on the change_view works.
A smoke test to ensure GET on the change_view works.
def test_basic_edit_GET(self): """ A smoke test to ensure GET on the change_view works. """ response = self.client.get('/test_admin/%s/admin_views/section/1/' % self.urlbit) self.assertIsInstance(response, TemplateResponse) self.assertEqual(response.status_code, 200)
[ "def", "test_basic_edit_GET", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "'/test_admin/%s/admin_views/section/1/'", "%", "self", ".", "urlbit", ")", "self", ".", "assertIsInstance", "(", "response", ",", "TemplateResponse", "...
[ 132, 4 ]
[ 138, 51 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_basic_edit_GET_string_PK
(self)
Ensure GET on the change_view works (returns an HTTP 404 error, see #11191) when passing a string as the PK argument for a model with an integer PK field.
Ensure GET on the change_view works (returns an HTTP 404 error, see #11191) when passing a string as the PK argument for a model with an integer PK field.
def test_basic_edit_GET_string_PK(self): """ Ensure GET on the change_view works (returns an HTTP 404 error, see #11191) when passing a string as the PK argument for a model with an integer PK field. """ response = self.client.get('/test_admin/%s/admin_views/section/abc/'...
[ "def", "test_basic_edit_GET_string_PK", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "'/test_admin/%s/admin_views/section/abc/'", "%", "self", ".", "urlbit", ")", "self", ".", "assertEqual", "(", "response", ".", "status_code", ...
[ 140, 4 ]
[ 147, 51 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_basic_inheritance_GET_string_PK
(self)
Ensure GET on the change_view works on inherited models (returns an HTTP 404 error, see #19951) when passing a string as the PK argument for a model with an integer PK field.
Ensure GET on the change_view works on inherited models (returns an HTTP 404 error, see #19951) when passing a string as the PK argument for a model with an integer PK field.
def test_basic_inheritance_GET_string_PK(self): """ Ensure GET on the change_view works on inherited models (returns an HTTP 404 error, see #19951) when passing a string as the PK argument for a model with an integer PK field. """ response = self.client.get('/test_admin/%...
[ "def", "test_basic_inheritance_GET_string_PK", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "'/test_admin/%s/admin_views/supervillain/abc/'", "%", "self", ".", "urlbit", ")", "self", ".", "assertEqual", "(", "response", ".", "sta...
[ 149, 4 ]
[ 156, 51 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_basic_add_POST
(self)
A smoke test to ensure POST on add_view works.
A smoke test to ensure POST on add_view works.
def test_basic_add_POST(self): """ A smoke test to ensure POST on add_view works. """ post_data = { "name": "Another Section", # inline data "article_set-TOTAL_FORMS": "3", "article_set-INITIAL_FORMS": "0", "article_set-MAX_NUM_...
[ "def", "test_basic_add_POST", "(", "self", ")", ":", "post_data", "=", "{", "\"name\"", ":", "\"Another Section\"", ",", "# inline data", "\"article_set-TOTAL_FORMS\"", ":", "\"3\"", ",", "\"article_set-INITIAL_FORMS\"", ":", "\"0\"", ",", "\"article_set-MAX_NUM_FORMS\"",...
[ 158, 4 ]
[ 170, 51 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_popup_add_POST
(self)
Ensure http response from a popup is properly escaped.
Ensure http response from a popup is properly escaped.
def test_popup_add_POST(self): """ Ensure http response from a popup is properly escaped. """ post_data = { '_popup': '1', 'title': 'title with a new\nline', 'content': 'some content', 'date_0': '2010-09-10', 'date_1': '14:55:39...
[ "def", "test_popup_add_POST", "(", "self", ")", ":", "post_data", "=", "{", "'_popup'", ":", "'1'", ",", "'title'", ":", "'title with a new\\nline'", ",", "'content'", ":", "'some content'", ",", "'date_0'", ":", "'2010-09-10'", ",", "'date_1'", ":", "'14:55:39'...
[ 172, 4 ]
[ 186, 68 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_basic_edit_POST
(self)
A smoke test to ensure POST on edit_view works.
A smoke test to ensure POST on edit_view works.
def test_basic_edit_POST(self): """ A smoke test to ensure POST on edit_view works. """ response = self.client.post('/test_admin/%s/admin_views/section/1/' % self.urlbit, self.inline_post_data) self.assertEqual(response.status_code, 302)
[ "def", "test_basic_edit_POST", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "post", "(", "'/test_admin/%s/admin_views/section/1/'", "%", "self", ".", "urlbit", ",", "self", ".", "inline_post_data", ")", "self", ".", "assertEqual", "(", "...
[ 229, 4 ]
[ 234, 51 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_edit_save_as
(self)
Test "save as".
Test "save as".
def test_edit_save_as(self): """ Test "save as". """ post_data = self.inline_post_data.copy() post_data.update({ '_saveasnew': 'Save+as+new', "article_set-1-section": "1", "article_set-2-section": "1", "article_set-3-section": "1", ...
[ "def", "test_edit_save_as", "(", "self", ")", ":", "post_data", "=", "self", ".", "inline_post_data", ".", "copy", "(", ")", "post_data", ".", "update", "(", "{", "'_saveasnew'", ":", "'Save+as+new'", ",", "\"article_set-1-section\"", ":", "\"1\"", ",", "\"art...
[ 236, 4 ]
[ 250, 51 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_change_list_sorting_callable
(self)
Ensure we can sort on a list_display field that is a callable (column 2 is callable_year in ArticleAdmin)
Ensure we can sort on a list_display field that is a callable (column 2 is callable_year in ArticleAdmin)
def test_change_list_sorting_callable(self): """ Ensure we can sort on a list_display field that is a callable (column 2 is callable_year in ArticleAdmin) """ response = self.client.get('/test_admin/%s/admin_views/article/' % self.urlbit, {'o': 2}) self.assertContentBefor...
[ "def", "test_change_list_sorting_callable", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "'/test_admin/%s/admin_views/article/'", "%", "self", ".", "urlbit", ",", "{", "'o'", ":", "2", "}", ")", "self", ".", "assertContentBef...
[ 252, 4 ]
[ 261, 63 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_change_list_sorting_model
(self)
Ensure we can sort on a list_display field that is a Model method (column 3 is 'model_year' in ArticleAdmin)
Ensure we can sort on a list_display field that is a Model method (column 3 is 'model_year' in ArticleAdmin)
def test_change_list_sorting_model(self): """ Ensure we can sort on a list_display field that is a Model method (column 3 is 'model_year' in ArticleAdmin) """ response = self.client.get('/test_admin/%s/admin_views/article/' % self.urlbit, {'o': '-3'}) self.assertContentBe...
[ "def", "test_change_list_sorting_model", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "'/test_admin/%s/admin_views/article/'", "%", "self", ".", "urlbit", ",", "{", "'o'", ":", "'-3'", "}", ")", "self", ".", "assertContentBef...
[ 263, 4 ]
[ 272, 67 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_change_list_sorting_model_admin
(self)
Ensure we can sort on a list_display field that is a ModelAdmin method (column 4 is 'modeladmin_year' in ArticleAdmin)
Ensure we can sort on a list_display field that is a ModelAdmin method (column 4 is 'modeladmin_year' in ArticleAdmin)
def test_change_list_sorting_model_admin(self): """ Ensure we can sort on a list_display field that is a ModelAdmin method (column 4 is 'modeladmin_year' in ArticleAdmin) """ response = self.client.get('/test_admin/%s/admin_views/article/' % self.urlbit, {'o': '4'}) self....
[ "def", "test_change_list_sorting_model_admin", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "'/test_admin/%s/admin_views/article/'", "%", "self", ".", "urlbit", ",", "{", "'o'", ":", "'4'", "}", ")", "self", ".", "assertConte...
[ 274, 4 ]
[ 283, 72 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_change_list_sorting_model_admin_reverse
(self)
Ensure we can sort on a list_display field that is a ModelAdmin method in reverse order (i.e. admin_order_field uses the '-' prefix) (column 6 is 'model_year_reverse' in ArticleAdmin)
Ensure we can sort on a list_display field that is a ModelAdmin method in reverse order (i.e. admin_order_field uses the '-' prefix) (column 6 is 'model_year_reverse' in ArticleAdmin)
def test_change_list_sorting_model_admin_reverse(self): """ Ensure we can sort on a list_display field that is a ModelAdmin method in reverse order (i.e. admin_order_field uses the '-' prefix) (column 6 is 'model_year_reverse' in ArticleAdmin) """ response = self.client.g...
[ "def", "test_change_list_sorting_model_admin_reverse", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "'/test_admin/%s/admin_views/article/'", "%", "self", ".", "urlbit", ",", "{", "'o'", ":", "'6'", "}", ")", "self", ".", "ass...
[ 285, 4 ]
[ 302, 72 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_change_list_sorting_preserve_queryset_ordering
(self)
If no ordering is defined in `ModelAdmin.ordering` or in the query string, then the underlying order of the queryset should not be changed, even if it is defined in `Modeladmin.get_queryset()`. Refs #11868, #7309.
If no ordering is defined in `ModelAdmin.ordering` or in the query string, then the underlying order of the queryset should not be changed, even if it is defined in `Modeladmin.get_queryset()`. Refs #11868, #7309.
def test_change_list_sorting_preserve_queryset_ordering(self): """ If no ordering is defined in `ModelAdmin.ordering` or in the query string, then the underlying order of the queryset should not be changed, even if it is defined in `Modeladmin.get_queryset()`. Refs #11868, #7309....
[ "def", "test_change_list_sorting_preserve_queryset_ordering", "(", "self", ")", ":", "p1", "=", "Person", ".", "objects", ".", "create", "(", "name", "=", "\"Amy\"", ",", "gender", "=", "1", ",", "alive", "=", "True", ",", "age", "=", "80", ")", "p2", "=...
[ 324, 4 ]
[ 342, 56 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_sort_indicators_admin_order
(self)
Ensures that the admin shows default sort indicators for all kinds of 'ordering' fields: field names, method on the model admin and model itself, and other callables. See #17252.
Ensures that the admin shows default sort indicators for all kinds of 'ordering' fields: field names, method on the model admin and model itself, and other callables. See #17252.
def test_sort_indicators_admin_order(self): """ Ensures that the admin shows default sort indicators for all kinds of 'ordering' fields: field names, method on the model admin and model itself, and other callables. See #17252. """ models = [(AdminOrderedField, 'adminorder...
[ "def", "test_sort_indicators_admin_order", "(", "self", ")", ":", "models", "=", "[", "(", "AdminOrderedField", ",", "'adminorderedfield'", ")", ",", "(", "AdminOrderedModelMethod", ",", "'adminorderedmodelmethod'", ")", ",", "(", "AdminOrderedAdminMethod", ",", "'adm...
[ 400, 4 ]
[ 424, 82 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_limited_filter
(self)
Ensure admin changelist filters do not contain objects excluded via limit_choices_to. This also tests relation-spanning filters (e.g. 'color__value').
Ensure admin changelist filters do not contain objects excluded via limit_choices_to. This also tests relation-spanning filters (e.g. 'color__value').
def test_limited_filter(self): """Ensure admin changelist filters do not contain objects excluded via limit_choices_to. This also tests relation-spanning filters (e.g. 'color__value'). """ response = self.client.get('/test_admin/%s/admin_views/thing/' % self.urlbit) self.assertEq...
[ "def", "test_limited_filter", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "'/test_admin/%s/admin_views/thing/'", "%", "self", ".", "urlbit", ")", "self", ".", "assertEqual", "(", "response", ".", "status_code", ",", "200", ...
[ 426, 4 ]
[ 435, 85 ]
python
en
['en', 'en', 'en']
True
AdminViewBasicTest.test_incorrect_lookup_parameters
(self)
Ensure incorrect lookup parameters are handled gracefully.
Ensure incorrect lookup parameters are handled gracefully.
def test_incorrect_lookup_parameters(self): """Ensure incorrect lookup parameters are handled gracefully.""" response = self.client.get('/test_admin/%s/admin_views/thing/' % self.urlbit, {'notarealfield': '5'}) self.assertRedirects(response, '/test_admin/%s/admin_views/thing/?e=1' % self.urlbit)...
[ "def", "test_incorrect_lookup_parameters", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "'/test_admin/%s/admin_views/thing/'", "%", "self", ".", "urlbit", ",", "{", "'notarealfield'", ":", "'5'", "}", ")", "self", ".", "asser...
[ 476, 4 ]
[ 490, 93 ]
python
en
['en', 'en', 'en']
True
AdminViewBasicTest.test_isnull_lookups
(self)
Ensure is_null is handled correctly.
Ensure is_null is handled correctly.
def test_isnull_lookups(self): """Ensure is_null is handled correctly.""" Article.objects.create(title="I Could Go Anywhere", content="Versatile", date=datetime.datetime.now()) response = self.client.get('/test_admin/%s/admin_views/article/' % self.urlbit) self.assertContains(response, '...
[ "def", "test_isnull_lookups", "(", "self", ")", ":", "Article", ".", "objects", ".", "create", "(", "title", "=", "\"I Could Go Anywhere\"", ",", "content", "=", "\"Versatile\"", ",", "date", "=", "datetime", ".", "datetime", ".", "now", "(", ")", ")", "re...
[ 492, 4 ]
[ 504, 50 ]
python
en
['en', 'en', 'en']
True
AdminViewBasicTest.test_named_group_field_choices_change_list
(self)
Ensures the admin changelist shows correct values in the relevant column for rows corresponding to instances of a model in which a named group has been used in the choices option of a field.
Ensures the admin changelist shows correct values in the relevant column for rows corresponding to instances of a model in which a named group has been used in the choices option of a field.
def test_named_group_field_choices_change_list(self): """ Ensures the admin changelist shows correct values in the relevant column for rows corresponding to instances of a model in which a named group has been used in the choices option of a field. """ link1 = reverse('ad...
[ "def", "test_named_group_field_choices_change_list", "(", "self", ")", ":", "link1", "=", "reverse", "(", "'admin:admin_views_fabric_change'", ",", "args", "=", "(", "1", ",", ")", ",", "current_app", "=", "self", ".", "urlbit", ")", "link2", "=", "reverse", "...
[ 511, 4 ]
[ 522, 106 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_named_group_field_choices_filter
(self)
Ensures the filter UI shows correctly when at least one named group has been used in the choices option of a model field.
Ensures the filter UI shows correctly when at least one named group has been used in the choices option of a model field.
def test_named_group_field_choices_filter(self): """ Ensures the filter UI shows correctly when at least one named group has been used in the choices option of a model field. """ response = self.client.get('/test_admin/%s/admin_views/fabric/' % self.urlbit) fail_msg = "Ch...
[ "def", "test_named_group_field_choices_filter", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "'/test_admin/%s/admin_views/fabric/'", "%", "self", ".", "urlbit", ")", "fail_msg", "=", "\"Changelist filter isn't showing options contained i...
[ 524, 4 ]
[ 535, 87 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_i18n_language_non_english_default
(self)
Check if the JavaScript i18n view returns an empty language catalog if the default language is non-English but the selected language is English. See #13388 and #3594 for more details.
Check if the JavaScript i18n view returns an empty language catalog if the default language is non-English but the selected language is English. See #13388 and #3594 for more details.
def test_i18n_language_non_english_default(self): """ Check if the JavaScript i18n view returns an empty language catalog if the default language is non-English but the selected language is English. See #13388 and #3594 for more details. """ with self.settings(LANGUAGE_CO...
[ "def", "test_i18n_language_non_english_default", "(", "self", ")", ":", "with", "self", ".", "settings", "(", "LANGUAGE_CODE", "=", "'fr'", ")", ",", "translation", ".", "override", "(", "'en-us'", ")", ":", "response", "=", "self", ".", "client", ".", "get"...
[ 545, 4 ]
[ 553, 65 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_i18n_language_non_english_fallback
(self)
Makes sure that the fallback language is still working properly in cases where the selected language cannot be found.
Makes sure that the fallback language is still working properly in cases where the selected language cannot be found.
def test_i18n_language_non_english_fallback(self): """ Makes sure that the fallback language is still working properly in cases where the selected language cannot be found. """ with self.settings(LANGUAGE_CODE='fr'), translation.override('none'): response = self.clien...
[ "def", "test_i18n_language_non_english_fallback", "(", "self", ")", ":", "with", "self", ".", "settings", "(", "LANGUAGE_CODE", "=", "'fr'", ")", ",", "translation", ".", "override", "(", "'none'", ")", ":", "response", "=", "self", ".", "client", ".", "get"...
[ 555, 4 ]
[ 562, 62 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_L10N_deactivated
(self)
Check if L10N is deactivated, the JavaScript i18n view doesn't return localized date/time formats. Refs #14824.
Check if L10N is deactivated, the JavaScript i18n view doesn't return localized date/time formats. Refs #14824.
def test_L10N_deactivated(self): """ Check if L10N is deactivated, the JavaScript i18n view doesn't return localized date/time formats. Refs #14824. """ with self.settings(LANGUAGE_CODE='ru', USE_L10N=False), translation.override('none'): response = self.client.get('/...
[ "def", "test_L10N_deactivated", "(", "self", ")", ":", "with", "self", ".", "settings", "(", "LANGUAGE_CODE", "=", "'ru'", ",", "USE_L10N", "=", "False", ")", ",", "translation", ".", "override", "(", "'none'", ")", ":", "response", "=", "self", ".", "cl...
[ 564, 4 ]
[ 572, 62 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_allowed_filtering_15103
(self)
Regressions test for ticket 15103 - filtering on fields defined in a ForeignKey 'limit_choices_to' should be allowed, otherwise raw_id_fields can break.
Regressions test for ticket 15103 - filtering on fields defined in a ForeignKey 'limit_choices_to' should be allowed, otherwise raw_id_fields can break.
def test_allowed_filtering_15103(self): """ Regressions test for ticket 15103 - filtering on fields defined in a ForeignKey 'limit_choices_to' should be allowed, otherwise raw_id_fields can break. """ # Filters should be allowed if they are defined on a ForeignKey pointin...
[ "def", "test_allowed_filtering_15103", "(", "self", ")", ":", "# Filters should be allowed if they are defined on a ForeignKey pointing to this model", "response", "=", "self", ".", "client", ".", "get", "(", "\"/test_admin/admin/admin_views/inquisition/?leader__name=Palin&leader__age=...
[ 649, 4 ]
[ 657, 51 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_popup_dismiss_related
(self)
Regression test for ticket 20664 - ensure the pk is properly quoted.
Regression test for ticket 20664 - ensure the pk is properly quoted.
def test_popup_dismiss_related(self): """ Regression test for ticket 20664 - ensure the pk is properly quoted. """ actor = Actor.objects.create(name="Palin", age=27) response = self.client.get("/test_admin/admin/admin_views/actor/?%s" % IS_POPUP_VAR) self.assertContains(r...
[ "def", "test_popup_dismiss_related", "(", "self", ")", ":", "actor", "=", "Actor", ".", "objects", ".", "create", "(", "name", "=", "\"Palin\"", ",", "age", "=", "27", ")", "response", "=", "self", ".", "client", ".", "get", "(", "\"/test_admin/admin/admin...
[ 659, 4 ]
[ 665, 106 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_hide_change_password
(self)
Tests if the "change password" link in the admin is hidden if the User does not have a usable password set. (against 9bea85795705d015cdadc82c68b99196a8554f5c)
Tests if the "change password" link in the admin is hidden if the User does not have a usable password set. (against 9bea85795705d015cdadc82c68b99196a8554f5c)
def test_hide_change_password(self): """ Tests if the "change password" link in the admin is hidden if the User does not have a usable password set. (against 9bea85795705d015cdadc82c68b99196a8554f5c) """ user = User.objects.get(username='super') user.set_unusable_...
[ "def", "test_hide_change_password", "(", "self", ")", ":", "user", "=", "User", ".", "objects", ".", "get", "(", "username", "=", "'super'", ")", "user", ".", "set_unusable_password", "(", ")", "user", ".", "save", "(", ")", "response", "=", "self", ".",...
[ 667, 4 ]
[ 679, 119 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_change_view_with_show_delete_extra_context
(self)
Ensured that the 'show_delete' context variable in the admin's change view actually controls the display of the delete button. Refs #10057.
Ensured that the 'show_delete' context variable in the admin's change view actually controls the display of the delete button. Refs #10057.
def test_change_view_with_show_delete_extra_context(self): """ Ensured that the 'show_delete' context variable in the admin's change view actually controls the display of the delete button. Refs #10057. """ instance = UndeletableObject.objects.create(name='foo') r...
[ "def", "test_change_view_with_show_delete_extra_context", "(", "self", ")", ":", "instance", "=", "UndeletableObject", ".", "objects", ".", "create", "(", "name", "=", "'foo'", ")", "response", "=", "self", ".", "client", ".", "get", "(", "'/test_admin/%s/admin_vi...
[ 681, 4 ]
[ 690, 54 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_allows_attributeerror_to_bubble_up
(self)
Ensure that AttributeErrors are allowed to bubble when raised inside a change list view. Requires a model to be created so there's something to be displayed Refs: #16655, #18593, and #18747
Ensure that AttributeErrors are allowed to bubble when raised inside a change list view.
def test_allows_attributeerror_to_bubble_up(self): """ Ensure that AttributeErrors are allowed to bubble when raised inside a change list view. Requires a model to be created so there's something to be displayed Refs: #16655, #18593, and #18747 """ Simple.object...
[ "def", "test_allows_attributeerror_to_bubble_up", "(", "self", ")", ":", "Simple", ".", "objects", ".", "create", "(", ")", "with", "self", ".", "assertRaises", "(", "AttributeError", ")", ":", "self", ".", "client", ".", "get", "(", "'/test_admin/%s/admin_views...
[ 692, 4 ]
[ 703, 79 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_changelist_with_no_change_url
(self)
ModelAdmin.changelist_view shouldn't result in a NoReverseMatch if url for change_view is removed from get_urls Regression test for #20934
ModelAdmin.changelist_view shouldn't result in a NoReverseMatch if url for change_view is removed from get_urls
def test_changelist_with_no_change_url(self): """ ModelAdmin.changelist_view shouldn't result in a NoReverseMatch if url for change_view is removed from get_urls Regression test for #20934 """ UnchangeableObject.objects.create() response = self.client.get('/test_...
[ "def", "test_changelist_with_no_change_url", "(", "self", ")", ":", "UnchangeableObject", ".", "objects", ".", "create", "(", ")", "response", "=", "self", ".", "client", ".", "get", "(", "'/test_admin/admin/admin_views/unchangeableobject/'", ")", "self", ".", "asse...
[ 705, 4 ]
[ 716, 108 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_invalid_appindex_url
(self)
#21056 -- URL reversing shouldn't work for nonexistent apps.
#21056 -- URL reversing shouldn't work for nonexistent apps.
def test_invalid_appindex_url(self): """ #21056 -- URL reversing shouldn't work for nonexistent apps. """ good_url = '/test_admin/admin/admin_views/' confirm_good_url = reverse('admin:app_list', kwargs={'app_label': 'admin_views'}) self....
[ "def", "test_invalid_appindex_url", "(", "self", ")", ":", "good_url", "=", "'/test_admin/admin/admin_views/'", "confirm_good_url", "=", "reverse", "(", "'admin:app_list'", ",", "kwargs", "=", "{", "'app_label'", ":", "'admin_views'", "}", ")", "self", ".", "assertE...
[ 718, 4 ]
[ 730, 61 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_proxy_model_content_type_is_used_for_log_entries
(self)
Log entries for proxy models should have the proxy model's content type. Regression test for #21084.
Log entries for proxy models should have the proxy model's content type.
def test_proxy_model_content_type_is_used_for_log_entries(self): """ Log entries for proxy models should have the proxy model's content type. Regression test for #21084. """ color2_content_type = ContentType.objects.get_for_model(Color2, for_concrete_model=False) ...
[ "def", "test_proxy_model_content_type_is_used_for_log_entries", "(", "self", ")", ":", "color2_content_type", "=", "ContentType", ".", "objects", ".", "get_for_model", "(", "Color2", ",", "for_concrete_model", "=", "False", ")", "# add", "color2_add_url", "=", "reverse"...
[ 732, 4 ]
[ 762, 77 ]
python
en
['en', 'error', 'th']
False
AdminViewBasicTest.test_adminsite_display_site_url
(self)
#13749 - Admin should display link to front-end site 'View site'
#13749 - Admin should display link to front-end site 'View site'
def test_adminsite_display_site_url(self): """ #13749 - Admin should display link to front-end site 'View site' """ url = reverse('admin:index') response = self.client.get(url) self.assertEqual(response.context['site_url'], '/my-site-url/') self.assertContains(res...
[ "def", "test_adminsite_display_site_url", "(", "self", ")", ":", "url", "=", "reverse", "(", "'admin:index'", ")", "response", "=", "self", ".", "client", ".", "get", "(", "url", ")", "self", ".", "assertEqual", "(", "response", ".", "context", "[", "'site...
[ 764, 4 ]
[ 771, 78 ]
python
en
['en', 'error', 'th']
False
_get_failure_view
()
Return the view to be used for CSRF rejections.
Return the view to be used for CSRF rejections.
def _get_failure_view(): """Return the view to be used for CSRF rejections.""" return get_callable(settings.CSRF_FAILURE_VIEW)
[ "def", "_get_failure_view", "(", ")", ":", "return", "get_callable", "(", "settings", ".", "CSRF_FAILURE_VIEW", ")" ]
[ 35, 0 ]
[ 37, 51 ]
python
en
['en', 'en', 'en']
True
_salt_cipher_secret
(secret)
Given a secret (assumed to be a string of CSRF_ALLOWED_CHARS), generate a token by adding a salt and using it to encrypt the secret.
Given a secret (assumed to be a string of CSRF_ALLOWED_CHARS), generate a token by adding a salt and using it to encrypt the secret.
def _salt_cipher_secret(secret): """ Given a secret (assumed to be a string of CSRF_ALLOWED_CHARS), generate a token by adding a salt and using it to encrypt the secret. """ salt = _get_new_csrf_string() chars = CSRF_ALLOWED_CHARS pairs = zip((chars.index(x) for x in secret), (chars.index(x)...
[ "def", "_salt_cipher_secret", "(", "secret", ")", ":", "salt", "=", "_get_new_csrf_string", "(", ")", "chars", "=", "CSRF_ALLOWED_CHARS", "pairs", "=", "zip", "(", "(", "chars", ".", "index", "(", "x", ")", "for", "x", "in", "secret", ")", ",", "(", "c...
[ 44, 0 ]
[ 53, 24 ]
python
en
['en', 'error', 'th']
False
_unsalt_cipher_token
(token)
Given a token (assumed to be a string of CSRF_ALLOWED_CHARS, of length CSRF_TOKEN_LENGTH, and that its first half is a salt), use it to decrypt the second half to produce the original secret.
Given a token (assumed to be a string of CSRF_ALLOWED_CHARS, of length CSRF_TOKEN_LENGTH, and that its first half is a salt), use it to decrypt the second half to produce the original secret.
def _unsalt_cipher_token(token): """ Given a token (assumed to be a string of CSRF_ALLOWED_CHARS, of length CSRF_TOKEN_LENGTH, and that its first half is a salt), use it to decrypt the second half to produce the original secret. """ salt = token[:CSRF_SECRET_LENGTH] token = token[CSRF_SECRET...
[ "def", "_unsalt_cipher_token", "(", "token", ")", ":", "salt", "=", "token", "[", ":", "CSRF_SECRET_LENGTH", "]", "token", "=", "token", "[", "CSRF_SECRET_LENGTH", ":", "]", "chars", "=", "CSRF_ALLOWED_CHARS", "pairs", "=", "zip", "(", "(", "chars", ".", "...
[ 56, 0 ]
[ 66, 50 ]
python
en
['en', 'error', 'th']
False
get_token
(request)
Return the CSRF token required for a POST form. The token is an alphanumeric value. A new token is created if one is not already set. A side effect of calling this function is to make the csrf_protect decorator and the CsrfViewMiddleware add a CSRF cookie and a 'Vary: Cookie' header to the outgoin...
Return the CSRF token required for a POST form. The token is an alphanumeric value. A new token is created if one is not already set.
def get_token(request): """ Return the CSRF token required for a POST form. The token is an alphanumeric value. A new token is created if one is not already set. A side effect of calling this function is to make the csrf_protect decorator and the CsrfViewMiddleware add a CSRF cookie and a 'Vary: Co...
[ "def", "get_token", "(", "request", ")", ":", "if", "\"CSRF_COOKIE\"", "not", "in", "request", ".", "META", ":", "csrf_secret", "=", "_get_new_csrf_string", "(", ")", "request", ".", "META", "[", "\"CSRF_COOKIE\"", "]", "=", "_salt_cipher_secret", "(", "csrf_s...
[ 73, 0 ]
[ 89, 43 ]
python
en
['en', 'error', 'th']
False
rotate_token
(request)
Change the CSRF token in use for a request - should be done on login for security purposes.
Change the CSRF token in use for a request - should be done on login for security purposes.
def rotate_token(request): """ Change the CSRF token in use for a request - should be done on login for security purposes. """ request.META.update({ "CSRF_COOKIE_USED": True, "CSRF_COOKIE": _get_new_csrf_token(), }) request.csrf_cookie_needs_reset = True
[ "def", "rotate_token", "(", "request", ")", ":", "request", ".", "META", ".", "update", "(", "{", "\"CSRF_COOKIE_USED\"", ":", "True", ",", "\"CSRF_COOKIE\"", ":", "_get_new_csrf_token", "(", ")", ",", "}", ")", "request", ".", "csrf_cookie_needs_reset", "=", ...
[ 92, 0 ]
[ 101, 42 ]
python
en
['en', 'error', 'th']
False
gitter_workspace_to_realm
( domain_name: str, gitter_data: GitterDataT, realm_subdomain: str )
Returns: 1. realm, converted realm data 2. avatars, which is list to map avatars to Zulip avatar records.json 3. user_map, which is a dictionary to map from Gitter user id to Zulip user id 4. stream_map, which is a dictionary to map from Gitter rooms to Zulip stream id
Returns: 1. realm, converted realm data 2. avatars, which is list to map avatars to Zulip avatar records.json 3. user_map, which is a dictionary to map from Gitter user id to Zulip user id 4. stream_map, which is a dictionary to map from Gitter rooms to Zulip stream id
def gitter_workspace_to_realm( domain_name: str, gitter_data: GitterDataT, realm_subdomain: str ) -> Tuple[ZerverFieldsT, List[ZerverFieldsT], Dict[str, int], Dict[str, int]]: """ Returns: 1. realm, converted realm data 2. avatars, which is list to map avatars to Zulip avatar records.json 3. use...
[ "def", "gitter_workspace_to_realm", "(", "domain_name", ":", "str", ",", "gitter_data", ":", "GitterDataT", ",", "realm_subdomain", ":", "str", ")", "->", "Tuple", "[", "ZerverFieldsT", ",", "List", "[", "ZerverFieldsT", "]", ",", "Dict", "[", "str", ",", "i...
[ 35, 0 ]
[ 61, 47 ]
python
en
['en', 'error', 'th']
False
build_userprofile
( timestamp: Any, domain_name: str, gitter_data: GitterDataT )
Returns: 1. zerver_userprofile, which is a list of user profile 2. avatar_list, which is list to map avatars to Zulip avatars records.json 3. added_users, which is a dictionary to map from Gitter user id to Zulip id
Returns: 1. zerver_userprofile, which is a list of user profile 2. avatar_list, which is list to map avatars to Zulip avatars records.json 3. added_users, which is a dictionary to map from Gitter user id to Zulip id
def build_userprofile( timestamp: Any, domain_name: str, gitter_data: GitterDataT ) -> Tuple[List[ZerverFieldsT], List[ZerverFieldsT], Dict[str, int]]: """ Returns: 1. zerver_userprofile, which is a list of user profile 2. avatar_list, which is list to map avatars to Zulip avatars records.json 3...
[ "def", "build_userprofile", "(", "timestamp", ":", "Any", ",", "domain_name", ":", "str", ",", "gitter_data", ":", "GitterDataT", ")", "->", "Tuple", "[", "List", "[", "ZerverFieldsT", "]", ",", "List", "[", "ZerverFieldsT", "]", ",", "Dict", "[", "str", ...
[ 64, 0 ]
[ 109, 52 ]
python
en
['en', 'error', 'th']
False
build_stream_map
( timestamp: Any, gitter_data: GitterDataT )
Returns: 1. stream, which is the list of streams 2. defaultstreams, which is the list of default streams 3. stream_map, which is a dictionary to map from Gitter rooms to Zulip stream id
Returns: 1. stream, which is the list of streams 2. defaultstreams, which is the list of default streams 3. stream_map, which is a dictionary to map from Gitter rooms to Zulip stream id
def build_stream_map( timestamp: Any, gitter_data: GitterDataT ) -> Tuple[List[ZerverFieldsT], List[ZerverFieldsT], Dict[str, int]]: """ Returns: 1. stream, which is the list of streams 2. defaultstreams, which is the list of default streams 3. stream_map, which is a dictionary to map from Gitte...
[ "def", "build_stream_map", "(", "timestamp", ":", "Any", ",", "gitter_data", ":", "GitterDataT", ")", "->", "Tuple", "[", "List", "[", "ZerverFieldsT", "]", ",", "List", "[", "ZerverFieldsT", "]", ",", "Dict", "[", "str", ",", "int", "]", "]", ":", "lo...
[ 118, 0 ]
[ 151, 46 ]
python
en
['en', 'error', 'th']
False
build_recipient_and_subscription
( zerver_userprofile: List[ZerverFieldsT], zerver_stream: List[ZerverFieldsT] )
Assumes that there is at least one stream with 'stream_id' = 0, and that this stream is the only defaultstream, with 'defaultstream_id' = 0 Returns: 1. zerver_recipient, which is a list of mapped recipient 2. zerver_subscription, which is a list of mapped subscription
Assumes that there is at least one stream with 'stream_id' = 0, and that this stream is the only defaultstream, with 'defaultstream_id' = 0 Returns: 1. zerver_recipient, which is a list of mapped recipient 2. zerver_subscription, which is a list of mapped subscription
def build_recipient_and_subscription( zerver_userprofile: List[ZerverFieldsT], zerver_stream: List[ZerverFieldsT] ) -> Tuple[List[ZerverFieldsT], List[ZerverFieldsT]]: """ Assumes that there is at least one stream with 'stream_id' = 0, and that this stream is the only defaultstream, with 'defaultstrea...
[ "def", "build_recipient_and_subscription", "(", "zerver_userprofile", ":", "List", "[", "ZerverFieldsT", "]", ",", "zerver_stream", ":", "List", "[", "ZerverFieldsT", "]", ")", "->", "Tuple", "[", "List", "[", "ZerverFieldsT", "]", ",", "List", "[", "ZerverField...
[ 154, 0 ]
[ 196, 48 ]
python
en
['en', 'error', 'th']
False
convert_gitter_workspace_messages
( gitter_data: GitterDataT, output_dir: str, subscriber_map: Dict[int, Set[int]], user_map: Dict[str, int], stream_map: Dict[str, int], user_short_name_to_full_name: Dict[str, str], chunk_size: int = MESSAGE_BATCH_CHUNK_SIZE, )
Messages are stored in batches
Messages are stored in batches
def convert_gitter_workspace_messages( gitter_data: GitterDataT, output_dir: str, subscriber_map: Dict[int, Set[int]], user_map: Dict[str, int], stream_map: Dict[str, int], user_short_name_to_full_name: Dict[str, str], chunk_size: int = MESSAGE_BATCH_CHUNK_SIZE, ) -> None: """ Messag...
[ "def", "convert_gitter_workspace_messages", "(", "gitter_data", ":", "GitterDataT", ",", "output_dir", ":", "str", ",", "subscriber_map", ":", "Dict", "[", "int", ",", "Set", "[", "int", "]", "]", ",", "user_map", ":", "Dict", "[", "str", ",", "int", "]", ...
[ 199, 0 ]
[ 266, 69 ]
python
en
['en', 'error', 'th']
False
DeleteCascadeTests.test_generic_relation_cascade
(self)
Django cascades deletes through generic-related objects to their reverse relations.
Django cascades deletes through generic-related objects to their reverse relations.
def test_generic_relation_cascade(self): """ Django cascades deletes through generic-related objects to their reverse relations. """ person = Person.objects.create(name='Nelson Mandela') award = Award.objects.create(name='Nobel', content_object=person) AwardNote....
[ "def", "test_generic_relation_cascade", "(", "self", ")", ":", "person", "=", "Person", ".", "objects", ".", "create", "(", "name", "=", "'Nelson Mandela'", ")", "award", "=", "Award", ".", "objects", ".", "create", "(", "name", "=", "'Nobel'", ",", "conte...
[ 59, 4 ]
[ 73, 54 ]
python
en
['en', 'error', 'th']
False
DeleteCascadeTests.test_fk_to_m2m_through
(self)
If an M2M relationship has an explicitly-specified through model, and some other model has an FK to that through model, deletion is cascaded from one of the participants in the M2M, to the through model, to its related model.
If an M2M relationship has an explicitly-specified through model, and some other model has an FK to that through model, deletion is cascaded from one of the participants in the M2M, to the through model, to its related model.
def test_fk_to_m2m_through(self): """ If an M2M relationship has an explicitly-specified through model, and some other model has an FK to that through model, deletion is cascaded from one of the participants in the M2M, to the through model, to its related model. """ ...
[ "def", "test_fk_to_m2m_through", "(", "self", ")", ":", "juan", "=", "Child", ".", "objects", ".", "create", "(", "name", "=", "'Juan'", ")", "paints", "=", "Toy", ".", "objects", ".", "create", "(", "name", "=", "'Paints'", ")", "played", "=", "Played...
[ 75, 4 ]
[ 93, 59 ]
python
en
['en', 'error', 'th']
False
DeleteCascadeTransactionTests.test_inheritance
(self)
Auto-created many-to-many through tables referencing a parent model are correctly found by the delete cascade when a child of that parent is deleted. Refs #14896.
Auto-created many-to-many through tables referencing a parent model are correctly found by the delete cascade when a child of that parent is deleted.
def test_inheritance(self): """ Auto-created many-to-many through tables referencing a parent model are correctly found by the delete cascade when a child of that parent is deleted. Refs #14896. """ r = Researcher.objects.create() email = Email.objects.cr...
[ "def", "test_inheritance", "(", "self", ")", ":", "r", "=", "Researcher", ".", "objects", ".", "create", "(", ")", "email", "=", "Email", ".", "objects", ".", "create", "(", "label", "=", "\"office-email\"", ",", "email_address", "=", "\"carl@science.edu\"",...
[ 107, 4 ]
[ 121, 22 ]
python
en
['en', 'error', 'th']
False
DeleteCascadeTransactionTests.test_to_field
(self)
Cascade deletion works with ForeignKey.to_field set to non-PK.
Cascade deletion works with ForeignKey.to_field set to non-PK.
def test_to_field(self): """ Cascade deletion works with ForeignKey.to_field set to non-PK. """ apple = Food.objects.create(name="apple") Eaten.objects.create(food=apple, meal="lunch") apple.delete() self.assertFalse(Food.objects.exists()) self.assertFal...
[ "def", "test_to_field", "(", "self", ")", ":", "apple", "=", "Food", ".", "objects", ".", "create", "(", "name", "=", "\"apple\"", ")", "Eaten", ".", "objects", ".", "create", "(", "food", "=", "apple", ",", "meal", "=", "\"lunch\"", ")", "apple", "....
[ 123, 4 ]
[ 133, 48 ]
python
en
['en', 'error', 'th']
False
LargeDeleteTests.test_large_deletes
(self)
Regression for #13309 -- if the number of objects > chunk size, deletion still occurs
Regression for #13309 -- if the number of objects > chunk size, deletion still occurs
def test_large_deletes(self): "Regression for #13309 -- if the number of objects > chunk size, deletion still occurs" for x in range(300): Book.objects.create(pagecount=x + 100) # attach a signal to make sure we will not fast-delete def noop(*args, **kwargs): pas...
[ "def", "test_large_deletes", "(", "self", ")", ":", "for", "x", "in", "range", "(", "300", ")", ":", "Book", ".", "objects", ".", "create", "(", "pagecount", "=", "x", "+", "100", ")", "# attach a signal to make sure we will not fast-delete", "def", "noop", ...
[ 137, 4 ]
[ 148, 49 ]
python
en
['en', 'en', 'en']
True
ProxyDeleteTest.create_image
(self)
Return an Image referenced by both a FooImage and a FooFile.
Return an Image referenced by both a FooImage and a FooFile.
def create_image(self): """Return an Image referenced by both a FooImage and a FooFile.""" # Create an Image test_image = Image() test_image.save() foo_image = FooImage(my_image=test_image) foo_image.save() # Get the Image instance as a File test_file = F...
[ "def", "create_image", "(", "self", ")", ":", "# Create an Image", "test_image", "=", "Image", "(", ")", "test_image", ".", "save", "(", ")", "foo_image", "=", "FooImage", "(", "my_image", "=", "test_image", ")", "foo_image", ".", "save", "(", ")", "# Get ...
[ 158, 4 ]
[ 171, 25 ]
python
en
['en', 'en', 'en']
True
ProxyDeleteTest.test_delete_proxy
(self)
Deleting the *proxy* instance bubbles through to its non-proxy and *all* referring objects are deleted.
Deleting the *proxy* instance bubbles through to its non-proxy and *all* referring objects are deleted.
def test_delete_proxy(self): """ Deleting the *proxy* instance bubbles through to its non-proxy and *all* referring objects are deleted. """ self.create_image() Image.objects.all().delete() # An Image deletion == File deletion self.assertEqual(len(Image...
[ "def", "test_delete_proxy", "(", "self", ")", ":", "self", ".", "create_image", "(", ")", "Image", ".", "objects", ".", "all", "(", ")", ".", "delete", "(", ")", "# An Image deletion == File deletion", "self", ".", "assertEqual", "(", "len", "(", "Image", ...
[ 173, 4 ]
[ 189, 55 ]
python
en
['en', 'error', 'th']
False
ProxyDeleteTest.test_delete_proxy_of_proxy
(self)
Deleting a proxy-of-proxy instance should bubble through to its proxy and non-proxy parents, deleting *all* referring objects.
Deleting a proxy-of-proxy instance should bubble through to its proxy and non-proxy parents, deleting *all* referring objects.
def test_delete_proxy_of_proxy(self): """ Deleting a proxy-of-proxy instance should bubble through to its proxy and non-proxy parents, deleting *all* referring objects. """ test_image = self.create_image() # Get the Image as a Photo test_photo = Photo.objects.ge...
[ "def", "test_delete_proxy_of_proxy", "(", "self", ")", ":", "test_image", "=", "self", ".", "create_image", "(", ")", "# Get the Image as a Photo", "test_photo", "=", "Photo", ".", "objects", ".", "get", "(", "pk", "=", "test_image", ".", "pk", ")", "foo_photo...
[ 191, 4 ]
[ 215, 56 ]
python
en
['en', 'error', 'th']
False
ProxyDeleteTest.test_delete_concrete_parent
(self)
Deleting an instance of a concrete model should also delete objects referencing its proxy subclass.
Deleting an instance of a concrete model should also delete objects referencing its proxy subclass.
def test_delete_concrete_parent(self): """ Deleting an instance of a concrete model should also delete objects referencing its proxy subclass. """ self.create_image() File.objects.all().delete() # A File deletion == Image deletion self.assertEqual(len(F...
[ "def", "test_delete_concrete_parent", "(", "self", ")", ":", "self", ".", "create_image", "(", ")", "File", ".", "objects", ".", "all", "(", ")", ".", "delete", "(", ")", "# A File deletion == Image deletion", "self", ".", "assertEqual", "(", "len", "(", "Fi...
[ 217, 4 ]
[ 234, 56 ]
python
en
['en', 'error', 'th']
False
ProxyDeleteTest.test_delete_proxy_pair
(self)
If a pair of proxy models are linked by an FK from one concrete parent to the other, deleting one proxy model cascade-deletes the other, and the deletion happens in the right order (not triggering an IntegrityError on databases unable to defer integrity checks). Refs #17918. ...
If a pair of proxy models are linked by an FK from one concrete parent to the other, deleting one proxy model cascade-deletes the other, and the deletion happens in the right order (not triggering an IntegrityError on databases unable to defer integrity checks).
def test_delete_proxy_pair(self): """ If a pair of proxy models are linked by an FK from one concrete parent to the other, deleting one proxy model cascade-deletes the other, and the deletion happens in the right order (not triggering an IntegrityError on databases unable to defe...
[ "def", "test_delete_proxy_pair", "(", "self", ")", ":", "# Create an Image (proxy of File) and FooFileProxy (proxy of FooFile,", "# which has an FK to File)", "image", "=", "Image", ".", "objects", ".", "create", "(", ")", "as_file", "=", "File", ".", "objects", ".", "g...
[ 236, 4 ]
[ 254, 60 ]
python
en
['en', 'error', 'th']
False
get_hstore_oids
(connection_alias)
Return hstore and hstore array OIDs.
Return hstore and hstore array OIDs.
def get_hstore_oids(connection_alias): """Return hstore and hstore array OIDs.""" with connections[connection_alias].cursor() as cursor: cursor.execute( "SELECT t.oid, typarray " "FROM pg_type t " "JOIN pg_namespace ns ON typnamespace = ns.oid " "WHERE typ...
[ "def", "get_hstore_oids", "(", "connection_alias", ")", ":", "with", "connections", "[", "connection_alias", "]", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor", ".", "execute", "(", "\"SELECT t.oid, typarray \"", "\"FROM pg_type t \"", "\"JOIN pg_namespace ns...
[ 11, 0 ]
[ 25, 45 ]
python
en
['en', 'en', 'en']
True
get_citext_oids
(connection_alias)
Return citext array OIDs.
Return citext array OIDs.
def get_citext_oids(connection_alias): """Return citext array OIDs.""" with connections[connection_alias].cursor() as cursor: cursor.execute("SELECT typarray FROM pg_type WHERE typname = 'citext'") return tuple(row[0] for row in cursor)
[ "def", "get_citext_oids", "(", "connection_alias", ")", ":", "with", "connections", "[", "connection_alias", "]", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor", ".", "execute", "(", "\"SELECT typarray FROM pg_type WHERE typname = 'citext'\"", ")", "return", ...
[ 29, 0 ]
[ 33, 46 ]
python
en
['en', 'fr', 'en']
True
accuracy
( sess, model, x, y, batch_size=None, devices=None, feed=None, attack=None, attack_params=None, )
Compute the accuracy of a TF model on some data :param sess: TF session to use when training the graph :param model: cleverhans.model.Model instance :param x: numpy array containing input examples (e.g. MNIST().x_test ) :param y: numpy array containing example labels (e.g. MNIST().y_test ) :par...
Compute the accuracy of a TF model on some data :param sess: TF session to use when training the graph :param model: cleverhans.model.Model instance :param x: numpy array containing input examples (e.g. MNIST().x_test ) :param y: numpy array containing example labels (e.g. MNIST().y_test ) :par...
def accuracy( sess, model, x, y, batch_size=None, devices=None, feed=None, attack=None, attack_params=None, ): """ Compute the accuracy of a TF model on some data :param sess: TF session to use when training the graph :param model: cleverhans.model.Model instance ...
[ "def", "accuracy", "(", "sess", ",", "model", ",", "x", ",", "y", ",", "batch_size", "=", "None", ",", "devices", "=", "None", ",", "feed", "=", "None", ",", "attack", "=", "None", ",", "attack_params", "=", "None", ",", ")", ":", "_check_x", "(", ...
[ 17, 0 ]
[ 68, 25 ]
python
en
['en', 'error', 'th']
False
class_and_confidence
( sess, model, x, y=None, batch_size=None, devices=None, feed=None, attack=None, attack_params=None, )
Return the model's classification of the input data, and the confidence (probability) assigned to each example. :param sess: tf.Session :param model: cleverhans.model.Model :param x: numpy array containing input examples (e.g. MNIST().x_test ) :param y: numpy array containing true labels ...
Return the model's classification of the input data, and the confidence (probability) assigned to each example. :param sess: tf.Session :param model: cleverhans.model.Model :param x: numpy array containing input examples (e.g. MNIST().x_test ) :param y: numpy array containing true labels ...
def class_and_confidence( sess, model, x, y=None, batch_size=None, devices=None, feed=None, attack=None, attack_params=None, ): """ Return the model's classification of the input data, and the confidence (probability) assigned to each example. :param sess: tf.Session ...
[ "def", "class_and_confidence", "(", "sess", ",", "model", ",", "x", ",", "y", "=", "None", ",", "batch_size", "=", "None", ",", "devices", "=", "None", ",", "feed", "=", "None", ",", "attack", "=", "None", ",", "attack_params", "=", "None", ",", ")",...
[ 71, 0 ]
[ 145, 14 ]
python
en
['en', 'error', 'th']
False
correctness_and_confidence
( sess, model, x, y, batch_size=None, devices=None, feed=None, attack=None, attack_params=None, )
Report whether the model is correct and its confidence on each example in a dataset. :param sess: tf.Session :param model: cleverhans.model.Model :param x: numpy array containing input examples (e.g. MNIST().x_test ) :param y: numpy array containing example labels (e.g. MNIST().y_test ) :pa...
Report whether the model is correct and its confidence on each example in a dataset. :param sess: tf.Session :param model: cleverhans.model.Model :param x: numpy array containing input examples (e.g. MNIST().x_test ) :param y: numpy array containing example labels (e.g. MNIST().y_test ) :pa...
def correctness_and_confidence( sess, model, x, y, batch_size=None, devices=None, feed=None, attack=None, attack_params=None, ): """ Report whether the model is correct and its confidence on each example in a dataset. :param sess: tf.Session :param model: cleverha...
[ "def", "correctness_and_confidence", "(", "sess", ",", "model", ",", "x", ",", "y", ",", "batch_size", "=", "None", ",", "devices", "=", "None", ",", "feed", "=", "None", ",", "attack", "=", "None", ",", "attack_params", "=", "None", ",", ")", ":", "...
[ 148, 0 ]
[ 218, 14 ]
python
en
['en', 'error', 'th']
False
run_attack
( sess, model, x, y, attack, attack_params, batch_size=None, devices=None, feed=None, pass_y=False, )
Run attack on every example in a dataset. :param sess: tf.Session :param model: cleverhans.model.Model :param x: numpy array containing input examples (e.g. MNIST().x_test ) :param y: numpy array containing example labels (e.g. MNIST().y_test ) :param attack: cleverhans.attack.Attack :param...
Run attack on every example in a dataset. :param sess: tf.Session :param model: cleverhans.model.Model :param x: numpy array containing input examples (e.g. MNIST().x_test ) :param y: numpy array containing example labels (e.g. MNIST().y_test ) :param attack: cleverhans.attack.Attack :param...
def run_attack( sess, model, x, y, attack, attack_params, batch_size=None, devices=None, feed=None, pass_y=False, ): """ Run attack on every example in a dataset. :param sess: tf.Session :param model: cleverhans.model.Model :param x: numpy array containing inp...
[ "def", "run_attack", "(", "sess", ",", "model", ",", "x", ",", "y", ",", "attack", ",", "attack_params", ",", "batch_size", "=", "None", ",", "devices", "=", "None", ",", "feed", "=", "None", ",", "pass_y", "=", "False", ",", ")", ":", "_check_x", ...
[ 221, 0 ]
[ 269, 14 ]
python
en
['en', 'error', 'th']
False
batch_eval_multi_worker
( sess, graph_factory, numpy_inputs, batch_size=None, devices=None, feed=None )
Generic computation engine for evaluating an expression across a whole dataset, divided into batches. This function assumes that the work can be parallelized with one worker device handling one batch of data. If you need multiple devices per batch, use `batch_eval`. The tensorflow graph for m...
Generic computation engine for evaluating an expression across a whole dataset, divided into batches.
def batch_eval_multi_worker( sess, graph_factory, numpy_inputs, batch_size=None, devices=None, feed=None ): """ Generic computation engine for evaluating an expression across a whole dataset, divided into batches. This function assumes that the work can be parallelized with one worker device ha...
[ "def", "batch_eval_multi_worker", "(", "sess", ",", "graph_factory", ",", "numpy_inputs", ",", "batch_size", "=", "None", ",", "devices", "=", "None", ",", "feed", "=", "None", ")", ":", "canary", ".", "run_canary", "(", ")", "global", "_batch_eval_multi_worke...
[ 272, 0 ]
[ 464, 14 ]
python
en
['en', 'error', 'th']
False
batch_eval
( sess, tf_inputs, tf_outputs, numpy_inputs, batch_size=None, feed=None, args=None )
A helper function that computes a tensor on numpy inputs by batches. This version uses exactly the tensorflow graph constructed by the caller, so the caller can place specific ops on specific devices to implement model parallelism. Most users probably prefer `batch_eval_multi_worker` which maps ...
A helper function that computes a tensor on numpy inputs by batches. This version uses exactly the tensorflow graph constructed by the caller, so the caller can place specific ops on specific devices to implement model parallelism. Most users probably prefer `batch_eval_multi_worker` which maps ...
def batch_eval( sess, tf_inputs, tf_outputs, numpy_inputs, batch_size=None, feed=None, args=None ): """ A helper function that computes a tensor on numpy inputs by batches. This version uses exactly the tensorflow graph constructed by the caller, so the caller can place specific ops on specific devi...
[ "def", "batch_eval", "(", "sess", ",", "tf_inputs", ",", "tf_outputs", ",", "numpy_inputs", ",", "batch_size", "=", "None", ",", "feed", "=", "None", ",", "args", "=", "None", ")", ":", "if", "args", "is", "not", "None", ":", "warnings", ".", "warn", ...
[ 467, 0 ]
[ 542, 14 ]
python
en
['en', 'error', 'th']
False
_check_x
(x)
Makes sure an `x` argument is a valid numpy dataset.
Makes sure an `x` argument is a valid numpy dataset.
def _check_x(x): """ Makes sure an `x` argument is a valid numpy dataset. """ if not isinstance(x, np.ndarray): raise TypeError( "x must be a numpy array. Typically x contains " "the entire test set inputs." )
[ "def", "_check_x", "(", "x", ")", ":", "if", "not", "isinstance", "(", "x", ",", "np", ".", "ndarray", ")", ":", "raise", "TypeError", "(", "\"x must be a numpy array. Typically x contains \"", "\"the entire test set inputs.\"", ")" ]
[ 774, 0 ]
[ 782, 9 ]
python
en
['en', 'error', 'th']
False
_check_y
(y)
Makes sure a `y` argument is a vliad numpy dataset.
Makes sure a `y` argument is a vliad numpy dataset.
def _check_y(y): """ Makes sure a `y` argument is a vliad numpy dataset. """ if not isinstance(y, np.ndarray): raise TypeError( "y must be numpy array. Typically y contains " "the entire test set labels. Got " + str(y) + " of type " + str(type(y)) )
[ "def", "_check_y", "(", "y", ")", ":", "if", "not", "isinstance", "(", "y", ",", "np", ".", "ndarray", ")", ":", "raise", "TypeError", "(", "\"y must be numpy array. Typically y contains \"", "\"the entire test set labels. Got \"", "+", "str", "(", "y", ")", "+"...
[ 785, 0 ]
[ 793, 9 ]
python
en
['en', 'error', 'th']
False
Polygon.__init__
(self, *args, **kwargs)
Initializes on an exterior ring and a sequence of holes (both instances may be either LinearRing instances, or a tuple/list that may be constructed into a LinearRing). Examples of initialization, where shell, hole1, and hole2 are valid LinearRing geometries: >>> from dj...
Initializes on an exterior ring and a sequence of holes (both instances may be either LinearRing instances, or a tuple/list that may be constructed into a LinearRing).
def __init__(self, *args, **kwargs): """ Initializes on an exterior ring and a sequence of holes (both instances may be either LinearRing instances, or a tuple/list that may be constructed into a LinearRing). Examples of initialization, where shell, hole1, and hole2 are ...
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "args", ":", "raise", "TypeError", "(", "'Must provide at least one LinearRing, or a tuple, to initialize a Polygon.'", ")", "# Getting the ext_ring and init_holes parameters...
[ 12, 4 ]
[ 47, 56 ]
python
en
['en', 'error', 'th']
False