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

26 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 

11# Third party libraries 

12import pytest 

13from tsfpga.system_utils import read_file 

14 

15# False positive for pytest fixtures 

16# pylint: disable=redefined-outer-name 

17 

18 

19@pytest.fixture(scope="module") 

20def default_accessor_py(generate_default_accessor) -> str: 

21 """ 

22 Get the python code of the default accessor class. 

23 Can also be shared in the whole module since no data is changed. 

24 """ 

25 tmp_session_path, _ = generate_default_accessor 

26 return read_file(tmp_session_path / "test_accessor.py") 

27 

28 

29def test_correct_methods_for_r_register(default_accessor_py): 

30 assert "def read_reg_r(" in default_accessor_py 

31 assert "def write_reg_r(" not in default_accessor_py 

32 assert "def write_reg_r_bit_aa0(" not in default_accessor_py 

33 

34 

35def test_correct_methods_for_w_register(default_accessor_py): 

36 assert "def read_reg_w(" not in default_accessor_py 

37 assert "def write_reg_w(" in default_accessor_py 

38 assert "def write_reg_w_bit_aa0(" in default_accessor_py 

39 

40 

41def test_correct_methods_for_r_w_register(default_accessor_py): 

42 assert "def read_reg_r_w(" in default_accessor_py 

43 assert "def write_reg_r_w(" in default_accessor_py 

44 assert "def write_reg_r_w_bit_aa0(" in default_accessor_py 

45 

46 

47def test_correct_methods_for_wpulse_register(default_accessor_py): 

48 assert "def read_reg_wpulse(" not in default_accessor_py 

49 assert "def write_reg_wpulse(" in default_accessor_py 

50 assert "def write_reg_wpulse_bit_aa0(" in default_accessor_py 

51 

52 

53def test_correct_methods_for_r_wpulse_register(default_accessor_py): 

54 assert "def read_reg_r_wpulse(" in default_accessor_py 

55 assert "def write_reg_r_wpulse(" in default_accessor_py 

56 assert "def write_reg_r_wpulse_bit_aa0(" in default_accessor_py