hjwp / hjwp/pytest-icdiff

Strange characters in output, even with colors disabled

Open
#35 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
329
Forks
16
PR merge metrics
No merged PRs in 30d

Description

I'm writing the output of of my tests to a log file that is visualized on a website. The UI does not support color so I'm running:

```
pytest ... --color=no > /tmp/test.log
```

If I `cat /tmp/test.log` the output looks OK.

```
self =

def foo(self):
# ...

> assert bar == {
"anId": "a53ffeb6-99b0-4a03-8fb3-278c2559efad",
"anotherId": "9d7a0b13-c92e-45f2-abc4-f260087516a7",
}
E AssertionError: assert equals failed
E { {
E - 'anId': 'e7dcba1a-d545-437c-8947-9d901729b51a', + 'anId': 'a53ffeb6-99b0-4a03-8fb3-278c2559efad',
E - 'anotherId': '34f4eeab-1f1b-4d41-8421-d87b80000f8f', + 'anotherId': '9d7a0b13-c92e-45f2-abc4-f260087516a7',
E } }
```

There's no colors on the output, which is expected.

But in my Web UI these strange `#x00` and `#x01` characters appear:

```
self =

def foo(self):
# ...

> assert bar == {
"anId": "a53ffeb6-99b0-4a03-8fb3-278c2559efad",
"anotherId": "9d7a0b13-c92e-45f2-abc4-f260087516a7",
}
E AssertionError: assert equals failed
E { {
E #x00- 'anId': 'e7dcba1a-d545-437c-8947-9d901729b51a',#x01 #x00+ 'anId': 'a53ffeb6-99b0-4a03-8fb3-278c2559efad,#x01
E #x00- 'anotherId': '34f4eeab-1f1b-4d41-8421-d87b80000f8f',#x01 #x00+ 'anotherId': '9d7a0b13-c92e-45f2-abc4-f260087516a7',#x01
E }
```

Also if I `cat -A` instead of just `cat` I can see some of these invisible characters, which show up as `^A` and `^@`

```
self =

def foo(self):
# ...

> assert bar == {
"anId": "a53ffeb6-99b0-4a03-8fb3-278c2559efad",
"anotherId": "9d7a0b13-c92e-45f2-abc4-f260087516a7",
}
E AssertionError: assert equals failed
E { {
E ^@- 'anId': 'e7dcba1a-d545-437c-8947-9d901729b51a',^A ^@+ 'anId': 'a53ffeb6-99b0-4a03-8fb3-278c2559efad',^A
E ^@- 'anotherId': '34f4eeab-1f1b-4d41-8421-d87b80000f8f',^A ^@+ 'anotherId': '9d7a0b13-c92e-45f2-abc4-f260087516a7',^A
E }
```

What are these? how can I get rid of them?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.