Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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

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

3# 

4# This file is part of the tsfpga project. 

5# https://tsfpga.com 

6# https://gitlab.com/tsfpga/tsfpga 

7# -------------------------------------------------------------------------------------------------- 

8 

9from pathlib import Path 

10 

11import pytest 

12 

13from tsfpga.constraint import Constraint 

14from tsfpga.hdl_file import HdlFile 

15 

16 

17def test_constraint(): 

18 constraint = Constraint(Path("dummy.tcl")) 

19 constraint.validate_scoped_entity([]) 

20 

21 assert constraint.ref is None 

22 assert constraint.used_in == "all" 

23 

24 constraint = Constraint(Path("dummy.tcl"), used_in="impl") 

25 assert constraint.used_in == "impl" 

26 

27 

28def test_scoped_constraint(tmp_path): 

29 constraint = Constraint( 

30 tmp_path / "a" / "scoped_constraints" / "apa.tcl", scoped_constraint=True 

31 ) 

32 assert constraint.ref == "apa" 

33 

34 source_files = [HdlFile(tmp_path / "a" / "apa.vhd")] 

35 constraint.validate_scoped_entity(source_files) 

36 

37 

38def test_matching_entity_not_existing_should_raise_exception(tmp_path): 

39 constraint = Constraint( 

40 tmp_path / "a" / "scoped_constraints" / "dummy.tcl", scoped_constraint=True 

41 ) 

42 with pytest.raises(FileNotFoundError) as exception_info: 

43 constraint.validate_scoped_entity([]) 

44 assert str(exception_info.value).startswith("Could not find a matching entity file") 

45 

46 

47def test_can_cast_to_string_without_error(): 

48 str(Constraint(Path("dummy.tcl"), used_in="impl"))