def test_isint(self): self.assertFalse(kc('1.5 isint')) self.assertTrue(kc('1.5 int isint')) self.assertFalse(kc('1.5 float isint')) self.assertFalse(kc('1.5,3.5 int isint'))
def test_isiter(self): self.assertFalse(kc('1.5 isiter')) self.assertFalse(kc('1.5 int isiter')) self.assertFalse(kc('1.5 float isiter')) self.assertTrue(kc('1.5,3.5 int isiter')) self.assertTrue(kc('1.5,3.5 split isiter'))
def test_escaped(self): self.assertEqual(kc(r'clear 12\t34\n'), r'12\t34\n') self.assertEqual(kc('escaped'), '12\t34\n')
def test_clear(self): self.assertEqual(kc('clear', returnval=-1), [])
def test_BasicstackThenClear(self): self.assertEqual(kc('0 clear', returnval=-1), [])
def test_BasicStack( self ): # all other tests in this file need to leave the stack empty self.assertEqual(kc('clear 0', returnval=-1), ['0'])
def test_PCBGettrackcount(self): # :persist newboard "Elements Create a new empty board and make it the current board." pcbnew list BOARD call delist Board spush ; # : newtrack "Elements Create bare, undefined track on current board" pcbnew list board list list TRACK callargs board list swap list Add callargs ; # new board pcb = kc('clear pcbnew list BOARD call delist Board spush board') num = kc('list GetNumSegmTrack call delist') self.assertEqual(num, 0) # Creates a new track #kc('clear pcbnew list board list list TRACK callargs') kc('clear pcbnew board TRACK callargs') # Adds track to Board kc('Board scopy swap Add callargs') # Obtain the number of tracks on this board num = kc('board GetNumSegmTrack call') self.assertEqual(num, 1) #kc(':persist newadd "Elements [TYPE PARENT] Add create a element of TYPE (TRACK, PAD) and add it to the PARENT." pcbnew list swap board list list swap stack') # Creates a new track # Adds track to Board kc('clear pcbnew board TRACK callargs') kc('board swap Add callargs') num = kc('board GetNumSegmTrack call') self.assertEqual(num, 2)
def test_PCBFindmodule_call_callargs(self): # reference = kc('board list P1 list list FindModule callargs GetReference call delist') reference = kc('board P1 FindModule callargs GetReference call') self.assertEqual(reference, 'P1')
def test_drawsegments_wxpoint_attr_length(self): result = kc('clear 0,0,1,1 mm drawsegments', returnval=-1) self.assertEqual(len(result), 1) self.assertEqual(len(result[0]), 1) # Test single list of list of numbers: result = kc('delist remove', returnval=-1) self.assertEqual(result, []) result = kc('clear 0,0,1,1 mm list drawsegments', returnval=-1) self.assertEqual(len(result), 1) self.assertEqual(len(result[0][0]), 1) result = kc('delist remove', returnval=-1) self.assertEqual(result, []) # Test single list of numbers: result = kc('clear 0,0,1,1,2,2,3,3 mm list drawsegments', returnval=-1) self.assertEqual(len(result), 1) self.assertEqual(len(result[0][0]), 3) result = kc('delist length roundint') self.assertEqual(result, [1414214.0, 1414214.0, 1414214.0]) # result = kc('delist remove',returnval=-1) # self.assertEqual(result,[]) # Test two lists of numbers: result = kc( 'clear 0,0,1,1 mm list 2,2,3,3 mm list extend drawsegments', returnval=-1) self.assertEqual(len(result), 1) self.assertEqual(len(result[0][0]), 1) self.assertEqual(len(result[0][1]), 1) result = kc('copy 1 index remove 0 index remove', returnval=-1) self.assertEqual(result, []) # list of numbers as comma-seperated string result = kc( 'clear 0,0,1000000,1000000 ,2000000,2000000,3000000,3000000 concat drawsegments', returnval=-1) self.assertEqual(len(result), 1) self.assertEqual(len(result[0][0]), 3) result = kc('delist remove', returnval=-1) self.assertEqual(result, []) result = kc( 'clear 0,0,1000000,1000000,2000000,2000000,3000000,3000000 drawsegments', returnval=-1) self.assertEqual(len(result), 1) self.assertEqual(len(result[0][0]), 3) result = kc('delist remove', returnval=-1) self.assertEqual(result, []) result = kc( 'clear 0,0,1000000,1000000 list 2000000,2000000,3000000,3000000 list extend drawsegments', returnval=-1) self.assertEqual(len(result), 1) self.assertEqual(len(result[0][0]), 1) self.assertEqual(len(result[0][1]), 1) result = kc('copy 1 index remove 0 index remove', returnval=-1) self.assertEqual(result, []) result = kc( 'clear 0,0 mm wxpoint list 1,1 mm wxpoint append 2,2 mm wxpoint append 3,3 mm wxpoint append drawsegments', returnval=-1) self.assertEqual(len(result), 1) self.assertEqual(len(result[0][0]), 3) result = kc('delist remove', returnval=-1) self.assertEqual(result, []) result = kc( 'clear 0,0 mm wxpoint list 1,1 mm wxpoint append list 2,2 mm wxpoint list 3,3 mm wxpoint append append drawsegments', returnval=-1) self.assertEqual(len(result), 1) self.assertEqual(len(result[0][0]), 1) self.assertEqual(len(result[0][1]), 1) result = kc('copy 1 index remove 0 index remove', returnval=-1) self.assertEqual(result, []) self.assertEqual( kc("clear 0,1 mm wxpoint list 2,3 mm wxpoint append 'x attr"), [0, 2000000]) self.assertEqual( kc("clear 0,1 mm wxpoint list 2,3 mm wxpoint append 'y attr"), [1000000, 3000000])