Comments (4)
Since I've updated to 4.0.0 this no longer works.
Please elaborate: what does not work anymore?
from pytest-watch.
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.
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.
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)
- broken link in the README: saythanks
- How to use with poetry? HOT 3
- Run ptw with -s HOT 3
- pytest watch seems to fail when pyproject.toml is used as a config file HOT 7
- Logging error when running pytest in pytest-watch HOT 1
- Integration with pytest-cov HOT 2
- My ptw doesn't "watch" subdirectories
- Running from "python -m pytest_watch" does not add current path to PYTHONPATH HOT 1
- ignore `Client.dataset is deprecated` warnings
- Maintenance Status? HOT 4
- pytest 7.0: AttributeError: 'dict' object has no attribute 'config' HOT 3
- error:'str' object has no attribute 'plate_num'
- Specify `python_requires` in the distribution package metadata
- Runner argument not parsed correctly on windows
- Error in Python 3.10: `module 'collections' has no attribute 'MutableSet'` HOT 5
- `ImportError` when running tests using `ptw` HOT 2
- Directories passed to pytest-watch are also passed to pytest, but shouldn't be
- sdist is missing LICENSE
- When I install pytest-watch with Python 3.11 and pip 22.3.1 I see deprecation warning HOT 1
- GO TO PYTEST-WATCHER HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytest-watch.