Commit 6a573cd8 authored by Stefan Behnel's avatar Stefan Behnel

Resolve some doctest issues in Python 3.11.

parent 01bca828
""" """
>>> import sys
>>> ONE, TEN, HUNDRED >>> ONE, TEN, HUNDRED
(1, 10, 100) (1, 10, 100)
>>> THOUSAND # doctest: +ELLIPSIS >>> THOUSAND # doctest: +ELLIPSIS
...@@ -35,8 +37,10 @@ NameError: ...name 'RANK_3' is not defined ...@@ -35,8 +37,10 @@ NameError: ...name 'RANK_3' is not defined
>>> set(PyxEnum) == {TWO, THREE, FIVE} >>> set(PyxEnum) == {TWO, THREE, FIVE}
True 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' '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 >>> PyxEnum.TWO + PyxEnum.THREE == PyxEnum.FIVE
True True
>>> PyxEnum(2) is PyxEnum["TWO"] is PyxEnum.TWO >>> PyxEnum(2) is PyxEnum["TWO"] is PyxEnum.TWO
......
# mode: run
class Foo: class Foo:
@property @property
def foo(self): def foo(self):
...@@ -36,6 +38,6 @@ def wrap_hasattr(obj, name): ...@@ -36,6 +38,6 @@ def wrap_hasattr(obj, name):
>>> hasattr(Foo(), None) #doctest: +ELLIPSIS >>> hasattr(Foo(), None) #doctest: +ELLIPSIS
Traceback (most recent call last): Traceback (most recent call last):
... ...
TypeError: hasattr(): attribute name must be string TypeError: ...attribute name must be string...
""" """
return hasattr(obj, name) return hasattr(obj, name)
...@@ -1482,7 +1482,7 @@ class UnicodeTest(CommonTest, ...@@ -1482,7 +1482,7 @@ class UnicodeTest(CommonTest,
self.assertEqual(('...%(foo)s...' % {'foo':Str.ABC}).replace("Str.", ""), self.assertEqual(('...%(foo)s...' % {'foo':Str.ABC}).replace("Str.", ""),
'...ABC...') '...ABC...')
self.assertEqual(('...%(foo)s...' % {'foo':Int.IDES}).replace("Int.", ""), 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}, self.assertEqual('...%(foo)i...' % {'foo':Int.IDES},
'...15...') '...15...')
self.assertEqual('...%(foo)d...' % {'foo':Int.IDES}, self.assertEqual('...%(foo)d...' % {'foo':Int.IDES},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment