All my files start with #-*- coding: utf-8 -*-
My virtualenv is set to python 3.5, virtualenv -p python3 venv
My app hierarchy looks like this :
app/app/[file].py
__init__.py
/tests/test_[file].py
/__init__.py
main.py
python --version
is 3.5 (venv is active)
If I python main.py
and uses sys.getdefaultencoding()
and print("é")
everyting is fine, i get :
> utf-8
and
> é
Under /tests, if i nosetests
i get errors related to unicode, which is normal since sys.getdefaultencoding()
gives me :
ascii
which pip
, which nosetests
and which python
all points to my venv.
Why would nose default to ascii when everything is not?
pip freeze
:
appdirs==1.4.2
beautifulsoup4==4.5.3
nose==1.3.7
packaging==16.8
pkg-resources==0.0.0
pyparsing==2.1.10
requests==2.13.0
six==1.10.0
Edit:
An example of nose error would be :
TypeError: descriptor 'strip' requires a 'str' object but received a 'unicode'
. I get why the error is happening, my misunderstanding is why only nose is doing it. I'm on Ubuntu 16.04.
Python 2.7 nose default installation on my system was in fault.
Without being in venv, i pip uninstall nose
. Then i activated my virtualenv which is using Python 3.5. Being in my venv, nose could then only choose nosetests from it. It worked!
It seems nosetests was prioritizing "global" nose before the specific one. I still don't know why it was this way.