[tox]
envlist = py3
skipsdist = true

###
# Cheatsheet:
#
#  * run a specific test suite: tox -- tests/test_layout.py
#  * run a specific single test case: tox -- tests/test_layout.py::test_single_frame_layout
#  * run tests matching a substring expression: tox -- _remove_
#  * run tests in parallel: tox -- -n auto
#
# Library references:
#  * ewmh: https://ewmh.readthedocs.io/en/latest/
###

###
[testenv]
# OBACHT / CAUTION: you need to have xvfb installed (xorg-server-xvfb)
#
# we need to ensure the local dependency (./python) is up to date
# in the virtual env, so we always re-install it before testing. (We do not
# need to do this in testenv:flake8, because that scans the entire git
# repository anyway)
commands =
    pip install ./python/
    {envpython} -m pytest {posargs}
deps =
    ewmh
    pytest-xdist
    # pin python-xlib to version 0.31 until the issue
    # https://github.com/python-xlib/python-xlib/pull/242
    # is fixed.
    python-xlib==0.31
    ./python/

; Pass $PWD as it is when tox is invoked to pytest (used to find hlwm binaries)
; LSAN_OPTIONS is used for suppressing warnings about known memory leaks
passenv =
    PWD
    LSAN_OPTIONS

[testenv:flake8]
deps =
    flake8 == 7.1.2
commands = flake8 .

[flake8]
ignore =
    # line too long
    E501,
    # incompatible with pep8.. "Line break occurred before a binary operator"
    W503,

[pytest]
markers =
    exclude_from_coverage: Some tests are not relevant for the coverage report
# get python stacktrace when a test takes more than 'faulthandler_timeout' secs
# https://docs.pytest.org/en/latest/reference.html#confval-faulthandler_timeout
faulthandler_timeout = 240
