mercredi 14 septembre 2016

"py.test" vs "pytest" command

The py.test command is failing in my case, whereas the pytest on the console is running totaly fine. I use the pytest-flask plugin.

platform linux -- Python 3.5.2, pytest-3.0.2, py-1.4.31, pluggy-0.3.1
rootdir: /home/sebastian/develop/py/flask-rest-template, inifile: 
plugins: flask-0.10.0

When I invoke $ py.test I get the following error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 301, in _getconftestmodules
    return self._path2confmods[path]
KeyError: local('/home/sebastian/develop/py/flask-rest-template')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 332, in _importconftest
    return self._conftestpath2mod[conftestpath]
KeyError: local('/home/sebastian/develop/py/flask-rest-template/conftest.py')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/_pytest/config.py", line 338, in _importconftest
    mod = conftestpath.pyimport()
  File "/usr/local/lib/python3.5/dist-packages/py/_path/local.py", line 650, in pyimport
    __import__(modname)
  File "/usr/local/lib/python3.5/dist-packages/_pytest/assertion/rewrite.py", line 207, in load_module
    py.builtin.exec_(co, mod.__dict__)
  File "/home/sebastian/develop/py/flask-rest-template/conftest.py", line 2, in <module>
    from app.app import create_app
  File "/home/sebastian/develop/py/flask-rest-template/app/app.py", line 1, in <module>
    from flask import Flask
ImportError: No module named 'flask'
ERROR: could not load /home/sebastian/develop/py/flask-rest-template/conftest.py

This is my actual conftest.py file:

import pytest
from app.app import create_app

@pytest.fixture
def app():
    app = create_app()
    return app

My project structure is as like:

.
├── app
│   └── app.py
├── conftest.py
├── requirements.txt
├── ...
└── tests
    └── ...

So what is the difference between the two commands?

Aucun commentaire:

Enregistrer un commentaire