killocircles.blogg.se

Python indent block pycharm
Python indent block pycharm










python indent block pycharm
  1. #Python indent block pycharm code#
  2. #Python indent block pycharm trial#

> assert "Easy!" > import math > math.floor(1.9) 1Īnd as many leading whitespace characters are stripped from the expected outputĪs appeared in the initial '> ' line that started the example.īy default, each time doctest finds a docstring to test, it uses a Preserve your backslashes exactly as you type them: Other reason use a backslash, you should use a raw docstring, which will If you continue a line via backslashing in an interactive session, or for any Output to stdout is captured, but not output to stderr (exception tracebacks It is possible to use a differentĪlgorithm for handling tabs by writing a custom DocTestParser class.

#Python indent block pycharm trial#

Source was arrived at through trial and error, and has proven to be the leastĮrror prone way of handling them. To an expected value as part of the test. Output includes hard tabs, the only way the doctest can pass is if theĪlternatively, the test can be rewritten to capture the output and compare it

#Python indent block pycharm code#

Hard tabs in the sample output are expanded, this means that if the code

python indent block pycharm python indent block pycharm

Tabs in output generated by the tested code are not modified. If expected output does contain aīlank line, put in your doctest example each place a blank lineĪll hard tab characters are expanded to spaces, using 8-column tab stops. Taken to signal the end of expected output. Line containing the code, and the expected output (if any) extends to the nextĮxpected output cannot contain an all-whitespace line, since such a line is no NO NO!!! >Īny expected output must immediately follow the final '> ' or '. > # comments are ignored > x = 12 > x 12 > if x = 13. Strings are treated as if they were docstrings. In addition, if M._test_ exists and “is true”, it must be a dict, and eachĮntry maps a (string) name to a function object, class object, or string.įunction and class object docstrings found from M._test_ are searched, and Objects imported into the module are not searched. The module docstring, and all function, class and method docstrings are Information about actually running doctest on these examples, see the following This is the information that you need to know to write doctest examples for Handles exceptions, and how option flags can be used to control its behavior. How it finds interactive examples, what execution context it uses, how it This section examines in detail how doctest works: which docstrings it looks at, It must be run with testfile(), not testmod().įor more information on testfile(), see section Basic API. If you run example.py directly from the command line, doctestīecause the file name does not end with. floor ( n ) != n : raise ValueError ( "n must be exact integer" ) if n + 1 = n : # catch a value like 1e300 raise OverflowError ( "n too large" ) result = 1 factor = 2 while factor <= n : result *= factor factor += 1 return result if _name_ = "_main_" : import doctest doctest. OverflowError: n too large """ import math if not n >= 0 : raise ValueError ( "n must be >= 0" ) if math. ValueError: n must be exact integer > factorial(30.0) 265252859812191058636308480000000 It must also not be ridiculously large: > factorial(1e100) Traceback (most recent call last). ValueError: n must be >= 0 Factorials of floats are OK, but the float must be an exact integer: > factorial(30.1) Traceback (most recent call last). For example, > factorial(5) 120 """ def factorial ( n ): """Return the factorial of n, an exact integer >= 0.

python indent block pycharm

The example module supplies one function, factorial().












Python indent block pycharm