byexamples / byexamples/byexample

Optional +norm-ws as strip (+strip-ws may be?)

Open
#40 2 comments 0 reactions 0 assignees View on GitHub
enhancement good first issue
Dominant language
Python
Stars
67
Forks
9
PR merge metrics
No merged PRs in 30d

Description

The option ``+norm-ws`` ignores the whitespace during the compare phase but it does not modify neither the expected nor the got outputs in any way.

This is critical if both strings have whitespace as integral part of their (like using indentation to make the string more easier to see and understand).
So preserving the whitespace is important when a test fails and we need to show a diff.

However there are cases where this is not desired.

For example:
```python
>>> [1, 2, 3, 4, 0, 6]
[1, 2, 3,
4, 5, 6]
```

The example will fail and the diff (``+diff ndiff``) will show:
```python
Differences:
+ [1, 2, 3, 4, 0, 6]
- [1, 2, 3,
- 4, 5, 6]
```

This is because the got output doesn't contain the extra newline between numbers 3 and 4.

If the whitespace is stripped off from the expected and got outputs (the whitespaces are not preserved), the diff should be:
```python
Differences:
- [1, 2, 3, 4, 5, 6]
? ^

+ [1, 2, 3, 4, 0, 6]
? ^
```

We should allow the user to control this with a flag probably introduced in a ``Concern``, may be in the same that in #39 .

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.