From 3e58a92dacd86d0d7d6158f9ce5c9ed6bfc48256 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Wed, 23 Apr 2025 09:43:30 +0200 Subject: [PATCH] Fix bug in unittest-xml-reporting on Python 3.11+ --- ...test-xml-reporting-3.1.0-GCCcore-12.3.0.eb | 7 +++- ...test-xml-reporting-3.1.0-GCCcore-13.2.0.eb | 7 +++- ...test-xml-reporting-3.1.0-GCCcore-13.3.0.eb | 7 +++- ...test-xml-reporting-3.1.0-GCCcore-14.2.0.eb | 7 +++- ...3.1.0_fix-getDescription-python-3.11.patch | 41 +++++++++++++++++++ 5 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 easybuild/easyconfigs/u/unittest-xml-reporting/unittest-xml-reporting-3.1.0_fix-getDescription-python-3.11.patch diff --git a/easybuild/easyconfigs/u/unittest-xml-reporting/unittest-xml-reporting-3.1.0-GCCcore-12.3.0.eb b/easybuild/easyconfigs/u/unittest-xml-reporting/unittest-xml-reporting-3.1.0-GCCcore-12.3.0.eb index eb8a88ae341..20289a5b00f 100644 --- a/easybuild/easyconfigs/u/unittest-xml-reporting/unittest-xml-reporting-3.1.0-GCCcore-12.3.0.eb +++ b/easybuild/easyconfigs/u/unittest-xml-reporting/unittest-xml-reporting-3.1.0-GCCcore-12.3.0.eb @@ -10,7 +10,12 @@ The files can be consumed by a wide range of tools, such as build systems, IDEs toolchain = {'name': 'GCCcore', 'version': '12.3.0'} sources = [SOURCE_TAR_GZ] -checksums = ['c6178ad2d782c5c21d129758f089fd26da2cba8428cf2905994aa105a13fb317'] +patches = ['unittest-xml-reporting-3.1.0_fix-getDescription-python-3.11.patch'] +checksums = [ + {'unittest-xml-reporting-3.1.0.tar.gz': 'c6178ad2d782c5c21d129758f089fd26da2cba8428cf2905994aa105a13fb317'}, + {'unittest-xml-reporting-3.1.0_fix-getDescription-python-3.11.patch': + '0be7cd72e25ffab26df2997ddc95124f99eb789715172f3433a4608bedd0a441'} +] builddependencies = [('binutils', '2.40')] dependencies = [ diff --git a/easybuild/easyconfigs/u/unittest-xml-reporting/unittest-xml-reporting-3.1.0-GCCcore-13.2.0.eb b/easybuild/easyconfigs/u/unittest-xml-reporting/unittest-xml-reporting-3.1.0-GCCcore-13.2.0.eb index 008cc3351f5..72873a5d815 100644 --- a/easybuild/easyconfigs/u/unittest-xml-reporting/unittest-xml-reporting-3.1.0-GCCcore-13.2.0.eb +++ b/easybuild/easyconfigs/u/unittest-xml-reporting/unittest-xml-reporting-3.1.0-GCCcore-13.2.0.eb @@ -10,7 +10,12 @@ The files can be consumed by a wide range of tools, such as build systems, IDEs toolchain = {'name': 'GCCcore', 'version': '13.2.0'} sources = [SOURCE_TAR_GZ] -checksums = ['c6178ad2d782c5c21d129758f089fd26da2cba8428cf2905994aa105a13fb317'] +patches = ['unittest-xml-reporting-3.1.0_fix-getDescription-python-3.11.patch'] +checksums = [ + {'unittest-xml-reporting-3.1.0.tar.gz': 'c6178ad2d782c5c21d129758f089fd26da2cba8428cf2905994aa105a13fb317'}, + {'unittest-xml-reporting-3.1.0_fix-getDescription-python-3.11.patch': + '0be7cd72e25ffab26df2997ddc95124f99eb789715172f3433a4608bedd0a441'} +] builddependencies = [('binutils', '2.40')] dependencies = [ diff --git a/easybuild/easyconfigs/u/unittest-xml-reporting/unittest-xml-reporting-3.1.0-GCCcore-13.3.0.eb b/easybuild/easyconfigs/u/unittest-xml-reporting/unittest-xml-reporting-3.1.0-GCCcore-13.3.0.eb index 258983d94b4..ffdee724f27 100644 --- a/easybuild/easyconfigs/u/unittest-xml-reporting/unittest-xml-reporting-3.1.0-GCCcore-13.3.0.eb +++ b/easybuild/easyconfigs/u/unittest-xml-reporting/unittest-xml-reporting-3.1.0-GCCcore-13.3.0.eb @@ -10,7 +10,12 @@ The files can be consumed by a wide range of tools, such as build systems, IDEs toolchain = {'name': 'GCCcore', 'version': '13.3.0'} sources = [SOURCE_TAR_GZ] -checksums = ['c6178ad2d782c5c21d129758f089fd26da2cba8428cf2905994aa105a13fb317'] +patches = ['unittest-xml-reporting-3.1.0_fix-getDescription-python-3.11.patch'] +checksums = [ + {'unittest-xml-reporting-3.1.0.tar.gz': 'c6178ad2d782c5c21d129758f089fd26da2cba8428cf2905994aa105a13fb317'}, + {'unittest-xml-reporting-3.1.0_fix-getDescription-python-3.11.patch': + '0be7cd72e25ffab26df2997ddc95124f99eb789715172f3433a4608bedd0a441'} +] builddependencies = [('binutils', '2.42')] dependencies = [ diff --git a/easybuild/easyconfigs/u/unittest-xml-reporting/unittest-xml-reporting-3.1.0-GCCcore-14.2.0.eb b/easybuild/easyconfigs/u/unittest-xml-reporting/unittest-xml-reporting-3.1.0-GCCcore-14.2.0.eb index 54ab7c3db19..2803c1c5f3c 100644 --- a/easybuild/easyconfigs/u/unittest-xml-reporting/unittest-xml-reporting-3.1.0-GCCcore-14.2.0.eb +++ b/easybuild/easyconfigs/u/unittest-xml-reporting/unittest-xml-reporting-3.1.0-GCCcore-14.2.0.eb @@ -10,7 +10,12 @@ The files can be consumed by a wide range of tools, such as build systems, IDEs toolchain = {'name': 'GCCcore', 'version': '14.2.0'} sources = [SOURCE_TAR_GZ] -checksums = ['c6178ad2d782c5c21d129758f089fd26da2cba8428cf2905994aa105a13fb317'] +patches = ['unittest-xml-reporting-3.1.0_fix-getDescription-python-3.11.patch'] +checksums = [ + {'unittest-xml-reporting-3.1.0.tar.gz': 'c6178ad2d782c5c21d129758f089fd26da2cba8428cf2905994aa105a13fb317'}, + {'unittest-xml-reporting-3.1.0_fix-getDescription-python-3.11.patch': + '0be7cd72e25ffab26df2997ddc95124f99eb789715172f3433a4608bedd0a441'} +] builddependencies = [('binutils', '2.42')] dependencies = [ diff --git a/easybuild/easyconfigs/u/unittest-xml-reporting/unittest-xml-reporting-3.1.0_fix-getDescription-python-3.11.patch b/easybuild/easyconfigs/u/unittest-xml-reporting/unittest-xml-reporting-3.1.0_fix-getDescription-python-3.11.patch new file mode 100644 index 00000000000..d99fe751050 --- /dev/null +++ b/easybuild/easyconfigs/u/unittest-xml-reporting/unittest-xml-reporting-3.1.0_fix-getDescription-python-3.11.patch @@ -0,0 +1,41 @@ +From https://github.com/xmlrunner/unittest-xml-reporting/pull/274 + +From: =?UTF-8?q?Arttu=20Per=C3=A4l=C3=A4?= +Date: Tue, 3 Jan 2023 14:36:48 +0200 +Subject: [PATCH] Fix test result description fetching on Python 3.11 + +Python 3.11 changes `TextTestResult.printErrors()` to print out +unexpected successes and their descriptions. + +Fixes: +> File "/lib/python3.12/unittest/runner.py", line 152, in printErrors +> self.stream.writeln(f"UNEXPECTED SUCCESS: {self.getDescription(test)}") +> ^^^^^^^^^^^^^^^^^^^^^^^^^ +> File "/lib/python3.12/unittest/runner.py", line 50, in getDescription +> doc_first_line = test.shortDescription() +> ^^^^^^^^^^^^^^^^^^^^^ +> AttributeError: 'tuple' object has no attribute 'shortDescription' + +diff --git a/xmlrunner/result.py b/xmlrunner/result.py +index 96fc675..03f2150 100644 +--- a/xmlrunner/result.py ++++ b/xmlrunner/result.py +@@ -188,6 +188,9 @@ def get_error_info(self): + """ + return self.test_exception_info + ++ def shortDescription(self): ++ return self.test_description ++ + + class _XMLTestResult(TextTestResult): + """ +@@ -673,3 +676,8 @@ def generate_reports(self, test_runner): + def _exc_info_to_string(self, err, test): + """Converts a sys.exc_info()-style tuple of values into a string.""" + return super(_XMLTestResult, self)._exc_info_to_string(err, test) ++ ++ def getDescription(self, test): ++ if isinstance(test, tuple): ++ test = test[0] ++ return super().getDescription(test)