test_builtins.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 unittest
  13. from zope.interface._compat import PY313_OR_OLDER
  14. from zope.interface.common import builtins
  15. from . import VerifyClassMixin
  16. from . import VerifyObjectMixin
  17. from . import add_verify_tests
  18. class TestVerifyClass(VerifyClassMixin,
  19. unittest.TestCase):
  20. pass
  21. VERIFY_TESTS = [
  22. (builtins.IList, (list,)),
  23. (builtins.ITuple, (tuple,)),
  24. (builtins.ITextString, (str,)),
  25. (builtins.INativeString, (str,)),
  26. (builtins.IBool, (bool,)),
  27. (builtins.IDict, (dict,)),
  28. (builtins.IFile, ()),
  29. ]
  30. if PY313_OR_OLDER:
  31. VERIFY_TESTS.append(
  32. (builtins.IByteString, (bytes,))
  33. )
  34. add_verify_tests(TestVerifyClass, tuple(VERIFY_TESTS))
  35. class TestVerifyObject(VerifyObjectMixin,
  36. TestVerifyClass):
  37. CONSTRUCTORS = {
  38. builtins.IFile: lambda: open(__file__)
  39. }