Failures when running Django test suite on main with Python 3.12.3

Hi everyone!

I’m setting up Django locally to start contributing. I cloned the repository and ran the full test suite on the main branch without making any code changes on linux (ubuntu 24.04).

.

I got this response at the end with some error stack trace:

Ran 18993 tests in 323.469s

FAILED (failures=2, errors=1, skipped=1402, expected failures=5)

.
The formatted errors using llm due to readability are:

1. SMTP Email Error
Test:
mail.tests.SMTPBackendTests.test_avoids_sending_to_invalid_addresses
Error:
Crashes inside Python’s standard email/_header_value_parser.py with email.errors.HeaderParseError: expected ':' at end of group display name but found '@', followed by an IndexError: string index out of range.

2. HTML Strip Tags Error
Test:
utils_tests.test_html.TestUtilsHtml.test_strip_tags
Error:
Fails with an AssertionError on two highly malformed HTML strings (><!&&&&... and ><a<a<a...). It looks like the output from Python’s built-in html.parser doesn’t match the hardcoded test assertions.

.
Question:
Are these known compatibility issues between Python 3.12.3’s stricter parsers and the current test assertions on main?
Should I just exclude these specific tests locally for now, or is there an environment configuration I might be missing?

Thanks.

My advice to you would be to run the latest version of Python 3.12, since Django doesn’t officially support older point releases.

The SMTP test hasn’t been edited to try to take these variances into account. The strip_tags test has – we’ve swapped expected results based on the point release of python.

If you can demonstrate that we’ve missed one, you could open a pull request with a fix, but it’s not the highest impact area for contributions, as we’ll be dropping support for 3.12 in about a year.

Thanks for guiding!
I switched my python version to 3.13.8. And no test failed.

Ran 18993 tests in 349.950s
OK (skipped=1402, expected failures=5)

Kindly guide me about skipped tests. I have 1402 skipped tests. In the blog, skipped tests are due to missing external libraries. So, should I have to install those external libraries?

Should I have to make skipped=0 and expected failures=0?
OR can I start making changes?

At this point you’ve demonstrated a working setup. I would get on with development and only worry about running other skipped tests if they become relevant to the area you’re working in, like GIS or caching.

1 Like