19
19
20
20
prefix = '.' if 'y' in getcwd ()[- 2 :] else '..'
21
21
22
- TO_SKIP = [
23
- "prob001_convert_data.py"
24
- ]
25
-
26
22
EXAMPLES = glob (join (prefix , "examples" , "*.py" )) + \
27
23
glob (join (prefix , "examples" , "csplib" , "*.py" ))
28
- EXAMPLES = [e for e in EXAMPLES if not any (x in e for x in TO_SKIP )]
29
24
30
25
ADVANCED_EXAMPLES = glob (join (prefix , "examples" , "advanced" , "*.py" ))
31
26
36
31
"minizinc" ,
37
32
]
38
33
39
- @pytest .mark .parametrize (("solver" , "example" ), itertools .product (SOLVERS , EXAMPLES )) # run the test for each combination of solver and example
34
+
35
+ # run the test for each combination of solver and example
36
+ @pytest .mark .parametrize (("solver" , "example" ), itertools .product (SOLVERS , EXAMPLES ))
40
37
@pytest .mark .timeout (60 ) # 60-second timeout for each test
41
38
def test_example (solver , example ):
42
39
"""Loads the example file and executes its __main__ block with the given solver being set as default.
@@ -45,7 +42,10 @@ def test_example(solver, example):
45
42
solver ([string]): Loaded with parametrized solver name
46
43
example ([string]): Loaded with parametrized example filename
47
44
"""
48
- if solver in ('gurobi' , 'minizinc' ) and any (x in example for x in ["npuzzle.py" , "tst_likevrp.py" , 'sudoku_' , 'pareto_optimal.py' , 'prob009_perfect_squares.py' , 'blocks_world.py' , 'flexible_jobshop.py' ]):
45
+ if solver in ('gurobi' , 'minizinc' ) and any (x in example for x in
46
+ ["npuzzle.py" , "tst_likevrp.py" , 'sudoku_' , 'pareto_optimal.py' ,
47
+ 'prob009_perfect_squares.py' , 'blocks_world.py' ,
48
+ 'flexible_jobshop.py' ]):
49
49
return pytest .skip (reason = f"exclude { example } for { solver } , too slow or solver-specific" )
50
50
51
51
base_solvers = SolverLookup .base_solvers
@@ -87,4 +87,4 @@ def test_advanced_example(example):
87
87
if "CPM_exact" .lower () in str (e ).lower ():
88
88
pytest .skip (reason = f"Skipped, example uses Exact but is not installed, raised: { e } " )
89
89
else :
90
- raise e
90
+ raise e
0 commit comments