-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert all tests to pytest #468
Comments
Is this consistent with Django's testing guidelines? It appears to prefer unittest. This is, after all, a Django-centric project. |
what we use internally for testing doesn't affect the user so that's up to DJA to decide. We simply have to make sure that a DJA user can use unittest to write tests. DJA already supports this by allowing DRF testing configuration. Why pytest over unittest: Also see pytest-django for more details. |
I guess my point is that as a "Django developer" I would prefer to use the Django core mechanism for testing unless there's a strong reason to do otherwise. I have found the tests in DJA to be quite confusing given the mixture of styles. But I don't have a lot of experience with python testing frameworks.... |
Whenever I review PRs or write PRs myself the most apparent issue of DJA is that the testing code is very messy and confusing for contributors how to write a test and where. The issues I see at this point:
I might have some time at hand to work on this. First I want though that we agree on how to do it before I start. Following points I see as a way forward:
This can be done gradually. So test module by test module can be moved to tests and converted to pytest. Once all is done the example app can be cleaned up @n2ygk This issue has been open for a while and the main issue here I guess was whether we can agree on converting tests to pytest . My point is that pytest has been around quite a while in the Python community and has been well established. In my experience it makes writing tests much simpler. And if we take the effort to clean up the tests we should also take the opportunity to convert them to pytest style. What is your take on this? Also comment on what you think is important when cleaning up the tests which I might not have mentioned yet. |
@sliverc I agree with all your points 100%. |
django rest framework suggest pytest like asserts |
anything required? or we are ok to close it |
there is actually a long way till this issue is closed. Goal is that all tests in |
if you want helping hand i can do some. i did something like this to DRF |
you can use me as helping hand. |
@auvipy Thanks for the offer. Currently it is not 100% clear how the conversions of the tests will happen. So usually while I am converting some tests I figure out on the way best practices. So for now I think it makes most sense I keep working on it. I think at a later stage help to work on a cleaning-up example app would certainly be appreciated. But this cannot happen as long as the tests are still depending on the example app. |
ok. |
Currently some tests are written in unit test and some in pytest.
As pytest is more flexible all tests should be converted to use pytest to be consistent.
It also needs to be considered whether
pytest_runner
in setup.py is really a good thing or whether just simply runningpytest
would not be more "pytesty".The text was updated successfully, but these errors were encountered: