neulab/docprompting-conala huggingface dataset:
doctest.DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None, setUp=None, tearDown=None, checker=None)  
Convert doctest tests for a module to a unittest.TestSuite. The returned unittest.TestSuite is to be run by the unittest framework and runs each doctest in the module. If any of the doctests fail, then the synthesized unit test fails, and a failureException exception is raised showing the name of the file containing the test and a (sometimes approximate) line number. Optional argument module provides the module to be tested. It can be a module object or a (possibly dotted) module name. If not specified, the module calling this function is used. Optional argument globs is a dictionary containing the initial global variables for the tests. A new copy of this dictionary is created for each test. By default, globs is a new empty dictionary. Optional argument extraglobs specifies an extra set of global variables, which is merged into globs. By default, no extra globals are used. Optional argument test_finder is the DocTestFinder object (or a drop-in replacement) that is used to extract doctests from the module. Optional arguments setUp, tearDown, and optionflags are the same as for function DocFileSuite() above. This function uses the same search technique as testmod().  Changed in version 3.5: DocTestSuite() returns an empty unittest.TestSuite if module contains no docstrings instead of raising ValueError.
doctest.DONT_ACCEPT_BLANKLINE  
By default, if an expected output block contains a line containing only the string <BLANKLINE>, then that line will match a blank line in the actual output. Because a genuinely blank line delimits the expected output, this is the only way to communicate that a blank line is expected. When DONT_ACCEPT_BLANKLINE is specified, this substitution is not allowed.
doctest.DONT_ACCEPT_TRUE_FOR_1  
By default, if an expected output block contains just 1, an actual output block containing just 1 or just True is considered to be a match, and similarly for 0 versus False. When DONT_ACCEPT_TRUE_FOR_1 is specified, neither substitution is allowed. The default behavior caters to that Python changed the return type of many functions from integer to boolean; doctests expecting “little integer” output still work in these cases. This option will probably go away, but not for several years.
doctest.ELLIPSIS  
When specified, an ellipsis marker (...) in the expected output can match any substring in the actual output. This includes substrings that span line boundaries, and empty substrings, so it’s best to keep usage of this simple. Complicated uses can lead to the same kinds of “oops, it matched too much!” surprises that .* is prone to in regular expressions.
class doctest.Example(source, want, exc_msg=None, lineno=0, indent=0, options=None)  
A single interactive example, consisting of a Python statement and its expected output. The constructor arguments are used to initialize the attributes of the same names. Example defines the following attributes. They are initialized by the constructor, and should not be modified directly.  
source  
A string containing the example’s source code. This source code consists of a single Python statement, and always ends with a newline; the constructor adds a newline when necessary. 
  
want  
The expected output from running the example’s source code (either from stdout, or a traceback in case of exception). want ends with a newline unless no output is expected, in which case it’s an empty string. The constructor adds a newline when necessary. 
  
exc_msg  
The exception message generated by the example, if the example is expected to generate an exception; or None if it is not expected to generate an exception. This exception message is compared against the return value of traceback.format_exception_only(). exc_msg ends with a newline unless it’s None. The constructor adds a newline if needed. 
  
lineno  
The line number within the string containing this example where the example begins. This line number is zero-based with respect to the beginning of the containing string. 
  
indent  
The example’s indentation in the containing string, i.e., the number of space characters that precede the example’s first prompt. 
  
options  
A dictionary mapping from option flags to True or False, which is used to override default options for this example. Any option flags not contained in this dictionary are left at their default value (as specified by the DocTestRunner’s optionflags). By default, no options are set.
exc_msg  
The exception message generated by the example, if the example is expected to generate an exception; or None if it is not expected to generate an exception. This exception message is compared against the return value of traceback.format_exception_only(). exc_msg ends with a newline unless it’s None. The constructor adds a newline if needed.
indent  
The example’s indentation in the containing string, i.e., the number of space characters that precede the example’s first prompt.
lineno  
The line number within the string containing this example where the example begins. This line number is zero-based with respect to the beginning of the containing string.
options  
A dictionary mapping from option flags to True or False, which is used to override default options for this example. Any option flags not contained in this dictionary are left at their default value (as specified by the DocTestRunner’s optionflags). By default, no options are set.
source  
A string containing the example’s source code. This source code consists of a single Python statement, and always ends with a newline; the constructor adds a newline when necessary.
want  
The expected output from running the example’s source code (either from stdout, or a traceback in case of exception). want ends with a newline unless no output is expected, in which case it’s an empty string. The constructor adds a newline when necessary.
doctest.FAIL_FAST  
When specified, exit after the first failing example and don’t attempt to run the remaining examples. Thus, the number of failures reported will be at most 1. This flag may be useful during debugging, since examples after the first failure won’t even produce debugging output. The doctest command line accepts the option -f as a shorthand for -o
FAIL_FAST.  New in version 3.4.
doctest.IGNORE_EXCEPTION_DETAIL  
When specified, an example that expects an exception passes if an exception of the expected type is raised, even if the exception detail does not match. For example, an example expecting ValueError: 42 will pass if the actual exception raised is ValueError: 3*14, but will fail, e.g., if TypeError is raised. It will also ignore the module name used in Python 3 doctest reports. Hence both of these variations will work with the flag specified, regardless of whether the test is run under Python 2.7 or Python 3.2 (or later versions): >>> raise CustomError('message')
Traceback (most recent call last):
CustomError: message

