test_shortcut.py 797 B

12345678910111213141516171819202122232425
  1. """Test win32 shortcut script
  2. """
  3. from twisted.trial import unittest
  4. import os
  5. if os.name == 'nt':
  6. skipWindowsNopywin32 = None
  7. try:
  8. from twisted.python import shortcut
  9. except ImportError:
  10. skipWindowsNopywin32 = ("On windows, twisted.python.shortcut is not "
  11. "available in the absence of win32com.")
  12. import os.path
  13. class ShortcutTests(unittest.TestCase):
  14. def testCreate(self):
  15. s1=shortcut.Shortcut("test_shortcut.py")
  16. tempname=self.mktemp() + '.lnk'
  17. s1.save(tempname)
  18. self.assertTrue(os.path.exists(tempname))
  19. sc=shortcut.open(tempname)
  20. self.assertTrue(sc.GetPath(0)[0].endswith('test_shortcut.py'))
  21. ShortcutTests.skip = skipWindowsNopywin32