Git Product home page Git Product logo

Comments (4)

blueyed avatar blueyed commented on August 11, 2024

Since I've updated to 4.0.0 this no longer works.

Please elaborate: what does not work anymore?

from pytest-watch.

remcohaszing avatar remcohaszing commented on August 11, 2024

I have installed pytest-watch using

$ pip install --user pytest-watch
$ which ptw
/home/remco/.local/bin/ptw

Now if I create a virtualenv, install requirements in that virtualenv and then run ptw, the tests will fail because of import errors.

$ mktmpenv
...
(tmp-55b2a2e395dca7) $ pip install flask
Error: Could not run --collect-only to find the pytest config file. Trying again without silencing stdout...
...
ImportError: No module named 'flask'
ERROR: could not load /home/remco/someproject/tests/conftest.py

However, when downgrading pytest-watch to ~2.0.0, I can run this just fine.

$ pip install --user -U 'pytest-watch~=2.0.0'  # outside of virtualenv

Then in the virtualenv again:

(tmp-55b2a2e395dca7) $ ptw
=== test session starts ===
platform linux -- Python 3.5.1+, pytest-2.9.1, py-1.4.31, pluggy-0.3.1
rootdir: /home/remco/someproject, inifile: 
collected 1 item

tests/test_spam.py .

=== 1 passed in 0.01 seconds ===

Sorry for the late reaction.

from pytest-watch.

bkcsfi avatar bkcsfi commented on August 11, 2024

I have the same issue. This tool looks useful, I installed it via pipx because I only want one copy.

I thought the --runner option would solve my problem, but it does not. The program appears to import code directly rather than just executing the runner arg when files change.

Maybe I'm not using it correctly. Running pytest (which has been installed in the virtual env) works, but running ptw from outside does not work. (fish shell in example below)

$ ptw -v --runner (which pytest)
Locating inifile...
Error: Could not run --collect-only to handle the pytest config file. Trying again without silencing output...
ImportError while loading conftest '<redacted-path>/tests/conftest.py'.
tests/conftest.py:6: in <module>
    from sqlalchemy.orm import sessionmaker
E   ModuleNotFoundError: No module named 'sqlalchemy'

vs

$ pytest -v
================================================================================= test session starts ==================================================================================
platform linux -- Python 3.7.10, pytest-6.2.2, py-1.10.0, pluggy-0.13.1 -- <redacted-path>/bin/python
cachedir: .pytest_cache
rootdir: <redacted-path>
plugins: cov-2.11.1
collected 3 items                                                                                                                                                                      

tests/test_organization.py::TestOrganization::test_add_invalid_organization PASSED                                                                                               [ 33%]
tests/test_organization.py::TestOrganization::test_add_update_get_organization PASSED                                                                                            [ 66%]
tests/test_organization.py::TestOrganization::test_list_organizations PASSED                                                                                                     [100%

from pytest-watch.

iameru avatar iameru commented on August 11, 2024

I'll also chip in and say that I have a virtualenv, I used poetry to install pytest and pytest-watch. pytest works, pytest-watch seems to have the wrong path when invoked directly:

>>>  ptw                                                                                                                                     
Error: Could not run --collect-only to handle the pytest config file. Trying again without silencing output...
ImportError while loading conftest '/home/myself/flask_layout/tests/conftest.py'.
tests/conftest.py:3: in <module>
    from flask_layout import create_app
E   ModuleNotFoundError: No module named 'flask_layout'


>>>  python -m pytest-watch                                                                                                                 
/home/myself/.cache/pypoetry/virtualenvs/flask-layout-j2jffhM1-py3.10/bin/python: No module named pytest-watch

from pytest-watch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.