Coverage for tests/fastercap/fastercap_runner_test.py: 100%
23 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-02 23:32 +0000
« 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
29from klayout_pex.fastercap.fastercap_runner import fastercap_parse_capacitance_matrix
32@allure.parent_suite("Unit Tests")
33@allure.tag("Capacitance", "FasterCap")
34class Test(unittest.TestCase):
35 @property
36 def fastercap_testdata_dir(self) -> str:
37 return os.path.realpath(os.path.join(__file__, '..', '..', '..', 'testdata', 'fastercap'))
39 def test_fastercap_parse_capacitance_matrix(self):
40 testdata_path = os.path.join(self.fastercap_testdata_dir, 'nmos_diode2_FasterCap_Output.txt')
41 obtained_matrix = fastercap_parse_capacitance_matrix(log_path=testdata_path)
42 self.assertEqual(3, len(obtained_matrix.rows))
43 self.assertEqual(3, len(obtained_matrix.rows[0]))
44 self.assertEqual(3, len(obtained_matrix.rows[1]))
45 self.assertEqual(3, len(obtained_matrix.rows[2]))
46 self.assertEqual(
47 ['g1_VSUBS', 'g1_VDD', 'g1_VSS'],
48 obtained_matrix.conductor_names
49 )
51 tmp_dir = tempfile.mkdtemp(prefix="fastercap_matrix_")
52 output_path = os.path.join(tmp_dir, 'nmos_diode2_FasterCap_Result_Matrix.csv')
53 obtained_matrix.write_csv(output_path=output_path, separator=';')
54 allure.attach.file(output_path, attachment_type=allure.attachment_type.CSV)