Пример #1
0
    def testOpenAttachmentWithNonAsciiFileNameThrowsException(
            self):  # pragma: no cover
        ''' os.startfile() does not accept unicode filenames. This will be 
            fixed in Python 2.5. This test will fail if the bug is fixed. '''
        self.errorMessage = ''  # pylint: disable-msg=W0201

        def onError(*args, **kwargs):  # pylint: disable-msg=W0613
            self.errorMessage = args[0]

        att = attachment.FileAttachment(u'tést.é')
        openAttachment = uicommand.AttachmentOpen(\
            viewer=self.editor._interior[6].viewer,
            attachments=attachment.AttachmentList([att]),
            settings=self.settings)
        openAttachment.doCommand(None, showerror=onError)
        if '__WXMSW__' in wx.PlatformInfo:  # pragma: no cover
            if sys.version_info < (2, 5):
                errorMessageStart = "'ascii' codec can't encode character"
            else:
                errorMessageStart = ''
        elif '__WXMAC__' in wx.PlatformInfo and sys.version_info >= (2, 5):
            errorMessageStart = ''  # pragma: no cover
        elif '__WXGTK__' in wx.PlatformInfo:  # pragma: no cover
            errorMessageStart = ''
        else:
            errorMessageStart = '[Error 2] '
        self.failUnless(self.errorMessage.startswith(errorMessageStart))
Пример #2
0
 def testOpenAttachmentWithNonAsciiFileName(self):
     self.errorMessage = ''  # pylint: disable=W0201
     
     def onError(*args, **kwargs):  # pylint: disable=W0613
         self.errorMessage = args[0]  # pragma: no cover
         
     att = attachment.FileAttachment(u'tést.é')
     openAttachment = uicommand.AttachmentOpen(\
         viewer=self.editor._interior[6].viewer,
         attachments=attachment.AttachmentList([att]),
         settings=self.settings)
     openAttachment.doCommand(None, showerror=onError)
     self.failIf(self.errorMessage)
Пример #3
0
 def createToolBarUICommands(self):
     commands = super(AttachmentViewer, self).createToolBarUICommands()
     commands[-2:-2] = [
         None,
         uicommand.AttachmentNew(attachments=self.presentation(),
                                 settings=self.settings),
         uicommand.AttachmentEdit(attachments=self.presentation(),
                                  viewer=self),
         uicommand.AttachmentDelete(attachments=self.presentation(),
                                    viewer=self), None,
         uicommand.AttachmentOpen(attachments=attachment.AttachmentList(),
                                  viewer=self,
                                  settings=self.settings)
     ]
     return commands
Пример #4
0
 def createActionToolBarUICommands(self):
     return (uicommand.AttachmentOpen(attachments=attachment.AttachmentList(),
                                      viewer=self, settings=self.settings),) + \
        super(AttachmentViewer, self).createActionToolBarUICommands()