Skip to content

Commit

Permalink
Support windows, bump linters (#57)
Browse files Browse the repository at this point in the history
Signed-off-by: Bernát Gábor <[email protected]>
Signed-off-by: Bernát Gábor <[email protected]>
  • Loading branch information
gaborbernat committed Jun 25, 2021
1 parent 168281d commit a96c7ad
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ repos:
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/tox-dev/tox-ini-fmt
rev: "0.5.0"
rev: "0.5.1"
hooks:
- id: tox-ini-fmt
- repo: https://github.com/PyCQA/flake8
Expand Down
4 changes: 2 additions & 2 deletions src/tox_ini_fmt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def tox_ini_path_creator(argument: str) -> Path:
if not path.is_file():
raise ArgumentTypeError("path is not a file")
if not os.access(path, os.R_OK):
raise ArgumentTypeError("cannot read path")
raise ArgumentTypeError("cannot read path") # pragma: no cover
if not os.access(path, os.W_OK):
raise ArgumentTypeError("cannot write path")
raise ArgumentTypeError("cannot write path") # pragma: no cover
return path


Expand Down
3 changes: 3 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os
import sys
from stat import S_IREAD, S_IWRITE

import pytest
Expand Down Expand Up @@ -37,6 +39,7 @@ def test_cli_tox_ini_not_file(tmp_path, capsys):
(S_IWRITE, "read"),
],
)
@pytest.mark.skipif(sys.platform == "win32", reason="On Windows files cannot be read only, only folders")
def test_cli_tox_ini_permission_fail(tmp_path, capsys, flag, error):
path = tmp_path / "tox.ini"
path.write_text("")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_tox_ini_fmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ def test_help_invocation_as_module():


def test_help_invocation_as_script():
subprocess.check_call([Path(sys.executable).parent / "tox-ini-fmt", "--help"])
subprocess.check_call([str(Path(sys.executable).parent / "tox-ini-fmt"), "--help"])
25 changes: 13 additions & 12 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@ minversion = 3.14.0
[testenv]
description = run the unit tests with pytest under {basepython}
setenv =
COVERAGE_FILE = {toxworkdir}/.coverage.{envname}
COVERAGE_PROCESS_START = {toxinidir}/setup.cfg
_COVERAGE_SRC = {envsitepackagesdir}/tox_ini_fmt
COVERAGE_FILE = {toxworkdir}{/}.coverage.{envname}
COVERAGE_PROCESS_START = {toxinidir}{/}setup.cfg
_COVERAGE_SRC = {envsitepackagesdir}{/}tox_ini_fmt
extras =
test
commands =
coverage erase
coverage run -m pytest --junitxml {toxworkdir}/junit.{envname}.xml {posargs:tests}
coverage run -m pytest {tty:--color=yes} --junitxml {toxworkdir}{/}junit.{envname}.xml {posargs:tests}
coverage combine
coverage xml -o {toxworkdir}/coverage.{envname}.xml
coverage html -d {envtmpdir}/htmlcov
coverage xml -o {toxworkdir}{/}coverage.{envname}.xml
coverage html -d {envtmpdir}{/}htmlcov
coverage report --skip-covered --show-missing --fail-under 100
isolated_build_env = .pkg
package = wheel

[testenv:fix]
description = run static analysis and style check using flake8
Expand All @@ -39,14 +41,13 @@ deps =
pre-commit>=2
commands =
pre-commit run --all-files --show-diff-on-failure
python -c 'print("hint: run {envdir}/bin/pre-commit install to add checks as pre-commit hook")'

[testenv:type]
description = run type check on code base
deps =
mypy==0.782
mypy==0.902
commands =
mypy --strict --python-version 3.9 {envsitepackagesdir}/tox_ini_fmt
mypy --strict --python-version 3.9 src{/}tox_ini_fmt

[testenv:pkg_check]
description = check that the long description is valid
Expand All @@ -55,12 +56,12 @@ passenv =
basepython = python3.9
skip_install = true
deps =
build>=0.0.4
build>=0.2
twine>=3.2
changedir = {toxinidir}
commands =
python-build -s -w -o {envtmpdir} .
twine check {envtmpdir}/*
pyproject-build -o {envtmpdir} .
twine check {envtmpdir}{/}*

[testenv:dev]
description = generate a DEV environment
Expand Down

0 comments on commit a96c7ad

Please sign in to comment.