Skip to content

Commit a418d4c

Browse files
authored
Merge pull request #265 from krcb197/256-optimise-test_inst_name
optimise `test_inst_name`
2 parents 6b63fef + 60fbdd2 commit a418d4c

3 files changed

Lines changed: 21 additions & 9 deletions

File tree

src/peakrdl_python/__about__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
"""
22
peakrdl-python is a tool to generate Python Register Access Layer (RAL) from SystemRDL
3-
Copyright (C) 2021 - 2023
3+
Copyright (C) 2021 - 2025
44
55
This program is free software: you can redistribute it and/or modify
6-
it under the terms of the GNU General Public License as published by
7-
the Free Software Foundation, either version 3 of the License, or
8-
(at your option) any later version.
6+
it under the terms of the GNU Lesser General Public License as
7+
published by the Free Software Foundation, either version 3 of
8+
the License, or (at your option) any later version.
99
1010
This program is distributed in the hope that it will be useful,
1111
but WITHOUT ANY WARRANTY; without even the implied warranty of
1212
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-
GNU General Public License for more details.
13+
GNU Lesser General Public License for more details.
1414
15-
You should have received a copy of the GNU General Public License
15+
You should have received a copy of the GNU Lesser General Public License
1616
along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
1818
Variables that describes the peakrdl-python Package
1919
"""
20-
__version__ = "3.0.0rc4"
20+
__version__ = "3.0.0rc5"

src/peakrdl_python/lib_test/_common_base_test_class.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,14 @@ def _single_node_rdl_name_and_desc_test(self,
125125
self.assertIsNone(dut.rdl_desc)
126126
else:
127127
self.assertEqual(dut.rdl_desc, rdl_desc)
128+
129+
def _test_node_inst_name(self,
130+
dut: Base,
131+
parent_full_inst_name:str,
132+
inst_name:str) -> None:
133+
"""
134+
Test the `inst_name` and `full_inst_name` attributes of a node
135+
"""
136+
self.assertEqual(dut.inst_name, inst_name)
137+
full_inst_name = parent_full_inst_name + '.' + inst_name
138+
self.assertEqual(dut.full_inst_name, full_inst_name)

src/peakrdl_python/templates/addrmap_tb.py.jinja

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ class {{fq_block_name}}_single_access({{top_node.inst_name}}_TestCase): # type:
9090
"""
9191
{% for node in owned_elements.nodes -%}
9292
with self.subTest(msg='node: {{'.'.join(node.get_path_segments())}}'):
93-
self.assertEqual(self.dut.{{'.'.join(get_python_path_segments(node))}}.inst_name, '{{node.get_path_segments()[-1]}}') # type: ignore[union-attr]
94-
self.assertEqual(self.dut.{{'.'.join(get_python_path_segments(node))}}.full_inst_name, '{{'.'.join(node.get_path_segments())}}') # type: ignore[union-attr]
93+
self._test_node_inst_name(dut=self.dut.{{'.'.join(get_python_path_segments(node))}},
94+
inst_name='{{node.get_path_segments()[-1]}}',
95+
parent_full_inst_name='{{'.'.join(node.get_path_segments()[:-1])}}')
9596
{% endfor %}
9697

9798
def test_rdl_name_and_desc_property(self) -> None:

0 commit comments

Comments
 (0)