Skip to content

UnicodeDecodeError in invalid assert statement #1331

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

Closed
pelme opened this issue Jan 15, 2016 · 3 comments
Closed

UnicodeDecodeError in invalid assert statement #1331

pelme opened this issue Jan 15, 2016 · 3 comments
Labels
type: bug problem that needs to be addressed

Comments

@pelme
Copy link
Member

pelme commented Jan 15, 2016

‹tempenv-55e831397233f› ~ → cat test_foo.py
# -*- coding: utf-8 -*-
assert 'ål', in 'a'
‹tempenv-55e831397233f› ~ → py.test --version
This is pytest version 2.8.5, imported from /Users/andreas/.virtualenvs/tempenv-55e831397233f/lib/python2.7/site-packages/pytest.pyc
‹tempenv-55e831397233f› ~ → py.test test_foo.py
================================================= test session starts ==================================================
platform darwin -- Python 2.7.10, pytest-2.8.5, py-1.4.31, pluggy-0.3.1
rootdir: /Users/andreas, inifile:
collected 0 items / 1 errors

======================================================== ERRORS ========================================================
_____________________________________________ ERROR collecting test_foo.py _____________________________________________
.virtualenvs/tempenv-55e831397233f/lib/python2.7/site-packages/py/_code/code.py:412: in getrepr
    return fmt.repr_excinfo(self)
.virtualenvs/tempenv-55e831397233f/lib/python2.7/site-packages/py/_code/code.py:590: in repr_excinfo
    reprtraceback = self.repr_traceback(excinfo)
.virtualenvs/tempenv-55e831397233f/lib/python2.7/site-packages/py/_code/code.py:582: in repr_traceback
    reprentry = self.repr_traceback_entry(entry, einfo)
.virtualenvs/tempenv-55e831397233f/lib/python2.7/site-packages/py/_code/code.py:543: in repr_traceback_entry
    s = self.get_source(source, line_index, excinfo, short=short)
.virtualenvs/tempenv-55e831397233f/lib/python2.7/site-packages/py/_code/code.py:489: in get_source
    lines.extend(self.get_exconly(excinfo, indent=indent, markall=True))
.virtualenvs/tempenv-55e831397233f/lib/python2.7/site-packages/py/_code/code.py:496: in get_exconly
    exlines = excinfo.exconly(tryshort=True).split('\n')
.virtualenvs/tempenv-55e831397233f/lib/python2.7/site-packages/py/_code/code.py:376: in exconly
    text = ''.join(lines)
E   UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 12: ordinal not in range(128)
=============================================== 1 error in 0.16 seconds ================================================
‹tempenv-55e831397233f› ~ → python test_foo.py
  File "test_foo.py", line 2
    assert 'ål', in 'a'
                   ^
SyntaxError: invalid syntax

The example is obviously not valid Python syntax and broken, but pytest should raise a SyntaxError.

@nicoddemus nicoddemus added the type: bug problem that needs to be addressed label Jan 15, 2016
@nicoddemus
Copy link
Member

Thanks! 😄

Related to #103.

@decentral1se
Copy link
Contributor

Well, #103 is closed off and the following happens:

$ pytest --version
This is pytest version 3.0.4 ...
$ echo "# -*- coding: utf-8 -*-\nassert 'ål', in 'a'" > test_foo.py | pytest
=================================================================================================================== ERRORS ====================================================================================================================
________________________________________________________________________________________________________ ERROR collecting test_foo.py _________________________________________________________________________________________________________
.venv/lib/python3.5/site-packages/_pytest/python.py:415: in _importtestmodule
    mod = self.fspath.pyimport(ensuresyspath=importmode)
.venv/lib/python3.5/site-packages/py/_path/local.py:650: in pyimport
    __import__(modname)
E     File "/home/lwm/hobby/pytest/test_foo.py", line 2
E       assert 'ål', in 'a'
E                     ^
E   SyntaxError: invalid syntax
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=========================================================================================================== 1 error in 1.63 seconds ===========================================================================================================

Looks like this one can be closed off!

@nicoddemus
Copy link
Member

@lwm thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

3 participants