Open blueyed opened 5 years ago
Hi,
Do you mean that pytest-django gets used always when installed systemwide? (there would be -p no:django to disable it)
That's it. You see, I maintain a number of Django apps alongside with non Django related applications. In such a case installing pytest-django
system wide seems useful but testing non-Django related apps leads to a forementioned side effects with wierd tracebacks. -p
workaround would require me to adopt
that option in config in an unrelated project. Why should I bother?
I found this very useful, especially with new projects - where it showed more than once that some validation could/should be done before any DB access.
That would depend on an approach. I prefer thick
models: if a feature clearly belongs to a certain model and only to it, there's no reason to factor it out (except maybe for test, but writing code for tests instead of writing tests for code, it's not what I want to do). It seems unfortunate that pytest-django
would require to mark a test with db
even if a model method under test doesn't perform any db hit at all.
And it is easy to work around by having e.g. an auto-use fixture that requests db. But maybe also adding an option for this might be worth it, not sure.
Once again the workaround is known, but why should I workaround at all. I would rather prefer a mark to ensure that there are no db hits in certain test than vice versa.
To wrap it up: taking aside fixtures, it's design decisions and scaffolding features (useful for testing mainly reusable apps rather than Django projects as a whole) that differ pytest-djangoapp
from pytest-django
.
Thanks for your clarifications.
It seems unfortunate that
pytest-django
would require to mark a test withdb
even if a model method under test doesn't perform any db hit at all.
That shouldn't be the case, i.e. it only blocks DB connections really - not models in general. (But depending on the methods used there you might actually use the DB connection then.)
Hi, just found this plugin, and read this in the README:
Can you elaborate on this? Do you mean that pytest-django gets used always when installed systemwide? (there would be
-p no:django
to disable it)I found this very useful, especially with new projects - where it showed more than once that some validation could/should be done before any DB access.
And it is easy to work around by having e.g. an auto-use fixture that requests
db
. But maybe also adding an option for this might be worth it, not sure. Typically you end up using fixtures, which then just themselves requestdb
already.