Blob Blame History Raw
From c97078652590b916830afd156a5269dfe5f54e40 Mon Sep 17 00:00:00 2001
From: Lumir Balhar <lbalhar@redhat.com>
Date: Mon, 18 Dec 2023 13:46:06 +0100
Subject: [PATCH] Make test_document compatible with Python 3.13

In Python 3.13, compiler strips indents from docstrings.
See https://github.com/python/cpython/issues/81283

Fixes: https://github.com/zopefoundation/zope.interface/issues/279
---
 src/zope/interface/tests/test_document.py | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/zope/interface/tests/test_document.py b/src/zope/interface/tests/test_document.py
index 3e6dddd8..f00e6311 100644
--- a/src/zope/interface/tests/test_document.py
+++ b/src/zope/interface/tests/test_document.py
@@ -13,6 +13,7 @@
 ##############################################################################
 """Documentation tests.
 """
+import sys
 import unittest
 
 
@@ -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:",
             "",
@@ -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:",
             "",