test_io.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. ##############################################################################
  2. # Copyright (c) 2020 Zope Foundation and Contributors.
  3. # All Rights Reserved.
  4. #
  5. # This software is subject to the provisions of the Zope Public License,
  6. # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
  7. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
  8. # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  9. # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
  10. # FOR A PARTICULAR PURPOSE.
  11. ##############################################################################
  12. import io as abc
  13. import unittest
  14. # Note that importing z.i.c.io does work on import.
  15. from zope.interface.common import io
  16. from . import VerifyClassMixin
  17. from . import VerifyObjectMixin
  18. from . import add_abc_interface_tests
  19. class TestVerifyClass(VerifyClassMixin,
  20. unittest.TestCase):
  21. pass
  22. add_abc_interface_tests(TestVerifyClass, io.IIOBase.__module__)
  23. class TestVerifyObject(VerifyObjectMixin,
  24. TestVerifyClass):
  25. CONSTRUCTORS = {
  26. abc.BufferedWriter: lambda: abc.BufferedWriter(abc.StringIO()),
  27. abc.BufferedReader: lambda: abc.BufferedReader(abc.StringIO()),
  28. abc.TextIOWrapper: lambda: abc.TextIOWrapper(abc.BytesIO()),
  29. abc.BufferedRandom: lambda: abc.BufferedRandom(abc.BytesIO()),
  30. abc.BufferedRWPair: lambda: abc.BufferedRWPair(
  31. abc.BytesIO(), abc.BytesIO()
  32. ),
  33. abc.FileIO: lambda: abc.FileIO(__file__),
  34. '_WindowsConsoleIO': unittest.SkipTest,
  35. 'WinConsoleIO': unittest.SkipTest, # breaks on PyPy-3.10
  36. }