[tox]
envlist = py2,py3,qa,py2-grab-release,py3-grab-release

[testenv]
install_command = pip install {opts} --no-binary=pycurl {packages}
passenv = LD_LIBRARY_PATH
commands =
    - python -c 'import pycurl; print("PYCURL VERSION: ", pycurl.version)'

    threaded-urllib3: - pip uninstall -y pycurl
    threaded-pycurl: - pip uninstall -y urllib3
    py27-recent-libcurl: python -c 'import pycurl; assert "libcurl/7.59" in pycurl.version'

    python setup.py check -s
    coverage: coverage run --source grab \
    ./runtest.py --test-all \
        --backend-mongo --backend-mysql --backend-redis --backend-postgres \
    mp: --mp-mode \
    threaded-pycurl: --network-service=threaded --grab-transport=pycurl \
    threaded-urllib3: --network-service=threaded --grab-transport=urllib3 \
    {posargs}
deps =
    -rrequirements_dev.txt
    -rrequirements_dev_backend.txt

[testenv:py-grab-release]
skip_install = True
deps =
    grab
    -rrequirements_dev.txt
    -rrequirements_dev_backend.txt

[testenv:py-sigint]
commands =
    ./runtest.py -t tests.spider_sigint
    ./runtest.py -t tests.grab_sigint

[testenv:py27-nobackend]
commands =
    ./runtest.py --test-all
deps =
    -rrequirements_dev.txt

[testenv:py-appveyor]
install_command = pip install {opts} {packages}
# sitepackages needs to get access to globally installed pycurl
# Curl is installed globally because old versionf of pycurl
# is not packaged as wheels, only exe or msi.
sitepackages = True
passenv = DISTUTILS_USE_SDK MSSdk INCLUDE LIB WINDIR
commands =
    {envpython} runtest.py --test-all \
    --backend-mongo --backend-mysql --backend-redis --backend-postgres
    {envpython} runtest.py --test-all \
    --backend-mongo --backend-mysql --backend-redis --backend-postgres \
    --network-service=threaded --grab-transport=pycurl
#    {envpython} runtest.py --test-all \
#    --backend-mongo --backend-mysql --backend-redis --backend-postgres \
#    --network-service=threaded --grab-transport=urllib3

deps =
    wheels/{env:LXML_BINARY:NA}
    wheels/{env:MYSQLCLIENT_BINARY:NA}
    pyquery
    -rrequirements_dev.txt
    -rrequirements_dev_backend.txt

[testenv:pylint-all]
commands = pylint setup.py tests grab --enable=all --disable=missing-docstring,locally-disabled,locally-enabled,suppressed-message
deps =
    -rrequirements_dev.txt
    -rrequirements_dev_backend.txt

[testenv:pylint-debug]
commands = pylint {posargs}
deps =
    -rrequirements_dev.txt
    -rrequirements_dev_backend.txt

[testenv:qa]
commands =
    python setup.py check -s
    pylint setup.py tests grab
    flake8 setup.py tests grab 
deps =
    -rrequirements_dev.txt
    -rrequirements_dev_backend.txt

[testenv:doc]
whitelist_externals=make
basepython=python3
skip_install = True
changedir = docs/en
commands = make html
deps = -rrequirements_readthedocs.txt

[testenv:doc-ru]
whitelist_externals=make
basepython=python3
skip_install = True
changedir = docs/ru
commands = make html
deps = -rrequirements_readthedocs.txt
