def testParseStyleData(self): """Test parsing Editra Style Sheets""" # Test valid style sheet data = common.GetFileContents(self.stylesheet) styledict = self.mgr.ParseStyleData(data) for tag, item in styledict.iteritems(): self.assertTrue(isinstance(tag, types.UnicodeType), "%s Is not Unicode!" % tag) self.assertTrue(isinstance(item, ed_style.StyleItem)) # Test loading sheet with malformed data sheet_path = common.GetDataFilePath('incorrect_syntax.ess') data = common.GetFileContents(sheet_path) styledict2 = self.mgr.ParseStyleData(data) self.assertTrue(len(styledict) > len(styledict2)) for tag, item in styledict2.iteritems(): self.assertTrue(isinstance(tag, types.UnicodeType), "%s Is not Unicode!" % tag) self.assertTrue(isinstance(item, ed_style.StyleItem)) # Test stylesheet that is all on one line sheet_path = common.GetDataFilePath('one_liner.ess') data = common.GetFileContents(sheet_path) styledict3 = self.mgr.ParseStyleData(data) for tag, item in styledict3.iteritems(): self.assertTrue(isinstance(tag, types.UnicodeType), "%s Is not Unicode!" % tag) self.assertTrue(isinstance(item, ed_style.StyleItem))
def setUp(self): self.path = common.GetDataFilePath(u'syntax.xml') self.bad = common.GetDataFilePath(u'bad.xml') self.xml = common.GetFileContents(self.path) self.badxml = common.GetFileContents(self.bad) self.fhandle = syntax.SyntaxModeHandler(self.path) self.fhandle.LoadFromDisk()
def testPathExists(self): """Test if a path exists""" path = common.GetDataFilePath(u'test_read_utf8.txt') fail = common.GetDataFilePath(u'fake_file.txt') # Test regular file paths self.assertTrue(ebmlib.PathExists(path)) self.assertFalse(ebmlib.PathExists(fail)) # Test URI path = u"file://" + path fail = u"file://" + fail self.assertTrue(ebmlib.PathExists(path)) self.assertFalse(ebmlib.PathExists(fail))
def setUp(self): self.mgr = ed_style.StyleMgr() self.dd = dict(ed_style.DEF_STYLE_DICT) self.bstr = [ "fore:#000000", "back:#FFFFFF", "face:%(primary)s", "size:%(size)d" ] self.stylesheet = common.GetDataFilePath('no_comment_style.ess')
def setUp(self): profiler.Profile_Set('ENCODING', locale.getpreferredencoding()) self.app = common.EdApp(False) self.path = common.GetDataFilePath(u'test_read_utf8.txt') self.file = ed_txt.EdFile(self.path) self.mtime = ebmlib.GetFileModTime(self.path) self.rpath = common.GetDataFilePath(u'embedded_nulls.txt') self.rfile = ed_txt.EdFile(self.rpath) self.ipath = common.GetDataFilePath(u'image_test.png') self.img = ed_txt.EdFile(self.ipath) self.bpath = common.GetDataFilePath(u'test_read_utf8_bom.txt') self.utf8_bom_file = ed_txt.EdFile(self.bpath)
def testReadUTF32Bom(self): """Test reading a file that has a UTF32 BOM""" fname = common.GetDataFilePath('test_read_utf32_bom.txt') fileutf32 = ed_txt.EdFile(fname) data = fileutf32.Read() self.assertTrue(fileutf32.HasBom(), "UTF-32 BOM not detected!") self.assertTrue(fileutf32.Encoding in ("utf-32", "utf_32"), "Incorrect Encoding detected: %s" % fileutf32.Encoding)
def testValidateColourData(self): """Validate that colour data is getting parsed correctly""" sheet_path = common.GetDataFilePath('old_format.ess') data = common.GetFileContents(sheet_path) styledict = self.mgr.ParseStyleData(data) styledict = self.mgr.PackStyleSet(styledict) for tag, item in styledict.iteritems(): self.doValidateColourAttrs(tag, item)
def testGetUniqueName(self): """Test getting a unique file name at a given path""" path = ebmlib.GetUniqueName(self.ddir, u'test_read_utf8.txt') self.assertTrue(path != self.fpath) # File that does not yet exist path = common.GetDataFilePath(u'newfile.txt') uname = ebmlib.GetUniqueName(self.ddir, u'newfile.txt') self.assertTrue(path == uname)
def testReadNonPrintChars(self): """Test reading a plain text file that has a non printable character in it. """ path = common.GetDataFilePath(u'non_print_char.txt') fileobj = ed_txt.EdFile(path) txt = fileobj.Read() self.assertTrue(type(txt) == types.UnicodeType) self.assertFalse(fileobj.IsRawBytes()) self.assertFalse(fileobj.IsReadOnly())
def setUp(self): # NEED this otherwise GetApp calls fail for some yet to be # determined reason even though an App has been created earlier # in runUnitTests... self.app = common.EdApp(False) self.path = common.GetDataFilePath(u'test_read_utf8.txt') self.file = ed_txt.EdFile(self.path) self.mtime = ebmlib.GetFileModTime(self.path) self.path_utf16 = common.GetDataFilePath(u'test_read_utf16.txt') self.mtime_utf16 = ebmlib.GetFileModTime(self.path_utf16) self.path_utf16_big = common.GetDataFilePath(u'test_read_utf16_big.txt') self.ipath = common.GetDataFilePath(u'image_test.png') self.img = ed_txt.EdFile(self.ipath) self.bpath = common.GetDataFilePath(u'test_read_utf8_bom.txt') self.utf8_bom_file = ed_txt.EdFile(self.bpath)
def testIsRawBytes(self): """Test reading a file that can't be properly encoded and was read as raw bytes. """ txt = self.file.Read() self.assertTrue(ebmlib.IsUnicode(txt)) self.assertFalse(self.file.IsRawBytes()) rpath = common.GetDataFilePath(u'embedded_nulls.txt') rfile = ed_txt.EdFile(rpath) txt = rfile.Read() self.assertTrue(ebmlib.IsUnicode(txt)) self.assertFalse(rfile.IsRawBytes()) bytes_value = self.img.Read() self.assertTrue(self.img.IsRawBytes())
def setUp(self): self.fpath = common.GetDataFilePath(u'test_read_utf8.txt') self.bpath = common.GetDataFilePath(u'image_test.png') self.checker = ebmlib.FileTypeChecker()
def setUp(self): self._mgr = ed_session.SessionManager(common.GetTempDir()) common.CopyToTempDir(common.GetDataFilePath('__default.session'))
def setUp(self): self.path = common.GetDataFilePath(u'test_read_utf8.txt') self.file = ebmlib.FileObjectImpl(self.path) self.mtime = ebmlib.GetFileModTime(self.path)
def setUp(self): self.fpath = common.GetDataFilePath(u'test_read_utf8.txt') self.bpath = common.GetDataFilePath(u'image_test.png')
def setUp(self): self.ddir = common.GetDataDir() self.tdir = common.GetTempDir() self.fpath = common.GetDataFilePath(u'test_read_utf8.txt')
def setUp(self): self.app = common.EdApp(False) self.path = common.GetDataFilePath(u'test_read_utf8.txt') self.file = ed_txt.EdFile(self.path) self.mtime = ebmlib.GetFileModTime(self.path)
def testLoadFile(self): """Test loading a file into the control""" path = common.GetDataFilePath("syntax.xml") self.assertTrue(self.stc.LoadFile(path)) self.assertFalse(self.stc.GetReadOnly()) # should be good text