How to insert trailing spaces in a doctest, so that it doesn't fail even when actual and expected result look the same? How to insert trailing spaces in a doctest, so that it doesn't fail even when actual and expected result look the same? python python

How to insert trailing spaces in a doctest, so that it doesn't fail even when actual and expected result look the same?


I found a solution, using the normalize white space flag

put it either in the doctest as

    >>> print new_data_variable # doctest: +NORMALIZE_WHITESPACE

or when calling the doctest

doctest.testmod( optionflags= doctest.NORMALIZE_WHITESPACE )