|
| 1 | +From f9ff9135b472c78a7333d6272c62b92217897464 Mon Sep 17 00:00:00 2001 |
| 2 | +From: =?UTF-8?q?Lum=C3=ADr=20=27Frenzy=27=20Balhar?= |
| 3 | + |
| 4 | +Date: Thu, 7 Mar 2024 10:23:46 +0100 |
| 5 | +Subject: [PATCH] Fix test_ne in test_cmp.py for Python 3.13 (#1255) |
| 6 | + |
| 7 | +* Fix test_ne in test_cmp.py for Python 3.13 |
| 8 | + |
| 9 | +Compiler in Python 3.13+ strips indents from docstrings |
| 10 | +so they need to be compared without it for new Pythons. |
| 11 | + |
| 12 | +Fixes: https://github.com/python-attrs/attrs/issues/1228 |
| 13 | + |
| 14 | +* [pre-commit.ci] auto fixes from pre-commit.com hooks |
| 15 | + |
| 16 | +for more information, see https://pre-commit.ci |
| 17 | + |
| 18 | +--------- |
| 19 | + |
| 20 | +Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> |
| 21 | +--- |
| 22 | + src/attr/_compat.py | 1 + |
| 23 | + tests/test_cmp.py | 11 +++++++---- |
| 24 | + 2 files changed, 8 insertions(+), 4 deletions(-) |
| 25 | + |
| 26 | +diff --git a/src/attr/_compat.py b/src/attr/_compat.py |
| 27 | +index 46b05ca..9010047 100644 |
| 28 | +--- a/src/attr/_compat.py |
| 29 | ++++ b/src/attr/_compat.py |
| 30 | +@@ -14,6 +14,7 @@ PY_3_8_PLUS = sys.version_info[:2] >= (3, 8) |
| 31 | + PY_3_9_PLUS = sys.version_info[:2] >= (3, 9) |
| 32 | + PY310 = sys.version_info[:2] >= (3, 10) |
| 33 | + PY_3_12_PLUS = sys.version_info[:2] >= (3, 12) |
| 34 | ++PY_3_13_PLUS = sys.version_info[:2] >= (3, 13) |
| 35 | + |
| 36 | + |
| 37 | + if sys.version_info < (3, 8): |
| 38 | +diff --git a/tests/test_cmp.py b/tests/test_cmp.py |
| 39 | +index 07bfc52..b84b66f 100644 |
| 40 | +--- a/tests/test_cmp.py |
| 41 | ++++ b/tests/test_cmp.py |
| 42 | +@@ -4,10 +4,10 @@ |
| 43 | + Tests for methods from `attrib._cmp`. |
| 44 | + """ |
| 45 | + |
| 46 | +- |
| 47 | + import pytest |
| 48 | + |
| 49 | + from attr._cmp import cmp_using |
| 50 | ++from attr._compat import PY_3_13_PLUS |
| 51 | + |
| 52 | + |
| 53 | + # Test parameters. |
| 54 | +@@ -54,6 +54,9 @@ order_ids = [c[0].__name__ for c in order_data] |
| 55 | + cmp_data = eq_data + order_data |
| 56 | + cmp_ids = eq_ids + order_ids |
| 57 | + |
| 58 | ++# Compiler strips indents from docstrings in Python 3.13+ |
| 59 | ++indent = "" if PY_3_13_PLUS else " " * 8 |
| 60 | ++ |
| 61 | + |
| 62 | + class TestEqOrder: |
| 63 | + """ |
| 64 | +@@ -325,7 +328,7 @@ class TestDundersUnnamedClass: |
| 65 | + method = self.cls.__ne__ |
| 66 | + assert method.__doc__.strip() == ( |
| 67 | + "Check equality and either forward a NotImplemented or\n" |
| 68 | +- " return the result negated." |
| 69 | ++ f"{indent}return the result negated." |
| 70 | + ) |
| 71 | + assert method.__name__ == "__ne__" |
| 72 | + |
| 73 | +@@ -393,7 +396,7 @@ class TestDundersPartialOrdering: |
| 74 | + method = self.cls.__ne__ |
| 75 | + assert method.__doc__.strip() == ( |
| 76 | + "Check equality and either forward a NotImplemented or\n" |
| 77 | +- " return the result negated." |
| 78 | ++ f"{indent}return the result negated." |
| 79 | + ) |
| 80 | + assert method.__name__ == "__ne__" |
| 81 | + |
| 82 | +@@ -465,7 +468,7 @@ class TestDundersFullOrdering: |
| 83 | + method = self.cls.__ne__ |
| 84 | + assert method.__doc__.strip() == ( |
| 85 | + "Check equality and either forward a NotImplemented or\n" |
| 86 | +- " return the result negated." |
| 87 | ++ f"{indent}return the result negated." |
| 88 | + ) |
| 89 | + assert method.__name__ == "__ne__" |
| 90 | + |
| 91 | +-- |
| 92 | +2.45.0 |
| 93 | + |
0 commit comments