aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/zope.interface/py3/zope/interface/common
diff options
context:
space:
mode:
authormaxim-yurchuk <maxim-yurchuk@yandex-team.com>2024-10-09 12:29:46 +0300
committermaxim-yurchuk <maxim-yurchuk@yandex-team.com>2024-10-09 13:14:22 +0300
commit9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80 (patch)
treea8fb3181d5947c0d78cf402aa56e686130179049 /contrib/python/zope.interface/py3/zope/interface/common
parenta44b779cd359f06c3ebbef4ec98c6b38609d9d85 (diff)
downloadydb-9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80.tar.gz
publishFullContrib: true for ydb
<HIDDEN_URL> commit_hash:c82a80ac4594723cebf2c7387dec9c60217f603e
Diffstat (limited to 'contrib/python/zope.interface/py3/zope/interface/common')
-rw-r--r--contrib/python/zope.interface/py3/zope/interface/common/tests/__init__.py146
-rw-r--r--contrib/python/zope.interface/py3/zope/interface/common/tests/basemapping.py115
-rw-r--r--contrib/python/zope.interface/py3/zope/interface/common/tests/test_builtins.py43
-rw-r--r--contrib/python/zope.interface/py3/zope/interface/common/tests/test_collections.py137
-rw-r--r--contrib/python/zope.interface/py3/zope/interface/common/tests/test_idatetime.py48
-rw-r--r--contrib/python/zope.interface/py3/zope/interface/common/tests/test_import_interfaces.py21
-rw-r--r--contrib/python/zope.interface/py3/zope/interface/common/tests/test_io.py46
-rw-r--r--contrib/python/zope.interface/py3/zope/interface/common/tests/test_numbers.py42
8 files changed, 598 insertions, 0 deletions
diff --git a/contrib/python/zope.interface/py3/zope/interface/common/tests/__init__.py b/contrib/python/zope.interface/py3/zope/interface/common/tests/__init__.py
new file mode 100644
index 0000000000..f70a530999
--- /dev/null
+++ b/contrib/python/zope.interface/py3/zope/interface/common/tests/__init__.py
@@ -0,0 +1,146 @@
+##############################################################################
+# Copyright (c) 2020 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+##############################################################################
+
+import unittest
+
+from zope.interface.common import ABCInterface
+from zope.interface.common import ABCInterfaceClass
+from zope.interface.verify import verifyClass
+from zope.interface.verify import verifyObject
+
+
+def iter_abc_interfaces(predicate=lambda iface: True):
+ # Iterate ``(iface, classes)``, where ``iface`` is a descendent of
+ # the ABCInterfaceClass passing the *predicate* and ``classes`` is
+ # an iterable of classes registered to conform to that interface.
+ #
+ # Note that some builtin classes are registered for two distinct parts of
+ # the ABC/interface tree. For example, bytearray is both ByteString and
+ # MutableSequence.
+ seen = set()
+ stack = list(
+ ABCInterface.dependents
+ ) # subclasses, but also implementedBy objects
+
+ while stack:
+ iface = stack.pop(0)
+ if iface in seen or not isinstance(iface, ABCInterfaceClass):
+ continue
+ seen.add(iface)
+ stack.extend(list(iface.dependents))
+ if not predicate(iface):
+ continue
+
+ registered = set(iface.getRegisteredConformers())
+ registered -= set(iface._ABCInterfaceClass__ignored_classes)
+ if registered:
+ yield iface, registered
+
+
+def add_abc_interface_tests(cls, module):
+ def predicate(iface):
+ return iface.__module__ == module
+ add_verify_tests(cls, iter_abc_interfaces(predicate))
+
+
+def add_verify_tests(cls, iface_classes_iter):
+ cls.maxDiff = None
+ for iface, registered_classes in iface_classes_iter:
+ for stdlib_class in registered_classes:
+ def test(self, stdlib_class=stdlib_class, iface=iface):
+ if (
+ stdlib_class in self.UNVERIFIABLE or
+ stdlib_class.__name__ in self.UNVERIFIABLE
+ ):
+ self.skipTest("Unable to verify %s" % stdlib_class)
+
+ self.assertTrue(self.verify(iface, stdlib_class))
+
+ suffix = "{}_{}_{}_{}".format(
+ stdlib_class.__module__.replace('.', '_'),
+ stdlib_class.__name__,
+ iface.__module__.replace('.', '_'),
+ iface.__name__
+ )
+ name = 'test_auto_' + suffix
+ test.__name__ = name
+ assert not hasattr(cls, name), (name, list(cls.__dict__))
+ setattr(cls, name, test)
+
+ def test_ro(self, stdlib_class=stdlib_class, iface=iface):
+ from zope.interface import Interface
+ from zope.interface import implementedBy
+ from zope.interface import ro
+ self.assertEqual(
+ tuple(ro.ro(iface, strict=True)),
+ iface.__sro__)
+ implements = implementedBy(stdlib_class)
+ sro = implements.__sro__
+ self.assertIs(sro[-1], Interface)
+
+ if stdlib_class not in self.UNVERIFIABLE_RO:
+ # Check that we got the strict C3 resolution order, unless
+ # we know we cannot. Note that 'Interface' is virtual base
+ # that doesn't necessarily appear at the same place in the
+ # calculated SRO as in the final SRO.
+ strict = stdlib_class not in self.NON_STRICT_RO
+ isro = ro.ro(implements, strict=strict)
+ isro.remove(Interface)
+ isro.append(Interface)
+
+ self.assertEqual(tuple(isro), sro)
+
+ name = 'test_auto_ro_' + suffix
+ test_ro.__name__ = name
+ assert not hasattr(cls, name)
+ setattr(cls, name, test_ro)
+
+
+class VerifyClassMixin(unittest.TestCase):
+ verifier = staticmethod(verifyClass)
+ UNVERIFIABLE = ()
+ NON_STRICT_RO = ()
+ UNVERIFIABLE_RO = ()
+
+ def _adjust_object_before_verify(self, iface, x):
+ return x
+
+ def verify(self, iface, klass, **kwargs):
+ return self.verifier(iface,
+ self._adjust_object_before_verify(iface, klass),
+ **kwargs)
+
+
+class VerifyObjectMixin(VerifyClassMixin):
+ verifier = staticmethod(verifyObject)
+ CONSTRUCTORS = {
+ }
+
+ def _adjust_object_before_verify(self, iface, x):
+ constructor = self.CONSTRUCTORS.get(x)
+ if not constructor:
+ constructor = self.CONSTRUCTORS.get(iface)
+ if not constructor:
+ constructor = self.CONSTRUCTORS.get(x.__name__)
+ if not constructor:
+ constructor = x
+ if constructor is unittest.SkipTest:
+ self.skipTest("Cannot create " + str(x))
+
+ try:
+ result = constructor()
+ except Exception as e: # pragma: no cover
+ raise TypeError(
+ f'Failed to create instance of {constructor}') from e
+ if hasattr(result, 'close'):
+ self.addCleanup(result.close)
+ return result
diff --git a/contrib/python/zope.interface/py3/zope/interface/common/tests/basemapping.py b/contrib/python/zope.interface/py3/zope/interface/common/tests/basemapping.py
new file mode 100644
index 0000000000..db4c091ff6
--- /dev/null
+++ b/contrib/python/zope.interface/py3/zope/interface/common/tests/basemapping.py
@@ -0,0 +1,115 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Base Mapping tests
+"""
+from operator import __getitem__
+
+
+def _testIReadMapping(self, inst, state, absent):
+ for key in state:
+ self.assertEqual(inst[key], state[key])
+ self.assertEqual(inst.get(key, None), state[key])
+ self.assertTrue(key in inst)
+
+ for key in absent:
+ self.assertEqual(inst.get(key, None), None)
+ self.assertEqual(inst.get(key), None)
+ self.assertEqual(inst.get(key, self), self)
+ self.assertRaises(KeyError, __getitem__, inst, key)
+
+
+def _test_keys(self, inst, state):
+ # Return the keys of the mapping object
+ inst_keys = sorted(inst.keys())
+ state_keys = sorted(state.keys())
+ self.assertEqual(inst_keys, state_keys)
+
+
+def _test_iter(self, inst, state):
+ # Return the keys of the mapping object
+ inst_keys = sorted(inst)
+ state_keys = sorted(state.keys())
+ self.assertEqual(inst_keys, state_keys)
+
+
+def _test_values(self, inst, state):
+ # Return the values of the mapping object
+ inst_values = sorted(inst.values())
+ state_values = sorted(state.values())
+ self.assertEqual(inst_values, state_values)
+
+
+def _test_items(self, inst, state):
+ # Return the items of the mapping object
+ inst_items = sorted(inst.items())
+ state_items = sorted(state.items())
+ self.assertEqual(inst_items, state_items)
+
+
+def _test___len__(self, inst, state):
+ # Return the number of items
+ self.assertEqual(len(inst), len(state))
+
+
+def _testIEnumerableMapping(self, inst, state):
+ _test_keys(self, inst, state)
+ _test_items(self, inst, state)
+ _test_values(self, inst, state)
+ _test___len__(self, inst, state)
+
+
+class BaseTestIReadMapping:
+
+ def testIReadMapping(self):
+ inst = self._IReadMapping__sample()
+ state = self._IReadMapping__stateDict()
+ absent = self._IReadMapping__absentKeys()
+ _testIReadMapping(self, inst, state, absent)
+
+
+class BaseTestIEnumerableMapping(BaseTestIReadMapping):
+ # Mapping objects whose items can be enumerated
+
+ def test_keys(self):
+ # Return the keys of the mapping object
+ inst = self._IEnumerableMapping__sample()
+ state = self._IEnumerableMapping__stateDict()
+ _test_keys(self, inst, state)
+
+ def test_values(self):
+ # Return the values of the mapping object
+ inst = self._IEnumerableMapping__sample()
+ state = self._IEnumerableMapping__stateDict()
+ _test_values(self, inst, state)
+
+ def test_items(self):
+ # Return the items of the mapping object
+ inst = self._IEnumerableMapping__sample()
+ state = self._IEnumerableMapping__stateDict()
+ _test_items(self, inst, state)
+
+ def test___len__(self):
+ # Return the number of items
+ inst = self._IEnumerableMapping__sample()
+ state = self._IEnumerableMapping__stateDict()
+ _test___len__(self, inst, state)
+
+ def _IReadMapping__stateDict(self):
+ return self._IEnumerableMapping__stateDict()
+
+ def _IReadMapping__sample(self):
+ return self._IEnumerableMapping__sample()
+
+ def _IReadMapping__absentKeys(self):
+ return self._IEnumerableMapping__absentKeys()
diff --git a/contrib/python/zope.interface/py3/zope/interface/common/tests/test_builtins.py b/contrib/python/zope.interface/py3/zope/interface/common/tests/test_builtins.py
new file mode 100644
index 0000000000..cf7019bfc5
--- /dev/null
+++ b/contrib/python/zope.interface/py3/zope/interface/common/tests/test_builtins.py
@@ -0,0 +1,43 @@
+##############################################################################
+# Copyright (c) 2020 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+##############################################################################
+
+import unittest
+
+from zope.interface.common import builtins
+
+from . import VerifyClassMixin
+from . import VerifyObjectMixin
+from . import add_verify_tests
+
+
+class TestVerifyClass(VerifyClassMixin,
+ unittest.TestCase):
+ pass
+
+
+add_verify_tests(TestVerifyClass, (
+ (builtins.IList, (list,)),
+ (builtins.ITuple, (tuple,)),
+ (builtins.ITextString, (str,)),
+ (builtins.IByteString, (bytes,)),
+ (builtins.INativeString, (str,)),
+ (builtins.IBool, (bool,)),
+ (builtins.IDict, (dict,)),
+ (builtins.IFile, ()),
+))
+
+
+class TestVerifyObject(VerifyObjectMixin,
+ TestVerifyClass):
+ CONSTRUCTORS = {
+ builtins.IFile: lambda: open(__file__)
+ }
diff --git a/contrib/python/zope.interface/py3/zope/interface/common/tests/test_collections.py b/contrib/python/zope.interface/py3/zope/interface/common/tests/test_collections.py
new file mode 100644
index 0000000000..6d23f6f960
--- /dev/null
+++ b/contrib/python/zope.interface/py3/zope/interface/common/tests/test_collections.py
@@ -0,0 +1,137 @@
+##############################################################################
+# Copyright (c) 2020 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+##############################################################################
+
+
+import array
+import unittest
+from collections import OrderedDict
+from collections import abc
+from collections import deque
+from types import MappingProxyType
+
+from zope.interface import Invalid
+from zope.interface._compat import PYPY
+# Note that importing z.i.c.collections does work on import.
+from zope.interface.common import collections
+
+from . import VerifyClassMixin
+from . import VerifyObjectMixin
+from . import add_abc_interface_tests
+
+
+class TestVerifyClass(VerifyClassMixin, unittest.TestCase):
+
+ # Here we test some known builtin classes that are defined to implement
+ # various collection interfaces as a quick sanity test.
+ def test_frozenset(self):
+ self.assertIsInstance(frozenset(), abc.Set)
+ self.assertTrue(self.verify(collections.ISet, frozenset))
+
+ def test_list(self):
+ self.assertIsInstance(list(), abc.MutableSequence)
+ self.assertTrue(self.verify(collections.IMutableSequence, list))
+
+ # Here we test some derived classes.
+ def test_UserList(self):
+ self.assertTrue(self.verify(collections.IMutableSequence,
+ collections.UserList))
+
+ def test_UserDict(self):
+ self.assertTrue(self.verify(collections.IMutableMapping,
+ collections.UserDict))
+
+ def test_UserString(self):
+ self.assertTrue(self.verify(collections.ISequence,
+ collections.UserString))
+
+ # Now we go through the registry, which should have several things, mostly
+ # builtins, but if we've imported other libraries already, it could
+ # contain things from outside of there too. We aren't concerned about
+ # third-party code here, just standard library types. We start with a
+ # blacklist of things to exclude, but if that gets out of hand we can
+ # figure out a better whitelisting.
+ UNVERIFIABLE = {
+ # This is declared to be an ISequence, but is missing lots of methods,
+ # including some that aren't part of a language protocol, such as
+ # ``index`` and ``count``.
+ memoryview,
+ # 'pkg_resources._vendor.pyparsing.ParseResults' is registered as a
+ # MutableMapping but is missing methods like ``popitem`` and
+ # ``setdefault``. It's imported due to namespace packages.
+ 'ParseResults',
+ # sqlite3.Row claims ISequence but also misses ``index`` and
+ # ``count``. It's imported because...? Coverage imports it, but why
+ # do we have it without coverage?
+ 'Row',
+ # In Python 3.10 ``array.array`` appears as ``IMutableSequence`` but it
+ # does not provide a ``clear()`` method and it cannot be instantiated
+ # using ``array.array()``.
+ array.array,
+ }
+
+ if PYPY:
+ UNVERIFIABLE.update({
+ # collections.deque.pop() doesn't support the index= argument to
+ # MutableSequence.pop(). We can't verify this on CPython because
+ # we can't get the signature, but on PyPy we /can/ get the
+ # signature, and of course it doesn't match.
+ deque,
+ # Likewise for index
+ range,
+ })
+ UNVERIFIABLE_RO = {
+ # ``array.array`` fails the ``test_auto_ro_*`` tests with and
+ # without strict RO but only on Windows (AppVeyor) on Python 3.10.0
+ # (in older versions ``array.array`` does not appear as
+ # ``IMutableSequence``).
+ array.array,
+ }
+
+
+add_abc_interface_tests(TestVerifyClass, collections.ISet.__module__)
+
+
+class TestVerifyObject(VerifyObjectMixin,
+ TestVerifyClass):
+ CONSTRUCTORS = {
+ collections.IValuesView: {}.values,
+ collections.IItemsView: {}.items,
+ collections.IKeysView: {}.keys,
+ memoryview: lambda: memoryview(b'abc'),
+ range: lambda: range(10),
+ MappingProxyType: lambda: MappingProxyType({}),
+ collections.UserString: lambda: collections.UserString('abc'),
+ type(iter(bytearray())): lambda: iter(bytearray()),
+ type(iter(b'abc')): lambda: iter(b'abc'),
+ 'coroutine': unittest.SkipTest,
+ type(iter({}.keys())): lambda: iter({}.keys()),
+ type(iter({}.items())): lambda: iter({}.items()),
+ type(iter({}.values())): lambda: iter({}.values()),
+ type(i for i in range(1)): lambda: (i for i in range(3)),
+ type(iter([])): lambda: iter([]),
+ type(reversed([])): lambda: reversed([]),
+ 'longrange_iterator': unittest.SkipTest,
+ 'range_iterator': lambda: iter(range(3)),
+ 'rangeiterator': lambda: iter(range(3)),
+ type(iter(set())): lambda: iter(set()),
+ type(iter('')): lambda: iter(''),
+ 'async_generator': unittest.SkipTest,
+ type(iter(tuple())): lambda: iter(tuple()),
+ }
+
+ UNVERIFIABLE_RO = {
+ # ``array.array`` fails the ``test_auto_ro_*`` tests with and
+ # without strict RO but only on Windows (AppVeyor) on Python 3.10.0
+ # (in older versions ``array.array`` does not appear as
+ # ``IMutableSequence``).
+ array.array,
+ }
diff --git a/contrib/python/zope.interface/py3/zope/interface/common/tests/test_idatetime.py b/contrib/python/zope.interface/py3/zope/interface/common/tests/test_idatetime.py
new file mode 100644
index 0000000000..9550daa1e4
--- /dev/null
+++ b/contrib/python/zope.interface/py3/zope/interface/common/tests/test_idatetime.py
@@ -0,0 +1,48 @@
+##############################################################################
+#
+# Copyright (c) 2003 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Test for datetime interfaces
+"""
+
+import unittest
+from datetime import date
+from datetime import datetime
+from datetime import time
+from datetime import timedelta
+from datetime import tzinfo
+
+from zope.interface.common.idatetime import IDate
+from zope.interface.common.idatetime import IDateClass
+from zope.interface.common.idatetime import IDateTime
+from zope.interface.common.idatetime import IDateTimeClass
+from zope.interface.common.idatetime import ITime
+from zope.interface.common.idatetime import ITimeClass
+from zope.interface.common.idatetime import ITimeDelta
+from zope.interface.common.idatetime import ITimeDeltaClass
+from zope.interface.common.idatetime import ITZInfo
+from zope.interface.verify import verifyClass
+from zope.interface.verify import verifyObject
+
+
+class TestDateTimeInterfaces(unittest.TestCase):
+
+ def test_interfaces(self):
+ verifyObject(ITimeDelta, timedelta(minutes=20))
+ verifyObject(IDate, date(2000, 1, 2))
+ verifyObject(IDateTime, datetime(2000, 1, 2, 10, 20))
+ verifyObject(ITime, time(20, 30, 15, 1234))
+ verifyObject(ITZInfo, tzinfo())
+ verifyClass(ITimeDeltaClass, timedelta)
+ verifyClass(IDateClass, date)
+ verifyClass(IDateTimeClass, datetime)
+ verifyClass(ITimeClass, time)
diff --git a/contrib/python/zope.interface/py3/zope/interface/common/tests/test_import_interfaces.py b/contrib/python/zope.interface/py3/zope/interface/common/tests/test_import_interfaces.py
new file mode 100644
index 0000000000..67d14487a9
--- /dev/null
+++ b/contrib/python/zope.interface/py3/zope/interface/common/tests/test_import_interfaces.py
@@ -0,0 +1,21 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+import unittest
+
+
+class TestInterfaceImport(unittest.TestCase):
+
+ def test_import(self):
+ import zope.interface.common.interfaces as x
+ self.assertIsNotNone(x)
diff --git a/contrib/python/zope.interface/py3/zope/interface/common/tests/test_io.py b/contrib/python/zope.interface/py3/zope/interface/common/tests/test_io.py
new file mode 100644
index 0000000000..72684bff06
--- /dev/null
+++ b/contrib/python/zope.interface/py3/zope/interface/common/tests/test_io.py
@@ -0,0 +1,46 @@
+##############################################################################
+# Copyright (c) 2020 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+##############################################################################
+
+
+import io as abc
+import unittest
+
+# Note that importing z.i.c.io does work on import.
+from zope.interface.common import io
+
+from . import VerifyClassMixin
+from . import VerifyObjectMixin
+from . import add_abc_interface_tests
+
+
+class TestVerifyClass(VerifyClassMixin,
+ unittest.TestCase):
+ pass
+
+
+add_abc_interface_tests(TestVerifyClass, io.IIOBase.__module__)
+
+
+class TestVerifyObject(VerifyObjectMixin,
+ TestVerifyClass):
+ CONSTRUCTORS = {
+ abc.BufferedWriter: lambda: abc.BufferedWriter(abc.StringIO()),
+ abc.BufferedReader: lambda: abc.BufferedReader(abc.StringIO()),
+ abc.TextIOWrapper: lambda: abc.TextIOWrapper(abc.BytesIO()),
+ abc.BufferedRandom: lambda: abc.BufferedRandom(abc.BytesIO()),
+ abc.BufferedRWPair: lambda: abc.BufferedRWPair(
+ abc.BytesIO(), abc.BytesIO()
+ ),
+ abc.FileIO: lambda: abc.FileIO(__file__),
+ '_WindowsConsoleIO': unittest.SkipTest,
+ 'WinConsoleIO': unittest.SkipTest, # breaks on PyPy-3.10
+ }
diff --git a/contrib/python/zope.interface/py3/zope/interface/common/tests/test_numbers.py b/contrib/python/zope.interface/py3/zope/interface/common/tests/test_numbers.py
new file mode 100644
index 0000000000..4e86514a1a
--- /dev/null
+++ b/contrib/python/zope.interface/py3/zope/interface/common/tests/test_numbers.py
@@ -0,0 +1,42 @@
+##############################################################################
+# Copyright (c) 2020 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+##############################################################################
+
+
+import numbers as abc
+import unittest
+
+# Note that importing z.i.c.numbers does work on import.
+from zope.interface.common import numbers
+
+from . import VerifyClassMixin
+from . import VerifyObjectMixin
+from . import add_abc_interface_tests
+
+
+class TestVerifyClass(VerifyClassMixin,
+ unittest.TestCase):
+
+ def test_int(self):
+ self.assertIsInstance(int(), abc.Integral)
+ self.assertTrue(self.verify(numbers.IIntegral, int))
+
+ def test_float(self):
+ self.assertIsInstance(float(), abc.Real)
+ self.assertTrue(self.verify(numbers.IReal, float))
+
+
+add_abc_interface_tests(TestVerifyClass, numbers.INumber.__module__)
+
+
+class TestVerifyObject(VerifyObjectMixin,
+ TestVerifyClass):
+ pass