Comments (3)
This could solve the problem currently I'm facing (or not sure I'm dealing it wrong). I'm trying to use this with pytest-django
. My environment variables are in a separate file(s), and I'm loading them through from my manage.py
file like below.
try:
ENV = os.environ['ENV']
with open('project/envs/env.' + ENV) as envfile:
for line in envfile:
if line.strip():
setting = line.strip().split('=', maxsplit=1)
os.environ.setdefault(setting[0], setting[1])
except KeyError:
print('ENV Key Not Provided')
except FileNotFoundError as e:
print('ENV File Doesn\'t Exist')
So ENV=test(/dev) python manage.py .....
will load my required ENV file before it loads settings.py
.
By following pytest-django 's documentation, I've created a Test Runner class
and TEST_RUNNER
in my settings.py
. This also works fine as expected by running the same command above ENV=test python manage.py test
.
Trying to introduce pytest-watch
here doesn't do the trick for me. It always trying to load the settings.py
file and fails as there are no ENV variables. I also tried to move the above code inside my custom_test_runner.py
file and run with --runner "python custom_test_runner.py"
but it still trying to load the settings.py
even before it executes the custom_test_runner
.
from pytest-watch.
@dacodekid
Just curious: why do you use TEST_RUNNER
. It is easier to run just pytest
by itself.
Check out https://github.com/jezdez/envdir/ for env(dir) handling.
from pytest-watch.
@blueyed I was aware of that package as my settings.py
is based on this article which suggests envdir
(original one). But I was skeptical about having one file per setting. For now I choose xdist
as my alternate. Still think pytest-watch
as a plugin would make more sense than its current form.
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.