geocoders / geocoder-tester

Run search queries against a geocoder that supports geocodejson spec.
Other
40 stars 23 forks source link

How to run the test suite? #19

Closed karussell closed 6 years ago

karussell commented 6 years ago

Could you explain how one needs to install python3 with virtualenvs? I fear I messed something up as I currently get:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/_pytest/config.py", line 379, in _importconftest
    mod = conftestpath.pyimport()
  File "/usr/local/lib/python2.7/dist-packages/py/_path/local.py", line 662, in pyimport
    __import__(modname)
  File "/usr/local/lib/python2.7/dist-packages/_pytest/assertion/rewrite.py", line 212, in load_module
    py.builtin.exec_(co, mod.__dict__)
  File "/usr/local/lib/python2.7/dist-packages/py/_builtin.py", line 221, in exec_
    exec2(obj, globals, locals)
  File "<string>", line 7, in exec2
  File "/home/peter/Documents/quell/examples/geocoder-tester/conftest.py", line 8, in <module>
    from geocoder_tester.base import assert_search, CONFIG
  File "/home/peter/Documents/quell/examples/geocoder-tester/geocoder_tester/base.py", line 57
SyntaxError: Non-ASCII character '\xc2' in file /home/peter/Documents/quell/examples/geocoder-tester/geocoder_tester/base.py on line 57, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
ERROR: could not load /home/peter/Documents/quell/examples/geocoder-tester/conftest.py
yohanboniface commented 6 years ago

Could you explain how one needs to install python3 with virtualenvs?

Well, you need to install python 3 on your system, along python 2.7 if you have it. The virtualenv is for installing python package out of your system.

Which OS are you running?

karussell commented 6 years ago

My problem is that it is an 16.04 Ubuntu with python 2.7 and so some tools from apt rely on python 2.7 and I did not find a way to use python3 on my system without deinstalling 2.7.

yohanboniface commented 6 years ago

Humm, isn't Ubuntu 16.04 shipped with both Python 3 and Python 2 pre-installed? What do you have if you type python3 on your terminal?

karussell commented 6 years ago

Ah, ok. This works ... so how do I pick the correct python when executing .py files :) ?

karussell commented 6 years ago

(And what about the pip requirements?)

yohanboniface commented 6 years ago

Ah, ok. This works ... so how do I pick the correct python when executing .py files :) ?

This is how I'd do it on a fresh Ubuntu server:

# You can store the venv where ever you want
python3 -m venv path/of/your/choice
# each time you want to activate the virtualenv
source path/of/your/choice/bin/activate
# Once the venv is active,  install dependencies
pip install -r path/to/geocoder-tester/requirements.txt
# And then
py.test -h

You may use higher level tools (like mkvirtualenv or pyenv) but that recipe is simple enough for baby steps imho.

karussell commented 6 years ago

Thanks, this worked. How do I run all tests?

py.test --api-url 'http://photon.komoot.de/api?'
==================== test session starts ====================
platform linux -- Python 3.5.2, pytest-3.2.3, py-1.4.34, pluggy-0.4.0 -- /path/to../.python-venv/bin/python3
cachedir: .cache
rootdir: /path../geocoder-tester, inifile: pytest.ini
collected 0 items                                                                                                                                     

=================== no tests ran in 0.01 seconds =============
yohanboniface commented 6 years ago

You need to run py.test from the root for geocoder-tester, is it the case?

karussell commented 6 years ago

Sorry, I messed up the repo when I tried the python3 stuff. Now this works.