title: "py.test" vs "pytest" command
body: <p>The <code>py.test</code> command is failing in my case, whereas <code>pytest</code> is running totally fine.</p>
  
  <p>I use the pytest-flask plugin:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>When I invoke <code>$ py.test</code> I get the following error:</p>
  
  <pre><code>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 &lt;module&gt;
      from app.app import create_app
    File "/home/sebastian/develop/py/flask-rest-template/app/app.py", line 1, in &lt;module&gt;
      from flask import Flask
  ImportError: No module named 'flask'
  ERROR: could not load /home/sebastian/develop/py/flask-rest-template/conftest.py
  </code></pre>
  
  <p>This is my actual <code>conftest.py</code> file:</p>
  
  <pre><code>import pytest
  from app.app import create_app
  
  @pytest.fixture
  def app():
      app = create_app()
      return app
  </code></pre>
  
  <p>My project structure is as like:</p>
  
  <pre><code>.
  ├── app
  │   ├── __init__.py
  │   ├── app.py
  │   └── config.py   # flask configuration objects
  ├── conftest.py     # pytest configruation
  ├── requirements.txt
  ├── ...
  └── tests
      └── ...
  </code></pre>
  
  <p><strong>So, what is the difference between the two commands? And why is one failing and the other not?</strong></p>
  
  <hr>
  
  <p>update 1</p>
  
  <p>1) I had to change my relative imports <code>from .config import Config</code> or <code>from config import Config</code> to absolute ones like <code>from app.config import Config</code></p>
  
  <p>2) Running flask with <code>python3 -m app.app</code></p>
  
  <p>3) now <code>pytest</code> and <code>py.test</code> work normal</p>
  
  <p>Thank you very much for your help, folks!</p>
  
  <hr>
  
  <p>update 2</p>
  
  <p>This is getting weird... when using absolute imports, running python with the <code>-m</code> option and flask with <code>debug=True</code> then the <code>werkzeug</code> library is not reloading the sources as expected:</p>
  
  <p><a href="http://chase-seibert.github.io/blog/2015/06/12/flask-werkzeug-reloader-python-dash-m.html" rel="noreferrer">http://chase-seibert.github.io/blog/2015/06/12/flask-werkzeug-reloader-python-dash-m.html</a></p>
  
  <p><a href="https://github.com/pallets/werkzeug/issues/461" rel="noreferrer">https://github.com/pallets/werkzeug/issues/461</a></p>
  
  <p><a href="https://github.com/pallets/flask/issues/1246" rel="noreferrer">https://github.com/pallets/flask/issues/1246</a></p>
  
  <p>This helped me in my <code>app/app.py</code>:</p>
  
  <pre><code>if __name__ == '__main__':
      app.run(debug=True, use_reloader=False)
  </code></pre>
  
  <p>Then <code>python -m app.app</code> works fine.</p>