From 3bdf6b8dc35aa30111b64558cc9a6a43f8b23ce9 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sun, 11 Feb 2024 12:25:26 +0300 Subject: [PATCH] gh-115285: Fix `test_dataclasses` with `-OO` mode --- Lib/test/test_dataclasses/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_dataclasses/__init__.py b/Lib/test/test_dataclasses/__init__.py index 272d427875ae40..74e364e69b40ff 100644 --- a/Lib/test/test_dataclasses/__init__.py +++ b/Lib/test/test_dataclasses/__init__.py @@ -22,6 +22,8 @@ import typing # Needed for the string "typing.ClassVar[int]" to work as an annotation. import dataclasses # Needed for the string "dataclasses.InitVar[int]" to work as an annotation. +from test import support + # Just any custom exception we can catch. class CustomError(Exception): pass @@ -2222,7 +2224,10 @@ class C: """Lorem ipsum""" x: int - self.assertEqual(C.__doc__, "Lorem ipsum") + if support.HAVE_DOCSTRINGS: + self.assertEqual(C.__doc__, "Lorem ipsum") + else: + self.assertEqual(C.__doc__, "C(x: int)") def test_docstring_no_fields(self): @dataclass