Skip to content

Commit ad0a40f

Browse files
committed
Make test_document compatible with Python 3.13
In Python 3.13, compiler strips indents from docstrings. See python/cpython#81283 Fixes: zopefoundation#279
1 parent 202d9dc commit ad0a40f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/zope/interface/tests/test_document.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
##############################################################################
1414
"""Documentation tests.
1515
"""
16+
import sys
1617
import unittest
1718

1819

@@ -50,14 +51,17 @@ class IEmpty(Interface):
5051

5152
def test_asStructuredText_empty_with_multiline_docstring(self):
5253
from zope.interface import Interface
54+
# In Python 3.13+, compiler strips indents from docstrings
55+
indent = " " * 12 if sys.version_info < (3, 13) else ""
56+
5357
EXPECTED = '\n'.join([
5458
"IEmpty",
5559
"",
5660
" This is an empty interface.",
5761
" ",
58-
(" It can be used to annotate any class or object, "
62+
(f"{indent} It can be used to annotate any class or object, "
5963
"because it promises"),
60-
" nothing.",
64+
f"{indent} nothing.",
6165
"",
6266
" Attributes:",
6367
"",
@@ -274,14 +278,16 @@ class IEmpty(Interface):
274278

275279
def test_asReStructuredText_empty_with_multiline_docstring(self):
276280
from zope.interface import Interface
281+
# In Python 3.13+, compiler strips indents from docstrings
282+
indent = " " * 12 if sys.version_info < (3, 13) else ""
277283
EXPECTED = '\n'.join([
278284
"``IEmpty``",
279285
"",
280286
" This is an empty interface.",
281287
" ",
282-
(" It can be used to annotate any class or object, "
288+
(f"{indent} It can be used to annotate any class or object, "
283289
"because it promises"),
284-
" nothing.",
290+
f"{indent} nothing.",
285291
"",
286292
" Attributes:",
287293
"",

0 commit comments

Comments
 (0)