This repository has been archived by the owner on Apr 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pytest_tspwplib.py
93 lines (74 loc) · 1.95 KB
/
pytest_tspwplib.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# -*- coding: utf-8 -*-
"""Fixtures for tspwplib tests"""
import os
from pathlib import Path
import pytest
from tspwplib import Alpha, Generation, GraphName
def pytest_addoption(parser):
"""Options for filepaths for pytest-tspwplib"""
group = parser.getgroup('tspwplib')
group.addoption(
"--tsplib-root",
default=os.getenv("TSPLIB_ROOT"),
required=False,
type=str,
help="Filepath to tsplib95 directory",
)
group.addoption(
"--oplib-root",
default=os.getenv("OPLIB_ROOT"),
required=False,
type=str,
help="Filepath to oplib directory",
)
# fixtures for filepaths
@pytest.fixture(scope="function")
def tsplib_root(request) -> Path:
"""Root of tsplib95 data"""
return Path(request.config.getoption("--tsplib-root"))
@pytest.fixture(scope="function")
def oplib_root(request) -> Path:
"""Root of the cloned OP lib"""
return Path(request.config.getoption("--oplib-root"))
# fixtures for types
@pytest.fixture(
scope="function",
params=[
Generation.gen1,
Generation.gen2,
Generation.gen3,
],
)
def generation(request) -> Generation:
"""Loop through valid generations"""
# NOTE generation 4 has different alpha values
return request.param
@pytest.fixture(scope="function", params=[Alpha.fifty])
def alpha(request) -> int:
"""Alpha values"""
return request.param.value
@pytest.fixture(
scope="function",
params=[
GraphName.eil76,
GraphName.st70,
GraphName.att48,
],
)
def graph_name(request) -> GraphName:
"""Loop through valid instance names"""
return request.param
# fixtures for complete graphs
@pytest.fixture(
scope="function",
params=[
0.0,
0.1,
0.5,
0.9,
1.0,
],
)
def edge_removal_probability(request) -> float:
"""Different valid values for probability of removing an edge"""
return request.param