#36720 closed Uncategorized (worksforme)
Printing how many tests found when running tests
| Reported by: | אורי | Owned by: | |
|---|---|---|---|
| Component: | Testing framework | Version: | 5.2 |
| Severity: | Normal | Keywords: | |
| Cc: | אורי | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Hi,
When I run tests in Django up to 5.1.*, Django prints "Found 798 test(s)." before running the tests. But in Django 5.2.*, Django prints "Found 798 test(s)." after running the tests. Since running the tests may take a long time, I would like Django to print the number of tests found before running the tests. This is a regression in Django 5.2. Is it possible to revert this change, at least in future versions of Django?
By the way, why "test(s)"? It should be "test" if the number is one or otherwise "tests".
Change History (7)
comment:1 by , 3 weeks ago
| Resolution: | → worksforme |
|---|---|
| Status: | new → closed |
comment:2 by , 3 weeks ago
I've seen some unexpectedly ordered test runner output in the past. I think it may have something to do with output buffer flushing and the fact that some output uses logging while other output uses print().
follow-up: 5 comment:3 by , 3 weeks ago
Hi,
Compare the following runs and see the versions of Django in pip freeze. It's quite consistent. When Django version >= 5.2 then it prints "Found 6398 test(s)." after the tests, otherwise it prints it before the tests. And also notice what I wrote about test(s), isn't it time to switch to test and tests?
https://github.com/speedy-net/speedy-net/actions/runs/19144998415/job/54720135356
https://github.com/speedy-net/speedy-net/actions/runs/17116743422/job/48549258817
https://github.com/speedy-net/speedy-net/actions/runs/17902974616/job/50899034080
https://github.com/speedy-net/speedy-net/actions/runs/17850504625/job/50757984152
https://github.com/speedy-net/speedy-net/actions/runs/16956025009/job/48058313847
Thanks,
Uri.
follow-up: 6 comment:4 by , 3 weeks ago
There are a lot of variables at play, here, custom test runners, logger configuration, so we can't infer that the version of Django has a regression.
Have you tried with altering your logging setup or with setting PYTHONUNBUFFERED = 1?
And also notice what I wrote about test(s), isn't it time to switch to test and tests?
A PR for that would be fine, but we don't need to have a ticket for it, nothing is strictly wrong with it.
comment:5 by , 3 weeks ago
Replying to אורי:
Hi,
Compare the following runs and see the versions of Django in pip freeze. It's quite consistent. When Django version >= 5.2 then it prints "Found 6398 test(s)." after the tests, otherwise it prints it before the tests.
Hello! This is not what I see locally when running the tests. I have tried the Django test suite and also running tests in other projects. I have tried Python 3.12, 3.13, and 3.14.
We can't debug in your project, I'm sorry, we need you to provide a minimal Django sample project or a failing test case for us to be able to accept/advance this ticket. You can also reach out in the forum to ask for debugging help.
comment:6 by , 3 weeks ago
Replying to Jacob Walls:
Have you tried with altering your logging setup or with setting
PYTHONUNBUFFERED = 1?
It looks like adding PYTHONUNBUFFERED=1 solves the problem. We are checking this now.
comment:7 by , 3 weeks ago
PYTHONUNBUFFERED=1 solves this problem locally and on GitHub tests. So there is no need to do anything else.
Do you have any additional information to reproduce? Could not reproduce at 2501958b5127020411df6271445ccfd0906df70e nor 5.2.8.