Coverage for venv / lib / python3.12 / site-packages / combinatrix / test / unit / test_combine.py: 0%

38 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-05-05 00:09 +0100

1import unittest, os 

2from parameterized import parameterized 

3from combinatrix.testintegration import load_parameter_sets, rel2abs 

4from combinatrix.core import CombinatrixException, combine, load_matrix 

5from combinatrix.test.fixtures.matrix_csv import MatrixCSVFactory 

6from combinatrix.test.fixtures.settings_json import SettingsJSONFactory 

7 

8 

9def load_cases(): 

10 return load_parameter_sets(rel2abs(__file__, "..", "resources", "bundles", "combine"), "combine", "test_id", 

11 {"test_id": []}) 

12 

13 

14EXCEPTIONS = { 

15 "CombinatrixException": CombinatrixException 

16} 

17 

18OUT_PATHS = { 

19 "none": None, 

20 "missing_dir": rel2abs(__file__, "path", "does", "not", "exist"), 

21 "available": rel2abs(__file__, "..", "resources", "tmp", "combine.matrix.csv") 

22} 

23 

24 

25class TestCombine(unittest.TestCase): 

26 

27 def setUp(self): 

28 super(TestCombine, self).setUp() 

29 

30 def tearDown(self): 

31 available = OUT_PATHS["available"] 

32 if os.path.exists(available): 

33 os.remove(available) 

34 

35 super(TestCombine, self).tearDown() 

36 

37 @parameterized.expand(load_cases) 

38 def test_combine(self, name, kwargs): 

39 parameters_arg = kwargs.get("parameters") 

40 out_path_arg = kwargs.get("out_path") 

41 check_matrix_arg = kwargs.get("check_matrix") 

42 raises_arg = kwargs.get("raises") 

43 

44 raises = EXCEPTIONS.get(raises_arg) 

45 parameters = SettingsJSONFactory.get_json(parameters_arg) 

46 out_path = OUT_PATHS.get(out_path_arg) 

47 

48 if raises is not None: 

49 with self.assertRaises(raises): 

50 combine(parameters, out_path) 

51 else: 

52 combinations = combine(parameters, out_path) 

53 

54 from_file = None 

55 if out_path_arg in ["available"]: 

56 assert os.path.exists(out_path) 

57 from_file = load_matrix(out_path) 

58 

59 matrix = MatrixCSVFactory.get_matrix(check_matrix_arg) 

60 

61 assert combinations == matrix 

62 assert combinations == from_file