Coverage for hdl_registers/generator/python/test/test_pickle.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.6.8, created at 2024-12-01 20:50 +0000

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

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

3# 

4# This file is part of the hdl-registers project, an HDL register generator fast enough to run 

5# in real time. 

6# https://hdl-registers.com 

7# https://github.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_TESTS 

15from hdl_registers.generator.python.pickle import PythonPickleGenerator 

16from hdl_registers.parser.toml import from_toml 

17 

18 

19def test_recreating_register_list_object(tmp_path): 

20 register_list = from_toml(name="caesar", toml_file=HDL_REGISTERS_TESTS / "regs_test.toml") 

21 PythonPickleGenerator(register_list, tmp_path).create() 

22 

23 test_recreated = load_python_module(tmp_path / "caesar.py").Caesar() 

24 assert repr(test_recreated) == repr(register_list) 

25 

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

27 assert repr(test_recreated) == repr(register_list)