Coverage for tests/fastercap/fastercap_runner_test.py: 100%

21 statements  

« prev     ^ index     » next       coverage.py v7.6.9, created at 2024-12-17 17:24 +0000

1# 

2# -------------------------------------------------------------------------------- 

3# SPDX-FileCopyrightText: 2024 Martin Jan Köhler and Harald Pretl 

4# Johannes Kepler University, Institute for Integrated Circuits. 

5# 

6# This file is part of KPEX  

7# (see https://github.com/martinjankoehler/klayout-pex). 

8# 

9# This program is free software: you can redistribute it and/or modify 

10# it under the terms of the GNU General Public License as published by 

11# the Free Software Foundation, either version 3 of the License, or 

12# (at your option) any later version. 

13# 

14# This program is distributed in the hope that it will be useful, 

15# but WITHOUT ANY WARRANTY; without even the implied warranty of 

16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

17# GNU General Public License for more details. 

18# 

19# You should have received a copy of the GNU General Public License 

20# along with this program. If not, see <http://www.gnu.org/licenses/>. 

21# SPDX-License-Identifier: GPL-3.0-or-later 

22# -------------------------------------------------------------------------------- 

23# 

24import allure 

25import os 

26import unittest 

27 

28from klayout_pex.fastercap.fastercap_runner import fastercap_parse_capacitance_matrix 

29 

30 

31@allure.parent_suite("Unit Tests") 

32@allure.tag("Capacitance", "FasterCap") 

33class Test(unittest.TestCase): 

34 @property 

35 def fastercap_testdata_dir(self) -> str: 

36 return os.path.realpath(os.path.join(__file__, '..', '..', '..', 'testdata', 'fastercap')) 

37 

38 def test_fastercap_parse_capacitance_matrix(self): 

39 testdata_path = os.path.join(self.fastercap_testdata_dir, 'nmos_diode2_FasterCap_Output.txt') 

40 obtained_matrix = fastercap_parse_capacitance_matrix(log_path=testdata_path) 

41 self.assertEqual(3, len(obtained_matrix.rows)) 

42 self.assertEqual(3, len(obtained_matrix.rows[0])) 

43 self.assertEqual(3, len(obtained_matrix.rows[1])) 

44 self.assertEqual(3, len(obtained_matrix.rows[2])) 

45 self.assertEqual( 

46 ['g1_VSUBS', 'g1_VDD', 'g1_VSS'], 

47 obtained_matrix.conductor_names 

48 ) 

49 

50 output_path = os.path.join(self.fastercap_testdata_dir, 'nmos_diode2_FasterCap_Result_Matrix.csv') 

51 obtained_matrix.write_csv(output_path=output_path, separator=';') 

52 allure.attach.file(output_path, attachment_type=allure.attachment_type.CSV)