Skip to content

Commit

Permalink
Fixing problem in the AscEditor testbench
Browse files Browse the repository at this point in the history
  • Loading branch information
nunobrum committed Aug 11, 2023
1 parent 741f877 commit a2692c2
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions unittests/test_asc_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,36 @@ def setUp(self):
self.edt = PyLTSpice.editor.asc_editor.AscEditor(test_dir + "DC sweep.asc")

def test_component_editing(self):
golden = './golden/'
self.assertEqual(self.edt.get_component_value('R1'), '10k', "Tested R1 Value") # add assertion here
self.assertListEqual(self.edt.get_components(), ['Vin', 'R1', 'R2', 'D1'], "Tested get_components") # add assertion here
self.edt.set_component_value('R1', '33k')
self.edt.write_netlist(test_dir + 'test_components_output.asc')
self.equalFiles(test_dir + 'test_components_output.asc', golden + 'test_components_output.asc')
self.equalFiles(test_dir + 'test_components_output.asc', golden_dir + 'test_components_output.asc')
self.assertEqual(self.edt.get_component_value('R1'), '33k', "Tested R1 Value") # add assertion here
self.edt.remove_component('R1')
self.edt.write_netlist(test_dir + 'test_components_output_1.asc')
self.equalFiles(test_dir + 'test_components_output_1.asc', golden + 'test_components_output_1.asc')
self.equalFiles(test_dir + 'test_components_output_1.asc', golden_dir + 'test_components_output_1.asc')

def test_parameter_edit(self):
golden = './golden/'
self.assertEqual(self.edt.get_parameter('TEMP'), '0', "Tested TEMP Parameter") # add assertion here
self.edt.set_parameter('TEMP', 25)
self.assertEqual(self.edt.get_parameter('TEMP'), '25', "Tested TEMP Parameter") # add assertion here
self.edt.write_netlist(test_dir + 'test_parameter_output.asc')
self.equalFiles(test_dir + 'test_parameter_output.asc', golden + 'test_parameter_output.asc')
self.equalFiles(test_dir + 'test_parameter_output.asc', golden_dir + 'test_parameter_output.asc')
self.edt.set_parameter('TEMP', 0) # reset to 0
self.assertEqual(self.edt.get_parameter('TEMP'), '0.0', "Tested TEMP Parameter") # add assertion here

def test_instructions(self):
golden = './golden/'
self.edt.add_instruction('.ac dec 10 1 100k')
self.edt.add_instruction('.save V(vout)')
self.edt.add_instruction('.save I(R1)')
self.edt.add_instruction('.save I(R2)')
self.edt.add_instruction('.save I(D1)')
self.edt.write_netlist(test_dir + 'test_instructions_output.asc')
self.equalFiles(test_dir + 'test_instructions_output.asc', golden + 'test_instructions_output.asc')
self.equalFiles(test_dir + 'test_instructions_output.asc', golden_dir + 'test_instructions_output.asc')
self.edt.remove_instruction('.save I(R1)')
self.edt.write_netlist(test_dir + 'test_instructions_output_1.asc')
self.equalFiles(test_dir + 'test_instructions_output_1.asc', golden + 'test_instructions_output_1.asc')
self.equalFiles(test_dir + 'test_instructions_output_1.asc', golden_dir + 'test_instructions_output_1.asc')

def equalFiles(self, file1, file2):
with open(file1, 'r') as f1:
Expand Down

0 comments on commit a2692c2

Please sign in to comment.