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
BaseReport.start
(self)
Start the timer.
Start the timer.
def start(self): """Start the timer.""" self._start_time = time.time()
[ "def", "start", "(", "self", ")", ":", "self", ".", "_start_time", "=", "time", ".", "time", "(", ")" ]
[ 2229, 4 ]
[ 2231, 38 ]
python
en
['en', 'no', 'en']
True
BaseReport.stop
(self)
Stop the timer.
Stop the timer.
def stop(self): """Stop the timer.""" self.elapsed = time.time() - self._start_time
[ "def", "stop", "(", "self", ")", ":", "self", ".", "elapsed", "=", "time", ".", "time", "(", ")", "-", "self", ".", "_start_time" ]
[ 2233, 4 ]
[ 2235, 53 ]
python
en
['en', 'en', 'en']
True
BaseReport.init_file
(self, filename, lines, expected, line_offset)
Signal a new file.
Signal a new file.
def init_file(self, filename, lines, expected, line_offset): """Signal a new file.""" self.filename = filename self.lines = lines self.expected = expected or () self.line_offset = line_offset self.file_errors = 0 self.counters['files'] += 1 self.counters['...
[ "def", "init_file", "(", "self", ",", "filename", ",", "lines", ",", "expected", ",", "line_offset", ")", ":", "self", ".", "filename", "=", "filename", "self", ".", "lines", "=", "lines", "self", ".", "expected", "=", "expected", "or", "(", ")", "self...
[ 2237, 4 ]
[ 2245, 53 ]
python
en
['en', 'en', 'en']
True
BaseReport.increment_logical_line
(self)
Signal a new logical line.
Signal a new logical line.
def increment_logical_line(self): """Signal a new logical line.""" self.counters['logical lines'] += 1
[ "def", "increment_logical_line", "(", "self", ")", ":", "self", ".", "counters", "[", "'logical lines'", "]", "+=", "1" ]
[ 2247, 4 ]
[ 2249, 43 ]
python
en
['en', 'en', 'en']
True
BaseReport.error
(self, line_number, offset, text, check)
Report an error, according to options.
Report an error, according to options.
def error(self, line_number, offset, text, check): """Report an error, according to options.""" code = text[:4] if self._ignore_code(code): return if code in self.counters: self.counters[code] += 1 else: self.counters[code] = 1 self...
[ "def", "error", "(", "self", ",", "line_number", ",", "offset", ",", "text", ",", "check", ")", ":", "code", "=", "text", "[", ":", "4", "]", "if", "self", ".", "_ignore_code", "(", "code", ")", ":", "return", "if", "code", "in", "self", ".", "co...
[ 2251, 4 ]
[ 2268, 19 ]
python
en
['en', 'en', 'en']
True
BaseReport.get_file_results
(self)
Return the count of errors and warnings for this file.
Return the count of errors and warnings for this file.
def get_file_results(self): """Return the count of errors and warnings for this file.""" return self.file_errors
[ "def", "get_file_results", "(", "self", ")", ":", "return", "self", ".", "file_errors" ]
[ 2270, 4 ]
[ 2272, 31 ]
python
en
['en', 'en', 'en']
True
BaseReport.get_count
(self, prefix='')
Return the total count of errors and warnings.
Return the total count of errors and warnings.
def get_count(self, prefix=''): """Return the total count of errors and warnings.""" return sum(self.counters[key] for key in self.messages if key.startswith(prefix))
[ "def", "get_count", "(", "self", ",", "prefix", "=", "''", ")", ":", "return", "sum", "(", "self", ".", "counters", "[", "key", "]", "for", "key", "in", "self", ".", "messages", "if", "key", ".", "startswith", "(", "prefix", ")", ")" ]
[ 2274, 4 ]
[ 2277, 70 ]
python
en
['en', 'en', 'en']
True
BaseReport.get_statistics
(self, prefix='')
Get statistics for message codes that start with the prefix. prefix='' matches all errors and warnings prefix='E' matches all errors prefix='W' matches all warnings prefix='E4' matches all errors that have to do with imports
Get statistics for message codes that start with the prefix.
def get_statistics(self, prefix=''): """Get statistics for message codes that start with the prefix. prefix='' matches all errors and warnings prefix='E' matches all errors prefix='W' matches all warnings prefix='E4' matches all errors that have to do with imports """ ...
[ "def", "get_statistics", "(", "self", ",", "prefix", "=", "''", ")", ":", "return", "[", "'%-7s %s %s'", "%", "(", "self", ".", "counters", "[", "key", "]", ",", "key", ",", "self", ".", "messages", "[", "key", "]", ")", "for", "key", "in", "sorted...
[ 2279, 4 ]
[ 2288, 75 ]
python
en
['en', 'en', 'en']
True
BaseReport.print_statistics
(self, prefix='')
Print overall statistics (number of errors and warnings).
Print overall statistics (number of errors and warnings).
def print_statistics(self, prefix=''): """Print overall statistics (number of errors and warnings).""" for line in self.get_statistics(prefix): print(line)
[ "def", "print_statistics", "(", "self", ",", "prefix", "=", "''", ")", ":", "for", "line", "in", "self", ".", "get_statistics", "(", "prefix", ")", ":", "print", "(", "line", ")" ]
[ 2290, 4 ]
[ 2293, 23 ]
python
en
['en', 'en', 'en']
True
BaseReport.print_benchmark
(self)
Print benchmark numbers.
Print benchmark numbers.
def print_benchmark(self): """Print benchmark numbers.""" print('%-7.2f %s' % (self.elapsed, 'seconds elapsed')) if self.elapsed: for key in self._benchmark_keys: print('%-7d %s per second (%d total)' % (self.counters[key] / self.elapsed, key, ...
[ "def", "print_benchmark", "(", "self", ")", ":", "print", "(", "'%-7.2f %s'", "%", "(", "self", ".", "elapsed", ",", "'seconds elapsed'", ")", ")", "if", "self", ".", "elapsed", ":", "for", "key", "in", "self", ".", "_benchmark_keys", ":", "print", "(", ...
[ 2295, 4 ]
[ 2302, 43 ]
python
en
['de', 'en', 'en']
True
StandardReport.init_file
(self, filename, lines, expected, line_offset)
Signal a new file.
Signal a new file.
def init_file(self, filename, lines, expected, line_offset): """Signal a new file.""" self._deferred_print = [] return super(StandardReport, self).init_file( filename, lines, expected, line_offset)
[ "def", "init_file", "(", "self", ",", "filename", ",", "lines", ",", "expected", ",", "line_offset", ")", ":", "self", ".", "_deferred_print", "=", "[", "]", "return", "super", "(", "StandardReport", ",", "self", ")", ".", "init_file", "(", "filename", "...
[ 2322, 4 ]
[ 2326, 51 ]
python
en
['en', 'en', 'en']
True
StandardReport.error
(self, line_number, offset, text, check)
Report an error, according to options.
Report an error, according to options.
def error(self, line_number, offset, text, check): """Report an error, according to options.""" code = super(StandardReport, self).error(line_number, offset, text, check) if code and (self.counters[code] == 1 or self._repeat): self._de...
[ "def", "error", "(", "self", ",", "line_number", ",", "offset", ",", "text", ",", "check", ")", ":", "code", "=", "super", "(", "StandardReport", ",", "self", ")", ".", "error", "(", "line_number", ",", "offset", ",", "text", ",", "check", ")", "if",...
[ 2328, 4 ]
[ 2335, 19 ]
python
en
['en', 'en', 'en']
True
StandardReport.get_file_results
(self)
Print results and return the overall count for this file.
Print results and return the overall count for this file.
def get_file_results(self): """Print results and return the overall count for this file.""" self._deferred_print.sort() for line_number, offset, code, text, doc in self._deferred_print: print(self._fmt % { 'path': self.filename, 'row': self.line_offset...
[ "def", "get_file_results", "(", "self", ")", ":", "self", ".", "_deferred_print", ".", "sort", "(", ")", "for", "line_number", ",", "offset", ",", "code", ",", "text", ",", "doc", "in", "self", ".", "_deferred_print", ":", "print", "(", "self", ".", "_...
[ 2337, 4 ]
[ 2363, 31 ]
python
en
['en', 'en', 'en']
True
StyleGuide.init_report
(self, reporter=None)
Initialize the report instance.
Initialize the report instance.
def init_report(self, reporter=None): """Initialize the report instance.""" self.options.report = (reporter or self.options.reporter)(self.options) return self.options.report
[ "def", "init_report", "(", "self", ",", "reporter", "=", "None", ")", ":", "self", ".", "options", ".", "report", "=", "(", "reporter", "or", "self", ".", "options", ".", "reporter", ")", "(", "self", ".", "options", ")", "return", "self", ".", "opti...
[ 2420, 4 ]
[ 2423, 34 ]
python
en
['en', 'en', 'en']
True
StyleGuide.check_files
(self, paths=None)
Run all checks on the paths.
Run all checks on the paths.
def check_files(self, paths=None): """Run all checks on the paths.""" if paths is None: paths = self.paths report = self.options.report runner = self.runner report.start() try: for path in paths: if os.path.isdir(path): ...
[ "def", "check_files", "(", "self", ",", "paths", "=", "None", ")", ":", "if", "paths", "is", "None", ":", "paths", "=", "self", ".", "paths", "report", "=", "self", ".", "options", ".", "report", "runner", "=", "self", ".", "runner", "report", ".", ...
[ 2425, 4 ]
[ 2441, 21 ]
python
en
['en', 'gd', 'en']
True
StyleGuide.input_file
(self, filename, lines=None, expected=None, line_offset=0)
Run all checks on a Python source file.
Run all checks on a Python source file.
def input_file(self, filename, lines=None, expected=None, line_offset=0): """Run all checks on a Python source file.""" if self.options.verbose: print('checking %s' % filename) fchecker = self.checker_class( filename, lines=lines, options=self.options) return fche...
[ "def", "input_file", "(", "self", ",", "filename", ",", "lines", "=", "None", ",", "expected", "=", "None", ",", "line_offset", "=", "0", ")", ":", "if", "self", ".", "options", ".", "verbose", ":", "print", "(", "'checking %s'", "%", "filename", ")", ...
[ 2443, 4 ]
[ 2449, 77 ]
python
en
['en', 'ceb', 'en']
True
StyleGuide.input_dir
(self, dirname)
Check all files in this directory and all subdirectories.
Check all files in this directory and all subdirectories.
def input_dir(self, dirname): """Check all files in this directory and all subdirectories.""" dirname = dirname.rstrip('/') if self.excluded(dirname): return 0 counters = self.options.report.counters verbose = self.options.verbose filepatterns = self.options.f...
[ "def", "input_dir", "(", "self", ",", "dirname", ")", ":", "dirname", "=", "dirname", ".", "rstrip", "(", "'/'", ")", "if", "self", ".", "excluded", "(", "dirname", ")", ":", "return", "0", "counters", "=", "self", ".", "options", ".", "report", ".",...
[ 2451, 4 ]
[ 2471, 56 ]
python
en
['en', 'en', 'en']
True
StyleGuide.excluded
(self, filename, parent=None)
Check if the file should be excluded. Check if 'options.exclude' contains a pattern matching filename.
Check if the file should be excluded.
def excluded(self, filename, parent=None): """Check if the file should be excluded. Check if 'options.exclude' contains a pattern matching filename. """ if not self.options.exclude: return False basename = os.path.basename(filename) if filename_match(basename...
[ "def", "excluded", "(", "self", ",", "filename", ",", "parent", "=", "None", ")", ":", "if", "not", "self", ".", "options", ".", "exclude", ":", "return", "False", "basename", "=", "os", ".", "path", ".", "basename", "(", "filename", ")", "if", "file...
[ 2473, 4 ]
[ 2486, 61 ]
python
en
['en', 'en', 'en']
True
StyleGuide.ignore_code
(self, code)
Check if the error code should be ignored. If 'options.select' contains a prefix of the error code, return False. Else, if 'options.ignore' contains a prefix of the error code, return True.
Check if the error code should be ignored.
def ignore_code(self, code): """Check if the error code should be ignored. If 'options.select' contains a prefix of the error code, return False. Else, if 'options.ignore' contains a prefix of the error code, return True. """ if len(code) < 4 and any(s.startswith(code) ...
[ "def", "ignore_code", "(", "self", ",", "code", ")", ":", "if", "len", "(", "code", ")", "<", "4", "and", "any", "(", "s", ".", "startswith", "(", "code", ")", "for", "s", "in", "self", ".", "options", ".", "select", ")", ":", "return", "False", ...
[ 2488, 4 ]
[ 2499, 57 ]
python
en
['en', 'en', 'en']
True
StyleGuide.get_checks
(self, argument_name)
Get all the checks for this category. Find all globally visible functions where the first argument name starts with argument_name and which contain selected tests.
Get all the checks for this category.
def get_checks(self, argument_name): """Get all the checks for this category. Find all globally visible functions where the first argument name starts with argument_name and which contain selected tests. """ checks = [] for check, attrs in _checks[argument_name].items():...
[ "def", "get_checks", "(", "self", ",", "argument_name", ")", ":", "checks", "=", "[", "]", "for", "check", ",", "attrs", "in", "_checks", "[", "argument_name", "]", ".", "items", "(", ")", ":", "(", "codes", ",", "args", ")", "=", "attrs", "if", "a...
[ 2501, 4 ]
[ 2512, 29 ]
python
en
['en', 'en', 'en']
True
PrefetchRelatedTests.test_in_and_prefetch_related
(self)
Regression test for #20242 - QuerySet "in" didn't work the first time when using prefetch_related. This was fixed by the removal of chunked reads from QuerySet iteration in 70679243d1786e03557c28929f9762a119e3ac14.
Regression test for #20242 - QuerySet "in" didn't work the first time when using prefetch_related. This was fixed by the removal of chunked reads from QuerySet iteration in 70679243d1786e03557c28929f9762a119e3ac14.
def test_in_and_prefetch_related(self): """ Regression test for #20242 - QuerySet "in" didn't work the first time when using prefetch_related. This was fixed by the removal of chunked reads from QuerySet iteration in 70679243d1786e03557c28929f9762a119e3ac14. """ q...
[ "def", "test_in_and_prefetch_related", "(", "self", ")", ":", "qs", "=", "Book", ".", "objects", ".", "prefetch_related", "(", "'first_time_authors'", ")", "self", ".", "assertTrue", "(", "qs", "[", "0", "]", "in", "qs", ")" ]
[ 107, 4 ]
[ 115, 36 ]
python
en
['en', 'error', 'th']
False
PrefetchRelatedTests.test_clear
(self)
Test that we can clear the behavior by calling prefetch_related()
Test that we can clear the behavior by calling prefetch_related()
def test_clear(self): """ Test that we can clear the behavior by calling prefetch_related() """ with self.assertNumQueries(5): with_prefetch = Author.objects.prefetch_related('books') without_prefetch = with_prefetch.prefetch_related(None) [list(a.book...
[ "def", "test_clear", "(", "self", ")", ":", "with", "self", ".", "assertNumQueries", "(", "5", ")", ":", "with_prefetch", "=", "Author", ".", "objects", ".", "prefetch_related", "(", "'books'", ")", "without_prefetch", "=", "with_prefetch", ".", "prefetch_rela...
[ 117, 4 ]
[ 124, 59 ]
python
en
['en', 'error', 'th']
False
PrefetchRelatedTests.test_m2m_then_m2m
(self)
Test we can follow a m2m and another m2m
Test we can follow a m2m and another m2m
def test_m2m_then_m2m(self): """ Test we can follow a m2m and another m2m """ with self.assertNumQueries(3): qs = Author.objects.prefetch_related('books__read_by') lists = [[[six.text_type(r) for r in b.read_by.all()] for b in a.books.all()] ...
[ "def", "test_m2m_then_m2m", "(", "self", ")", ":", "with", "self", ".", "assertNumQueries", "(", "3", ")", ":", "qs", "=", "Author", ".", "objects", ".", "prefetch_related", "(", "'books__read_by'", ")", "lists", "=", "[", "[", "[", "six", ".", "text_typ...
[ 126, 4 ]
[ 141, 14 ]
python
en
['en', 'error', 'th']
False
PrefetchRelatedTests.test_get
(self)
Test that objects retrieved with .get() get the prefetch behavior.
Test that objects retrieved with .get() get the prefetch behavior.
def test_get(self): """ Test that objects retrieved with .get() get the prefetch behavior. """ # Need a double with self.assertNumQueries(3): author = Author.objects.prefetch_related('books__read_by').get(name="Charlotte") lists = [[six.text_type(r) for r ...
[ "def", "test_get", "(", "self", ")", ":", "# Need a double", "with", "self", ".", "assertNumQueries", "(", "3", ")", ":", "author", "=", "Author", ".", "objects", ".", "prefetch_related", "(", "'books__read_by'", ")", ".", "get", "(", "name", "=", "\"Charl...
[ 169, 4 ]
[ 178, 59 ]
python
en
['en', 'error', 'th']
False
PrefetchRelatedTests.test_foreign_key_then_m2m
(self)
Test we can follow an m2m relation after a relation like ForeignKey that doesn't have many objects
Test we can follow an m2m relation after a relation like ForeignKey that doesn't have many objects
def test_foreign_key_then_m2m(self): """ Test we can follow an m2m relation after a relation like ForeignKey that doesn't have many objects """ with self.assertNumQueries(2): qs = Author.objects.select_related('first_book').prefetch_related('first_book__read_by') ...
[ "def", "test_foreign_key_then_m2m", "(", "self", ")", ":", "with", "self", ".", "assertNumQueries", "(", "2", ")", ":", "qs", "=", "Author", ".", "objects", ".", "select_related", "(", "'first_book'", ")", ".", "prefetch_related", "(", "'first_book__read_by'", ...
[ 180, 4 ]
[ 192, 57 ]
python
en
['en', 'error', 'th']
False
PrefetchRelatedTests.test_reverse_one_to_one_then_m2m
(self)
Test that we can follow a m2m relation after going through the select_related reverse of an o2o.
Test that we can follow a m2m relation after going through the select_related reverse of an o2o.
def test_reverse_one_to_one_then_m2m(self): """ Test that we can follow a m2m relation after going through the select_related reverse of an o2o. """ qs = Author.objects.prefetch_related('bio__books').select_related('bio') with self.assertNumQueries(1): list(q...
[ "def", "test_reverse_one_to_one_then_m2m", "(", "self", ")", ":", "qs", "=", "Author", ".", "objects", ".", "prefetch_related", "(", "'bio__books'", ")", ".", "select_related", "(", "'bio'", ")", "with", "self", ".", "assertNumQueries", "(", "1", ")", ":", "...
[ 194, 4 ]
[ 206, 26 ]
python
en
['en', 'error', 'th']
False
CustomPrefetchTests.traverse_qs
(cls, obj_iter, path)
Helper method that returns a list containing a list of the objects in the obj_iter. Then for each object in the obj_iter, the path will be recursively travelled and the found objects are added to the return value.
Helper method that returns a list containing a list of the objects in the obj_iter. Then for each object in the obj_iter, the path will be recursively travelled and the found objects are added to the return value.
def traverse_qs(cls, obj_iter, path): """ Helper method that returns a list containing a list of the objects in the obj_iter. Then for each object in the obj_iter, the path will be recursively travelled and the found objects are added to the return value. """ ret_val = []...
[ "def", "traverse_qs", "(", "cls", ",", "obj_iter", ",", "path", ")", ":", "ret_val", "=", "[", "]", "if", "hasattr", "(", "obj_iter", ",", "'all'", ")", ":", "obj_iter", "=", "obj_iter", ".", "all", "(", ")", "try", ":", "iter", "(", "obj_iter", ")...
[ 226, 4 ]
[ 254, 22 ]
python
en
['en', 'error', 'th']
False
GenericRelationTests.test_traverse_GFK
(self)
Test that we can traverse a 'content_object' with prefetch_related() and get to related objects on the other side (assuming it is suitably filtered)
Test that we can traverse a 'content_object' with prefetch_related() and get to related objects on the other side (assuming it is suitably filtered)
def test_traverse_GFK(self): """ Test that we can traverse a 'content_object' with prefetch_related() and get to related objects on the other side (assuming it is suitably filtered) """ TaggedItem.objects.create(tag="awesome", content_object=self.book1) TaggedItem...
[ "def", "test_traverse_GFK", "(", "self", ")", ":", "TaggedItem", ".", "objects", ".", "create", "(", "tag", "=", "\"awesome\"", ",", "content_object", "=", "self", ".", "book1", ")", "TaggedItem", ".", "objects", ".", "create", "(", "tag", "=", "\"awesome\...
[ 701, 4 ]
[ 723, 80 ]
python
en
['en', 'error', 'th']
False
NullableTest.test_in_bulk
(self)
In-bulk does correctly prefetch objects by not using .iterator() directly.
In-bulk does correctly prefetch objects by not using .iterator() directly.
def test_in_bulk(self): """ In-bulk does correctly prefetch objects by not using .iterator() directly. """ boss1 = Employee.objects.create(name="Peter") boss2 = Employee.objects.create(name="Jack") with self.assertNumQueries(2): # Check that prefetch i...
[ "def", "test_in_bulk", "(", "self", ")", ":", "boss1", "=", "Employee", ".", "objects", ".", "create", "(", "name", "=", "\"Peter\"", ")", "boss2", "=", "Employee", ".", "objects", ".", "create", "(", "name", "=", "\"Jack\"", ")", "with", "self", ".", ...
[ 954, 4 ]
[ 965, 35 ]
python
en
['en', 'error', 'th']
False
_get_all_permissions
(opts)
Return (codename, name) for all permissions in the given opts.
Return (codename, name) for all permissions in the given opts.
def _get_all_permissions(opts): """ Return (codename, name) for all permissions in the given opts. """ return [*_get_builtin_permissions(opts), *opts.permissions]
[ "def", "_get_all_permissions", "(", "opts", ")", ":", "return", "[", "*", "_get_builtin_permissions", "(", "opts", ")", ",", "*", "opts", ".", "permissions", "]" ]
[ 13, 0 ]
[ 17, 63 ]
python
en
['en', 'error', 'th']
False
_get_builtin_permissions
(opts)
Return (codename, name) for all autogenerated permissions. By default, this is ('add', 'change', 'delete', 'view')
Return (codename, name) for all autogenerated permissions. By default, this is ('add', 'change', 'delete', 'view')
def _get_builtin_permissions(opts): """ Return (codename, name) for all autogenerated permissions. By default, this is ('add', 'change', 'delete', 'view') """ perms = [] for action in opts.default_permissions: perms.append(( get_permission_codename(action, opts), ...
[ "def", "_get_builtin_permissions", "(", "opts", ")", ":", "perms", "=", "[", "]", "for", "action", "in", "opts", ".", "default_permissions", ":", "perms", ".", "append", "(", "(", "get_permission_codename", "(", "action", ",", "opts", ")", ",", "'Can %s %s'"...
[ 20, 0 ]
[ 31, 16 ]
python
en
['en', 'error', 'th']
False
get_system_username
()
Return the current system user's username, or an empty string if the username could not be determined.
Return the current system user's username, or an empty string if the username could not be determined.
def get_system_username(): """ Return the current system user's username, or an empty string if the username could not be determined. """ try: result = getpass.getuser() except (ImportError, KeyError): # KeyError will be raised by os.getpwuid() (called by getuser()) # if ...
[ "def", "get_system_username", "(", ")", ":", "try", ":", "result", "=", "getpass", ".", "getuser", "(", ")", "except", "(", "ImportError", ",", "KeyError", ")", ":", "# KeyError will be raised by os.getpwuid() (called by getuser())", "# if there is no corresponding entry ...
[ 88, 0 ]
[ 100, 17 ]
python
en
['en', 'error', 'th']
False
get_default_username
(check_db=True)
Try to determine the current system user's username to use as a default. :param check_db: If ``True``, requires that the username does not match an existing ``auth.User`` (otherwise returns an empty string). :returns: The username, or an empty string if no username can be determined.
Try to determine the current system user's username to use as a default.
def get_default_username(check_db=True): """ Try to determine the current system user's username to use as a default. :param check_db: If ``True``, requires that the username does not match an existing ``auth.User`` (otherwise returns an empty string). :returns: The username, or an empty string...
[ "def", "get_default_username", "(", "check_db", "=", "True", ")", ":", "# This file is used in apps.py, it should not trigger models import.", "from", "django", ".", "contrib", ".", "auth", "import", "models", "as", "auth_app", "# If the User model has been swapped out, we can'...
[ 103, 0 ]
[ 144, 27 ]
python
en
['en', 'error', 'th']
False
load_target_class
(input_dir)
Loads target classes.
Loads target classes.
def load_target_class(input_dir): """Loads target classes.""" with tf.gfile.Open(os.path.join(input_dir, "target_class.csv")) as f: return {row[0]: int(row[1]) for row in csv.reader(f) if len(row) >= 2}
[ "def", "load_target_class", "(", "input_dir", ")", ":", "with", "tf", ".", "gfile", ".", "Open", "(", "os", ".", "path", ".", "join", "(", "input_dir", ",", "\"target_class.csv\"", ")", ")", "as", "f", ":", "return", "{", "row", "[", "0", "]", ":", ...
[ 44, 0 ]
[ 47, 78 ]
python
en
['en', 'bg', 'en']
True
load_images
(input_dir, batch_shape)
Read png images from input directory in batches. Args: input_dir: input directory batch_shape: shape of minibatch array, i.e. [batch_size, height, width, 3] Yields: filenames: list file names without path of each image Lenght of this list could be less than batch_size, in this case o...
Read png images from input directory in batches.
def load_images(input_dir, batch_shape): """Read png images from input directory in batches. Args: input_dir: input directory batch_shape: shape of minibatch array, i.e. [batch_size, height, width, 3] Yields: filenames: list file names without path of each image Lenght of this li...
[ "def", "load_images", "(", "input_dir", ",", "batch_shape", ")", ":", "images", "=", "np", ".", "zeros", "(", "batch_shape", ")", "filenames", "=", "[", "]", "idx", "=", "0", "batch_size", "=", "batch_shape", "[", "0", "]", "for", "filepath", "in", "tf...
[ 50, 0 ]
[ 80, 31 ]
python
en
['en', 'en', 'en']
True
save_images
(images, filenames, output_dir)
Saves images to the output directory. Args: images: array with minibatch of images filenames: list of filenames without path If number of file names in this list less than number of images in the minibatch then only first len(filenames) images will be saved. output_dir: directory ...
Saves images to the output directory.
def save_images(images, filenames, output_dir): """Saves images to the output directory. Args: images: array with minibatch of images filenames: list of filenames without path If number of file names in this list less than number of images in the minibatch then only first len(filena...
[ "def", "save_images", "(", "images", ",", "filenames", ",", "output_dir", ")", ":", "for", "i", ",", "filename", "in", "enumerate", "(", "filenames", ")", ":", "# Images for inception classifier are normalized to be in [-1, 1] interval,", "# so rescale them back to [0, 1]."...
[ 83, 0 ]
[ 97, 69 ]
python
en
['en', 'en', 'en']
True
main
(_)
Run the sample attack
Run the sample attack
def main(_): """Run the sample attack""" # Images for inception classifier are normalized to be in [-1, 1] interval, # eps is a difference between pixels so it should be in [0, 2] interval. # Renormalizing epsilon from [0, 255] to [0, 2]. eps = 2.0 * FLAGS.max_epsilon / 255.0 alpha = 2.0 * FLAGS...
[ "def", "main", "(", "_", ")", ":", "# Images for inception classifier are normalized to be in [-1, 1] interval,", "# eps is a difference between pixels so it should be in [0, 2] interval.", "# Renormalizing epsilon from [0, 255] to [0, 2].", "eps", "=", "2.0", "*", "FLAGS", ".", "max_e...
[ 100, 0 ]
[ 166, 68 ]
python
en
['en', 'it', 'en']
True
EWSRequest.__init__
(self, body, impersonation=None)
Initialize the request. :param body: Lxml element. The actual SOAP message. :param impersonation: Impersonation information. Currently supported is passing the impersonatee's SMTP address, or a raw `Excha...
Initialize the request.
def __init__(self, body, impersonation=None): """ Initialize the request. :param body: Lxml element. The actual SOAP message. :param impersonation: Impersonation information. Currently supported is passing the impersonatee's SM...
[ "def", "__init__", "(", "self", ",", "body", ",", "impersonation", "=", "None", ")", ":", "self", ".", "body", "=", "body", "self", ".", "impersonation", "=", "impersonation" ]
[ 11, 4 ]
[ 23, 42 ]
python
en
['en', 'error', 'th']
False
EWSRequest.envelop
(self)
Get this request's body enveloped for SOAP usage. :return: A bar of soap
Get this request's body enveloped for SOAP usage.
def envelop(self): """ Get this request's body enveloped for SOAP usage. :return: A bar of soap """ if isinstance(self.impersonation, string_types): impersonation = T.ExchangeImpersonation( T.ConnectingSID( T.SmtpAddress(self.imper...
[ "def", "envelop", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "impersonation", ",", "string_types", ")", ":", "impersonation", "=", "T", ".", "ExchangeImpersonation", "(", "T", ".", "ConnectingSID", "(", "T", ".", "SmtpAddress", "(", "self...
[ 25, 4 ]
[ 46, 9 ]
python
en
['en', 'error', 'th']
False
EWSRequest.send
(self, sess)
Send this request and return appropriately mangled response content. :param sess: The EWSSession to send this request with. :return:
Send this request and return appropriately mangled response content.
def send(self, sess): """ Send this request and return appropriately mangled response content. :param sess: The EWSSession to send this request with. :return: """ raise NotImplementedError("%r does not implement send()" % self)
[ "def", "send", "(", "self", ",", "sess", ")", ":", "raise", "NotImplementedError", "(", "\"%r does not implement send()\"", "%", "self", ")" ]
[ 48, 4 ]
[ 55, 72 ]
python
en
['en', 'error', 'th']
False
DispatcherTests._testIsClean
(self, signal)
Assert that everything has been cleaned up automatically
Assert that everything has been cleaned up automatically
def _testIsClean(self, signal): """Assert that everything has been cleaned up automatically""" # Note that dead weakref cleanup happens as side effect of using # the signal's receivers through the signals API. So, first do a # call to an API method to force cleanup. self.assertFa...
[ "def", "_testIsClean", "(", "self", ",", "signal", ")", ":", "# Note that dead weakref cleanup happens as side effect of using", "# the signal's receivers through the signals API. So, first do a", "# call to an API method to force cleanup.", "self", ".", "assertFalse", "(", "signal", ...
[ 47, 4 ]
[ 53, 46 ]
python
en
['en', 'en', 'en']
True
DispatcherTests.test_cached_garbaged_collected
(self)
Make sure signal caching sender receivers don't prevent garbage collection of senders.
Make sure signal caching sender receivers don't prevent garbage collection of senders.
def test_cached_garbaged_collected(self): """ Make sure signal caching sender receivers don't prevent garbage collection of senders. """ class sender: pass wref = weakref.ref(sender) d_signal.connect(receiver_1_arg) d_signal.send(sender, val='g...
[ "def", "test_cached_garbaged_collected", "(", "self", ")", ":", "class", "sender", ":", "pass", "wref", "=", "weakref", ".", "ref", "(", "sender", ")", "d_signal", ".", "connect", "(", "receiver_1_arg", ")", "d_signal", ".", "send", "(", "sender", ",", "va...
[ 81, 4 ]
[ 97, 47 ]
python
en
['en', 'error', 'th']
False
DispatcherTests.test_robust
(self)
Test the sendRobust function
Test the sendRobust function
def test_robust(self): """Test the sendRobust function""" def fails(val, **kwargs): raise ValueError('this') a_signal.connect(fails) result = a_signal.send_robust(sender=self, val="test") err = result[0][1] self.assertIsInstance(err, ValueError) self.a...
[ "def", "test_robust", "(", "self", ")", ":", "def", "fails", "(", "val", ",", "*", "*", "kwargs", ")", ":", "raise", "ValueError", "(", "'this'", ")", "a_signal", ".", "connect", "(", "fails", ")", "result", "=", "a_signal", ".", "send_robust", "(", ...
[ 128, 4 ]
[ 140, 35 ]
python
en
['en', 'en', 'en']
True
UpdateCacheMiddleware.process_response
(self, request, response)
Sets the cache, if needed.
Sets the cache, if needed.
def process_response(self, request, response): """Sets the cache, if needed.""" if not self._should_update_cache(request, response): # We don't need to update the cache, just return. return response if response.streaming or response.status_code != 200: return...
[ "def", "process_response", "(", "self", ",", "request", ",", "response", ")", ":", "if", "not", "self", ".", "_should_update_cache", "(", "request", ",", "response", ")", ":", "# We don't need to update the cache, just return.", "return", "response", "if", "response...
[ 75, 4 ]
[ 107, 23 ]
python
en
['en', 'en', 'en']
True
FetchFromCacheMiddleware.process_request
(self, request)
Checks whether the page is already cached and returns the cached version if available.
Checks whether the page is already cached and returns the cached version if available.
def process_request(self, request): """ Checks whether the page is already cached and returns the cached version if available. """ if request.method not in ('GET', 'HEAD'): request._cache_update_cache = False return None # Don't bother checking the cache....
[ "def", "process_request", "(", "self", ",", "request", ")", ":", "if", "request", ".", "method", "not", "in", "(", "'GET'", ",", "'HEAD'", ")", ":", "request", ".", "_cache_update_cache", "=", "False", "return", "None", "# Don't bother checking the cache.", "#...
[ 123, 4 ]
[ 149, 23 ]
python
en
['en', 'error', 'th']
False
require_http_methods
(request_method_list)
Decorator to make a view only accept particular request methods. Usage:: @require_http_methods(["GET", "POST"]) def my_view(request): # I can assume now that only GET or POST requests make it this far # ... Note that request methods should be in uppercase.
Decorator to make a view only accept particular request methods. Usage::
def require_http_methods(request_method_list): """ Decorator to make a view only accept particular request methods. Usage:: @require_http_methods(["GET", "POST"]) def my_view(request): # I can assume now that only GET or POST requests make it this far # ... Note th...
[ "def", "require_http_methods", "(", "request_method_list", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "wraps", "(", "func", ",", "assigned", "=", "available_attrs", "(", "func", ")", ")", "def", "inner", "(", "request", ",", "*", "args", "...
[ 18, 0 ]
[ 42, 20 ]
python
en
['en', 'error', 'th']
False
condition
(etag_func=None, last_modified_func=None)
Decorator to support conditional retrieval (or change) for a view function. The parameters are callables to compute the ETag and last modified time for the requested resource, respectively. The callables are passed the same parameters as the view itself. The Etag function should return a string (o...
Decorator to support conditional retrieval (or change) for a view function.
def condition(etag_func=None, last_modified_func=None): """ Decorator to support conditional retrieval (or change) for a view function. The parameters are callables to compute the ETag and last modified time for the requested resource, respectively. The callables are passed the same parameters ...
[ "def", "condition", "(", "etag_func", "=", "None", ",", "last_modified_func", "=", "None", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "wraps", "(", "func", ",", "assigned", "=", "available_attrs", "(", "func", ")", ")", "def", "inner", "...
[ 54, 0 ]
[ 158, 20 ]
python
en
['en', 'error', 'th']
False
Link.__init__
( self, url, # type: str comes_from=None, # type: Optional[Union[str, HTMLPage]] requires_python=None, # type: Optional[str] yanked_reason=None, # type: Optional[Text] cache_link_parsing=True, # type: bool )
:param url: url of the resource pointed to (href of the link) :param comes_from: instance of HTMLPage where the link was found, or string. :param requires_python: String containing the `Requires-Python` metadata field, specified in PEP 345. This may be specified by ...
:param url: url of the resource pointed to (href of the link) :param comes_from: instance of HTMLPage where the link was found, or string. :param requires_python: String containing the `Requires-Python` metadata field, specified in PEP 345. This may be specified by ...
def __init__( self, url, # type: str comes_from=None, # type: Optional[Union[str, HTMLPage]] requires_python=None, # type: Optional[str] yanked_reason=None, # type: Optional[Text] cache_link_parsing=True, # type: bool ): # type: (....
[ "def", "__init__", "(", "self", ",", "url", ",", "# type: str", "comes_from", "=", "None", ",", "# type: Optional[Union[str, HTMLPage]]", "requires_python", "=", "None", ",", "# type: Optional[str]", "yanked_reason", "=", "None", ",", "# type: Optional[Text]", "cache_li...
[ 26, 4 ]
[ 71, 52 ]
python
en
['en', 'error', 'th']
False
Link.netloc
(self)
This can contain auth information.
This can contain auth information.
def netloc(self): # type: () -> str """ This can contain auth information. """ return self._parsed_url.netloc
[ "def", "netloc", "(", "self", ")", ":", "# type: () -> str", "return", "self", ".", "_parsed_url", ".", "netloc" ]
[ 121, 4 ]
[ 126, 38 ]
python
en
['en', 'error', 'th']
False
Link.is_hash_allowed
(self, hashes)
Return True if the link has a hash and it is allowed.
Return True if the link has a hash and it is allowed.
def is_hash_allowed(self, hashes): # type: (Optional[Hashes]) -> bool """ Return True if the link has a hash and it is allowed. """ if hashes is None or not self.has_hash: return False # Assert non-None so mypy knows self.hash_name and self.hash are str. ...
[ "def", "is_hash_allowed", "(", "self", ",", "hashes", ")", ":", "# type: (Optional[Hashes]) -> bool", "if", "hashes", "is", "None", "or", "not", "self", ".", "has_hash", ":", "return", "False", "# Assert non-None so mypy knows self.hash_name and self.hash are str.", "asse...
[ 224, 4 ]
[ 235, 75 ]
python
en
['en', 'error', 'th']
False
sql_create
(app_config, style, connection)
Returns a list of the CREATE TABLE SQL statements for the given app.
Returns a list of the CREATE TABLE SQL statements for the given app.
def sql_create(app_config, style, connection): "Returns a list of the CREATE TABLE SQL statements for the given app." check_for_migrations(app_config, connection) if connection.settings_dict['ENGINE'] == 'django.db.backends.dummy': # This must be the "dummy" database backend, which means the user ...
[ "def", "sql_create", "(", "app_config", ",", "style", ",", "connection", ")", ":", "check_for_migrations", "(", "app_config", ",", "connection", ")", "if", "connection", ".", "settings_dict", "[", "'ENGINE'", "]", "==", "'django.db.backends.dummy'", ":", "# This m...
[ 25, 0 ]
[ 70, 23 ]
python
en
['en', 'en', 'en']
True
sql_delete
(app_config, style, connection, close_connection=True)
Returns a list of the DROP TABLE SQL statements for the given app.
Returns a list of the DROP TABLE SQL statements for the given app.
def sql_delete(app_config, style, connection, close_connection=True): "Returns a list of the DROP TABLE SQL statements for the given app." check_for_migrations(app_config, connection) # This should work even if a connection isn't available try: cursor = connection.cursor() except Exception...
[ "def", "sql_delete", "(", "app_config", ",", "style", ",", "connection", ",", "close_connection", "=", "True", ")", ":", "check_for_migrations", "(", "app_config", ",", "connection", ")", "# This should work even if a connection isn't available", "try", ":", "cursor", ...
[ 73, 0 ]
[ 120, 23 ]
python
en
['en', 'en', 'en']
True
sql_flush
(style, connection, only_django=False, reset_sequences=True, allow_cascade=False)
Returns a list of the SQL statements used to flush the database. If only_django is True, then only table names that have associated Django models and are in INSTALLED_APPS will be included.
Returns a list of the SQL statements used to flush the database.
def sql_flush(style, connection, only_django=False, reset_sequences=True, allow_cascade=False): """ Returns a list of the SQL statements used to flush the database. If only_django is True, then only table names that have associated Django models and are in INSTALLED_APPS will be included. """ i...
[ "def", "sql_flush", "(", "style", ",", "connection", ",", "only_django", "=", "False", ",", "reset_sequences", "=", "True", ",", "allow_cascade", "=", "False", ")", ":", "if", "only_django", ":", "tables", "=", "connection", ".", "introspection", ".", "djang...
[ 123, 0 ]
[ 136, 21 ]
python
en
['en', 'error', 'th']
False
sql_custom
(app_config, style, connection)
Returns a list of the custom table modifying SQL statements for the given app.
Returns a list of the custom table modifying SQL statements for the given app.
def sql_custom(app_config, style, connection): "Returns a list of the custom table modifying SQL statements for the given app." check_for_migrations(app_config, connection) output = [] app_models = router.get_migratable_models(app_config, connection.alias) for model in app_models: output...
[ "def", "sql_custom", "(", "app_config", ",", "style", ",", "connection", ")", ":", "check_for_migrations", "(", "app_config", ",", "connection", ")", "output", "=", "[", "]", "app_models", "=", "router", ".", "get_migratable_models", "(", "app_config", ",", "c...
[ 139, 0 ]
[ 151, 17 ]
python
en
['en', 'en', 'en']
True
sql_indexes
(app_config, style, connection)
Returns a list of the CREATE INDEX SQL statements for all models in the given app.
Returns a list of the CREATE INDEX SQL statements for all models in the given app.
def sql_indexes(app_config, style, connection): "Returns a list of the CREATE INDEX SQL statements for all models in the given app." check_for_migrations(app_config, connection) output = [] for model in router.get_migratable_models(app_config, connection.alias, include_auto_created=True): outp...
[ "def", "sql_indexes", "(", "app_config", ",", "style", ",", "connection", ")", ":", "check_for_migrations", "(", "app_config", ",", "connection", ")", "output", "=", "[", "]", "for", "model", "in", "router", ".", "get_migratable_models", "(", "app_config", ","...
[ 154, 0 ]
[ 162, 17 ]
python
en
['en', 'en', 'en']
True
sql_destroy_indexes
(app_config, style, connection)
Returns a list of the DROP INDEX SQL statements for all models in the given app.
Returns a list of the DROP INDEX SQL statements for all models in the given app.
def sql_destroy_indexes(app_config, style, connection): "Returns a list of the DROP INDEX SQL statements for all models in the given app." check_for_migrations(app_config, connection) output = [] for model in router.get_migratable_models(app_config, connection.alias, include_auto_created=True): ...
[ "def", "sql_destroy_indexes", "(", "app_config", ",", "style", ",", "connection", ")", ":", "check_for_migrations", "(", "app_config", ",", "connection", ")", "output", "=", "[", "]", "for", "model", "in", "router", ".", "get_migratable_models", "(", "app_config...
[ 165, 0 ]
[ 173, 17 ]
python
en
['en', 'en', 'en']
True
sql_all
(app_config, style, connection)
Returns a list of CREATE TABLE SQL, initial-data inserts, and CREATE INDEX SQL for the given module.
Returns a list of CREATE TABLE SQL, initial-data inserts, and CREATE INDEX SQL for the given module.
def sql_all(app_config, style, connection): check_for_migrations(app_config, connection) "Returns a list of CREATE TABLE SQL, initial-data inserts, and CREATE INDEX SQL for the given module." return ( sql_create(app_config, style, connection) + sql_custom(app_config, style, connection) + ...
[ "def", "sql_all", "(", "app_config", ",", "style", ",", "connection", ")", ":", "check_for_migrations", "(", "app_config", ",", "connection", ")", "return", "(", "sql_create", "(", "app_config", ",", "style", ",", "connection", ")", "+", "sql_custom", "(", "...
[ 176, 0 ]
[ 185, 5 ]
python
en
['en', 'en', 'en']
True
RDS.manage_subfleet
(self)
Manage start/stop actions for subfleet RDS instances
Manage start/stop actions for subfleet RDS instances
def manage_subfleet(self): """Manage start/stop actions for subfleet RDS instances """ if "rds" not in self.context["o_state"].get_resource_services(): return states = defaultdict(int) arns = self.get_subfleet_arns() for arn in arns: subfleet_na...
[ "def", "manage_subfleet", "(", "self", ")", ":", "if", "\"rds\"", "not", "in", "self", ".", "context", "[", "\"o_state\"", "]", ".", "get_resource_services", "(", ")", ":", "return", "states", "=", "defaultdict", "(", "int", ")", "arns", "=", "self", "."...
[ 126, 4 ]
[ 178, 59 ]
python
en
['en', 'en', 'en']
True
RDS._check_db_exception
(need_longterm_record, response, ex)
Check if we encountered exception and if we need to create a LongTerm record for this event
Check if we encountered exception and if we need to create a LongTerm record for this event
def _check_db_exception(need_longterm_record, response, ex): """ Check if we encountered exception and if we need to create a LongTerm record for this event """ need_shortterm_record = True if ex is not None: # If we received an InvalidDBClusterStateFault/InvalidDBInstanceSta...
[ "def", "_check_db_exception", "(", "need_longterm_record", ",", "response", ",", "ex", ")", ":", "need_shortterm_record", "=", "True", "if", "ex", "is", "not", "None", ":", "# If we received an InvalidDBClusterStateFault/InvalidDBInstanceState exception, we do not create ", "...
[ 181, 4 ]
[ 200, 57 ]
python
en
['en', 'en', 'en']
True
PublicURLTest.test_public_urls
(self)
Test which views are accessible when not logged in.
Test which views are accessible when not logged in.
def test_public_urls(self) -> None: """ Test which views are accessible when not logged in. """ # FIXME: We should also test the Tornado URLs -- this codepath # can't do so because this Django test mechanism doesn't go # through Tornado. denmark_stream_id = Stream...
[ "def", "test_public_urls", "(", "self", ")", "->", "None", ":", "# FIXME: We should also test the Tornado URLs -- this codepath", "# can't do so because this Django test mechanism doesn't go", "# through Tornado.", "denmark_stream_id", "=", "Stream", ".", "objects", ".", "get", "...
[ 28, 4 ]
[ 96, 60 ]
python
en
['en', 'error', 'th']
False
PublicURLTest.test_config_error_endpoints_dev_env
(self)
The content of these pages is tested separately. Here we simply sanity-check that all the URLs load correctly.
The content of these pages is tested separately. Here we simply sanity-check that all the URLs load correctly.
def test_config_error_endpoints_dev_env(self) -> None: """ The content of these pages is tested separately. Here we simply sanity-check that all the URLs load correctly. """ auth_types = [auth.lower() for auth in Realm.AUTHENTICATION_FLAGS] for auth in [ ...
[ "def", "test_config_error_endpoints_dev_env", "(", "self", ")", "->", "None", ":", "auth_types", "=", "[", "auth", ".", "lower", "(", ")", "for", "auth", "in", "Realm", ".", "AUTHENTICATION_FLAGS", "]", "for", "auth", "in", "[", "\"azuread\"", ",", "\"email\...
[ 98, 4 ]
[ 121, 82 ]
python
en
['en', 'error', 'th']
False
HeadersCheckMixin.assertMessageHasHeaders
(self, message, headers)
Check that :param message: has all :param headers: headers. :param message: can be an instance of an email.Message subclass or a string with the contents of an email message. :param headers: should be a set of (header-name, header-value) tuples.
Check that :param message: has all :param headers: headers.
def assertMessageHasHeaders(self, message, headers): """ Check that :param message: has all :param headers: headers. :param message: can be an instance of an email.Message subclass or a string with the contents of an email message. :param headers: should be a set of (header-name...
[ "def", "assertMessageHasHeaders", "(", "self", ",", "message", ",", "headers", ")", ":", "if", "isinstance", "(", "message", ",", "binary_type", ")", ":", "message", "=", "message_from_bytes", "(", "message", ")", "msg_headers", "=", "set", "(", "message", "...
[ 36, 4 ]
[ 48, 79 ]
python
en
['en', 'error', 'th']
False
MailTests.test_cc
(self)
Regression test for #7722
Regression test for #7722
def test_cc(self): """Regression test for #7722""" email = EmailMessage('Subject', 'Content', 'from@example.com', ['to@example.com'], cc=['cc@example.com']) message = email.message() self.assertEqual(message['Cc'], 'cc@example.com') self.assertEqual(email.recipients(), ['to@examp...
[ "def", "test_cc", "(", "self", ")", ":", "email", "=", "EmailMessage", "(", "'Subject'", ",", "'Content'", ",", "'from@example.com'", ",", "[", "'to@example.com'", "]", ",", "cc", "=", "[", "'cc@example.com'", "]", ")", "message", "=", "email", ".", "messa...
[ 72, 4 ]
[ 89, 146 ]
python
en
['en', 'en', 'en']
True
MailTests.test_space_continuation
(self)
Test for space continuation character in long (ASCII) subject headers (#7747)
Test for space continuation character in long (ASCII) subject headers (#7747)
def test_space_continuation(self): """ Test for space continuation character in long (ASCII) subject headers (#7747) """ email = EmailMessage('Long subject lines that get wrapped should contain a space continuation character to get expected behavior in Outlook and Thunderbird', 'Content'...
[ "def", "test_space_continuation", "(", "self", ")", ":", "email", "=", "EmailMessage", "(", "'Long subject lines that get wrapped should contain a space continuation character to get expected behavior in Outlook and Thunderbird'", ",", "'Content'", ",", "'from@example.com'", ",", "["...
[ 103, 4 ]
[ 110, 193 ]
python
en
['en', 'error', 'th']
False
MailTests.test_message_header_overrides
(self)
Specifying dates or message-ids in the extra headers overrides the default values (#9233)
Specifying dates or message-ids in the extra headers overrides the default values (#9233)
def test_message_header_overrides(self): """ Specifying dates or message-ids in the extra headers overrides the default values (#9233) """ headers = {"date": "Fri, 09 Nov 2001 01:08:47 -0000", "Message-ID": "foo"} email = EmailMessage('subject', 'content', 'from@example.c...
[ "def", "test_message_header_overrides", "(", "self", ")", ":", "headers", "=", "{", "\"date\"", ":", "\"Fri, 09 Nov 2001 01:08:47 -0000\"", ",", "\"Message-ID\"", ":", "\"foo\"", "}", "email", "=", "EmailMessage", "(", "'subject'", ",", "'content'", ",", "'from@exam...
[ 112, 4 ]
[ 129, 10 ]
python
en
['en', 'error', 'th']
False
MailTests.test_from_header
(self)
Make sure we can manually set the From header (#9214)
Make sure we can manually set the From header (#9214)
def test_from_header(self): """ Make sure we can manually set the From header (#9214) """ email = EmailMessage('Subject', 'Content', 'bounce@example.com', ['to@example.com'], headers={'From': 'from@example.com'}) message = email.message() self.assertEqual(message['From'],...
[ "def", "test_from_header", "(", "self", ")", ":", "email", "=", "EmailMessage", "(", "'Subject'", ",", "'Content'", ",", "'bounce@example.com'", ",", "[", "'to@example.com'", "]", ",", "headers", "=", "{", "'From'", ":", "'from@example.com'", "}", ")", "messag...
[ 131, 4 ]
[ 137, 61 ]
python
en
['en', 'error', 'th']
False
MailTests.test_to_header
(self)
Make sure we can manually set the To header (#17444)
Make sure we can manually set the To header (#17444)
def test_to_header(self): """ Make sure we can manually set the To header (#17444) """ email = EmailMessage('Subject', 'Content', 'bounce@example.com', ['list-subscriber@example.com', 'list-subscriber2@example.com'], headers={'To'...
[ "def", "test_to_header", "(", "self", ")", ":", "email", "=", "EmailMessage", "(", "'Subject'", ",", "'Content'", ",", "'bounce@example.com'", ",", "[", "'list-subscriber@example.com'", ",", "'list-subscriber2@example.com'", "]", ",", "headers", "=", "{", "'To'", ...
[ 139, 4 ]
[ 155, 99 ]
python
en
['en', 'error', 'th']
False
MailTests.test_multiple_message_call
(self)
Regression for #13259 - Make sure that headers are not changed when calling EmailMessage.message()
Regression for #13259 - Make sure that headers are not changed when calling EmailMessage.message()
def test_multiple_message_call(self): """ Regression for #13259 - Make sure that headers are not changed when calling EmailMessage.message() """ email = EmailMessage('Subject', 'Content', 'bounce@example.com', ['to@example.com'], headers={'From': 'from@example.com'}) mess...
[ "def", "test_multiple_message_call", "(", "self", ")", ":", "email", "=", "EmailMessage", "(", "'Subject'", ",", "'Content'", ",", "'bounce@example.com'", ",", "[", "'to@example.com'", "]", ",", "headers", "=", "{", "'From'", ":", "'from@example.com'", "}", ")",...
[ 157, 4 ]
[ 166, 61 ]
python
en
['en', 'error', 'th']
False
MailTests.test_unicode_address_header
(self)
Regression for #11144 - When a to/from/cc header contains unicode, make sure the email addresses are parsed correctly (especially with regards to commas)
Regression for #11144 - When a to/from/cc header contains unicode, make sure the email addresses are parsed correctly (especially with regards to commas)
def test_unicode_address_header(self): """ Regression for #11144 - When a to/from/cc header contains unicode, make sure the email addresses are parsed correctly (especially with regards to commas) """ email = EmailMessage('Subject', 'Content', 'from@example.com', ['"First...
[ "def", "test_unicode_address_header", "(", "self", ")", ":", "email", "=", "EmailMessage", "(", "'Subject'", ",", "'Content'", ",", "'from@example.com'", ",", "[", "'\"Firstname Sürname\" <to@example.com>',", " ", "other@example.com']", ")", "", "self", ".", "assertEq...
[ 168, 4 ]
[ 177, 124 ]
python
en
['en', 'error', 'th']
False
MailTests.test_safe_mime_multipart
(self)
Make sure headers can be set with a different encoding than utf-8 in SafeMIMEMultipart as well
Make sure headers can be set with a different encoding than utf-8 in SafeMIMEMultipart as well
def test_safe_mime_multipart(self): """ Make sure headers can be set with a different encoding than utf-8 in SafeMIMEMultipart as well """ headers = {"Date": "Fri, 09 Nov 2001 01:08:47 -0000", "Message-ID": "foo"} from_email, to = 'from@example.com', '"Sürname, Firstname"...
[ "def", "test_safe_mime_multipart", "(", "self", ")", ":", "headers", "=", "{", "\"Date\"", ":", "\"Fri, 09 Nov 2001 01:08:47 -0000\"", ",", "\"Message-ID\"", ":", "\"foo\"", "}", "from_email", ",", "to", "=", "'from@example.com'", ",", "'\"Sürname, Firstname\" <to@examp...
[ 188, 4 ]
[ 201, 103 ]
python
en
['en', 'error', 'th']
False
MailTests.test_encoding
(self)
Regression for #12791 - Encode body correctly with other encodings than utf-8
Regression for #12791 - Encode body correctly with other encodings than utf-8
def test_encoding(self): """ Regression for #12791 - Encode body correctly with other encodings than utf-8 """ email = EmailMessage('Subject', 'Firstname Sürname is a great guy.', 'from@example.com', ['other@example.com']) email.encoding = 'iso-8859-1' message = e...
[ "def", "test_encoding", "(", "self", ")", ":", "email", "=", "EmailMessage", "(", "'Subject'", ",", "'Firstname Sürname is a great guy.',", " ", "from@example.com',", " ", "'", "other@example.com']", ")", "", "email", ".", "encoding", "=", "'iso-8859-1'", "message",...
[ 203, 4 ]
[ 237, 121 ]
python
en
['en', 'error', 'th']
False
MailTests.test_attachments
(self)
Regression test for #9367
Regression test for #9367
def test_attachments(self): """Regression test for #9367""" headers = {"Date": "Fri, 09 Nov 2001 01:08:47 -0000", "Message-ID": "foo"} subject, from_email, to = 'hello', 'from@example.com', 'to@example.com' text_content = 'This is an important message.' html_content = '<p>This is...
[ "def", "test_attachments", "(", "self", ")", ":", "headers", "=", "{", "\"Date\"", ":", "\"Fri, 09 Nov 2001 01:08:47 -0000\"", ",", "\"Message-ID\"", ":", "\"foo\"", "}", "subject", ",", "from_email", ",", "to", "=", "'hello'", ",", "'from@example.com'", ",", "'...
[ 239, 4 ]
[ 255, 74 ]
python
en
['en', 'en', 'en']
True
MailTests.test_non_ascii_attachment_filename
(self)
Regression test for #14964
Regression test for #14964
def test_non_ascii_attachment_filename(self): """Regression test for #14964""" headers = {"Date": "Fri, 09 Nov 2001 01:08:47 -0000", "Message-ID": "foo"} subject, from_email, to = 'hello', 'from@example.com', 'to@example.com' content = 'This is the message.' msg = EmailMessage(su...
[ "def", "test_non_ascii_attachment_filename", "(", "self", ")", ":", "headers", "=", "{", "\"Date\"", ":", "\"Fri, 09 Nov 2001 01:08:47 -0000\"", ",", "\"Message-ID\"", ":", "\"foo\"", "}", "subject", ",", "from_email", ",", "to", "=", "'hello'", ",", "'from@example....
[ 257, 4 ]
[ 268, 76 ]
python
en
['en', 'en', 'en']
True
MailTests.test_dummy_backend
(self)
Make sure that dummy backends returns correct number of sent messages
Make sure that dummy backends returns correct number of sent messages
def test_dummy_backend(self): """ Make sure that dummy backends returns correct number of sent messages """ connection = dummy.EmailBackend() email = EmailMessage('Subject', 'Content', 'bounce@example.com', ['to@example.com'], headers={'From': 'from@example.com'}) self.as...
[ "def", "test_dummy_backend", "(", "self", ")", ":", "connection", "=", "dummy", ".", "EmailBackend", "(", ")", "email", "=", "EmailMessage", "(", "'Subject'", ",", "'Content'", ",", "'bounce@example.com'", ",", "[", "'to@example.com'", "]", ",", "headers", "="...
[ 270, 4 ]
[ 276, 76 ]
python
en
['en', 'error', 'th']
False
MailTests.test_arbitrary_keyword
(self)
Make sure that get_connection() accepts arbitrary keyword that might be used with custom backends.
Make sure that get_connection() accepts arbitrary keyword that might be used with custom backends.
def test_arbitrary_keyword(self): """ Make sure that get_connection() accepts arbitrary keyword that might be used with custom backends. """ c = mail.get_connection(fail_silently=True, foo='bar') self.assertTrue(c.fail_silently)
[ "def", "test_arbitrary_keyword", "(", "self", ")", ":", "c", "=", "mail", ".", "get_connection", "(", "fail_silently", "=", "True", ",", "foo", "=", "'bar'", ")", "self", ".", "assertTrue", "(", "c", ".", "fail_silently", ")" ]
[ 278, 4 ]
[ 284, 40 ]
python
en
['en', 'error', 'th']
False
MailTests.test_custom_backend
(self)
Test custom backend defined in this suite.
Test custom backend defined in this suite.
def test_custom_backend(self): """Test custom backend defined in this suite.""" conn = mail.get_connection('mail.custombackend.EmailBackend') self.assertTrue(hasattr(conn, 'test_outbox')) email = EmailMessage('Subject', 'Content', 'bounce@example.com', ['to@example.com'], headers={'From'...
[ "def", "test_custom_backend", "(", "self", ")", ":", "conn", "=", "mail", ".", "get_connection", "(", "'mail.custombackend.EmailBackend'", ")", "self", ".", "assertTrue", "(", "hasattr", "(", "conn", ",", "'test_outbox'", ")", ")", "email", "=", "EmailMessage", ...
[ 286, 4 ]
[ 292, 50 ]
python
en
['en', 'en', 'en']
True
MailTests.test_backend_arg
(self)
Test backend argument of mail.get_connection()
Test backend argument of mail.get_connection()
def test_backend_arg(self): """Test backend argument of mail.get_connection()""" self.assertIsInstance(mail.get_connection('django.core.mail.backends.smtp.EmailBackend'), smtp.EmailBackend) self.assertIsInstance(mail.get_connection('django.core.mail.backends.locmem.EmailBackend'), locmem.EmailBa...
[ "def", "test_backend_arg", "(", "self", ")", ":", "self", ".", "assertIsInstance", "(", "mail", ".", "get_connection", "(", "'django.core.mail.backends.smtp.EmailBackend'", ")", ",", "smtp", ".", "EmailBackend", ")", "self", ".", "assertIsInstance", "(", "mail", "...
[ 294, 4 ]
[ 305, 73 ]
python
en
['en', 'en', 'en']
True
MailTests.test_connection_arg
(self)
Test connection argument to send_mail(), et. al.
Test connection argument to send_mail(), et. al.
def test_connection_arg(self): """Test connection argument to send_mail(), et. al.""" mail.outbox = [] # Send using non-default connection connection = mail.get_connection('mail.custombackend.EmailBackend') send_mail('Subject', 'Content', 'from@example.com', ['to@example.com'], ...
[ "def", "test_connection_arg", "(", "self", ")", ":", "mail", ".", "outbox", "=", "[", "]", "# Send using non-default connection", "connection", "=", "mail", ".", "get_connection", "(", "'mail.custombackend.EmailBackend'", ")", "send_mail", "(", "'Subject'", ",", "'C...
[ 311, 4 ]
[ 342, 87 ]
python
en
['en', 'fr', 'en']
True
BaseEmailBackendTests.test_plaintext_send_mail
(self)
Test send_mail without the html_message regression test for adding html_message parameter to send_mail()
Test send_mail without the html_message regression test for adding html_message parameter to send_mail()
def test_plaintext_send_mail(self): """ Test send_mail without the html_message regression test for adding html_message parameter to send_mail() """ send_mail('Subject', 'Content', 'sender@example.com', ['nobody@example.com']) message = self.get_the_message() sel...
[ "def", "test_plaintext_send_mail", "(", "self", ")", ":", "send_mail", "(", "'Subject'", ",", "'Content'", ",", "'sender@example.com'", ",", "[", "'nobody@example.com'", "]", ")", "message", "=", "self", ".", "get_the_message", "(", ")", "self", ".", "assertEqua...
[ 497, 4 ]
[ 509, 66 ]
python
en
['en', 'error', 'th']
False
BaseEmailBackendTests.test_html_send_mail
(self)
Test html_message argument to send_mail
Test html_message argument to send_mail
def test_html_send_mail(self): """Test html_message argument to send_mail""" send_mail('Subject', 'Content', 'sender@example.com', ['nobody@example.com'], html_message='HTML Content') message = self.get_the_message() self.assertEqual(message.get('subject'), 'Subject') self.asser...
[ "def", "test_html_send_mail", "(", "self", ")", ":", "send_mail", "(", "'Subject'", ",", "'Content'", ",", "'sender@example.com'", ",", "[", "'nobody@example.com'", "]", ",", "html_message", "=", "'HTML Content'", ")", "message", "=", "self", ".", "get_the_message...
[ 511, 4 ]
[ 523, 80 ]
python
en
['en', 'en', 'en']
True
BaseEmailBackendTests.test_html_mail_managers
(self)
Test html_message argument to mail_managers
Test html_message argument to mail_managers
def test_html_mail_managers(self): """Test html_message argument to mail_managers""" mail_managers('Subject', 'Content', html_message='HTML Content') message = self.get_the_message() self.assertEqual(message.get('subject'), '[Django] Subject') self.assertEqual(message.get_all('t...
[ "def", "test_html_mail_managers", "(", "self", ")", ":", "mail_managers", "(", "'Subject'", ",", "'Content'", ",", "html_message", "=", "'HTML Content'", ")", "message", "=", "self", ".", "get_the_message", "(", ")", "self", ".", "assertEqual", "(", "message", ...
[ 526, 4 ]
[ 538, 80 ]
python
en
['en', 'en', 'en']
True
BaseEmailBackendTests.test_html_mail_admins
(self)
Test html_message argument to mail_admins
Test html_message argument to mail_admins
def test_html_mail_admins(self): """Test html_message argument to mail_admins """ mail_admins('Subject', 'Content', html_message='HTML Content') message = self.get_the_message() self.assertEqual(message.get('subject'), '[Django] Subject') self.assertEqual(message.get_all('to'), ...
[ "def", "test_html_mail_admins", "(", "self", ")", ":", "mail_admins", "(", "'Subject'", ",", "'Content'", ",", "html_message", "=", "'HTML Content'", ")", "message", "=", "self", ".", "get_the_message", "(", ")", "self", ".", "assertEqual", "(", "message", "."...
[ 541, 4 ]
[ 553, 80 ]
python
en
['en', 'en', 'en']
True
BaseEmailBackendTests.test_manager_and_admin_mail_prefix
(self)
String prefix + lazy translated subject = bad output Regression for #13494
String prefix + lazy translated subject = bad output Regression for #13494
def test_manager_and_admin_mail_prefix(self): """ String prefix + lazy translated subject = bad output Regression for #13494 """ mail_managers(ugettext_lazy('Subject'), 'Content') message = self.get_the_message() self.assertEqual(message.get('subject'), '[Django] ...
[ "def", "test_manager_and_admin_mail_prefix", "(", "self", ")", ":", "mail_managers", "(", "ugettext_lazy", "(", "'Subject'", ")", ",", "'Content'", ")", "message", "=", "self", ".", "get_the_message", "(", ")", "self", ".", "assertEqual", "(", "message", ".", ...
[ 558, 4 ]
[ 570, 68 ]
python
en
['en', 'error', 'th']
False
BaseEmailBackendTests.test_empty_admins
(self)
Test that mail_admins/mail_managers doesn't connect to the mail server if there are no recipients (#9383)
Test that mail_admins/mail_managers doesn't connect to the mail server if there are no recipients (#9383)
def test_empty_admins(self): """ Test that mail_admins/mail_managers doesn't connect to the mail server if there are no recipients (#9383) """ mail_admins('hi', 'there') self.assertEqual(self.get_mailbox_content(), []) mail_managers('hi', 'there') self.ass...
[ "def", "test_empty_admins", "(", "self", ")", ":", "mail_admins", "(", "'hi'", ",", "'there'", ")", "self", ".", "assertEqual", "(", "self", ".", "get_mailbox_content", "(", ")", ",", "[", "]", ")", "mail_managers", "(", "'hi'", ",", "'there'", ")", "sel...
[ 573, 4 ]
[ 581, 56 ]
python
en
['en', 'error', 'th']
False
BaseEmailBackendTests.test_message_cc_header
(self)
Regression test for #7722
Regression test for #7722
def test_message_cc_header(self): """ Regression test for #7722 """ email = EmailMessage('Subject', 'Content', 'from@example.com', ['to@example.com'], cc=['cc@example.com']) mail.get_connection().send_messages([email]) message = self.get_the_message() self.assertM...
[ "def", "test_message_cc_header", "(", "self", ")", ":", "email", "=", "EmailMessage", "(", "'Subject'", ",", "'Content'", ",", "'from@example.com'", ",", "[", "'to@example.com'", "]", ",", "cc", "=", "[", "'cc@example.com'", "]", ")", "mail", ".", "get_connect...
[ 583, 4 ]
[ 598, 54 ]
python
en
['en', 'error', 'th']
False
BaseEmailBackendTests.test_idn_send
(self)
Regression test for #14301
Regression test for #14301
def test_idn_send(self): """ Regression test for #14301 """ self.assertTrue(send_mail('Subject', 'Content', 'from@öäü.com', ['to@öäü.com'])) message = self.get_the_message() self.assertEqual(message.get('subject'), 'Subject') self.assertEqual(message.get('from'), ...
[ "def", "test_idn_send", "(", "self", ")", ":", "self", ".", "assertTrue", "(", "send_mail", "(", "'Subject'", ",", "'Content'", ",", "'from@öäü.com', [", "'", "o", "@öäü.com']))", "", "", "", "message", "=", "self", ".", "get_the_message", "(", ")", "self"...
[ 600, 4 ]
[ 618, 64 ]
python
en
['en', 'error', 'th']
False
BaseEmailBackendTests.test_recipient_without_domain
(self)
Regression test for #15042
Regression test for #15042
def test_recipient_without_domain(self): """ Regression test for #15042 """ self.assertTrue(send_mail("Subject", "Content", "tester", ["django"])) message = self.get_the_message() self.assertEqual(message.get('subject'), 'Subject') self.assertEqual(message.get('fr...
[ "def", "test_recipient_without_domain", "(", "self", ")", ":", "self", ".", "assertTrue", "(", "send_mail", "(", "\"Subject\"", ",", "\"Content\"", ",", "\"tester\"", ",", "[", "\"django\"", "]", ")", ")", "message", "=", "self", ".", "get_the_message", "(", ...
[ 620, 4 ]
[ 628, 53 ]
python
en
['en', 'error', 'th']
False
BaseEmailBackendTests.test_close_connection
(self)
Test that connection can be closed (even when not explicitly opened)
Test that connection can be closed (even when not explicitly opened)
def test_close_connection(self): """ Test that connection can be closed (even when not explicitly opened) """ conn = mail.get_connection(username='', password='') try: conn.close() except Exception as e: self.fail("close() unexpectedly raised an ex...
[ "def", "test_close_connection", "(", "self", ")", ":", "conn", "=", "mail", ".", "get_connection", "(", "username", "=", "''", ",", "password", "=", "''", ")", "try", ":", "conn", ".", "close", "(", ")", "except", "Exception", "as", "e", ":", "self", ...
[ 630, 4 ]
[ 638, 73 ]
python
en
['en', 'error', 'th']
False
BaseEmailBackendTests.test_use_as_contextmanager
(self)
Test that the connection can be used as a contextmanager.
Test that the connection can be used as a contextmanager.
def test_use_as_contextmanager(self): """ Test that the connection can be used as a contextmanager. """ opened = [False] closed = [False] conn = mail.get_connection(username='', password='') def open(): opened[0] = True conn.open = open ...
[ "def", "test_use_as_contextmanager", "(", "self", ")", ":", "opened", "=", "[", "False", "]", "closed", "=", "[", "False", "]", "conn", "=", "mail", ".", "get_connection", "(", "username", "=", "''", ",", "password", "=", "''", ")", "def", "open", "(",...
[ 640, 4 ]
[ 659, 34 ]
python
en
['en', 'error', 'th']
False
LocmemBackendTests.test_locmem_shared_messages
(self)
Make sure that the locmen backend populates the outbox.
Make sure that the locmen backend populates the outbox.
def test_locmem_shared_messages(self): """ Make sure that the locmen backend populates the outbox. """ connection = locmem.EmailBackend() connection2 = locmem.EmailBackend() email = EmailMessage('Subject', 'Content', 'bounce@example.com', ['to@example.com'], headers={'Fro...
[ "def", "test_locmem_shared_messages", "(", "self", ")", ":", "connection", "=", "locmem", ".", "EmailBackend", "(", ")", "connection2", "=", "locmem", ".", "EmailBackend", "(", ")", "email", "=", "EmailMessage", "(", "'Subject'", ",", "'Content'", ",", "'bounc...
[ 675, 4 ]
[ 684, 45 ]
python
en
['en', 'error', 'th']
False
FileBackendTests.test_file_sessions
(self)
Make sure opening a connection creates a new file
Make sure opening a connection creates a new file
def test_file_sessions(self): """Make sure opening a connection creates a new file""" msg = EmailMessage('Subject', 'Content', 'bounce@example.com', ['to@example.com'], headers={'From': 'from@example.com'}) connection = mail.get_connection() connection.send_messages([msg]) self....
[ "def", "test_file_sessions", "(", "self", ")", ":", "msg", "=", "EmailMessage", "(", "'Subject'", ",", "'Content'", ",", "'bounce@example.com'", ",", "[", "'to@example.com'", "]", ",", "headers", "=", "{", "'From'", ":", "'from@example.com'", "}", ")", "connec...
[ 718, 4 ]
[ 746, 26 ]
python
en
['en', 'en', 'en']
True
ConsoleBackendTests.test_console_stream_kwarg
(self)
Test that the console backend can be pointed at an arbitrary stream.
Test that the console backend can be pointed at an arbitrary stream.
def test_console_stream_kwarg(self): """ Test that the console backend can be pointed at an arbitrary stream. """ s = StringIO() connection = mail.get_connection('django.core.mail.backends.console.EmailBackend', stream=s) send_mail('Subject', 'Content', 'from@example.com'...
[ "def", "test_console_stream_kwarg", "(", "self", ")", ":", "s", "=", "StringIO", "(", ")", "connection", "=", "mail", ".", "get_connection", "(", "'django.core.mail.backends.console.EmailBackend'", ",", "stream", "=", "s", ")", "send_mail", "(", "'Subject'", ",", ...
[ 770, 4 ]
[ 785, 43 ]
python
en
['en', 'error', 'th']
False
SMTPBackendTests.test_auth_attempted
(self)
Test that opening the backend with non empty username/password tries to authenticate against the SMTP server.
Test that opening the backend with non empty username/password tries to authenticate against the SMTP server.
def test_auth_attempted(self): """ Test that opening the backend with non empty username/password tries to authenticate against the SMTP server. """ backend = smtp.EmailBackend( username='not empty username', password='not empty password') try: sel...
[ "def", "test_auth_attempted", "(", "self", ")", ":", "backend", "=", "smtp", ".", "EmailBackend", "(", "username", "=", "'not empty username'", ",", "password", "=", "'not empty password'", ")", "try", ":", "self", ".", "assertRaisesMessage", "(", "SMTPException",...
[ 907, 4 ]
[ 918, 27 ]
python
en
['en', 'error', 'th']
False
SMTPBackendTests.test_server_open
(self)
Test that open() tells us whether it opened a connection.
Test that open() tells us whether it opened a connection.
def test_server_open(self): """ Test that open() tells us whether it opened a connection. """ backend = smtp.EmailBackend(username='', password='') self.assertFalse(backend.connection) opened = backend.open() backend.close() self.assertTrue(opened)
[ "def", "test_server_open", "(", "self", ")", ":", "backend", "=", "smtp", ".", "EmailBackend", "(", "username", "=", "''", ",", "password", "=", "''", ")", "self", ".", "assertFalse", "(", "backend", ".", "connection", ")", "opened", "=", "backend", ".",...
[ 920, 4 ]
[ 928, 31 ]
python
en
['en', 'error', 'th']
False
SMTPBackendTests.test_server_stopped
(self)
Test that closing the backend while the SMTP server is stopped doesn't raise an exception.
Test that closing the backend while the SMTP server is stopped doesn't raise an exception.
def test_server_stopped(self): """ Test that closing the backend while the SMTP server is stopped doesn't raise an exception. """ backend = smtp.EmailBackend(username='', password='') backend.open() self.server.stop() try: backend.close() ...
[ "def", "test_server_stopped", "(", "self", ")", ":", "backend", "=", "smtp", ".", "EmailBackend", "(", "username", "=", "''", ",", "password", "=", "''", ")", "backend", ".", "open", "(", ")", "self", ".", "server", ".", "stop", "(", ")", "try", ":",...
[ 930, 4 ]
[ 941, 73 ]
python
en
['en', 'error', 'th']
False
SMTPBackendTests.test_connection_timeout_default
(self)
Test that the connection's timeout value is None by default.
Test that the connection's timeout value is None by default.
def test_connection_timeout_default(self): """Test that the connection's timeout value is None by default.""" connection = mail.get_connection('django.core.mail.backends.smtp.EmailBackend') self.assertEqual(connection.timeout, None)
[ "def", "test_connection_timeout_default", "(", "self", ")", ":", "connection", "=", "mail", ".", "get_connection", "(", "'django.core.mail.backends.smtp.EmailBackend'", ")", "self", ".", "assertEqual", "(", "connection", ".", "timeout", ",", "None", ")" ]
[ 1018, 4 ]
[ 1021, 50 ]
python
en
['en', 'en', 'en']
True
SMTPBackendTests.test_connection_timeout_custom
(self)
Test that the timeout parameter can be customized.
Test that the timeout parameter can be customized.
def test_connection_timeout_custom(self): """Test that the timeout parameter can be customized.""" class MyEmailBackend(smtp.EmailBackend): def __init__(self, *args, **kwargs): kwargs.setdefault('timeout', 42) super(MyEmailBackend, self).__init__(*args, **kwar...
[ "def", "test_connection_timeout_custom", "(", "self", ")", ":", "class", "MyEmailBackend", "(", "smtp", ".", "EmailBackend", ")", ":", "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", ...
[ 1023, 4 ]
[ 1034, 30 ]
python
en
['en', 'en', 'en']
True
import_string
(dotted_path)
Import a dotted module path and return the attribute/class designated by the last name in the path. Raise ImportError if the import failed.
Import a dotted module path and return the attribute/class designated by the last name in the path. Raise ImportError if the import failed.
def import_string(dotted_path): """ Import a dotted module path and return the attribute/class designated by the last name in the path. Raise ImportError if the import failed. """ try: module_path, class_name = dotted_path.rsplit('.', 1) except ValueError as err: raise ImportErro...
[ "def", "import_string", "(", "dotted_path", ")", ":", "try", ":", "module_path", ",", "class_name", "=", "dotted_path", ".", "rsplit", "(", "'.'", ",", "1", ")", "except", "ValueError", "as", "err", ":", "raise", "ImportError", "(", "\"%s doesn't look like a m...
[ 6, 0 ]
[ 23, 18 ]
python
en
['en', 'error', 'th']
False
autodiscover_modules
(*args, **kwargs)
Auto-discover INSTALLED_APPS modules and fail silently when not present. This forces an import on them to register any admin bits they may want. You may provide a register_to keyword parameter as a way to access a registry. This register_to object must have a _registry instance variable to acc...
Auto-discover INSTALLED_APPS modules and fail silently when not present. This forces an import on them to register any admin bits they may want.
def autodiscover_modules(*args, **kwargs): """ Auto-discover INSTALLED_APPS modules and fail silently when not present. This forces an import on them to register any admin bits they may want. You may provide a register_to keyword parameter as a way to access a registry. This register_to object ...
[ "def", "autodiscover_modules", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "django", ".", "apps", "import", "apps", "register_to", "=", "kwargs", ".", "get", "(", "'register_to'", ")", "for", "app_config", "in", "apps", ".", "get_app_confi...
[ 26, 0 ]
[ 59, 25 ]
python
en
['en', 'error', 'th']
False
module_has_submodule
(package, module_name)
See if 'module' is in 'package'.
See if 'module' is in 'package'.
def module_has_submodule(package, module_name): """See if 'module' is in 'package'.""" try: package_name = package.__name__ package_path = package.__path__ except AttributeError: # package isn't a package. return False full_module_name = package_name + '.' + module_name ...
[ "def", "module_has_submodule", "(", "package", ",", "module_name", ")", ":", "try", ":", "package_name", "=", "package", ".", "__name__", "package_path", "=", "package", ".", "__path__", "except", "AttributeError", ":", "# package isn't a package.", "return", "False...
[ 62, 0 ]
[ 78, 20 ]
python
en
['en', 'en', 'en']
True