-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
implement django tests with custom runner #22222
Conversation
This change will be permanent in the settings.py module, and on the other hand, I don't think it's a good idea for a plugin to allow itself to make such a change in one of the most important project files.
|
Aha! Fabulous, I must have missed the |
hello @mh-firouzjah, I have switched to using |
] | ||
print("Running Django run tests with command: ", command) | ||
try: | ||
subprocess.run(" ".join(command), shell=True, check=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a space as the join argument? I think I already put one in between the " but ill check
I reviewed the changes here, and what I understood from the code:
Awesome! Good job. But if these changes are not just to execute tests but also to discover tests as well(regarding the separation of these two jobs in the extension till now), as far as I know, the |
I was working on this patch. but reviewing your code here changed my mind. According to what I had there and what you brought here:
|
Thanks for your expertise! Ill look into the build_suite method for the discovery part as well! In terms of the UI, we are planning on having a way similar to what it is like now to setup Django testing. We are moving to a new style of how testing args work as proposed / discussed here: #21845. With this change we might be changing around our menu flow but I was thinking it would look something like this: click See below for how the Django env var would then show up in our proposed config json design:
|
hi👋 Now it seems because surly there will be a
Notice: test_list discovered by |
Hello again! Your suggestion for setting the DJANGO_SETTINGS_MODULE and call django.setup() sounds good to me. As I am not very familiar with Django can you provide an example where Django setup is required for test discovery? I am still trying to wrap my head around what setup provides for the actions taken during discovery. Secondly I updated the proposal to feature what we have discussed here. I would appreciate any comments you could add there on our discovery discussion as I did not include that just yet and wanted to instead continue our discussion on it either here or in that thread. Finally, I wanted to give you a bit of a timeline on this specific project. Due to scheduling, including a personal vacation and then housekeeping work in December I will not be able to make progress on this for the reminder of the calendar year. Additionally, since I want to implement this using env vars, those are currently not configurable with testing as of the rewrite and will require this proposal to be finalized and implemented. Once that is done we can then expose env vars for people to set and to enable this Django testing design. We are not sure on the timeline for the testing args proposal but it is a substantial change that will require input from many stakeholders and therefore do not think it would be done before March of next year. I cannot promise any dates but wanted to give you a heads up about the timeline and that this feature, as it is dependent on the proposal, will not be completed for some time. I am sorry about this as I know Django testing has been highly requested for a while but appreciate your patience in the next few months as we look to make architecture changes that will enable us to add Django support. Thanks |
Calling django.setup() is required for “standalone” Django usage
Since in the last shot, you fixed the test running problem by using a custom test-runner, I think what @carltongibson mentioned about taking care of database creation and tearing-down and so on, will be covered behind the since(well, it is basically what they did themselves:
|
makes sense! Thanks for your reply and therefore we will use your original recommendation around setup for discovery! |
Has there been any progress on this? Without this debugging testing process is currently painful. It would be useful to have this :) |
Hello! As an update I will be beginning development work on this next week! The previous blocker, custom args, has gotten delayed but we want to get working on this feature. If I end up needing to start a new PR I will attach that here. Thanks! |
closing in favor of #23935, please check this one out and give me your feedback! Thanks |
This PR is a working demo of how use a custom runner for Django which defines
kwargs["resultclass"] = UnittestTestResult
that allows for the results to get processed and sent exactly like unittest. This also allows for django tests to be run withpython manage.py test
so that setup and teardown work. This is an alternative solution to #21468 which allows the extension to run Django tests exactly like the command line.This is still an experiment, much more analysis will have to be conducted into if this is a feasible solution.