2

I'm writing, in Python, a class that emulates a numeric types. I'd like to have some numerous doctests, as well as to have no pycodestyle warning from pylava.

Here is my difficulty.

For the following doctest

        Traceback (most recent call last):
            ...
        TypeError: Only RiemannSphere, integers or floats can be added to a RiemannSphere

I've got a warning from pylava, because my line TypeError: ...is too long.

Is someone knows how to cut it into two lines even if it is in a doctest?

Thanks,

1 Answers1

2

I've just found out a nice solution, using ELLIPSIS:

The initial doctest was:

        >>> 1j / z1
        Traceback (most recent call last):
            ...
        TypeError: Only RiemannSphere, integers or floats can be added to a RiemannSphere

Using the # doctest: +ELLIPSIS directive, this can be written shortly:

        >>> 1j / z1
        ... # doctest: +ELLIPSIS
        Traceback (most recent call last):
            ...
        TypeError: Only a RiemannSphere, ... divided by a RiemannSphere number

Consequently, it's now easy to change the message in the Traceback so that pylava does not give warning.