Skip to content

Commit

Permalink
Make test_document compatible with Python 3.13 (#281)
Browse files Browse the repository at this point in the history
In Python 3.13, compiler strips indents from docstrings.
See python/cpython#81283

Fixes: #279
  • Loading branch information
frenzymadness committed Dec 20, 2023
1 parent 202d9dc commit 5d42886
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/zope/interface/tests/test_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
##############################################################################
"""Documentation tests.
"""
import sys
import unittest


Expand Down Expand Up @@ -50,14 +51,17 @@ class IEmpty(Interface):

def test_asStructuredText_empty_with_multiline_docstring(self):
from zope.interface import Interface
# In Python 3.13+, compiler strips indents from docstrings
indent = " " * 12 if sys.version_info < (3, 13) else ""

EXPECTED = '\n'.join([
"IEmpty",
"",
" This is an empty interface.",
" ",
(" It can be used to annotate any class or object, "
(f"{indent} It can be used to annotate any class or object, "
"because it promises"),
" nothing.",
f"{indent} nothing.",
"",
" Attributes:",
"",
Expand Down Expand Up @@ -274,14 +278,17 @@ class IEmpty(Interface):

def test_asReStructuredText_empty_with_multiline_docstring(self):
from zope.interface import Interface
# In Python 3.13+, compiler strips indents from docstrings
indent = " " * 12 if sys.version_info < (3, 13) else ""

EXPECTED = '\n'.join([
"``IEmpty``",
"",
" This is an empty interface.",
" ",
(" It can be used to annotate any class or object, "
(f"{indent} It can be used to annotate any class or object, "
"because it promises"),
" nothing.",
f"{indent} nothing.",
"",
" Attributes:",
"",
Expand Down

0 comments on commit 5d42886

Please sign in to comment.