>>> raise CustomError('message')
Traceback (most recent call last):
my_module.CustomError: message
 Note that ELLIPSIS can also be used to ignore the details of the exception message, but such a test may still fail based on whether or not the module details are printed as part of the exception name. Using IGNORE_EXCEPTION_DETAIL and the details from Python 2.3 is also the only clear way to write a doctest that doesn’t care about the exception detail yet continues to pass under Python 2.3 or earlier (those releases do not support doctest directives and ignore them as irrelevant comments). For example: >>> (1, 2)[3] = 'moo'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: object doesn't support item assignment
 passes under Python 2.3 and later Python versions with the flag specified, even though the detail changed in Python 2.4 to say “does not” instead of “doesn’t”.  Changed in version 3.2: IGNORE_EXCEPTION_DETAIL now also ignores any information relating to the module containing the exception under test.
doctest.NORMALIZE_WHITESPACE  
When specified, all sequences of whitespace (blanks and newlines) are treated as equal. Any sequence of whitespace within the expected output will match any sequence of whitespace within the actual output. By default, whitespace must match exactly. NORMALIZE_WHITESPACE is especially useful when a line of expected output is very long, and you want to wrap it across multiple lines in your source.
class doctest.OutputChecker  
A class used to check the whether the actual output from a doctest example matches the expected output. OutputChecker defines two methods: check_output(), which compares a given pair of outputs, and returns True if they match; and output_difference(), which returns a string describing the differences between two outputs. OutputChecker defines the following methods:  
check_output(want, got, optionflags)  
Return True iff the actual output from an example (got) matches the expected output (want). These strings are always considered to match if they are identical; but depending on what option flags the test runner is using, several non-exact match types are also possible. See section Option Flags for more information about option flags. 
  
output_difference(example, got, optionflags)  
Return a string describing the differences between the expected output for a given example (example) and the actual output (got). optionflags is the set of option flags used to compare want and got.
check_output(want, got, optionflags)  
Return True iff the actual output from an example (got) matches the expected output (want). These strings are always considered to match if they are identical; but depending on what option flags the test runner is using, several non-exact match types are also possible. See section Option Flags for more information about option flags.
output_difference(example, got, optionflags)  
Return a string describing the differences between the expected output for a given example (example) and the actual output (got). optionflags is the set of option flags used to compare want and got.
doctest.register_optionflag(name)  
Create a new option flag with a given name, and return the new flag’s integer value. register_optionflag() can be used when subclassing OutputChecker or DocTestRunner to create new options that are supported by your subclasses. register_optionflag() should always be called using the following idiom: MY_FLAG = register_optionflag('MY_FLAG')
doctest.REPORTING_FLAGS  
A bitmask or’ing together all the reporting flags above.
doctest.REPORT_CDIFF  
When specified, failures that involve multi-line expected and actual outputs will be displayed using a context diff.
doctest.REPORT_NDIFF  
When specified, differences are computed by difflib.Differ, using the same algorithm as the popular ndiff.py utility. This is the only method that marks differences within lines as well as across lines. For example, if a line of expected output contains digit 1 where actual output contains letter l, a line is inserted with a caret marking the mismatching column positions.
doctest.REPORT_ONLY_FIRST_FAILURE  
When specified, display the first failing example in each doctest, but suppress output for all remaining examples. This will prevent doctest from reporting correct examples that break because of earlier failures; but it might also hide incorrect examples that fail independently of the first failure. When REPORT_ONLY_FIRST_FAILURE is specified, the remaining examples are still run, and still count towards the total number of failures reported; only the output is suppressed.
doctest.REPORT_UDIFF  
When specified, failures that involve multi-line expected and actual outputs are displayed using a unified diff.
doctest.run_docstring_examples(f, globs, verbose=False, name="NoName", compileflags=None, optionflags=0)  
Test examples associated with object f; for example, f may be a string, a module, a function, or a class object. A shallow copy of dictionary argument globs is used for the execution context. Optional argument name is used in failure messages, and defaults to "NoName". If optional argument verbose is true, output is generated even if there are no failures. By default, output is generated only in case of an example failure. Optional argument compileflags gives the set of flags that should be used by the Python compiler when running the examples. By default, or if None, flags are deduced corresponding to the set of future features found in globs. Optional argument optionflags works as for function testfile() above.
doctest.script_from_examples(s)  
Convert text with examples to a script. Argument s is a string containing doctest examples. The string is converted to a Python script, where doctest examples in s are converted to regular code, and everything else is converted to Python comments. The generated script is returned as a string. For example, import doctest
print(doctest.script_from_examples(r"""
    Set x and y to 1 and 2.
    >>> x, y = 1, 2

    Print their sum:
    >>> print(x+y)
    3
"""))
 displays: # Set x and y to 1 and 2.
