Skip to content

Commit fb14e89

Browse files
committed
Add pytest for ModParse
1 parent f361b32 commit fb14e89

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

hdltools/mod_parse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from hdltools.hdl_sanitize import HdlSanitize
1616

1717

18-
class Modparse:
18+
class ModParse:
1919
"""Extract information about parameters and ports from modules."""
2020

2121
def __init__(self, fpath):
@@ -101,5 +101,5 @@ def __str__(self):
101101
parser = argparse.ArgumentParser()
102102
parser.add_argument('svfile')
103103
args = parser.parse_args()
104-
modules = Modparse(args.svfile)
104+
modules = ModParse(args.svfile)
105105
print(modules)

tests/test_modparse.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from pathlib import Path
2+
3+
from hdltools.mod_parse import ModParse
4+
5+
vfile = Path(__file__).parent.resolve() / 'hdl/modules.sv'
6+
7+
8+
def test_modules():
9+
vobj = ModParse(vfile)
10+
modules = vobj.get_modules()
11+
assert len(modules) == 3
12+
13+
14+
def test_params():
15+
vobj = ModParse(vfile)
16+
modules = vobj.get_modules()
17+
assert 'params' in modules['mod_param']
18+
19+
20+
def test_ports():
21+
vobj = ModParse(vfile)
22+
modules = vobj.get_modules()
23+
assert 'ports' in modules['mod_param']
24+
assert 'ports' in modules['mod_nopar']

0 commit comments

Comments
 (0)