Coverage for rust2rpm/tests/test_crate.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-10-27 15:21 +0100

1import pytest 

2 

3from rust2rpm.crate import guess_local_project_version_from_dir 

4 

5 

6@pytest.mark.parametrize( 

7 "path,project,version", 

8 [ 

9 ("project-1.2.3", "project", "1.2.3"), 

10 ("test-project-1.2.3", "test-project", "1.2.3"), 

11 ], 

12 ids=repr, 

13) 

14def test_guess_local_project_version_from_dir(path: str, project: str, version: str): 

15 p, v = guess_local_project_version_from_dir(path) 

16 assert (p, v) == (project, version) 

17 

18 

19@pytest.mark.parametrize( 

20 "path,error", 

21 [ 

22 ("helix-23.10-source", "Invalid version"), 

23 ], 

24 ids=repr, 

25) 

26def test_guess_local_project_version_from_dir_fail(path: str, error: str): 

27 with pytest.raises(ValueError) as exc: 

28 guess_local_project_version_from_dir(path) 

29 assert error in str(exc.value)