BOARD saving test
This commit is contained in:
parent
9263a4e798
commit
bbcd2c61d6
|
@ -1,29 +0,0 @@
|
||||||
from pcbnew import *
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
class TestLoadSave(unittest.TestCase):
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
self.TITLE="Test Board"
|
|
||||||
self.COMMENT1="For load/save test"
|
|
||||||
self.FILENAME="/tmp/test.brd"
|
|
||||||
|
|
||||||
def test_00_save(self):
|
|
||||||
pcb = BOARD()
|
|
||||||
pcb.GetTitleBlock().SetTitle(self.TITLE)
|
|
||||||
pcb.GetTitleBlock().SetComment1(self.COMMENT1)
|
|
||||||
result = SaveBoard(self.FILENAME,pcb)
|
|
||||||
self.assertTrue(result)
|
|
||||||
|
|
||||||
def test_01_load(self):
|
|
||||||
pcb2 = LoadBoard(self.FILENAME)
|
|
||||||
self.assertIsNotNone(pcb2)
|
|
||||||
|
|
||||||
def test_02_titleblock_ok(self):
|
|
||||||
pcb2 = LoadBoard(self.FILENAME)
|
|
||||||
tb = pcb2.GetTitleBlock()
|
|
||||||
self.assertEqual(tb.GetTitle(),self.TITLE)
|
|
||||||
self.assertEqual(tb.GetComment1(),self.COMMENT1)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
unittest.main()
|
|
|
@ -1,7 +1,10 @@
|
||||||
import code
|
import code
|
||||||
import unittest
|
import unittest
|
||||||
|
import os
|
||||||
import pcbnew
|
import pcbnew
|
||||||
import pdb
|
import pdb
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
|
||||||
from pcbnew import *
|
from pcbnew import *
|
||||||
|
|
||||||
|
@ -9,6 +12,9 @@ class TestBoardClass(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.pcb = LoadBoard("data/complex_hierarchy.kicad_pcb")
|
self.pcb = LoadBoard("data/complex_hierarchy.kicad_pcb")
|
||||||
|
self.TITLE="Test Board"
|
||||||
|
self.COMMENT1="For load/save test"
|
||||||
|
self.FILENAME=tempfile.mktemp()+".kicad_pcb"
|
||||||
|
|
||||||
def test_pcb_find_module(self):
|
def test_pcb_find_module(self):
|
||||||
module = self.pcb.FindModule('P1')
|
module = self.pcb.FindModule('P1')
|
||||||
|
@ -74,6 +80,22 @@ class TestBoardClass(unittest.TestCase):
|
||||||
self.assertEqual(pad.this, p2.this)
|
self.assertEqual(pad.this, p2.this)
|
||||||
self.assertEqual(pad.this, p3.this)
|
self.assertEqual(pad.this, p3.this)
|
||||||
|
|
||||||
|
def test_pcb_save_and_load(self):
|
||||||
|
pcb = BOARD()
|
||||||
|
pcb.GetTitleBlock().SetTitle(self.TITLE)
|
||||||
|
pcb.GetTitleBlock().SetComment1(self.COMMENT1)
|
||||||
|
result = SaveBoard(self.FILENAME,pcb)
|
||||||
|
self.assertTrue(result)
|
||||||
|
|
||||||
|
pcb2 = LoadBoard(self.FILENAME)
|
||||||
|
self.assertIsNotNone(pcb2)
|
||||||
|
|
||||||
|
tb = pcb2.GetTitleBlock()
|
||||||
|
self.assertEqual(tb.GetTitle(),self.TITLE)
|
||||||
|
self.assertEqual(tb.GetComment1(),self.COMMENT1)
|
||||||
|
|
||||||
|
os.remove(self.FILENAME)
|
||||||
|
|
||||||
#def test_interactive(self):
|
#def test_interactive(self):
|
||||||
# code.interact(local=locals())
|
# code.interact(local=locals())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue