Fix unit tests for Python 3.11

Bug #2002012 reported by Lena Voytek
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-django (Ubuntu)
Fix Released
Undecided
Lena Voytek

Bug Description

When building Django for Lunar, which will be using Python 3.11, some unit tests fail. This causes a build failure, such as with the most recent merge:

https://launchpadlibrarian.net/638379708/buildlog_ubuntu-lunar-amd64.python-django_3%3A3.2.16-1_BUILDING.txt.gz

This is due to a change with the unittest library where, when printing self, it now also shows the runTest function name with the class. For example, with the following code:

from unittest import TestCase
class SimpleTestcase(TestCase):
    def test_foo(self):
     print(self)

t = SimpleTestcase()
t.test_foo()

in Python 3.10 "runTest (__main__.SimpleTestcase)" is printed; while in Python 3.11 "runTest (__main__.SimpleTestcase.runTest)" is printed.

This breaks the tests:
test_add_failing_subtests
test_skip_if_db_feature
test_skip_unless_db_feature
test_output_verbose

Related branches

Lena Voytek (lvoytek)
Changed in python-django (Ubuntu):
status: New → In Progress
assignee: nobody → Lena Voytek (lvoytek)
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-django - 3:3.2.16-1ubuntu1

---------------
python-django (3:3.2.16-1ubuntu1) lunar; urgency=medium

  * d/p/0012-Add-Python-3.11-support-for-tests.patch: Make unit tests
    compatible with Python 3.11 to fix build errors (LP: #2002012)

 -- Lena Voytek <email address hidden> Fri, 06 Jan 2023 11:02:03 -0700

Changed in python-django (Ubuntu):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.