Skip to content

Commit

Permalink
Merge pull request #6 from PatrickOHara/pytest-plugin
Browse files Browse the repository at this point in the history
Pytest plugin
  • Loading branch information
PatrickOHara authored Dec 2, 2020
2 parents c87a1bb + ccd1fe3 commit 004fba7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 96 deletions.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ mkdocstrings>=0.13.6
mkdocs-material>=6.0.2
mypy>=0.782
pylint>=2.6.0
pytest>=6.1.1
pytest>=6.1.1
pytest-tspwplib@git+https://github.com/PatrickOHara/pytest-tspwplib.git#egg=pytest-tspwplib>=0.1.0
10 changes: 10 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,14 @@
packages=["tspwplib"],
python_requires=">=3.6",
version="0.1",
classifiers=[
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3 :: Only',
'Operating System :: OS Independent',
'License :: MIT License',
],
)
95 changes: 0 additions & 95 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,96 +1 @@
"""Fixtures for testing"""

import os
from pathlib import Path
import pytest
from tspwplib.types import Alpha, Generation, InstanceName


# add parser options


def pytest_addoption(parser):
"""Add option to enable travis specific options"""
parser.addoption(
"--tsplib-root",
default=os.environ.get("TSPLIB_ROOT"),
required=False,
type=str,
help="Filepath to tsplib95 directory",
)
parser.addoption(
"--oplib-root",
default=os.environ.get("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.one,
Generation.two,
Generation.three,
],
)
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) -> Alpha:
"""Alpha values"""
return request.param


@pytest.fixture(
scope="function",
params=[
InstanceName.eil76,
InstanceName.st70,
InstanceName.rat195,
],
)
def instance_name(request) -> InstanceName:
"""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

0 comments on commit 004fba7

Please sign in to comment.