Mercurial > lcfOS
view python/testhexfile.py @ 240:6259856841a0
Remove project
author | Windel Bouwman |
---|---|
date | Mon, 22 Jul 2013 22:37:33 +0200 |
parents | d3dccf12ca88 |
children | 58155c7c4a8e |
line wrap: on
line source
import unittest import io import hexfile class testHexFile(unittest.TestCase): def setUp(self): pass def testSave(self): hf = hexfile.HexFile() f = io.StringIO() region = hexfile.HexFileRegion(0x8000, bytes.fromhex('aabbcc')) hf.regions.append(region) hf.save(f) def testLoad(self): hf = hexfile.HexFile() dummyhex = """ :01400000aa15 """ f = io.StringIO(dummyhex) hf.load(f) def testIncorrectCrc(self): hf = hexfile.HexFile() txt = ":01400000aabb" f = io.StringIO(txt) with self.assertRaises(hexfile.HexFileException): hf.load(f) def testIncorrectLength(self): hf = hexfile.HexFile() txt = ":0140002200aabb" f = io.StringIO(txt) with self.assertRaises(hexfile.HexFileException): hf.load(f) if __name__ == '__main__': unittest.main()