vendredi 5 août 2016

pytest unicode syntaxerror with '£' symbol

I have a test file: test_pytest.py:

def test_pytest():
    s = '£'
    assert True

Using pytest, I run it like this: python -m pytest test_pytest.py

The result:

> python -m pytest test_pytest.py
============================= test session starts =============================
platform win32 -- Python 3.5.2, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
rootdir: c:\temp, inifile:
collected 0 items / 1 errors

=================================== ERRORS ====================================
_______________________ ERROR collecting test_pytest.py _______________________
c:\projects\aio-rpc\venv\lib\site-packages\_pytest\python.py:611: in _importtestmodule
    mod = self.fspath.pyimport(ensuresyspath=importmode)
c:\projects\aio-rpc\venv\lib\site-packages\py\_path\local.py:650: in pyimport
    __import__(modname)
E     File "c:\temp\test_pytest.py", line 3
E   SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xa3 in position 0: invalid start byte
=========================== 1 error in 0.07 seconds ===========================

What gives?

Note that commenting the s='£' allows the test to pass

Aucun commentaire:

Enregistrer un commentaire