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
PingdomHookTests.test_pingdom_from_down_to_up_imap_check_message
(self)
Tests if pingdom imap check from down to up is handled correctly
Tests if pingdom imap check from down to up is handled correctly
def test_pingdom_from_down_to_up_imap_check_message(self) -> None: """ Tests if pingdom imap check from down to up is handled correctly """ expected_message = "Service imap.someurl.com changed its IMAP status from DOWN to UP." self.check_webhook("imap_down_to_up", "IMAP check sta...
[ "def", "test_pingdom_from_down_to_up_imap_check_message", "(", "self", ")", "->", "None", ":", "expected_message", "=", "\"Service imap.someurl.com changed its IMAP status from DOWN to UP.\"", "self", ".", "check_webhook", "(", "\"imap_down_to_up\"", ",", "\"IMAP check status.\"", ...
[ 29, 4 ]
[ 34, 85 ]
python
en
['en', 'error', 'th']
False
reset_format_cache
()
Clear any cached formats. This method is provided primarily for testing purposes, so that the effects of cached formats can be removed.
Clear any cached formats.
def reset_format_cache(): """Clear any cached formats. This method is provided primarily for testing purposes, so that the effects of cached formats can be removed. """ global _format_cache, _format_modules_cache _format_cache = {} _format_modules_cache = {}
[ "def", "reset_format_cache", "(", ")", ":", "global", "_format_cache", ",", "_format_modules_cache", "_format_cache", "=", "{", "}", "_format_modules_cache", "=", "{", "}" ]
[ 33, 0 ]
[ 41, 30 ]
python
en
['en', 'en', 'en']
True
iter_format_modules
(lang, format_module_path=None)
Does the heavy lifting of finding format modules.
Does the heavy lifting of finding format modules.
def iter_format_modules(lang, format_module_path=None): """ Does the heavy lifting of finding format modules. """ if not check_for_language(lang): return if format_module_path is None: format_module_path = settings.FORMAT_MODULE_PATH format_locations = [] if format_module_p...
[ "def", "iter_format_modules", "(", "lang", ",", "format_module_path", "=", "None", ")", ":", "if", "not", "check_for_language", "(", "lang", ")", ":", "return", "if", "format_module_path", "is", "None", ":", "format_module_path", "=", "settings", ".", "FORMAT_MO...
[ 44, 0 ]
[ 70, 20 ]
python
en
['en', 'error', 'th']
False
get_format_modules
(lang=None, reverse=False)
Returns a list of the format modules found
Returns a list of the format modules found
def get_format_modules(lang=None, reverse=False): """ Returns a list of the format modules found """ if lang is None: lang = get_language() modules = _format_modules_cache.setdefault(lang, list(iter_format_modules(lang, settings.FORMAT_MODULE_PATH))) if reverse: return list(rever...
[ "def", "get_format_modules", "(", "lang", "=", "None", ",", "reverse", "=", "False", ")", ":", "if", "lang", "is", "None", ":", "lang", "=", "get_language", "(", ")", "modules", "=", "_format_modules_cache", ".", "setdefault", "(", "lang", ",", "list", "...
[ 73, 0 ]
[ 82, 18 ]
python
en
['en', 'error', 'th']
False
get_format
(format_type, lang=None, use_l10n=None)
For a specific format type, returns the format for the current language (locale), defaults to the format in the settings. format_type is the name of the format, e.g. 'DATE_FORMAT' If use_l10n is provided and is not None, that will force the value to be localized (or not), overriding the value of s...
For a specific format type, returns the format for the current language (locale), defaults to the format in the settings. format_type is the name of the format, e.g. 'DATE_FORMAT'
def get_format(format_type, lang=None, use_l10n=None): """ For a specific format type, returns the format for the current language (locale), defaults to the format in the settings. format_type is the name of the format, e.g. 'DATE_FORMAT' If use_l10n is provided and is not None, that will force the...
[ "def", "get_format", "(", "format_type", ",", "lang", "=", "None", ",", "use_l10n", "=", "None", ")", ":", "format_type", "=", "force_str", "(", "format_type", ")", "if", "use_l10n", "or", "(", "use_l10n", "is", "None", "and", "settings", ".", "USE_L10N", ...
[ 85, 0 ]
[ 120, 41 ]
python
en
['en', 'error', 'th']
False
date_format
(value, format=None, use_l10n=None)
Formats a datetime.date or datetime.datetime object using a localizable format If use_l10n is provided and is not None, that will force the value to be localized (or not), overriding the value of settings.USE_L10N.
Formats a datetime.date or datetime.datetime object using a localizable format
def date_format(value, format=None, use_l10n=None): """ Formats a datetime.date or datetime.datetime object using a localizable format If use_l10n is provided and is not None, that will force the value to be localized (or not), overriding the value of settings.USE_L10N. """ return dateforma...
[ "def", "date_format", "(", "value", ",", "format", "=", "None", ",", "use_l10n", "=", "None", ")", ":", "return", "dateformat", ".", "format", "(", "value", ",", "get_format", "(", "format", "or", "'DATE_FORMAT'", ",", "use_l10n", "=", "use_l10n", ")", "...
[ 125, 0 ]
[ 133, 91 ]
python
en
['en', 'error', 'th']
False
time_format
(value, format=None, use_l10n=None)
Formats a datetime.time object using a localizable format If use_l10n is provided and is not None, that will force the value to be localized (or not), overriding the value of settings.USE_L10N.
Formats a datetime.time object using a localizable format
def time_format(value, format=None, use_l10n=None): """ Formats a datetime.time object using a localizable format If use_l10n is provided and is not None, that will force the value to be localized (or not), overriding the value of settings.USE_L10N. """ return dateformat.time_format(value, get_...
[ "def", "time_format", "(", "value", ",", "format", "=", "None", ",", "use_l10n", "=", "None", ")", ":", "return", "dateformat", ".", "time_format", "(", "value", ",", "get_format", "(", "format", "or", "'TIME_FORMAT'", ",", "use_l10n", "=", "use_l10n", ")"...
[ 136, 0 ]
[ 143, 96 ]
python
en
['en', 'error', 'th']
False
number_format
(value, decimal_pos=None, use_l10n=None, force_grouping=False)
Formats a numeric value using localization settings If use_l10n is provided and is not None, that will force the value to be localized (or not), overriding the value of settings.USE_L10N.
Formats a numeric value using localization settings
def number_format(value, decimal_pos=None, use_l10n=None, force_grouping=False): """ Formats a numeric value using localization settings If use_l10n is provided and is not None, that will force the value to be localized (or not), overriding the value of settings.USE_L10N. """ if use_l10n or (us...
[ "def", "number_format", "(", "value", ",", "decimal_pos", "=", "None", ",", "use_l10n", "=", "None", ",", "force_grouping", "=", "False", ")", ":", "if", "use_l10n", "or", "(", "use_l10n", "is", "None", "and", "settings", ".", "USE_L10N", ")", ":", "lang...
[ 146, 0 ]
[ 164, 5 ]
python
en
['en', 'error', 'th']
False
localize
(value, use_l10n=None)
Checks if value is a localizable type (date, number...) and returns it formatted as a string using current locale format. If use_l10n is provided and is not None, that will force the value to be localized (or not), overriding the value of settings.USE_L10N.
Checks if value is a localizable type (date, number...) and returns it formatted as a string using current locale format.
def localize(value, use_l10n=None): """ Checks if value is a localizable type (date, number...) and returns it formatted as a string using current locale format. If use_l10n is provided and is not None, that will force the value to be localized (or not), overriding the value of settings.USE_L10N. ...
[ "def", "localize", "(", "value", ",", "use_l10n", "=", "None", ")", ":", "if", "isinstance", "(", "value", ",", "bool", ")", ":", "return", "mark_safe", "(", "six", ".", "text_type", "(", "value", ")", ")", "elif", "isinstance", "(", "value", ",", "(...
[ 167, 0 ]
[ 186, 20 ]
python
en
['en', 'error', 'th']
False
localize_input
(value, default=None)
Checks if an input value is a localizable type and returns it formatted with the appropriate formatting string of the current locale.
Checks if an input value is a localizable type and returns it formatted with the appropriate formatting string of the current locale.
def localize_input(value, default=None): """ Checks if an input value is a localizable type and returns it formatted with the appropriate formatting string of the current locale. """ if isinstance(value, (decimal.Decimal, float) + six.integer_types): return number_format(value) elif isin...
[ "def", "localize_input", "(", "value", ",", "default", "=", "None", ")", ":", "if", "isinstance", "(", "value", ",", "(", "decimal", ".", "Decimal", ",", "float", ")", "+", "six", ".", "integer_types", ")", ":", "return", "number_format", "(", "value", ...
[ 189, 0 ]
[ 207, 16 ]
python
en
['en', 'error', 'th']
False
sanitize_separators
(value)
Sanitizes a value according to the current decimal and thousand separator setting. Used with form field input.
Sanitizes a value according to the current decimal and thousand separator setting. Used with form field input.
def sanitize_separators(value): """ Sanitizes a value according to the current decimal and thousand separator setting. Used with form field input. """ if settings.USE_L10N and isinstance(value, six.string_types): parts = [] decimal_separator = get_format('DECIMAL_SEPARATOR') ...
[ "def", "sanitize_separators", "(", "value", ")", ":", "if", "settings", ".", "USE_L10N", "and", "isinstance", "(", "value", ",", "six", ".", "string_types", ")", ":", "parts", "=", "[", "]", "decimal_separator", "=", "get_format", "(", "'DECIMAL_SEPARATOR'", ...
[ 210, 0 ]
[ 232, 16 ]
python
en
['en', 'error', 'th']
False
_clean_credentials
(credentials)
Cleans a dictionary of credentials of potentially sensitive info before sending to less secure functions. Not comprehensive - intended for user_login_failed signal
Cleans a dictionary of credentials of potentially sensitive info before sending to less secure functions.
def _clean_credentials(credentials): """ Cleans a dictionary of credentials of potentially sensitive info before sending to less secure functions. Not comprehensive - intended for user_login_failed signal """ SENSITIVE_CREDENTIALS = re.compile('api|token|key|secret|password|signature', re.I) ...
[ "def", "_clean_credentials", "(", "credentials", ")", ":", "SENSITIVE_CREDENTIALS", "=", "re", ".", "compile", "(", "'api|token|key|secret|password|signature'", ",", "re", ".", "I", ")", "CLEANSED_SUBSTITUTE", "=", "'********************'", "for", "key", "in", "creden...
[ 34, 0 ]
[ 46, 22 ]
python
en
['en', 'error', 'th']
False
authenticate
(**credentials)
If the given credentials are valid, return a User object.
If the given credentials are valid, return a User object.
def authenticate(**credentials): """ If the given credentials are valid, return a User object. """ for backend in get_backends(): try: inspect.getcallargs(backend.authenticate, **credentials) except TypeError: # This backend doesn't accept these credentials as arg...
[ "def", "authenticate", "(", "*", "*", "credentials", ")", ":", "for", "backend", "in", "get_backends", "(", ")", ":", "try", ":", "inspect", ".", "getcallargs", "(", "backend", ".", "authenticate", ",", "*", "*", "credentials", ")", "except", "TypeError", ...
[ 49, 0 ]
[ 73, 56 ]
python
en
['en', 'error', 'th']
False
login
(request, user)
Persist a user id and a backend in the request. This way a user doesn't have to reauthenticate on every request. Note that data set during the anonymous session is retained when the user logs in.
Persist a user id and a backend in the request. This way a user doesn't have to reauthenticate on every request. Note that data set during the anonymous session is retained when the user logs in.
def login(request, user): """ Persist a user id and a backend in the request. This way a user doesn't have to reauthenticate on every request. Note that data set during the anonymous session is retained when the user logs in. """ session_auth_hash = '' if user is None: user = request...
[ "def", "login", "(", "request", ",", "user", ")", ":", "session_auth_hash", "=", "''", "if", "user", "is", "None", ":", "user", "=", "request", ".", "user", "if", "hasattr", "(", "user", ",", "'get_session_auth_hash'", ")", ":", "session_auth_hash", "=", ...
[ 76, 0 ]
[ 104, 74 ]
python
en
['en', 'error', 'th']
False
logout
(request)
Removes the authenticated user's ID from the request and flushes their session data.
Removes the authenticated user's ID from the request and flushes their session data.
def logout(request): """ Removes the authenticated user's ID from the request and flushes their session data. """ # Dispatch the signal before the user is logged out so the receivers have a # chance to find out *who* logged out. user = getattr(request, 'user', None) if hasattr(user, 'is_...
[ "def", "logout", "(", "request", ")", ":", "# Dispatch the signal before the user is logged out so the receivers have a", "# chance to find out *who* logged out.", "user", "=", "getattr", "(", "request", ",", "'user'", ",", "None", ")", "if", "hasattr", "(", "user", ",", ...
[ 107, 0 ]
[ 129, 38 ]
python
en
['en', 'error', 'th']
False
get_user_model
()
Returns the User model that is active in this project.
Returns the User model that is active in this project.
def get_user_model(): """ Returns the User model that is active in this project. """ try: return django_apps.get_model(settings.AUTH_USER_MODEL) except ValueError: raise ImproperlyConfigured("AUTH_USER_MODEL must be of the form 'app_label.model_name'") except LookupError: ...
[ "def", "get_user_model", "(", ")", ":", "try", ":", "return", "django_apps", ".", "get_model", "(", "settings", ".", "AUTH_USER_MODEL", ")", "except", "ValueError", ":", "raise", "ImproperlyConfigured", "(", "\"AUTH_USER_MODEL must be of the form 'app_label.model_name'\""...
[ 132, 0 ]
[ 143, 9 ]
python
en
['en', 'error', 'th']
False
get_user
(request)
Returns the user model instance associated with the given request session. If no user is retrieved an instance of `AnonymousUser` is returned.
Returns the user model instance associated with the given request session. If no user is retrieved an instance of `AnonymousUser` is returned.
def get_user(request): """ Returns the user model instance associated with the given request session. If no user is retrieved an instance of `AnonymousUser` is returned. """ from .models import AnonymousUser user = None try: user_id = request.session[SESSION_KEY] backend_path...
[ "def", "get_user", "(", "request", ")", ":", "from", ".", "models", "import", "AnonymousUser", "user", "=", "None", "try", ":", "user_id", "=", "request", ".", "session", "[", "SESSION_KEY", "]", "backend_path", "=", "request", ".", "session", "[", "BACKEN...
[ 146, 0 ]
[ 162, 34 ]
python
en
['en', 'error', 'th']
False
get_permission_codename
(action, opts)
Returns the codename of the permission for the specified action.
Returns the codename of the permission for the specified action.
def get_permission_codename(action, opts): """ Returns the codename of the permission for the specified action. """ return '%s_%s' % (action, opts.model_name)
[ "def", "get_permission_codename", "(", "action", ",", "opts", ")", ":", "return", "'%s_%s'", "%", "(", "action", ",", "opts", ".", "model_name", ")" ]
[ 165, 0 ]
[ 169, 46 ]
python
en
['en', 'error', 'th']
False
update_session_auth_hash
(request, user)
Updating a user's password logs out all sessions for the user if django.contrib.auth.middleware.SessionAuthenticationMiddleware is enabled. This function takes the current request and the updated user object from which the new session hash will be derived and updates the session hash appropriately...
Updating a user's password logs out all sessions for the user if django.contrib.auth.middleware.SessionAuthenticationMiddleware is enabled.
def update_session_auth_hash(request, user): """ Updating a user's password logs out all sessions for the user if django.contrib.auth.middleware.SessionAuthenticationMiddleware is enabled. This function takes the current request and the updated user object from which the new session hash will be de...
[ "def", "update_session_auth_hash", "(", "request", ",", "user", ")", ":", "if", "hasattr", "(", "user", ",", "'get_session_auth_hash'", ")", "and", "request", ".", "user", "==", "user", ":", "request", ".", "session", "[", "HASH_SESSION_KEY", "]", "=", "user...
[ 172, 0 ]
[ 183, 72 ]
python
en
['en', 'error', 'th']
False
make_entity
(key)
Helper method to make FakeDatastoreEntity. This method allows to path either tuple or FakeDatastoreKey as a key. Args: key: entity key, either tuple or FakeDatastoreKey Returns: Instance of FakeDatastoreEntity
Helper method to make FakeDatastoreEntity.
def make_entity(key): """Helper method to make FakeDatastoreEntity. This method allows to path either tuple or FakeDatastoreKey as a key. Args: key: entity key, either tuple or FakeDatastoreKey Returns: Instance of FakeDatastoreEntity """ if isinstance(key, tuple): key = F...
[ "def", "make_entity", "(", "key", ")", ":", "if", "isinstance", "(", "key", ",", "tuple", ")", ":", "key", "=", "FakeDatastoreKey", "(", "*", "key", ")", "return", "FakeDatastoreEntity", "(", "key", ")" ]
[ 138, 0 ]
[ 151, 35 ]
python
en
['en', 'et', 'en']
True
FakeBlob.__init__
(self, content)
Initializes FakeBlob with given content.
Initializes FakeBlob with given content.
def __init__(self, content): """Initializes FakeBlob with given content.""" if six.PY3 and isinstance(content, str): self._content = content.encode() else: self._content = content self.size = len(content)
[ "def", "__init__", "(", "self", ",", "content", ")", ":", "if", "six", ".", "PY3", "and", "isinstance", "(", "content", ",", "str", ")", ":", "self", ".", "_content", "=", "content", ".", "encode", "(", ")", "else", ":", "self", ".", "_content", "=...
[ 15, 4 ]
[ 21, 32 ]
python
en
['en', 'en', 'en']
True
FakeBlob.download_to_file
(self, fobj)
Writes content of this blob into given file object.
Writes content of this blob into given file object.
def download_to_file(self, fobj): """Writes content of this blob into given file object.""" fobj.write(self._content)
[ "def", "download_to_file", "(", "self", ",", "fobj", ")", ":", "fobj", ".", "write", "(", "self", ".", "_content", ")" ]
[ 23, 4 ]
[ 25, 33 ]
python
en
['en', 'en', 'en']
True
FakeStorageClient.__init__
(self, blobs=None)
Inits FakeStorageClient with given blobs. Args: blobs: either list of blob names or dict with mapping from blob names to their content Raises: TypeError: if blobs argument has invalid type
Inits FakeStorageClient with given blobs.
def __init__(self, blobs=None): """Inits FakeStorageClient with given blobs. Args: blobs: either list of blob names or dict with mapping from blob names to their content Raises: TypeError: if blobs argument has invalid type """ if blobs is not No...
[ "def", "__init__", "(", "self", ",", "blobs", "=", "None", ")", ":", "if", "blobs", "is", "not", "None", ":", "if", "isinstance", "(", "blobs", ",", "dict", ")", ":", "self", ".", "_blobs", "=", "copy", ".", "deepcopy", "(", "blobs", ")", "elif", ...
[ 31, 4 ]
[ 49, 28 ]
python
en
['en', 'en', 'en']
True
FakeStorageClient.list_blobs
(self, prefix="")
Lists names of all blobs by their prefix.
Lists names of all blobs by their prefix.
def list_blobs(self, prefix=""): """Lists names of all blobs by their prefix.""" return [b for b in self._blobs.keys() if b.startswith(prefix)]
[ "def", "list_blobs", "(", "self", ",", "prefix", "=", "\"\"", ")", ":", "return", "[", "b", "for", "b", "in", "self", ".", "_blobs", ".", "keys", "(", ")", "if", "b", ".", "startswith", "(", "prefix", ")", "]" ]
[ 51, 4 ]
[ 53, 70 ]
python
en
['en', 'en', 'en']
True
FakeStorageClient.get_blob
(self, blob_name)
Gets google.cloud.storage.blob.Blob object by blob name.
Gets google.cloud.storage.blob.Blob object by blob name.
def get_blob(self, blob_name): """Gets google.cloud.storage.blob.Blob object by blob name.""" if blob_name in self._blobs: return FakeBlob(self._blobs[blob_name]) else: return None
[ "def", "get_blob", "(", "self", ",", "blob_name", ")", ":", "if", "blob_name", "in", "self", ".", "_blobs", ":", "return", "FakeBlob", "(", "self", ".", "_blobs", "[", "blob_name", "]", ")", "else", ":", "return", "None" ]
[ 55, 4 ]
[ 60, 23 ]
python
en
['en', 'en', 'en']
True
FakeStorageClient.new_blob
(self, blob_name)
Creates new storage blob with provided name.
Creates new storage blob with provided name.
def new_blob(self, blob_name): """Creates new storage blob with provided name.""" del blob_name raise NotImplementedError("new_blob is not implemented in fake client.")
[ "def", "new_blob", "(", "self", ",", "blob_name", ")", ":", "del", "blob_name", "raise", "NotImplementedError", "(", "\"new_blob is not implemented in fake client.\"", ")" ]
[ 62, 4 ]
[ 65, 80 ]
python
en
['en', 'en', 'en']
True
FakeDatastoreClientBatch.__init__
(self, fake_datastore_client)
Init FakeDatastoreClientBatch.
Init FakeDatastoreClientBatch.
def __init__(self, fake_datastore_client): """Init FakeDatastoreClientBatch.""" self._fake_datastore_client = fake_datastore_client self._mutations = []
[ "def", "__init__", "(", "self", ",", "fake_datastore_client", ")", ":", "self", ".", "_fake_datastore_client", "=", "fake_datastore_client", "self", ".", "_mutations", "=", "[", "]" ]
[ 157, 4 ]
[ 160, 28 ]
python
en
['en', 'la', 'en']
False
FakeDatastoreClientBatch.put
(self, entity)
Adds entity mutation to the batch.
Adds entity mutation to the batch.
def put(self, entity): """Adds entity mutation to the batch.""" assert isinstance(entity, FakeDatastoreEntity) self._mutations.append(copy.deepcopy(entity))
[ "def", "put", "(", "self", ",", "entity", ")", ":", "assert", "isinstance", "(", "entity", ",", "FakeDatastoreEntity", ")", "self", ".", "_mutations", ".", "append", "(", "copy", ".", "deepcopy", "(", "entity", ")", ")" ]
[ 170, 4 ]
[ 173, 53 ]
python
en
['en', 'en', 'en']
True
FakeDatastoreClientTransaction.__init__
(self, fake_datastore_client)
Init FakeDatastoreClientTransaction.
Init FakeDatastoreClientTransaction.
def __init__(self, fake_datastore_client): """Init FakeDatastoreClientTransaction.""" self._client = fake_datastore_client # snapshot of the data in the fake datastore self._data_snapshot = copy.deepcopy(fake_datastore_client.entities) # transaction stated: 'init', 'started', 'co...
[ "def", "__init__", "(", "self", ",", "fake_datastore_client", ")", ":", "self", ".", "_client", "=", "fake_datastore_client", "# snapshot of the data in the fake datastore", "self", ".", "_data_snapshot", "=", "copy", ".", "deepcopy", "(", "fake_datastore_client", ".", ...
[ 183, 4 ]
[ 194, 31 ]
python
en
['en', 'la', 'en']
False
FakeDatastoreClientTransaction._check_transaction_started
(self)
Helper method to check that transaction has been started.
Helper method to check that transaction has been started.
def _check_transaction_started(self): """Helper method to check that transaction has been started.""" if self._state != "started": raise ValueError( ("Invalid state of transaction, " "expected started, was %s") % self._state )
[ "def", "_check_transaction_started", "(", "self", ")", ":", "if", "self", ".", "_state", "!=", "\"started\"", ":", "raise", "ValueError", "(", "(", "\"Invalid state of transaction, \"", "\"expected started, was %s\"", ")", "%", "self", ".", "_state", ")" ]
[ 196, 4 ]
[ 202, 13 ]
python
en
['en', 'en', 'en']
True
FakeDatastoreClientTransaction._check_update_state
(self, old_state, new_state)
Checks old state and updates it to new state.
Checks old state and updates it to new state.
def _check_update_state(self, old_state, new_state): """Checks old state and updates it to new state.""" if self._state != old_state: raise ValueError( "Invalid state of transaction, expected %s, was %s" % (old_state, self._state) ) self._s...
[ "def", "_check_update_state", "(", "self", ",", "old_state", ",", "new_state", ")", ":", "if", "self", ".", "_state", "!=", "old_state", ":", "raise", "ValueError", "(", "\"Invalid state of transaction, expected %s, was %s\"", "%", "(", "old_state", ",", "self", "...
[ 204, 4 ]
[ 211, 31 ]
python
en
['en', 'en', 'en']
True
FakeDatastoreClientTransaction.begin
(self)
Begins transaction.
Begins transaction.
def begin(self): """Begins transaction.""" self._check_update_state("init", "started")
[ "def", "begin", "(", "self", ")", ":", "self", ".", "_check_update_state", "(", "\"init\"", ",", "\"started\"", ")" ]
[ 213, 4 ]
[ 215, 51 ]
python
en
['en', 'da', 'en']
False
FakeDatastoreClientTransaction.commit
(self)
Commits transaction.
Commits transaction.
def commit(self): """Commits transaction.""" self._check_transaction_started() # before committing transaction verity that all entities which # were read or updated in the transaction were not modified outside # of transaction touched_keys = self._read_keys | set([e.key f...
[ "def", "commit", "(", "self", ")", ":", "self", ".", "_check_transaction_started", "(", ")", "# before committing transaction verity that all entities which", "# were read or updated in the transaction were not modified outside", "# of transaction", "touched_keys", "=", "self", "."...
[ 217, 4 ]
[ 236, 31 ]
python
en
['en', 'en', 'en']
False
FakeDatastoreClientTransaction.rollback
(self)
Rolls back current transaction.
Rolls back current transaction.
def rollback(self): """Rolls back current transaction.""" self._check_update_state("started", "rolledback") self._mutations = []
[ "def", "rollback", "(", "self", ")", ":", "self", ".", "_check_update_state", "(", "\"started\"", ",", "\"rolledback\"", ")", "self", ".", "_mutations", "=", "[", "]" ]
[ 238, 4 ]
[ 241, 28 ]
python
en
['en', 'da', 'en']
True
FakeDatastoreClientTransaction.put
(self, entity)
Puts entity to datastore.
Puts entity to datastore.
def put(self, entity): """Puts entity to datastore.""" assert isinstance(entity, FakeDatastoreEntity) self._check_transaction_started() self._mutations.append(copy.deepcopy(entity))
[ "def", "put", "(", "self", ",", "entity", ")", ":", "assert", "isinstance", "(", "entity", ",", "FakeDatastoreEntity", ")", "self", ".", "_check_transaction_started", "(", ")", "self", ".", "_mutations", ".", "append", "(", "copy", ".", "deepcopy", "(", "e...
[ 243, 4 ]
[ 247, 53 ]
python
en
['en', 'en', 'en']
True
FakeDatastoreClientTransaction.get
(self, key)
Gets entity from the datastore.
Gets entity from the datastore.
def get(self, key): """Gets entity from the datastore.""" assert isinstance(key, FakeDatastoreKey) self._check_transaction_started() self._read_keys.add(key) return copy.deepcopy(self._data_snapshot.get(key))
[ "def", "get", "(", "self", ",", "key", ")", ":", "assert", "isinstance", "(", "key", ",", "FakeDatastoreKey", ")", "self", ".", "_check_transaction_started", "(", ")", "self", ".", "_read_keys", ".", "add", "(", "key", ")", "return", "copy", ".", "deepco...
[ 249, 4 ]
[ 254, 58 ]
python
en
['en', 'en', 'en']
True
FakeDatastoreClient.__init__
(self, entities=None)
Init FakeDatastoreClient with specified entities.
Init FakeDatastoreClient with specified entities.
def __init__(self, entities=None): """Init FakeDatastoreClient with specified entities.""" self._transaction_hook = None if isinstance(entities, list): self._entities = {e.key: e for e in entities} elif isinstance(entities, dict): self._entities = entities ...
[ "def", "__init__", "(", "self", ",", "entities", "=", "None", ")", ":", "self", ".", "_transaction_hook", "=", "None", "if", "isinstance", "(", "entities", ",", "list", ")", ":", "self", ".", "_entities", "=", "{", "e", ".", "key", ":", "e", "for", ...
[ 279, 4 ]
[ 290, 84 ]
python
en
['en', 'en', 'en']
True
FakeDatastoreClient.entities
(self)
List of stored entities.
List of stored entities.
def entities(self): """List of stored entities.""" return self._entities
[ "def", "entities", "(", "self", ")", ":", "return", "self", ".", "_entities" ]
[ 293, 4 ]
[ 295, 29 ]
python
en
['en', 'en', 'en']
True
FakeDatastoreClient.key
(self, *args, **kwargs)
Creates datastore key.
Creates datastore key.
def key(self, *args, **kwargs): """Creates datastore key.""" return FakeDatastoreKey(*args, **kwargs)
[ "def", "key", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "FakeDatastoreKey", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 297, 4 ]
[ 299, 48 ]
python
en
['fr', 'et', 'en']
False
FakeDatastoreClient.entity
(self, key)
Creates datastore entity.
Creates datastore entity.
def entity(self, key): """Creates datastore entity.""" assert isinstance(key, FakeDatastoreKey) return FakeDatastoreEntity(key)
[ "def", "entity", "(", "self", ",", "key", ")", ":", "assert", "isinstance", "(", "key", ",", "FakeDatastoreKey", ")", "return", "FakeDatastoreEntity", "(", "key", ")" ]
[ 301, 4 ]
[ 304, 39 ]
python
en
['fr', 'la', 'en']
False
FakeDatastoreClient.no_transact_batch
(self)
Starts batch of mutation which is committed without transaction.
Starts batch of mutation which is committed without transaction.
def no_transact_batch(self): """Starts batch of mutation which is committed without transaction.""" return FakeDatastoreClientBatch(self)
[ "def", "no_transact_batch", "(", "self", ")", ":", "return", "FakeDatastoreClientBatch", "(", "self", ")" ]
[ 306, 4 ]
[ 308, 45 ]
python
en
['en', 'en', 'en']
True
FakeDatastoreClient.transaction
(self)
Starts datastore transaction.
Starts datastore transaction.
def transaction(self): """Starts datastore transaction.""" result = FakeDatastoreClientTransaction(self) if self._transaction_hook: self._transaction_hook(self) self._transaction_hook = None return result
[ "def", "transaction", "(", "self", ")", ":", "result", "=", "FakeDatastoreClientTransaction", "(", "self", ")", "if", "self", ".", "_transaction_hook", ":", "self", ".", "_transaction_hook", "(", "self", ")", "self", ".", "_transaction_hook", "=", "None", "ret...
[ 310, 4 ]
[ 316, 21 ]
python
en
['fr', 'fi', 'en']
False
FakeDatastoreClient.get
(self, key, transaction=None)
Gets an entity with given key.
Gets an entity with given key.
def get(self, key, transaction=None): """Gets an entity with given key.""" assert isinstance(key, FakeDatastoreKey) if transaction: return transaction.get(key) return copy.deepcopy(self._entities.get(key))
[ "def", "get", "(", "self", ",", "key", ",", "transaction", "=", "None", ")", ":", "assert", "isinstance", "(", "key", ",", "FakeDatastoreKey", ")", "if", "transaction", ":", "return", "transaction", ".", "get", "(", "key", ")", "return", "copy", ".", "...
[ 318, 4 ]
[ 323, 53 ]
python
en
['en', 'en', 'en']
True
FakeDatastoreClient.put
(self, entity)
Updates entity in the datastore.
Updates entity in the datastore.
def put(self, entity): """Updates entity in the datastore.""" assert isinstance(entity, FakeDatastoreEntity) entity = copy.deepcopy(entity) if entity.key in self.entities: self.entities[entity.key].update(entity) else: self.entities[entity.key] = entity
[ "def", "put", "(", "self", ",", "entity", ")", ":", "assert", "isinstance", "(", "entity", ",", "FakeDatastoreEntity", ")", "entity", "=", "copy", ".", "deepcopy", "(", "entity", ")", "if", "entity", ".", "key", "in", "self", ".", "entities", ":", "sel...
[ 325, 4 ]
[ 332, 46 ]
python
en
['en', 'en', 'en']
True
FakeDatastoreClient.batch
(self)
Starts batch of mutations.
Starts batch of mutations.
def batch(self): """Starts batch of mutations.""" raise NotImplementedError("FakeDatastoreClient.batch not implemented")
[ "def", "batch", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "\"FakeDatastoreClient.batch not implemented\"", ")" ]
[ 334, 4 ]
[ 336, 78 ]
python
en
['en', 'bg', 'en']
True
FakeDatastoreClient.query_fetch
(self, **kwargs)
Queries datastore.
Queries datastore.
def query_fetch(self, **kwargs): """Queries datastore.""" kind = kwargs.get("kind", None) ancestor = kwargs.get("ancestor", None) filters = kwargs.get("filters", []) if ancestor and not isinstance(ancestor, FakeDatastoreKey): raise ValueError("Invalid ancestor type: "...
[ "def", "query_fetch", "(", "self", ",", "*", "*", "kwargs", ")", ":", "kind", "=", "kwargs", ".", "get", "(", "\"kind\"", ",", "None", ")", "ancestor", "=", "kwargs", ".", "get", "(", "\"ancestor\"", ",", "None", ")", "filters", "=", "kwargs", ".", ...
[ 338, 4 ]
[ 368, 19 ]
python
en
['fr', 'la', 'en']
False
FakeDatastoreClient.set_transaction_hook
(self, hook)
Sets transaction hook. This hook will be executed right after next transaction created. It helps to model a situation when data are modified outside of transaction. To be used in tests to test how your code handles edits concurrent with transaction. Args: hook: transa...
Sets transaction hook.
def set_transaction_hook(self, hook): """Sets transaction hook. This hook will be executed right after next transaction created. It helps to model a situation when data are modified outside of transaction. To be used in tests to test how your code handles edits concurrent with t...
[ "def", "set_transaction_hook", "(", "self", ",", "hook", ")", ":", "if", "self", ".", "_transaction_hook", "is", "not", "None", ":", "raise", "ValueError", "(", "\"Attempt to set transaction hook twice\"", ")", "self", ".", "_transaction_hook", "=", "hook" ]
[ 370, 4 ]
[ 387, 37 ]
python
en
['en', 'da', 'en']
True
FakeDatastoreClient.__str__
(self)
Returns string representation of all stored entities.
Returns string representation of all stored entities.
def __str__(self): """Returns string representation of all stored entities.""" buf = StringIO() for entity in self.entities.values(): buf.write(u"Entity {0}:\n".format(entity.key.flat_path)) buf.write(u" {0}\n".format(dict(entity))) return buf.getvalue()
[ "def", "__str__", "(", "self", ")", ":", "buf", "=", "StringIO", "(", ")", "for", "entity", "in", "self", ".", "entities", ".", "values", "(", ")", ":", "buf", ".", "write", "(", "u\"Entity {0}:\\n\"", ".", "format", "(", "entity", ".", "key", ".", ...
[ 389, 4 ]
[ 395, 29 ]
python
en
['en', 'en', 'en']
True
FileField.generate_filename
(self, instance, filename)
Apply (if callable) or prepend (if a string) upload_to to the filename, then delegate further processing of the name to the storage backend. Until the storage layer, all file paths are expected to be Unix style (with forward slashes).
Apply (if callable) or prepend (if a string) upload_to to the filename, then delegate further processing of the name to the storage backend. Until the storage layer, all file paths are expected to be Unix style (with forward slashes).
def generate_filename(self, instance, filename): """ Apply (if callable) or prepend (if a string) upload_to to the filename, then delegate further processing of the name to the storage backend. Until the storage layer, all file paths are expected to be Unix style (with forward sl...
[ "def", "generate_filename", "(", "self", ",", "instance", ",", "filename", ")", ":", "if", "callable", "(", "self", ".", "upload_to", ")", ":", "filename", "=", "self", ".", "upload_to", "(", "instance", ",", "filename", ")", "else", ":", "dirname", "=",...
[ 294, 4 ]
[ 306, 55 ]
python
en
['en', 'error', 'th']
False
ImageField.update_dimension_fields
(self, instance, force=False, *args, **kwargs)
Update field's width and height fields, if defined. This method is hooked up to model's post_init signal to update dimensions after instantiating a model instance. However, dimensions won't be updated if the dimensions fields are already populated. This avoids unnecessary rec...
Update field's width and height fields, if defined.
def update_dimension_fields(self, instance, force=False, *args, **kwargs): """ Update field's width and height fields, if defined. This method is hooked up to model's post_init signal to update dimensions after instantiating a model instance. However, dimensions won't be update...
[ "def", "update_dimension_fields", "(", "self", ",", "instance", ",", "force", "=", "False", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Nothing to update if the field doesn't have dimension fields or if", "# the field is deferred.", "has_dimension_fields", "="...
[ 404, 4 ]
[ 459, 56 ]
python
en
['en', 'error', 'th']
False
add_srs_entry
(srs, auth_name='EPSG', auth_srid=None, ref_sys_name=None, database=None)
Take a GDAL SpatialReference system and add its information to the `spatial_ref_sys` table of the spatial backend. Doing this enables database-level spatial transformations for the backend. Thus, this utility is useful for adding spatial reference systems not included by default with the backend: ...
Take a GDAL SpatialReference system and add its information to the `spatial_ref_sys` table of the spatial backend. Doing this enables database-level spatial transformations for the backend. Thus, this utility is useful for adding spatial reference systems not included by default with the backend:
def add_srs_entry(srs, auth_name='EPSG', auth_srid=None, ref_sys_name=None, database=None): """ Take a GDAL SpatialReference system and add its information to the `spatial_ref_sys` table of the spatial backend. Doing this enables database-level spatial transformations for the backend. ...
[ "def", "add_srs_entry", "(", "srs", ",", "auth_name", "=", "'EPSG'", ",", "auth_srid", "=", "None", ",", "ref_sys_name", "=", "None", ",", "database", "=", "None", ")", ":", "database", "=", "database", "or", "DEFAULT_DB_ALIAS", "connection", "=", "connectio...
[ 4, 0 ]
[ 75, 62 ]
python
en
['en', 'error', 'th']
False
check_cs_ptr
(result, func, cargs)
Error checking on routines that return Geometries.
Error checking on routines that return Geometries.
def check_cs_ptr(result, func, cargs): "Error checking on routines that return Geometries." if not result: raise GEOSException( 'Error encountered checking Coordinate Sequence returned from GEOS ' 'C function "%s".' % func.__name__ ) return result
[ "def", "check_cs_ptr", "(", "result", ",", "func", ",", "cargs", ")", ":", "if", "not", "result", ":", "raise", "GEOSException", "(", "'Error encountered checking Coordinate Sequence returned from GEOS '", "'C function \"%s\".'", "%", "func", ".", "__name__", ")", "re...
[ 7, 0 ]
[ 14, 17 ]
python
en
['en', 'el-Latn', 'en']
True
check_cs_op
(result, func, cargs)
Checks the status code of a coordinate sequence operation.
Checks the status code of a coordinate sequence operation.
def check_cs_op(result, func, cargs): "Checks the status code of a coordinate sequence operation." if result == 0: raise GEOSException('Could not set value on coordinate sequence') else: return result
[ "def", "check_cs_op", "(", "result", ",", "func", ",", "cargs", ")", ":", "if", "result", "==", "0", ":", "raise", "GEOSException", "(", "'Could not set value on coordinate sequence'", ")", "else", ":", "return", "result" ]
[ 17, 0 ]
[ 22, 21 ]
python
en
['en', 'en', 'en']
True
check_cs_get
(result, func, cargs)
Checking the coordinate sequence retrieval.
Checking the coordinate sequence retrieval.
def check_cs_get(result, func, cargs): "Checking the coordinate sequence retrieval." check_cs_op(result, func, cargs) # Object in by reference, return its value. return last_arg_byref(cargs)
[ "def", "check_cs_get", "(", "result", ",", "func", ",", "cargs", ")", ":", "check_cs_op", "(", "result", ",", "func", ",", "cargs", ")", "# Object in by reference, return its value.", "return", "last_arg_byref", "(", "cargs", ")" ]
[ 25, 0 ]
[ 29, 32 ]
python
en
['en', 'en', 'en']
True
cs_int
(func)
For coordinate sequence routines that return an integer.
For coordinate sequence routines that return an integer.
def cs_int(func): "For coordinate sequence routines that return an integer." func.argtypes = [CS_PTR, POINTER(c_uint)] func.restype = c_int func.errcheck = check_cs_get return func
[ "def", "cs_int", "(", "func", ")", ":", "func", ".", "argtypes", "=", "[", "CS_PTR", ",", "POINTER", "(", "c_uint", ")", "]", "func", ".", "restype", "=", "c_int", "func", ".", "errcheck", "=", "check_cs_get", "return", "func" ]
[ 33, 0 ]
[ 38, 15 ]
python
en
['en', 'en', 'en']
True
cs_operation
(func, ordinate=False, get=False)
For coordinate sequence operations.
For coordinate sequence operations.
def cs_operation(func, ordinate=False, get=False): "For coordinate sequence operations." if get: # Get routines get double parameter passed-in by reference. func.errcheck = check_cs_get dbl_param = POINTER(c_double) else: func.errcheck = check_cs_op dbl_param = c_doub...
[ "def", "cs_operation", "(", "func", ",", "ordinate", "=", "False", ",", "get", "=", "False", ")", ":", "if", "get", ":", "# Get routines get double parameter passed-in by reference.", "func", ".", "errcheck", "=", "check_cs_get", "dbl_param", "=", "POINTER", "(", ...
[ 41, 0 ]
[ 58, 15 ]
python
en
['en', 'en', 'en']
True
cs_output
(func, argtypes)
For routines that return a coordinate sequence.
For routines that return a coordinate sequence.
def cs_output(func, argtypes): "For routines that return a coordinate sequence." func.argtypes = argtypes func.restype = CS_PTR func.errcheck = check_cs_ptr return func
[ "def", "cs_output", "(", "func", ",", "argtypes", ")", ":", "func", ".", "argtypes", "=", "argtypes", "func", ".", "restype", "=", "CS_PTR", "func", ".", "errcheck", "=", "check_cs_ptr", "return", "func" ]
[ 61, 0 ]
[ 66, 15 ]
python
en
['en', 'en', 'en']
True
post_form_view
(request)
A view that returns a POST form (without a token)
A view that returns a POST form (without a token)
def post_form_view(request): """A view that returns a POST form (without a token)""" return post_form_response()
[ "def", "post_form_view", "(", "request", ")", ":", "return", "post_form_response", "(", ")" ]
[ 21, 0 ]
[ 23, 31 ]
python
en
['en', 'en', 'en']
True
token_view
(request)
A view that uses {% csrf_token %}
A view that uses {% csrf_token %}
def token_view(request): """A view that uses {% csrf_token %}""" context = RequestContext(request, processors=[csrf]) template = Template("{% csrf_token %}") return HttpResponse(template.render(context))
[ "def", "token_view", "(", "request", ")", ":", "context", "=", "RequestContext", "(", "request", ",", "processors", "=", "[", "csrf", "]", ")", "template", "=", "Template", "(", "\"{% csrf_token %}\"", ")", "return", "HttpResponse", "(", "template", ".", "re...
[ 28, 0 ]
[ 32, 49 ]
python
en
['en', 'en', 'en']
True
non_token_view_using_request_processor
(request)
A view that doesn't use the token, but does use the csrf view processor.
A view that doesn't use the token, but does use the csrf view processor.
def non_token_view_using_request_processor(request): """ A view that doesn't use the token, but does use the csrf view processor. """ context = RequestContext(request, processors=[csrf]) template = Template("") return HttpResponse(template.render(context))
[ "def", "non_token_view_using_request_processor", "(", "request", ")", ":", "context", "=", "RequestContext", "(", "request", ",", "processors", "=", "[", "csrf", "]", ")", "template", "=", "Template", "(", "\"\"", ")", "return", "HttpResponse", "(", "template", ...
[ 35, 0 ]
[ 41, 49 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_process_view_token_too_long
(self)
Check that if the token is longer than expected, it is ignored and a new token is created.
Check that if the token is longer than expected, it is ignored and a new token is created.
def test_process_view_token_too_long(self): """ Check that if the token is longer than expected, it is ignored and a new token is created. """ req = self._get_GET_no_csrf_cookie_request() req.COOKIES[settings.CSRF_COOKIE_NAME] = 'x' * 10000000 CsrfViewMiddleware()...
[ "def", "test_process_view_token_too_long", "(", "self", ")", ":", "req", "=", "self", ".", "_get_GET_no_csrf_cookie_request", "(", ")", "req", ".", "COOKIES", "[", "settings", ".", "CSRF_COOKIE_NAME", "]", "=", "'x'", "*", "10000000", "CsrfViewMiddleware", "(", ...
[ 85, 4 ]
[ 96, 65 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_process_response_get_token_used
(self)
When get_token is used, check that the cookie is created and headers patched.
When get_token is used, check that the cookie is created and headers patched.
def test_process_response_get_token_used(self): """ When get_token is used, check that the cookie is created and headers patched. """ req = self._get_GET_no_csrf_cookie_request() # Put tests for CSRF_COOKIE_* settings here with self.settings(CSRF_COOKIE_NAME='myn...
[ "def", "test_process_response_get_token_used", "(", "self", ")", ":", "req", "=", "self", ".", "_get_GET_no_csrf_cookie_request", "(", ")", "# Put tests for CSRF_COOKIE_* settings here", "with", "self", ".", "settings", "(", "CSRF_COOKIE_NAME", "=", "'myname'", ",", "CS...
[ 98, 4 ]
[ 121, 58 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_process_response_get_token_not_used
(self)
Check that if get_token() is not called, the view middleware does not add a cookie.
Check that if get_token() is not called, the view middleware does not add a cookie.
def test_process_response_get_token_not_used(self): """ Check that if get_token() is not called, the view middleware does not add a cookie. """ # This is important to make pages cacheable. Pages which do call # get_token(), assuming they use the token, are not cacheable ...
[ "def", "test_process_response_get_token_not_used", "(", "self", ")", ":", "# This is important to make pages cacheable. Pages which do call", "# get_token(), assuming they use the token, are not cacheable because", "# the token is specific to the user", "req", "=", "self", ".", "_get_GET_...
[ 123, 4 ]
[ 141, 44 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_process_request_no_csrf_cookie
(self)
Check that if no CSRF cookies is present, the middleware rejects the incoming request. This will stop login CSRF.
Check that if no CSRF cookies is present, the middleware rejects the incoming request. This will stop login CSRF.
def test_process_request_no_csrf_cookie(self): """ Check that if no CSRF cookies is present, the middleware rejects the incoming request. This will stop login CSRF. """ req = self._get_POST_no_csrf_cookie_request() req2 = CsrfViewMiddleware().process_view(req, post_form_...
[ "def", "test_process_request_no_csrf_cookie", "(", "self", ")", ":", "req", "=", "self", ".", "_get_POST_no_csrf_cookie_request", "(", ")", "req2", "=", "CsrfViewMiddleware", "(", ")", ".", "process_view", "(", "req", ",", "post_form_view", ",", "(", ")", ",", ...
[ 144, 4 ]
[ 151, 47 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_process_request_csrf_cookie_no_token
(self)
Check that if a CSRF cookie is present but no token, the middleware rejects the incoming request.
Check that if a CSRF cookie is present but no token, the middleware rejects the incoming request.
def test_process_request_csrf_cookie_no_token(self): """ Check that if a CSRF cookie is present but no token, the middleware rejects the incoming request. """ req = self._get_POST_csrf_cookie_request() req2 = CsrfViewMiddleware().process_view(req, post_form_view, (), {}) ...
[ "def", "test_process_request_csrf_cookie_no_token", "(", "self", ")", ":", "req", "=", "self", ".", "_get_POST_csrf_cookie_request", "(", ")", "req2", "=", "CsrfViewMiddleware", "(", ")", ".", "process_view", "(", "req", ",", "post_form_view", ",", "(", ")", ","...
[ 153, 4 ]
[ 160, 47 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_process_request_csrf_cookie_and_token
(self)
Check that if both a cookie and a token is present, the middleware lets it through.
Check that if both a cookie and a token is present, the middleware lets it through.
def test_process_request_csrf_cookie_and_token(self): """ Check that if both a cookie and a token is present, the middleware lets it through. """ req = self._get_POST_request_with_token() req2 = CsrfViewMiddleware().process_view(req, post_form_view, (), {}) self.assertEqu...
[ "def", "test_process_request_csrf_cookie_and_token", "(", "self", ")", ":", "req", "=", "self", ".", "_get_POST_request_with_token", "(", ")", "req2", "=", "CsrfViewMiddleware", "(", ")", ".", "process_view", "(", "req", ",", "post_form_view", ",", "(", ")", ","...
[ 162, 4 ]
[ 168, 36 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_process_request_csrf_cookie_no_token_exempt_view
(self)
Check that if a CSRF cookie is present and no token, but the csrf_exempt decorator has been applied to the view, the middleware lets it through
Check that if a CSRF cookie is present and no token, but the csrf_exempt decorator has been applied to the view, the middleware lets it through
def test_process_request_csrf_cookie_no_token_exempt_view(self): """ Check that if a CSRF cookie is present and no token, but the csrf_exempt decorator has been applied to the view, the middleware lets it through """ req = self._get_POST_csrf_cookie_request() req2 = CsrfV...
[ "def", "test_process_request_csrf_cookie_no_token_exempt_view", "(", "self", ")", ":", "req", "=", "self", ".", "_get_POST_csrf_cookie_request", "(", ")", "req2", "=", "CsrfViewMiddleware", "(", ")", ".", "process_view", "(", "req", ",", "csrf_exempt", "(", "post_fo...
[ 170, 4 ]
[ 177, 36 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_csrf_token_in_header
(self)
Check that we can pass in the token in a header instead of in the form
Check that we can pass in the token in a header instead of in the form
def test_csrf_token_in_header(self): """ Check that we can pass in the token in a header instead of in the form """ req = self._get_POST_csrf_cookie_request() req.META['HTTP_X_CSRFTOKEN'] = self._csrf_id req2 = CsrfViewMiddleware().process_view(req, post_form_view, (), {}...
[ "def", "test_csrf_token_in_header", "(", "self", ")", ":", "req", "=", "self", ".", "_get_POST_csrf_cookie_request", "(", ")", "req", ".", "META", "[", "'HTTP_X_CSRFTOKEN'", "]", "=", "self", ".", "_csrf_id", "req2", "=", "CsrfViewMiddleware", "(", ")", ".", ...
[ 179, 4 ]
[ 186, 36 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_put_and_delete_rejected
(self)
Tests that HTTP PUT and DELETE methods have protection
Tests that HTTP PUT and DELETE methods have protection
def test_put_and_delete_rejected(self): """ Tests that HTTP PUT and DELETE methods have protection """ req = TestingHttpRequest() req.method = 'PUT' req2 = CsrfViewMiddleware().process_view(req, post_form_view, (), {}) self.assertEqual(403, req2.status_code) ...
[ "def", "test_put_and_delete_rejected", "(", "self", ")", ":", "req", "=", "TestingHttpRequest", "(", ")", "req", ".", "method", "=", "'PUT'", "req2", "=", "CsrfViewMiddleware", "(", ")", ".", "process_view", "(", "req", ",", "post_form_view", ",", "(", ")", ...
[ 188, 4 ]
[ 200, 47 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_put_and_delete_allowed
(self)
Tests that HTTP PUT and DELETE methods can get through with X-CSRFToken and a cookie
Tests that HTTP PUT and DELETE methods can get through with X-CSRFToken and a cookie
def test_put_and_delete_allowed(self): """ Tests that HTTP PUT and DELETE methods can get through with X-CSRFToken and a cookie """ req = self._get_GET_csrf_cookie_request() req.method = 'PUT' req.META['HTTP_X_CSRFTOKEN'] = self._csrf_id req2 = CsrfViewMid...
[ "def", "test_put_and_delete_allowed", "(", "self", ")", ":", "req", "=", "self", ".", "_get_GET_csrf_cookie_request", "(", ")", "req", ".", "method", "=", "'PUT'", "req", ".", "META", "[", "'HTTP_X_CSRFTOKEN'", "]", "=", "self", ".", "_csrf_id", "req2", "=",...
[ 202, 4 ]
[ 217, 36 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_token_node_no_csrf_cookie
(self)
Check that CsrfTokenNode works when no CSRF cookie is set
Check that CsrfTokenNode works when no CSRF cookie is set
def test_token_node_no_csrf_cookie(self): """ Check that CsrfTokenNode works when no CSRF cookie is set """ req = self._get_GET_no_csrf_cookie_request() resp = token_view(req) self.assertEqual(resp.content, b'')
[ "def", "test_token_node_no_csrf_cookie", "(", "self", ")", ":", "req", "=", "self", ".", "_get_GET_no_csrf_cookie_request", "(", ")", "resp", "=", "token_view", "(", "req", ")", "self", ".", "assertEqual", "(", "resp", ".", "content", ",", "b''", ")" ]
[ 220, 4 ]
[ 226, 43 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_token_node_empty_csrf_cookie
(self)
Check that we get a new token if the csrf_cookie is the empty string
Check that we get a new token if the csrf_cookie is the empty string
def test_token_node_empty_csrf_cookie(self): """ Check that we get a new token if the csrf_cookie is the empty string """ req = self._get_GET_no_csrf_cookie_request() req.COOKIES[settings.CSRF_COOKIE_NAME] = b"" CsrfViewMiddleware().process_view(req, token_view, (), {}) ...
[ "def", "test_token_node_empty_csrf_cookie", "(", "self", ")", ":", "req", "=", "self", ".", "_get_GET_no_csrf_cookie_request", "(", ")", "req", ".", "COOKIES", "[", "settings", ".", "CSRF_COOKIE_NAME", "]", "=", "b\"\"", "CsrfViewMiddleware", "(", ")", ".", "pro...
[ 228, 4 ]
[ 237, 45 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_token_node_with_csrf_cookie
(self)
Check that CsrfTokenNode works when a CSRF cookie is set
Check that CsrfTokenNode works when a CSRF cookie is set
def test_token_node_with_csrf_cookie(self): """ Check that CsrfTokenNode works when a CSRF cookie is set """ req = self._get_GET_csrf_cookie_request() CsrfViewMiddleware().process_view(req, token_view, (), {}) resp = token_view(req) self._check_token_present(resp)
[ "def", "test_token_node_with_csrf_cookie", "(", "self", ")", ":", "req", "=", "self", ".", "_get_GET_csrf_cookie_request", "(", ")", "CsrfViewMiddleware", "(", ")", ".", "process_view", "(", "req", ",", "token_view", ",", "(", ")", ",", "{", "}", ")", "resp"...
[ 239, 4 ]
[ 246, 39 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_get_token_for_exempt_view
(self)
Check that get_token still works for a view decorated with 'csrf_exempt'.
Check that get_token still works for a view decorated with 'csrf_exempt'.
def test_get_token_for_exempt_view(self): """ Check that get_token still works for a view decorated with 'csrf_exempt'. """ req = self._get_GET_csrf_cookie_request() CsrfViewMiddleware().process_view(req, csrf_exempt(token_view), (), {}) resp = token_view(req) sel...
[ "def", "test_get_token_for_exempt_view", "(", "self", ")", ":", "req", "=", "self", ".", "_get_GET_csrf_cookie_request", "(", ")", "CsrfViewMiddleware", "(", ")", ".", "process_view", "(", "req", ",", "csrf_exempt", "(", "token_view", ")", ",", "(", ")", ",", ...
[ 248, 4 ]
[ 255, 39 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_get_token_for_requires_csrf_token_view
(self)
Check that get_token works for a view decorated solely with requires_csrf_token
Check that get_token works for a view decorated solely with requires_csrf_token
def test_get_token_for_requires_csrf_token_view(self): """ Check that get_token works for a view decorated solely with requires_csrf_token """ req = self._get_GET_csrf_cookie_request() resp = requires_csrf_token(token_view)(req) self._check_token_present(resp)
[ "def", "test_get_token_for_requires_csrf_token_view", "(", "self", ")", ":", "req", "=", "self", ".", "_get_GET_csrf_cookie_request", "(", ")", "resp", "=", "requires_csrf_token", "(", "token_view", ")", "(", "req", ")", "self", ".", "_check_token_present", "(", "...
[ 257, 4 ]
[ 263, 39 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_token_node_with_new_csrf_cookie
(self)
Check that CsrfTokenNode works when a CSRF cookie is created by the middleware (when one was not already present)
Check that CsrfTokenNode works when a CSRF cookie is created by the middleware (when one was not already present)
def test_token_node_with_new_csrf_cookie(self): """ Check that CsrfTokenNode works when a CSRF cookie is created by the middleware (when one was not already present) """ req = self._get_GET_no_csrf_cookie_request() CsrfViewMiddleware().process_view(req, token_view, (), {}...
[ "def", "test_token_node_with_new_csrf_cookie", "(", "self", ")", ":", "req", "=", "self", ".", "_get_GET_no_csrf_cookie_request", "(", ")", "CsrfViewMiddleware", "(", ")", ".", "process_view", "(", "req", ",", "token_view", ",", "(", ")", ",", "{", "}", ")", ...
[ 265, 4 ]
[ 275, 66 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_https_bad_referer
(self)
Test that a POST HTTPS request with a bad referer is rejected
Test that a POST HTTPS request with a bad referer is rejected
def test_https_bad_referer(self): """ Test that a POST HTTPS request with a bad referer is rejected """ req = self._get_POST_request_with_token() req._is_secure_override = True req.META['HTTP_HOST'] = 'www.example.com' req.META['HTTP_REFERER'] = 'https://www.evil....
[ "def", "test_https_bad_referer", "(", "self", ")", ":", "req", "=", "self", ".", "_get_POST_request_with_token", "(", ")", "req", ".", "_is_secure_override", "=", "True", "req", ".", "META", "[", "'HTTP_HOST'", "]", "=", "'www.example.com'", "req", ".", "META"...
[ 278, 4 ]
[ 288, 47 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_https_malformed_referer
(self)
Test that a POST HTTPS request with a bad referer is rejected
Test that a POST HTTPS request with a bad referer is rejected
def test_https_malformed_referer(self): """ Test that a POST HTTPS request with a bad referer is rejected """ req = self._get_POST_request_with_token() req._is_secure_override = True req.META['HTTP_HOST'] = 'www.example.com' req.META['HTTP_REFERER'] = 'http://http...
[ "def", "test_https_malformed_referer", "(", "self", ")", ":", "req", "=", "self", ".", "_get_POST_request_with_token", "(", ")", "req", ".", "_is_secure_override", "=", "True", "req", ".", "META", "[", "'HTTP_HOST'", "]", "=", "'www.example.com'", "req", ".", ...
[ 291, 4 ]
[ 301, 47 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_https_good_referer
(self)
Test that a POST HTTPS request with a good referer is accepted
Test that a POST HTTPS request with a good referer is accepted
def test_https_good_referer(self): """ Test that a POST HTTPS request with a good referer is accepted """ req = self._get_POST_request_with_token() req._is_secure_override = True req.META['HTTP_HOST'] = 'www.example.com' req.META['HTTP_REFERER'] = 'https://www.exa...
[ "def", "test_https_good_referer", "(", "self", ")", ":", "req", "=", "self", ".", "_get_POST_request_with_token", "(", ")", "req", ".", "_is_secure_override", "=", "True", "req", ".", "META", "[", "'HTTP_HOST'", "]", "=", "'www.example.com'", "req", ".", "META...
[ 304, 4 ]
[ 313, 36 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_https_good_referer_2
(self)
Test that a POST HTTPS request with a good referer is accepted where the referer contains no trailing slash
Test that a POST HTTPS request with a good referer is accepted where the referer contains no trailing slash
def test_https_good_referer_2(self): """ Test that a POST HTTPS request with a good referer is accepted where the referer contains no trailing slash """ # See ticket #15617 req = self._get_POST_request_with_token() req._is_secure_override = True req.META['...
[ "def", "test_https_good_referer_2", "(", "self", ")", ":", "# See ticket #15617", "req", "=", "self", ".", "_get_POST_request_with_token", "(", ")", "req", ".", "_is_secure_override", "=", "True", "req", ".", "META", "[", "'HTTP_HOST'", "]", "=", "'www.example.com...
[ 316, 4 ]
[ 327, 36 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_ensures_csrf_cookie_no_middleware
(self)
Tests that ensures_csrf_cookie decorator fulfils its promise with no middleware
Tests that ensures_csrf_cookie decorator fulfils its promise with no middleware
def test_ensures_csrf_cookie_no_middleware(self): """ Tests that ensures_csrf_cookie decorator fulfils its promise with no middleware """ @ensure_csrf_cookie def view(request): # Doesn't insert a token or anything return HttpResponse(content="") ...
[ "def", "test_ensures_csrf_cookie_no_middleware", "(", "self", ")", ":", "@", "ensure_csrf_cookie", "def", "view", "(", "request", ")", ":", "# Doesn't insert a token or anything", "return", "HttpResponse", "(", "content", "=", "\"\"", ")", "req", "=", "self", ".", ...
[ 329, 4 ]
[ 342, 57 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_ensures_csrf_cookie_with_middleware
(self)
Tests that ensures_csrf_cookie decorator fulfils its promise with the middleware enabled.
Tests that ensures_csrf_cookie decorator fulfils its promise with the middleware enabled.
def test_ensures_csrf_cookie_with_middleware(self): """ Tests that ensures_csrf_cookie decorator fulfils its promise with the middleware enabled. """ @ensure_csrf_cookie def view(request): # Doesn't insert a token or anything return HttpResponse(co...
[ "def", "test_ensures_csrf_cookie_with_middleware", "(", "self", ")", ":", "@", "ensure_csrf_cookie", "def", "view", "(", "request", ")", ":", "# Doesn't insert a token or anything", "return", "HttpResponse", "(", "content", "=", "\"\"", ")", "req", "=", "self", ".",...
[ 344, 4 ]
[ 359, 58 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_ensures_csrf_cookie_no_logging
(self)
Tests that ensure_csrf_cookie doesn't log warnings. See #19436.
Tests that ensure_csrf_cookie doesn't log warnings. See #19436.
def test_ensures_csrf_cookie_no_logging(self): """ Tests that ensure_csrf_cookie doesn't log warnings. See #19436. """ @ensure_csrf_cookie def view(request): # Doesn't insert a token or anything return HttpResponse(content="") class TestHandler(lo...
[ "def", "test_ensures_csrf_cookie_no_logging", "(", "self", ")", ":", "@", "ensure_csrf_cookie", "def", "view", "(", "request", ")", ":", "# Doesn't insert a token or anything", "return", "HttpResponse", "(", "content", "=", "\"\"", ")", "class", "TestHandler", "(", ...
[ 361, 4 ]
[ 385, 42 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_csrf_cookie_age
(self)
Test to verify CSRF cookie age can be set using settings.CSRF_COOKIE_AGE.
Test to verify CSRF cookie age can be set using settings.CSRF_COOKIE_AGE.
def test_csrf_cookie_age(self): """ Test to verify CSRF cookie age can be set using settings.CSRF_COOKIE_AGE. """ req = self._get_GET_no_csrf_cookie_request() MAX_AGE = 123 with self.settings(CSRF_COOKIE_NAME='csrfcookie', CSRF_COOKIE_D...
[ "def", "test_csrf_cookie_age", "(", "self", ")", ":", "req", "=", "self", ".", "_get_GET_no_csrf_cookie_request", "(", ")", "MAX_AGE", "=", "123", "with", "self", ".", "settings", "(", "CSRF_COOKIE_NAME", "=", "'csrfcookie'", ",", "CSRF_COOKIE_DOMAIN", "=", "'.e...
[ 387, 4 ]
[ 407, 46 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_csrf_cookie_age_none
(self)
Test to verify CSRF cookie age does not have max age set and therefore uses session-based cookies.
Test to verify CSRF cookie age does not have max age set and therefore uses session-based cookies.
def test_csrf_cookie_age_none(self): """ Test to verify CSRF cookie age does not have max age set and therefore uses session-based cookies. """ req = self._get_GET_no_csrf_cookie_request() MAX_AGE = None with self.settings(CSRF_COOKIE_NAME='csrfcookie', ...
[ "def", "test_csrf_cookie_age_none", "(", "self", ")", ":", "req", "=", "self", ".", "_get_GET_no_csrf_cookie_request", "(", ")", "MAX_AGE", "=", "None", "with", "self", ".", "settings", "(", "CSRF_COOKIE_NAME", "=", "'csrfcookie'", ",", "CSRF_COOKIE_DOMAIN", "=", ...
[ 409, 4 ]
[ 429, 41 ]
python
en
['en', 'error', 'th']
False
CsrfViewMiddlewareTest.test_post_data_read_failure
(self)
#20128 -- IOErrors during POST data reading should be caught and treated as if the POST data wasn't there.
#20128 -- IOErrors during POST data reading should be caught and treated as if the POST data wasn't there.
def test_post_data_read_failure(self): """ #20128 -- IOErrors during POST data reading should be caught and treated as if the POST data wasn't there. """ class CsrfPostRequest(HttpRequest): """ HttpRequest that can raise an IOError when accessing POST data...
[ "def", "test_post_data_read_failure", "(", "self", ")", ":", "class", "CsrfPostRequest", "(", "HttpRequest", ")", ":", "\"\"\"\n HttpRequest that can raise an IOError when accessing POST data\n \"\"\"", "def", "__init__", "(", "self", ",", "token", ",", ...
[ 431, 4 ]
[ 470, 47 ]
python
en
['en', 'error', 'th']
False
generate_metadata
(build_env, backend)
Generate metadata using mechanisms described in PEP 517. Returns the generated metadata directory.
Generate metadata using mechanisms described in PEP 517.
def generate_metadata(build_env, backend): # type: (BuildEnvironment, Pep517HookCaller) -> str """Generate metadata using mechanisms described in PEP 517. Returns the generated metadata directory. """ metadata_tmpdir = TempDirectory( kind="modern-metadata", globally_managed=True ) ...
[ "def", "generate_metadata", "(", "build_env", ",", "backend", ")", ":", "# type: (BuildEnvironment, Pep517HookCaller) -> str", "metadata_tmpdir", "=", "TempDirectory", "(", "kind", "=", "\"modern-metadata\"", ",", "globally_managed", "=", "True", ")", "metadata_dir", "=",...
[ 17, 0 ]
[ 39, 51 ]
python
en
['en', 'nl', 'en']
True
Index.clone
(self)
Create a copy of this Index.
Create a copy of this Index.
def clone(self): """Create a copy of this Index.""" _, _, kwargs = self.deconstruct() return self.__class__(**kwargs)
[ "def", "clone", "(", "self", ")", ":", "_", ",", "_", ",", "kwargs", "=", "self", ".", "deconstruct", "(", ")", "return", "self", ".", "__class__", "(", "*", "*", "kwargs", ")" ]
[ 73, 4 ]
[ 76, 39 ]
python
en
['en', 'en', 'en']
True
Index.set_name_with_model
(self, model)
Generate a unique name for the index. The name is divided into 3 parts - table name (12 chars), field name (8 chars) and unique hash + suffix (10 chars). Each part is made to fit its size by truncating the excess length.
Generate a unique name for the index.
def set_name_with_model(self, model): """ Generate a unique name for the index. The name is divided into 3 parts - table name (12 chars), field name (8 chars) and unique hash + suffix (10 chars). Each part is made to fit its size by truncating the excess length. """ ...
[ "def", "set_name_with_model", "(", "self", ",", "model", ")", ":", "_", ",", "table_name", "=", "split_identifier", "(", "model", ".", "_meta", ".", "db_table", ")", "column_names", "=", "[", "model", ".", "_meta", ".", "get_field", "(", "field_name", ")",...
[ 78, 4 ]
[ 105, 45 ]
python
en
['en', 'error', 'th']
False
prepare_activation_url
( email: str, request: HttpRequest, realm_creation: bool = False, streams: Optional[List[Stream]] = None, invited_as: Optional[int] = None, )
Send an email with a confirmation link to the provided e-mail so the user can complete their registration.
Send an email with a confirmation link to the provided e-mail so the user can complete their registration.
def prepare_activation_url( email: str, request: HttpRequest, realm_creation: bool = False, streams: Optional[List[Stream]] = None, invited_as: Optional[int] = None, ) -> str: """ Send an email with a confirmation link to the provided e-mail so the user can complete their registration. ...
[ "def", "prepare_activation_url", "(", "email", ":", "str", ",", "request", ":", "HttpRequest", ",", "realm_creation", ":", "bool", "=", "False", ",", "streams", ":", "Optional", "[", "List", "[", "Stream", "]", "]", "=", "None", ",", "invited_as", ":", "...
[ 491, 0 ]
[ 518, 25 ]
python
en
['en', 'error', 'th']
False
BaseAggregateTestCase.test_dates_with_aggregation
(self)
Test that .dates() returns a distinct set of dates when applied to a QuerySet with aggregation. Refs #18056. Previously, .dates() would return distinct (date_kind, aggregation) sets, in this case (year, num_authors), so 2008 would be returned twice because there are books from ...
Test that .dates() returns a distinct set of dates when applied to a QuerySet with aggregation.
def test_dates_with_aggregation(self): """ Test that .dates() returns a distinct set of dates when applied to a QuerySet with aggregation. Refs #18056. Previously, .dates() would return distinct (date_kind, aggregation) sets, in this case (year, num_authors), so 2008 would be ...
[ "def", "test_dates_with_aggregation", "(", "self", ")", ":", "dates", "=", "Book", ".", "objects", ".", "annotate", "(", "num_authors", "=", "Count", "(", "\"authors\"", ")", ")", ".", "dates", "(", "'pubdate'", ",", "'year'", ")", "self", ".", "assertQuer...
[ 597, 4 ]
[ 615, 9 ]
python
en
['en', 'error', 'th']
False
BaseAggregateTestCase.test_ticket17424
(self)
Check that doing exclude() on a foreign model after annotate() doesn't crash.
Check that doing exclude() on a foreign model after annotate() doesn't crash.
def test_ticket17424(self): """ Check that doing exclude() on a foreign model after annotate() doesn't crash. """ all_books = list(Book.objects.values_list('pk', flat=True).order_by('pk')) annotated_books = Book.objects.order_by('pk').annotate(one=Count("id")) # ...
[ "def", "test_ticket17424", "(", "self", ")", ":", "all_books", "=", "list", "(", "Book", ".", "objects", ".", "values_list", "(", "'pk'", ",", "flat", "=", "True", ")", ".", "order_by", "(", "'pk'", ")", ")", "annotated_books", "=", "Book", ".", "objec...
[ 628, 4 ]
[ 647, 87 ]
python
en
['en', 'error', 'th']
False
BaseAggregateTestCase.test_ticket12886
(self)
Check that aggregation over sliced queryset works correctly.
Check that aggregation over sliced queryset works correctly.
def test_ticket12886(self): """ Check that aggregation over sliced queryset works correctly. """ qs = Book.objects.all().order_by('-rating')[0:3] vals = qs.aggregate(average_top3_rating=Avg('rating'))['average_top3_rating'] self.assertAlmostEqual(vals, 4.5, places=2)
[ "def", "test_ticket12886", "(", "self", ")", ":", "qs", "=", "Book", ".", "objects", ".", "all", "(", ")", ".", "order_by", "(", "'-rating'", ")", "[", "0", ":", "3", "]", "vals", "=", "qs", ".", "aggregate", "(", "average_top3_rating", "=", "Avg", ...
[ 649, 4 ]
[ 655, 51 ]
python
en
['en', 'error', 'th']
False
BaseAggregateTestCase.test_ticket11881
(self)
Check that subqueries do not needlessly contain ORDER BY, SELECT FOR UPDATE or select_related() stuff.
Check that subqueries do not needlessly contain ORDER BY, SELECT FOR UPDATE or select_related() stuff.
def test_ticket11881(self): """ Check that subqueries do not needlessly contain ORDER BY, SELECT FOR UPDATE or select_related() stuff. """ qs = Book.objects.all().select_for_update().order_by( 'pk').select_related('publisher').annotate(max_pk=Max('pk')) with C...
[ "def", "test_ticket11881", "(", "self", ")", ":", "qs", "=", "Book", ".", "objects", ".", "all", "(", ")", ".", "select_for_update", "(", ")", ".", "order_by", "(", "'pk'", ")", ".", "select_related", "(", "'publisher'", ")", ".", "annotate", "(", "max...
[ 657, 4 ]
[ 679, 53 ]
python
en
['en', 'error', 'th']
False
ViewTest.test_no_init_kwargs
(self)
Test that a view can't be accidentally instantiated before deployment
Test that a view can't be accidentally instantiated before deployment
def test_no_init_kwargs(self): """ Test that a view can't be accidentally instantiated before deployment """ try: SimpleView(key='value').as_view() self.fail('Should not be able to instantiate a view') except AttributeError: pass
[ "def", "test_no_init_kwargs", "(", "self", ")", ":", "try", ":", "SimpleView", "(", "key", "=", "'value'", ")", ".", "as_view", "(", ")", "self", ".", "fail", "(", "'Should not be able to instantiate a view'", ")", "except", "AttributeError", ":", "pass" ]
[ 74, 4 ]
[ 82, 16 ]
python
en
['en', 'error', 'th']
False
ViewTest.test_no_init_args
(self)
Test that a view can't be accidentally instantiated before deployment
Test that a view can't be accidentally instantiated before deployment
def test_no_init_args(self): """ Test that a view can't be accidentally instantiated before deployment """ try: SimpleView.as_view('value') self.fail('Should not be able to use non-keyword arguments instantiating a view') except TypeError: pass
[ "def", "test_no_init_args", "(", "self", ")", ":", "try", ":", "SimpleView", ".", "as_view", "(", "'value'", ")", "self", ".", "fail", "(", "'Should not be able to use non-keyword arguments instantiating a view'", ")", "except", "TypeError", ":", "pass" ]
[ 84, 4 ]
[ 92, 16 ]
python
en
['en', 'error', 'th']
False
ViewTest.test_pathological_http_method
(self)
The edge case of a http request that spoofs an existing method name is caught.
The edge case of a http request that spoofs an existing method name is caught.
def test_pathological_http_method(self): """ The edge case of a http request that spoofs an existing method name is caught. """ self.assertEqual(SimpleView.as_view()( self.rf.get('/', REQUEST_METHOD='DISPATCH') ).status_code, 405)
[ "def", "test_pathological_http_method", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "SimpleView", ".", "as_view", "(", ")", "(", "self", ".", "rf", ".", "get", "(", "'/'", ",", "REQUEST_METHOD", "=", "'DISPATCH'", ")", ")", ".", "status_code", ...
[ 94, 4 ]
[ 100, 27 ]
python
en
['en', 'error', 'th']
False
ViewTest.test_get_only
(self)
Test a view which only allows GET doesn't allow other methods.
Test a view which only allows GET doesn't allow other methods.
def test_get_only(self): """ Test a view which only allows GET doesn't allow other methods. """ self._assert_simple(SimpleView.as_view()(self.rf.get('/'))) self.assertEqual(SimpleView.as_view()(self.rf.post('/')).status_code, 405) self.assertEqual(SimpleView.as_view()( ...
[ "def", "test_get_only", "(", "self", ")", ":", "self", ".", "_assert_simple", "(", "SimpleView", ".", "as_view", "(", ")", "(", "self", ".", "rf", ".", "get", "(", "'/'", ")", ")", ")", "self", ".", "assertEqual", "(", "SimpleView", ".", "as_view", "...
[ 102, 4 ]
[ 110, 27 ]
python
en
['en', 'error', 'th']
False
ViewTest.test_get_and_head
(self)
Test a view which supplies a GET method also responds correctly to HEAD.
Test a view which supplies a GET method also responds correctly to HEAD.
def test_get_and_head(self): """ Test a view which supplies a GET method also responds correctly to HEAD. """ self._assert_simple(SimpleView.as_view()(self.rf.get('/'))) response = SimpleView.as_view()(self.rf.head('/')) self.assertEqual(response.status_code, 200)
[ "def", "test_get_and_head", "(", "self", ")", ":", "self", ".", "_assert_simple", "(", "SimpleView", ".", "as_view", "(", ")", "(", "self", ".", "rf", ".", "get", "(", "'/'", ")", ")", ")", "response", "=", "SimpleView", ".", "as_view", "(", ")", "("...
[ 112, 4 ]
[ 118, 51 ]
python
en
['en', 'error', 'th']
False
ViewTest.test_head_no_get
(self)
Test a view which supplies no GET method responds to HEAD with HTTP 405.
Test a view which supplies no GET method responds to HEAD with HTTP 405.
def test_head_no_get(self): """ Test a view which supplies no GET method responds to HEAD with HTTP 405. """ response = PostOnlyView.as_view()(self.rf.head('/')) self.assertEqual(response.status_code, 405)
[ "def", "test_head_no_get", "(", "self", ")", ":", "response", "=", "PostOnlyView", ".", "as_view", "(", ")", "(", "self", ".", "rf", ".", "head", "(", "'/'", ")", ")", "self", ".", "assertEqual", "(", "response", ".", "status_code", ",", "405", ")" ]
[ 120, 4 ]
[ 125, 51 ]
python
en
['en', 'error', 'th']
False