Implement Tox for testing (#1504)

* Get rid of `make` in favor of `poe`
This moves the tasks that were previously in Makefile, into
pyproject.toml (with all the other config)

This is also more inclusive of Windows developers since they only need
Python, and no longer have to install make separately.

* update docs
* don't make code blocks also links
* implement tox for testing
* update command to use new task runner
This commit is contained in:
Jonathan Wren 2022-06-18 11:54:28 -07:00 committed by GitHub
parent bd590213a1
commit 7dccc469b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 209 additions and 104 deletions

View file

@ -37,20 +37,12 @@ parsedatetime = ">=2.6"
python-dateutil = "^2.8" # https://github.com/dateutil/dateutil/blob/master/RELEASING
pyxdg = ">=0.27.0"
"ruamel.yaml" = "^0.17.21"
rich = "^12.2.0"
# dayone-only deps
pytz = ">=2020" # https://pythonhosted.org/pytz/#issues-limitations
tzlocal = ">2.0, <3.0" # https://github.com/regebro/tzlocal/blob/master/CHANGES.txt
# Minimal deps required for testing
# I don't like repeating deps here, but
# there's no other way to do this yet until poetry v1.2 releases
# see: https://github.com/python-poetry/poetry/issues/1644
pytest = { version = ">=6.2", optional = true }
pytest-bdd = { version = ">=4.0.1", optional = true }
toml = { version = ">=0.10", optional = true }
rich = "^12.2.0"
[tool.poetry.dev-dependencies]
mkdocs = ">=1.0,<1.3"
black = { version = ">=21.5b2", allow-prereleases = true }
@ -62,6 +54,7 @@ poethepoet = "*"
pytest-clarity = "*"
pyproject-flake8 = "*"
yq = "*"
tox = "*"
[tool.poetry.extras]
testing = [ "pytest", "pytest-bdd", "toml" ]
@ -70,23 +63,46 @@ testing = [ "pytest", "pytest-bdd", "toml" ]
jrnl = 'jrnl.cli:cli'
[tool.poe.tasks]
bdd = "pytest tests/bdd --gherkin-terminal-reporter --tb=native"
bdd-debug = "poe bdd -x -vv"
format = "black ."
format-check = "black --check --diff ."
format-version = "black --version"
style-check = "pflake8 jrnl tests"
style-version = "pflake8 --version"
docs = "mkdocs serve"
unit = "pytest tests/unit"
test-unit = "tox -q -e unit --"
test-bdd = "tox -q -e bdd --"
test-all = "tox -e py --"
installer-check = "poetry check"
installer-version = "poetry --version"
# Groups of tasks
lint = [
{cmd = "poetry check"},
{cmd = "pflake8 jrnl tests"},
{cmd = "black --check --diff ."},
"installer-check",
"style-check",
"format-check",
]
test = [
"lint",
"unit",
"bdd",
"test-unit",
"test-bdd",
]
ci-lint = [
"installer-version",
"installer-check",
"style-version",
"style-check",
"format-version",
"format-check",
]
ci-test = [
"test-all",
]
[tool.isort]
@ -127,3 +143,25 @@ extend-ignore = "E101,E111,E114,E115,E116,E117,E12,E13,E2,E3,E401,E5,E70,W1,W2,W
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.tox]
# see: https://tox.wiki/en/latest/example/basic.html
legacy_tox_ini = """
[tox]
envlist = py-{unit,bdd}
isolated_build = True
[testenv]
deps =
pytest >= 6.2
pytest-bdd >=4.0.1
toml >=0.10
commands = pytest --junitxml=reports/pytest/results.xml {posargs}
passenv = HOME
[testenv:unit]
commands = pytest tests/unit {posargs}
[testenv:bdd]
commands = pytest tests/bdd --gherkin-terminal-reporter --tb=native {posargs}
"""