Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tests.py 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. ##############################################################################
  2. #
  3. # Copyright (c) 2003 Zope Foundation and Contributors.
  4. # All Rights Reserved.
  5. #
  6. # This software is subject to the provisions of the Zope Public License,
  7. # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
  8. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
  9. # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10. # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
  11. # FOR A PARTICULAR PURPOSE.
  12. #
  13. ##############################################################################
  14. import unittest
  15. class TestMethodObject(unittest.TestCase):
  16. def test_compilation(self):
  17. from ExtensionClass import _IS_PYPY
  18. try:
  19. from MethodObject import _MethodObject
  20. except ImportError: # pragma: no cover
  21. self.assertTrue(_IS_PYPY)
  22. else:
  23. self.assertTrue(hasattr(_MethodObject, 'Method'))
  24. def test_methodobject(self):
  25. from ExtensionClass import Base
  26. from MethodObject import Method
  27. class Callable(Method):
  28. def __call__(self, ob, *args, **kw):
  29. return (repr(ob), args, kw)
  30. class ExClass(Base):
  31. def __repr__(self):
  32. return "bar()"
  33. hi = Callable()
  34. x = ExClass()
  35. hi = x.hi
  36. result = hi(1, 2, 3, name='spam')
  37. self.assertEqual(result,
  38. ("bar()", (1, 2, 3), {'name': 'spam'}))
  39. def test_suite():
  40. return unittest.defaultTestLoader.loadTestsFromName(__name__)