Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tox4: Use mypy --strict #111

Merged
merged 1 commit into from Jan 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions pyproject.toml
Expand Up @@ -19,6 +19,9 @@ source = [
"*/site-packages",
]

[tool.mypy]
strict = true

[tool.pytest.ini_options]
markers = [
"integration: mark as an integration test.",
Expand Down
34 changes: 26 additions & 8 deletions tests/test_plugin.py
@@ -1,4 +1,7 @@
from typing import Any, Dict, Iterable, List, Tuple

import pytest
from pytest_mock import MockerFixture

from tox_gh_actions import plugin

Expand Down Expand Up @@ -182,14 +185,20 @@
),
],
)
def test_get_factors(mocker, config, version, environ, expected):
# TODO Improve type hints for config
def test_get_factors(
mocker: MockerFixture,
config: Dict[str, Any],
version: List[str],
environ: Dict[str, str],
expected: List[str],
) -> None:
mocker.patch("tox_gh_actions.plugin.os.environ", environ)
result = normalize_factors_list(plugin.get_factors(config, version))
expected = normalize_factors_list(expected)
assert result == expected
assert result == normalize_factors_list(expected)


def normalize_factors_list(factors):
def normalize_factors_list(factors: Iterable[str]) -> List[Tuple[str, ...]]:
"""Utility to make it compare equality of a list of factors"""
result = [tuple(sorted(f.split("-"))) for f in factors]
result.sort()
Expand Down Expand Up @@ -231,7 +240,9 @@ def normalize_factors_list(factors):
),
],
)
def test_get_envlist_from_factors(envlist, factors, expected):
def test_get_envlist_from_factors(
envlist: List[str], factors: List[str], expected: List[str]
) -> None:
assert plugin.get_envlist_from_factors(envlist, factors) == expected


Expand All @@ -251,13 +262,18 @@ def test_get_envlist_from_factors(envlist, factors, expected):
),
],
)
def test_get_version_keys(mocker, version, info, expected):
def test_get_version_keys(
mocker: MockerFixture,
version: str,
info: Tuple[int, int, int, str, int],
expected: List[str],
) -> None:
mocker.patch("tox_gh_actions.plugin.sys.version", version)
mocker.patch("tox_gh_actions.plugin.sys.version_info", info)
assert plugin.get_python_version_keys() == expected


def test_get_version_keys_on_pyston(mocker):
def test_get_version_keys_on_pyston(mocker: MockerFixture) -> None:
mocker.patch(
"tox_gh_actions.plugin.sys.pyston_version_info",
(2, 2, 0, "final", 0),
Expand All @@ -283,6 +299,8 @@ def test_get_version_keys_on_pyston(mocker):
({}, False),
],
)
def test_is_running_on_actions(mocker, environ, expected):
def test_is_running_on_actions(
mocker: MockerFixture, environ: Dict[str, str], expected: bool
) -> None:
mocker.patch("tox_gh_actions.plugin.os.environ", environ)
assert plugin.is_running_on_actions() == expected