Skip to content

Commit 5d42886

Browse files
Make test_document compatible with Python 3.13 (#281)
In Python 3.13, compiler strips indents from docstrings. See python/cpython#81283 Fixes: #279
1 parent 202d9dc commit 5d42886

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/zope/interface/tests/test_document.py

+11-4
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,17 @@ 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 ""
283+
277284
EXPECTED = '\n'.join([
278285
"``IEmpty``",
279286
"",
280287
" This is an empty interface.",
281288
" ",
282-
(" It can be used to annotate any class or object, "
289+
(f"{indent} It can be used to annotate any class or object, "
283290
"because it promises"),
284-
" nothing.",
291+
f"{indent} nothing.",
285292
"",
286293
" Attributes:",
287294
"",

0 commit comments

Comments
 (0)