testROT.py 756 B

1234567891011121314151617181920212223242526
  1. import pythoncom
  2. import unittest
  3. import win32com.test.util
  4. import winerror
  5. class TestROT(win32com.test.util.TestCase):
  6. def testit(self):
  7. ctx = pythoncom.CreateBindCtx()
  8. rot = pythoncom.GetRunningObjectTable()
  9. num = 0
  10. for mk in rot:
  11. name = mk.GetDisplayName(ctx, None)
  12. num += 1
  13. # Monikers themselves can iterate their contents (sometimes :)
  14. try:
  15. for sub in mk:
  16. num += 1
  17. except pythoncom.com_error as exc:
  18. if exc.hresult != winerror.E_NOTIMPL:
  19. raise
  20. #if num < 2:
  21. # print "Only", num, "objects in the ROT - this is unusual"
  22. if __name__=='__main__':
  23. unittest.main()