Skip to content

Commit

Permalink
pythongh-115285: Fix test_dataclasses with -OO mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn committed Feb 11, 2024
1 parent f8e9c57 commit 3bdf6b8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Lib/test/test_dataclasses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3bdf6b8

Please sign in to comment.