x, y = 1, 2
#
# Print their sum:
print(x+y)
# Expected:
## 3
 This function is used internally by other functions (see below), but can also be useful when you want to transform an interactive Python session into a Python script.
doctest.set_unittest_reportflags(flags)  
Set the doctest reporting flags to use. Argument flags takes the bitwise OR of option flags. See section Option Flags. Only “reporting flags” can be used. This is a module-global setting, and affects all future doctests run by module unittest: the runTest() method of DocTestCase looks at the option flags specified for the test case when the DocTestCase instance was constructed. If no reporting flags were specified (which is the typical and expected case), doctest’s unittest reporting flags are bitwise ORed into the option flags, and the option flags so augmented are passed to the DocTestRunner instance created to run the doctest. If any reporting flags were specified when the DocTestCase instance was constructed, doctest’s unittest reporting flags are ignored. The value of the unittest reporting flags in effect before the function was called is returned by the function.
doctest.SKIP  
When specified, do not run the example at all. This can be useful in contexts where doctest examples serve as both documentation and test cases, and an example should be included for documentation purposes, but should not be checked. E.g., the example’s output might be random; or the example might depend on resources which would be unavailable to the test driver. The SKIP flag can also be used for temporarily “commenting out” examples.
doctest.testmod(m=None, name=None, globs=None, verbose=None, report=True, optionflags=0, extraglobs=None, raise_on_error=False, exclude_empty=False)  
All arguments are optional, and all except for m should be specified in keyword form. Test examples in docstrings in functions and classes reachable from module m (or module __main__ if m is not supplied or is None), starting with m.__doc__. Also test examples reachable from dict m.__test__, if it exists and is not None. m.__test__ maps names (strings) to functions, classes and strings; function and class docstrings are searched for examples; strings are searched directly, as if they were docstrings. Only docstrings attached to objects belonging to module m are searched. Return (failure_count, test_count). Optional argument name gives the name of the module; by default, or if None, m.__name__ is used. Optional argument exclude_empty defaults to false. If true, objects for which no doctests are found are excluded from consideration. The default is a backward compatibility hack, so that code still using doctest.master.summarize() in conjunction with testmod() continues to get output for objects with no tests. The exclude_empty argument to the newer DocTestFinder constructor defaults to true. Optional arguments extraglobs, verbose, report, optionflags, raise_on_error, and globs are the same as for function testfile() above, except that globs defaults to m.__dict__.
doctest.testsource(module, name)  
Convert the doctest for an object to a script. Argument module is a module object, or dotted name of a module, containing the object whose doctests are of interest. Argument name is the name (within the module) of the object with the doctests of interest. The result is a string, containing the object’s docstring converted to a Python script, as described for script_from_examples() above. For example, if module a.py contains a top-level function f(), then import a, doctest
print(doctest.testsource(a, "a.f"))
 prints a script version of function f()’s docstring, with doctests converted to code, and the rest placed in comments.
