Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text dump instead of graph #91

Open
zyxue opened this issue Apr 26, 2016 · 13 comments
Open

text dump instead of graph #91

zyxue opened this issue Apr 26, 2016 · 13 comments
Labels

Comments

@zyxue
Copy link

zyxue commented Apr 26, 2016

I am seeing this instead of graph

\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m                                                               \x1b[32m98%...
Results (0.73s):
      85 passed

The dump is very very long. It's supposed to be rendered to graph. I am inside a docker container, what could be the reason, please? I have tested color display, it's ok. The 85 passed part is in green.

@The-Compiler
Copy link

Do you run docker with -it - if not, does that change anything?

@zyxue
Copy link
Author

zyxue commented Apr 27, 2016

Yes, I specified --rm -t -i, and then py.test interactively inside the docker container.

@dobesv
Copy link

dobesv commented May 10, 2016

I'm seeing the same issue if I run tests inside docker, it looks like it is escaping the control character as \x1b perhaps? Very odd. I am using docker run -it ...

@dobesv
Copy link

dobesv commented May 11, 2016

Here's some more data points:

>>> import sys
>>> sys.stdout.encoding
'ANSI_X3.4-1968'
>>> import py.io
>>> tw = py.io.TerminalWriter(sys.stdout)
>>> tw.write(u'\r \x1b[36mfilename.py\x1b[0mtest_name\x1b[0m \x1b[32m\u2713\x1b[0m\n\n')
\r \x1b[36mfilename.py\x1b[0mtest_name\x1b[0m \x1b[32m\u2713\x1b[0m\n\n>>> 

Note how when the encoding is 'ANSI_X3.4-1968' it puts in the escape characters.

Outside of docker this works fine:

>>> import sys
>>> sys.stdout.encoding
'UTF-8'
>>> import py.io
>>> py.io.TerminalWriter(sys.stdout).write(u'\r \x1b[36mtest_file.py\x1b[0mtest_name\x1b[0m \x1b[32m\u2713\x1b[0m\n\n')
 test_file.test_name ✓

@dobesv
Copy link

dobesv commented May 11, 2016

Workaround:

# PYTHONIOENCODING=UTF-8 python
>>> import sys
>>> sys.stdout.encoding
'UTF-8'
>>> import py.io
>>> py.io.TerminalWriter(sys.stdout).write(u'\r \x1b[36mtest_file.py\x1b[0mtest_name\x1b[0m \x1b[32m\u2713\x1b[0m\n\n')
 test_file.pytest_name ✓

So, setting PYTHONIOENCODING=UTF-8 seems to resolve the problem, as long as your terminal actually supports UTF-8 encoding.

@dobesv
Copy link

dobesv commented May 11, 2016

I do wish I knew why sys.stdout.encoding was UTF-8 outside docker and ANSI_X3.4-1968 within.

@The-Compiler
Copy link

ANSI_X3.4-1968 is a fancy way to say ASCII, so I'm guessing locale will show a C locale inside docker, i.e. the locale was not generated/configured properly.

@dobesv
Copy link

dobesv commented May 12, 2016

Inside docker:

root@d4cf4ef0c83f:/# locale
LANG=
LANGUAGE=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=

Outside docker:

$ locale
LANG=en_CA.UTF-8
LANGUAGE=
LC_CTYPE="en_CA.UTF-8"
LC_NUMERIC="en_CA.UTF-8"
LC_TIME="en_CA.UTF-8"
LC_COLLATE="en_CA.UTF-8"
LC_MONETARY="en_CA.UTF-8"
LC_MESSAGES="en_CA.UTF-8"
LC_PAPER="en_CA.UTF-8"
LC_NAME="en_CA.UTF-8"
LC_ADDRESS="en_CA.UTF-8"
LC_TELEPHONE="en_CA.UTF-8"
LC_MEASUREMENT="en_CA.UTF-8"
LC_IDENTIFICATION="en_CA.UTF-8"
LC_ALL=

Anyway, it this point it's pretty clearly a docker issue, not a pytest-sugar issue. This issue should hopefully serve as a reference for other who run into this problem.

@dobesv
Copy link

dobesv commented May 12, 2016

Or instead of setting PYTHONIOENCODING, setting up the locale correctly in the Dockerfile should work, and might help with other things that rely on locale as well:

# Set the locale
RUN locale-gen en_US.UTF-8  
ENV LANG en_US.UTF-8  
ENV LANGUAGE en_US:en  
ENV LC_ALL en_US.UTF-8  

(from http://jaredmarkell.com/docker-and-locales/)

@nlamirault
Copy link

I've got this error too without using Docker but Tox.

$ tox -r  -epy27                                                                                                                                               
py27 recreate: /home/vagrant/Cloud/git/nimbus-sirocco/.tox/py27
py27 installdeps: -r/home/vagrant/Cloud/git/nimbus-sirocco/requirements.txt, -r/home/vagrant/Cloud/git/nimbus-sirocco/requirements-test.txt
py27 installed: apache-libcloud==0.14.0,cffi==1.6.0,cookies==2.2.1,coverage==4.1,cryptography==1.3.2,enum34==1.1.6,flasgger==0.5.12,Flask==0.10.1,Flask-Cache==0.13.1,flup6==1.1,functools32==3.2.3.post2,idna==2.1,ipaddress==1.0.16,itsdangerous==0.24,Jinja2==2.8,jsonschema==2.5.1,ldap3==0.9.8.4,libraries==3.2.2,MarkupSafe==0.23,mistune==0.7.2,mock==1.0.1,mysql-connector-python==2.0.4,netaddr==0.7.18,py==1.4.31,pyasn1==0.1.9,pycparser==2.14,pyOpenSSL==0.15.1,pytest==2.9.2,pytest-cov==2.2.0,pytest-sugar==0.7.1,pyvmomi==6.0.0.2016.4,PyYAML==3.11,requests==2.7.0,responses==0.5.1,six==1.9.0,termcolor==1.1.0,vmware-api==3.16.0,Werkzeug==0.11.10
py27 runtests: PYTHONHASHSEED='2820986654'
py27 runtests: commands[0] | py.test --ignore=venv
Test session starts (platform: linux2, Python 2.7.10, pytest 2.9.2, pytest-sugar 0.7.1)
rootdir: /home/vagrant/Cloud/git/nimbus-sirocco, inifile: 
plugins: cov-2.2.0, sugar-0.7.1

\r \x1b[36mnimbussirocco/integration_tests/api/v1/\x1b[0mtest_api_catalog.py\x1b[0m \x1b[32m\u2713\x1b[0m                                                                                                                                          \x1b[32m1% \x1b[0m\x1b[40m\x1b[32m\u258f\x1b[0m\x1b[40m\x1b[32m         \x1b[0m\r \x1b[36mnimbussirocco/integration_tests/api/v1/\x1b[0mtest_api_catalog.py\x1b[0m \x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m                                                                                                                                         \x1b[32m1% \x1b[0m\x1b[40m\x1b[32m\u258e\x1b[0m\x1b

But if i use directly py.test it works :

$ .tox/py27/bin/py.test --ignore=venv
Test session starts (platform: linux2, Python 2.7.10, pytest 2.9.2, pytest-sugar 0.7.1)
rootdir: /home/vagrant/Cloud/git/nimbus-sirocco, inifile: 
plugins: cov-2.2.0, sugar-0.7.1

 nimbussirocco/integration_tests/api/v1/test_api_catalog.py ✓✓                                                                                                                                         1% ▎         

Any idea how fix that ?

@zyxue
Copy link
Author

zyxue commented Jun 22, 2016

Just to add that this happens when the test is run on a jenkins server, as well if the output is sent to the browser.

@Sup3rGeo
Copy link

Same thing happens to me on Windows 10 cmd.

@Teemu
Copy link
Owner

Teemu commented Oct 17, 2018

@Sup3rGeo You might wanna take a look into #49 (comment)

@Teemu Teemu added the question label Aug 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants