Opened 3 weeks ago

Closed 3 weeks ago

Last modified 3 weeks ago

#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 Jacob Walls, 3 weeks ago

Resolution: worksforme
Status: newclosed

Do you have any additional information to reproduce? Could not reproduce at 2501958b5127020411df6271445ccfd0906df70e nor 5.2.8.

python3 manage.py test
Found 43 test(s).
Creating test database for alias 'default'...

comment:2 by Tim Graham, 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().

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

If you can't view the above logs when you're logged in to GitHub, write me your username on GitHub and I will add you to our repository as a reader.

Thanks,
Uri.

Last edited 3 weeks ago by אורי (previous) (diff)

comment:4 by Jacob Walls, 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.

in reply to:  3 comment:5 by Natalia Bidart, 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.

in reply to:  4 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.

Note: See TracTickets for help on using tickets.
Back to Top