Skip to content

Add doctest option for allowing splitting strings without whitespaces #138135

@picnixz

Description

@picnixz

Feature or enhancement

Proposal:

The NORMALIZE_WHITESPACE option allows to split long output into multiple lines but this doesn't work with strings that do not have whitespaces. For instance:

>>> ok = "foo bar"
>>> ok  # doctest: +NORMALIZE_WHITESPACE
'foo
bar'

>>> fail = "foobar"
>>> fail  # doctest: +NORMALIZE_WHITESPACE
'foo
bar'

I suggest adding an option to handle very long strings (I don't think we should extend NORMALIZE_WHITESPACE as someone might want the new line in the output to match a whitespace). It would be possible to use +ELLIPSIS but sometimes I find myself wanting to match the entire string (e.g., when the output is deterministic but looks random).

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

Labels

stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions