コード例 #1
0
 def _testSimple(self, make_unicode):
     fgd = shell.FILEGROUPDESCRIPTORAsString([], make_unicode)
     header = struct.pack("i", 0)
     self.assertEqual(header, fgd[:len(header)])
     self._testRT(dict())
     d = dict()
     fgd = shell.FILEGROUPDESCRIPTORAsString([d], make_unicode)
     header = struct.pack("i", 1)
     self.assertEqual(header, fgd[:len(header)])
     self._testRT(d)
コード例 #2
0
ファイル: testShell.py プロジェクト: xiaoxi-s/MyEdaCalculator
 def testUnicode(self):
     # exercise a bug fixed in build 210 - multiple unicode objects failed.
     ctime, atime, wtime = self._getTestTimes()
     d = [
         dict(cFileName="foo.txt",
              sizel=(1, 2),
              pointl=(3, 4),
              dwFileAttributes=win32con.FILE_ATTRIBUTE_NORMAL,
              ftCreationTime=ctime,
              ftLastAccessTime=atime,
              ftLastWriteTime=wtime,
              nFileSize=sys_maxsize + 1),
         dict(cFileName="foo2.txt",
              sizel=(1, 2),
              pointl=(3, 4),
              dwFileAttributes=win32con.FILE_ATTRIBUTE_NORMAL,
              ftCreationTime=ctime,
              ftLastAccessTime=atime,
              ftLastWriteTime=wtime,
              nFileSize=sys_maxsize + 1),
         dict(cFileName="foo\xa9.txt",
              sizel=(1, 2),
              pointl=(3, 4),
              dwFileAttributes=win32con.FILE_ATTRIBUTE_NORMAL,
              ftCreationTime=ctime,
              ftLastAccessTime=atime,
              ftLastWriteTime=wtime,
              nFileSize=sys_maxsize + 1),
     ]
     s = shell.FILEGROUPDESCRIPTORAsString(d, 1)
     d2 = shell.StringAsFILEGROUPDESCRIPTOR(s)
     # clobber 'dwFlags' - they are not expected to be identical
     for t in d2:
         del t['dwFlags']
     self.assertEqual(d, d2)
コード例 #3
0
    def _testRT(self, fd):
        fgd_string = shell.FILEGROUPDESCRIPTORAsString([fd])
        fd2 = shell.StringAsFILEGROUPDESCRIPTOR(fgd_string)[0]

        fd = fd.copy()
        fd2 = fd2.copy()

        # The returned objects *always* have dwFlags and cFileName.
        if "dwFlags" not in fd:
            del fd2["dwFlags"]
        if "cFileName" not in fd:
            self.assertEqual(fd2["cFileName"], "")
            del fd2["cFileName"]

        self.assertEqual(fd, fd2)
コード例 #4
0
    def _testRT(self, fd):
        fgd_string = shell.FILEGROUPDESCRIPTORAsString([fd])
        fd2 = shell.StringAsFILEGROUPDESCRIPTOR(fgd_string)[0]

        fd = fd.copy()
        fd2 = fd2.copy()

        # The returned objects *always* have dwFlags and cFileName.
        if not fd.has_key('dwFlags'):
            del fd2['dwFlags']
        if not fd.has_key('cFileName'):
            self.assertEqual(fd2['cFileName'], '')
            del fd2['cFileName']

        self.assertEqual(fd, fd2)
コード例 #5
0
    def _testRT(self, fd):
        fgd_string = shell.FILEGROUPDESCRIPTORAsString([fd])
        fd2 = shell.StringAsFILEGROUPDESCRIPTOR(fgd_string)[0]

        fd = fd.copy()
        fd2 = fd2.copy()

        # The returned objects *always* have dwFlags and cFileName.
        if 'dwFlags' not in fd:
            del fd2['dwFlags']
        if 'cFileName' not in fd:
            assert fd2['cFileName'] == ''
            del fd2['cFileName']

        assert fd == fd2
コード例 #6
0
 def testUnicode(self):
     # exercise a bug fixed in build 210 - multiple unicode objects failed.
     if sys.hexversion < 0x2030000:
         # no kw-args to dict in 2.2 - not worth converting!
         return
     d = [
         dict(cFileName=u"foo.txt",
              sizel=(1, 2),
              pointl=(3, 4),
              dwFileAttributes=win32con.FILE_ATTRIBUTE_NORMAL,
              ftCreationTime=pythoncom.MakeTime(10),
              ftLastAccessTime=pythoncom.MakeTime(11),
              ftLastWriteTime=pythoncom.MakeTime(12),
              nFileSize=sys.maxint + 1),
         dict(cFileName=u"foo2.txt",
              sizel=(1, 2),
              pointl=(3, 4),
              dwFileAttributes=win32con.FILE_ATTRIBUTE_NORMAL,
              ftCreationTime=pythoncom.MakeTime(10),
              ftLastAccessTime=pythoncom.MakeTime(11),
              ftLastWriteTime=pythoncom.MakeTime(12),
              nFileSize=sys.maxint + 1),
         dict(cFileName=u"foo\xa9.txt",
              sizel=(1, 2),
              pointl=(3, 4),
              dwFileAttributes=win32con.FILE_ATTRIBUTE_NORMAL,
              ftCreationTime=pythoncom.MakeTime(10),
              ftLastAccessTime=pythoncom.MakeTime(11),
              ftLastWriteTime=pythoncom.MakeTime(12),
              nFileSize=sys.maxint + 1),
     ]
     s = shell.FILEGROUPDESCRIPTORAsString(d, 1)
     d2 = shell.StringAsFILEGROUPDESCRIPTOR(s)
     # clobber 'dwFlags' - they are not expected to be identical
     for t in d2:
         del t['dwFlags']
     self.assertEqual(d, d2)