Coverage for tests/fastcap/fastcap_runner_test.py: 100%

24 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-02 23:32 +0000

1# 

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

3# SPDX-FileCopyrightText: 2024-2025 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/iic-jku/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 tempfile 

27import unittest 

28 

29from klayout_pex.fastcap.fastcap_runner import fastcap_parse_capacitance_matrix 

30 

31 

32@allure.parent_suite("Unit Tests") 

33@allure.tag("Capacitance", "FastCap") 

34class Test(unittest.TestCase): 

35 @property 

36 def fastcap_testdata_dir(self) -> str: 

37 return os.path.realpath(os.path.join(__file__, '..', '..', '..', 'testdata', 'fastcap')) 

38 

39 def test_fastcap_parse_capacitance_matrix(self): 

40 testdata_path = os.path.join(self.fastcap_testdata_dir, 'cap_mim_m3_w18p9_l5p1__REDUX122_FastCap_Output.txt') 

41 obtained_matrix = fastcap_parse_capacitance_matrix(log_path=testdata_path) 

42 self.assertEqual(4, len(obtained_matrix.rows)) 

43 self.assertEqual(4, len(obtained_matrix.rows[0])) 

44 self.assertEqual(4, len(obtained_matrix.rows[1])) 

45 self.assertEqual(4, len(obtained_matrix.rows[2])) 

46 self.assertEqual(4, len(obtained_matrix.rows[3])) 

47 self.assertEqual( 

48 ['$1%GROUP2', '$1%GROUP2', '$2%GROUP3', '$2%GROUP3'], 

49 obtained_matrix.conductor_names 

50 ) 

51 

52 tmp_dir = tempfile.mkdtemp(prefix="fastcap_matrix_") 

53 output_path = os.path.join(tmp_dir, 'cap_mim_m3_w18p9_l5p1__REDUX122_FastCap_Result_Matrix.csv') 

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

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