Documentation of doctestprinter

doctestprinter contains convenience functions to print outputs more adequate for doctests.

Example features:

  • removes trailing whitespaces: pandas.DataFrame generates trailing whitespaces, which interferes with auto text ‘trailing whitespace’ removal features, leading to failed tests.

  • maximum line width: break long sequences at whitespaces to a paragraph.

my_module

Indices and tables

Installation

Either install the current release from pip …

pip install doctestprinter

… or the latest development state of the gitlab repository.

$ pip install git+https://gitlab.com/david.scheliga/doctestprinter.git@dev --upgrade

doctestprinter.doctest_print(anything_to_print)

The general printing method for doctests.

doctestprinter.doctest_iter_print(…[, …])

Prints the first level of the iterable or mapping.

doctestprinter.EditingItem(editor, …)

EditingItem is a wrapper class for the edit_item argument of doctest_iter_print().

doctestprinter.prepare_print(anything_to_print)

Prepares anything for printing.

doctestprinter.prepare_pandas([…])

Builds explicitly string representations for pandas.DataFrame and pandas.Series objects.

doctestprinter.print_pandas([…])

Prints explicitly pandas.DataFrame and pandas.Series objects.

doctestprinter.round_collections(item_to_round)

Rounds items within collections (dict, list, tuple).

doctestprinter.repr_posix_path(any_path)

Represents the path on a Windows machine as a Posix-Path representation turning back slashes to forward slashes.

doctestprinter.set_in_quotes(item)

Set the string represenation of anything in quotes.

doctestprinter.strip_base_path(…)

Strips the given base path from the path to show and performing repr_posix_path() on the result.

doctestprinter.strip_trailing_tabs(text)

Strips trailing tabs from the text.

doctestprinter.strip_trailing_whitespaces(text)

Strips trailing whitespaces from the text.

doctestprinter.strip_trailing_whitespaces_and_tabs(text)

Strips both trailing whitespaces and tabs from the text.