home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_2593 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  3.3 KB  |  88 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import sys
  5. import os
  6. import unittest
  7. import win32rcparser
  8. import win32con
  9. import tempfile
  10.  
  11. class TestParser(unittest.TestCase):
  12.     
  13.     def setUp(self):
  14.         rc_file = os.path.join(os.path.dirname(__file__), 'win32rcparser', 'test.rc')
  15.         self.resources = win32rcparser.Parse(rc_file)
  16.  
  17.     
  18.     def testStrings(self):
  19.         for sid, expected in [
  20.             ('IDS_TEST_STRING4', "Test 'single quoted' string"),
  21.             ('IDS_TEST_STRING1', 'Test "quoted" string'),
  22.             ('IDS_TEST_STRING3', 'String with single " quote'),
  23.             ('IDS_TEST_STRING2', 'Test string')]:
  24.             got = self.resources.stringTable[sid].value
  25.             self.assertEqual(got, expected)
  26.         
  27.  
  28.     
  29.     def testStandardIds(self):
  30.         for idc in 'IDOK IDCANCEL'.split():
  31.             correct = getattr(win32con, idc)
  32.             self.assertEqual(self.resources.names[correct], idc)
  33.             self.assertEqual(self.resources.ids[idc], correct)
  34.         
  35.  
  36.     
  37.     def testTabStop(self):
  38.         d = self.resources.dialogs['IDD_TEST_DIALOG2']
  39.         tabstop_names = [
  40.             'IDC_EDIT1',
  41.             'IDOK']
  42.         tabstop_ids = [ self.resources.ids[name] for name in tabstop_names ]
  43.         notabstop_names = [
  44.             'IDC_EDIT2']
  45.         notabstop_ids = [ self.resources.ids[name] for name in notabstop_names ]
  46.         num_ok = 0
  47.         for cdef in d[1:]:
  48.             cid = cdef[2]
  49.             style = cdef[-2]
  50.             styleex = cdef[-1]
  51.             if cid in tabstop_ids:
  52.                 self.failUnlessEqual(style & win32con.WS_TABSTOP, win32con.WS_TABSTOP)
  53.                 num_ok += 1
  54.                 continue
  55.             []
  56.             if cid in notabstop_ids:
  57.                 self.failUnlessEqual(style & win32con.WS_TABSTOP, 0)
  58.                 num_ok += 1
  59.                 continue
  60.             []
  61.         
  62.         self.failUnlessEqual(num_ok, len(tabstop_ids) + len(notabstop_ids))
  63.  
  64.  
  65.  
  66. class TestGenerated(TestParser):
  67.     
  68.     def setUp(self):
  69.         rc_file = os.path.join(os.path.dirname(__file__), 'win32rcparser', 'test.rc')
  70.         py_file = tempfile.mktemp('test_win32rcparser.py')
  71.         
  72.         try:
  73.             win32rcparser.GenerateFrozenResource(rc_file, py_file)
  74.             py_source = open(py_file).read()
  75.         finally:
  76.             if os.path.isfile(py_file):
  77.                 os.unlink(py_file)
  78.             
  79.  
  80.         globs = { }
  81.         exec py_source in globs, globs
  82.         self.resources = globs['FakeParser']()
  83.  
  84.  
  85. if __name__ == '__main__':
  86.     unittest.main()
  87.  
  88.