exception doctest.UnexpectedException(test, example, exc_info)  
An exception raised by DocTestRunner to signal that a doctest example raised an unexpected exception. The constructor arguments are used to initialize the attributes of the same names.
UnexpectedException.exc_info  
A tuple containing information about the unexpected exception, as returned by sys.exc_info().
UnexpectedException.test  
The DocTest object that was being run when the example failed.
Ellipsis  
The same as the ellipsis literal “...”. Special value used mostly in conjunction with extended slicing syntax for user-defined container data types.
email.charset.add_alias(alias, canonical)  
Add a character set alias. alias is the alias name, e.g. latin-1. canonical is the character set’s canonical name, e.g. iso-8859-1. The global charset alias registry is kept in the module global dictionary ALIASES.
email.charset.add_charset(charset, header_enc=None, body_enc=None, output_charset=None)  
Add character properties to the global registry. charset is the input character set, and must be the canonical name of a character set. Optional header_enc and body_enc is either Charset.QP for quoted-printable, Charset.BASE64 for base64 encoding, Charset.SHORTEST for the shortest of quoted-printable or base64 encoding, or None for no encoding. SHORTEST is only valid for header_enc. The default is None for no encoding. Optional output_charset is the character set that the output should be in. Conversions will proceed from input charset, to Unicode, to the output charset when the method Charset.convert() is called. The default is to output in the same character set as the input. Both input_charset and output_charset must have Unicode codec entries in the module’s character set-to-codec mapping; use add_codec() to add codecs the module does not know about. See the codecs module’s documentation for more information. The global character set registry is kept in the module global dictionary CHARSETS.
email.charset.add_codec(charset, codecname)  
Add a codec that map characters in the given character set to and from Unicode. charset is the canonical name of a character set. codecname is the name of a Python codec, as appropriate for the second argument to the str’s encode() method.
body_encode(string)  
Body-encode the string string. The type of encoding (base64 or quoted-printable) will be based on the body_encoding attribute.
body_encoding  
Same as header_encoding, but describes the encoding for the mail message’s body, which indeed may be different than the header encoding. Charset.SHORTEST is not allowed for body_encoding.
get_body_encoding()  
Return the content transfer encoding used for body encoding. This is either the string quoted-printable or base64 depending on the encoding used, or it is a function, in which case you should call the function with a single argument, the Message object being encoded. The function should then set the Content-Transfer-Encoding header itself to whatever is appropriate. Returns the string quoted-printable if body_encoding is QP, returns the string base64 if body_encoding is BASE64, and returns the string 7bit otherwise.
get_output_charset()  
Return the output character set. This is the output_charset attribute if that is not None, otherwise it is input_charset.
header_encode(string)  
Header-encode the string string. The type of encoding (base64 or quoted-printable) will be based on the header_encoding attribute.
header_encode_lines(string, maxlengths)  
Header-encode a string by converting it first to bytes. This is similar to header_encode() except that the string is fit into maximum line lengths as given by the argument maxlengths, which must be an iterator: each element returned from this iterator will provide the next maximum line length.
header_encoding  
If the character set must be encoded before it can be used in an email header, this attribute will be set to Charset.QP (for quoted-printable), Charset.BASE64 (for base64 encoding), or Charset.SHORTEST for the shortest of QP or BASE64 encoding. Otherwise, it will be None.
input_charset  
The initial character set specified. Common aliases are converted to their official email names (e.g. latin_1 is converted to iso-8859-1). Defaults to 7-bit us-ascii.
input_codec  
The name of the Python codec used to convert the input_charset to Unicode. If no conversion codec is necessary, this attribute will be None.
output_charset  
Some character sets must be converted before they can be used in email headers or bodies. If the input_charset is one of them, this attribute will contain the name of the character set output will be converted to. Otherwise, it will be None.
output_codec  
The name of the Python codec used to convert Unicode to the output_charset. If no conversion codec is necessary, this attribute will have the same value as the input_codec.
__str__()  
Returns input_charset as a string coerced to lower case. __repr__() is an alias for __str__().
class email.contentmanager.ContentManager  
Base class for content managers. Provides the standard registry mechanisms to register converters between MIME content and other representations, as well as the get_content and set_content dispatch methods.  
get_content(msg, *args, **kw)  
Look up a handler function based on the mimetype of msg (see next paragraph), call it, passing through all arguments, and return the result of the call. The expectation is that the handler will extract the payload from msg and return an object that encodes information about the extracted data. To find the handler, look for the following keys in the registry, stopping with the first one found:  the string representing the full MIME type (maintype/subtype) the string representing the maintype
 the empty string  If none of these keys produce a handler, raise a KeyError for the full MIME type. 
  
set_content(msg, obj, *args, **kw)  
If the maintype is multipart, raise a TypeError; otherwise look up a handler function based on the type of obj (see next paragraph), call clear_content() on the msg, and call the handler function, passing through all arguments. The expectation is that the handler will transform and store obj into msg, possibly making other changes to msg as well, such as adding various MIME headers to encode information needed to interpret the stored data. To find the handler, obtain the type of obj (typ = type(obj)), and look for the following keys in the registry, stopping with the first one found:  the type itself (typ) the type’s fully qualified name (typ.__module__ + '.' +
typ.__qualname__). the type’s qualname (typ.__qualname__) the type’s name (typ.__name__).  If none of the above match, repeat all of the checks above for each of the types in the MRO (typ.__mro__). Finally, if no other key yields a handler, check for a handler for the key None. If there is no handler for None, raise a KeyError for the fully qualified name of the type. Also add a MIME-Version header if one is not present (see also MIMEPart). 
  
add_get_handler(key, handler)  
Record the function handler as the handler for key. For the possible values of key, see get_content(). 
  
add_set_handler(typekey, handler)  
Record handler as the function to call when an object of a type matching typekey is passed to set_content(). For the possible values of typekey, see set_content().
add_get_handler(key, handler)  
Record the function handler as the handler for key. For the possible values of key, see get_content().