Fix test_ne in test_cmp.py for Python 3.13 (#1255)

* Fix test_ne in test_cmp.py for Python 3.13

Compiler in Python 3.13+ strips indents from docstrings
so they need to be compared without it for new Pythons.

Fixes: https://github.com/python-attrs/attrs/issues/1228

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Lumír 'Frenzy' Balhar 2024-03-07 10:23:46 +01:00 committed by GitHub
parent b9084fab02
commit f9ff9135b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View File

@ -14,6 +14,7 @@ PY_3_8_PLUS = sys.version_info[:2] >= (3, 8)
PY_3_9_PLUS = sys.version_info[:2] >= (3, 9)
PY310 = sys.version_info[:2] >= (3, 10)
PY_3_12_PLUS = sys.version_info[:2] >= (3, 12)
PY_3_13_PLUS = sys.version_info[:2] >= (3, 13)
if sys.version_info < (3, 8):

View File

@ -4,10 +4,10 @@
Tests for methods from `attrib._cmp`.
"""
import pytest
from attr._cmp import cmp_using
from attr._compat import PY_3_13_PLUS
# Test parameters.
@ -54,6 +54,9 @@ order_ids = [c[0].__name__ for c in order_data]
cmp_data = eq_data + order_data
cmp_ids = eq_ids + order_ids
# Compiler strips indents from docstrings in Python 3.13+
indent = "" if PY_3_13_PLUS else " " * 8
class TestEqOrder:
"""
@ -325,7 +328,7 @@ class TestDundersUnnamedClass:
method = self.cls.__ne__
assert method.__doc__.strip() == (
"Check equality and either forward a NotImplemented or\n"
" return the result negated."
f"{indent}return the result negated."
)
assert method.__name__ == "__ne__"
@ -393,7 +396,7 @@ class TestDundersPartialOrdering:
method = self.cls.__ne__
assert method.__doc__.strip() == (
"Check equality and either forward a NotImplemented or\n"
" return the result negated."
f"{indent}return the result negated."
)
assert method.__name__ == "__ne__"
@ -465,7 +468,7 @@ class TestDundersFullOrdering:
method = self.cls.__ne__
assert method.__doc__.strip() == (
"Check equality and either forward a NotImplemented or\n"
" return the result negated."
f"{indent}return the result negated."
)
assert method.__name__ == "__ne__"