diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2022-02-24 19:22:46 +0100 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2022-02-24 19:22:46 +0100 |
commit | 6a573cd8fc169f5e53ea7090dec7fe6512a3ff6a (patch) | |
tree | a0eb5511ff6df7713a047ff63d2153ae5a3e817f | |
parent | 01bca8285cb2f5caf9ddf49a8ec33a2581898402 (diff) | |
download | cython-6a573cd8fc169f5e53ea7090dec7fe6512a3ff6a.tar.gz |
Resolve some doctest issues in Python 3.11.
-rw-r--r-- | tests/run/cpdef_enums.pyx | 6 | ||||
-rw-r--r-- | tests/run/hasattr.pyx | 4 | ||||
-rw-r--r-- | tests/run/test_unicode.pyx | 2 |
3 files changed, 9 insertions, 3 deletions
diff --git a/tests/run/cpdef_enums.pyx b/tests/run/cpdef_enums.pyx index c8d9d8205..69c90d90a 100644 --- a/tests/run/cpdef_enums.pyx +++ b/tests/run/cpdef_enums.pyx @@ -1,4 +1,6 @@ """ +>>> import sys + >>> ONE, TEN, HUNDRED (1, 10, 100) >>> THOUSAND # doctest: +ELLIPSIS @@ -35,8 +37,10 @@ NameError: ...name 'RANK_3' is not defined >>> set(PyxEnum) == {TWO, THREE, FIVE} True ->>> str(PyxEnum.TWO).split(".")[-1] # Py3.10 changed the output here +>>> str(PyxEnum.TWO).split(".")[-1] if sys.version_info < (3,11) else "TWO" # Py3.10/11 changed the output here 'TWO' +>>> str(PyxEnum.TWO) if sys.version_info >= (3,11) else "2" # Py3.10/11 changed the output here +'2' >>> PyxEnum.TWO + PyxEnum.THREE == PyxEnum.FIVE True >>> PyxEnum(2) is PyxEnum["TWO"] is PyxEnum.TWO diff --git a/tests/run/hasattr.pyx b/tests/run/hasattr.pyx index 59eeb739a..00d005d6c 100644 --- a/tests/run/hasattr.pyx +++ b/tests/run/hasattr.pyx @@ -1,3 +1,5 @@ +# mode: run + class Foo: @property def foo(self): @@ -36,6 +38,6 @@ def wrap_hasattr(obj, name): >>> hasattr(Foo(), None) #doctest: +ELLIPSIS Traceback (most recent call last): ... - TypeError: hasattr(): attribute name must be string + TypeError: ...attribute name must be string... """ return hasattr(obj, name) diff --git a/tests/run/test_unicode.pyx b/tests/run/test_unicode.pyx index 4616acf2c..179081daf 100644 --- a/tests/run/test_unicode.pyx +++ b/tests/run/test_unicode.pyx @@ -1482,7 +1482,7 @@ class UnicodeTest(CommonTest, self.assertEqual(('...%(foo)s...' % {'foo':Str.ABC}).replace("Str.", ""), '...ABC...') self.assertEqual(('...%(foo)s...' % {'foo':Int.IDES}).replace("Int.", ""), - '...IDES...') + '...IDES...' if sys.version_info < (3,11) else '...15...') self.assertEqual('...%(foo)i...' % {'foo':Int.IDES}, '...15...') self.assertEqual('...%(foo)d...' % {'foo':Int.IDES}, |