Coverage for hdl_registers/test/unit/test_register_python_generator.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2023-01-29 22:03 +0000

1# -------------------------------------------------------------------------------------------------- 

2# Copyright (c) Lukas Vik. All rights reserved. 

3# 

4# This file is part of the hdl_registers project, a HDL register generator fast enough to be run 

5# in real time. 

6# https://hdl-registers.com 

7# https://gitlab.com/hdl_registers/hdl_registers 

8# -------------------------------------------------------------------------------------------------- 

9 

10# Third party libraries 

11from tsfpga.system_utils import load_python_module 

12 

13# First party libraries 

14from hdl_registers import HDL_REGISTERS_TEST 

15from hdl_registers.parser import from_toml 

16 

17 

18def test_recreating_register_list_object(tmp_path): 

19 toml_file = HDL_REGISTERS_TEST / "regs_test.toml" 

20 test_regs = from_toml("test", toml_file) 

21 test_regs.create_python_class(tmp_path) 

22 

23 test_recreated = load_python_module(tmp_path / "test.py").Test() 

24 assert repr(test_recreated) == repr(test_regs) 

25 

26 test_recreated = load_python_module(tmp_path / "test.py").get_register_list() 

27 assert repr(test_recreated) == repr(test_regs)