[tox] envlist = py3, lowest-supported-dev, flake8, pylint, black, isort recreate = True [testenv] basepython = python3 setenv = LC_ALL = en_US.utf-8 passenv= PYTEST_ADDOPTS [flake_env] envdir = {toxworkdir}/.flake_env deps = flake8==3.9.2 pylint==2.11.1 black==21.12b0 isort==5.10.1 -r{toxinidir}/test-requirements.txt -r{toxinidir}/integration-requirements.txt [testenv:flake8] envdir = {[flake_env]envdir} deps = {[flake_env]deps} commands = {envpython} -m flake8 {posargs:cloudinit/ tests/ tools/ setup.py} [testenv:pylint] envdir = {[flake_env]envdir} deps = {[flake_env]deps} commands = {envpython} -m pylint {posargs:cloudinit tests tools} [testenv:black] envdir = {[flake_env]envdir} deps = {[flake_env]deps} commands = {envpython} -m black . --check [testenv:isort] envdir = {[flake_env]envdir} deps = {[flake_env]deps} commands = {envpython} -m isort . --check-only [testenv:format] envdir = {[flake_env]envdir} deps = {[flake_env]deps} commands = {envpython} -m isort . {envpython} -m black . [testenv:py3] deps = -r{toxinidir}/test-requirements.txt commands = {envpython} -m pytest \ --durations 10 \ {posargs:--cov=cloudinit --cov-branch \ tests/unittests} [lowest-supported-deps] # Tox is going to install requirements from pip. This is fine for # testing python version compatibility, but when we build cloud-init, we are # building against the dependencies in the OS repo, not pip. The OS # dependencies will generally be older than what is found in pip. # To obtain these versions, check the versions of these libraries # in the oldest support Ubuntu distro. # httpretty isn't included here because python2.7 requires a higher version # than whats run on bionic, so we need two different definitions. deps = jinja2==2.10 oauthlib==2.0.6 pyserial==3.4 configobj==5.0.6 pyyaml==3.12 requests==2.18.4 jsonpatch==1.16 jsonschema==2.6.0 netifaces==0.10.4 # test-requirements pytest==3.3.2 pytest-cov==2.5.1 # Needed by pytest and default causes failures attrs==17.4.0 [testenv:lowest-supported] # This definition will run on bionic with the version of httpretty # that runs there deps = {[lowest-supported-deps]deps} httpretty==0.8.14 commands = {[testenv:py3]commands} [testenv:lowest-supported-dev] # The oldest httpretty version to work with Python 3.7+ is 0.9.5, # because it is the first to include this commit: # https://github.com/gabrielfalcao/HTTPretty/commit/5776d97da3992b9071db5e21faf175f6e8729060 deps = {[lowest-supported-deps]deps} httpretty==0.9.5 commands = {[testenv:py3]commands} [testenv:doc] deps = -r{toxinidir}/doc-requirements.txt commands = {envpython} -m sphinx {posargs:doc/rtd doc/rtd_html} doc8 doc/rtd [testenv:tip-flake8] commands = {envpython} -m flake8 {posargs:cloudinit/ tests/ tools/ setup.py} deps = flake8 [testenv:tip-pylint] commands = {envpython} -m pylint {posargs:cloudinit tests tools} deps = # requirements pylint # test-requirements -r{toxinidir}/test-requirements.txt -r{toxinidir}/integration-requirements.txt [testenv:integration-tests] commands = {envpython} -m pytest --log-cli-level=INFO {posargs:tests/integration_tests} deps = -r{toxinidir}/integration-requirements.txt passenv = CLOUD_INIT_* SSH_AUTH_SOCK OS_* [testenv:integration-tests-ci] commands = {[testenv:integration-tests]commands} deps = {[testenv:integration-tests]deps} passenv = CLOUD_INIT_* SSH_AUTH_SOCK OS_* TRAVIS setenv = PYTEST_ADDOPTS="-m ci and not adhoc" [testenv:integration-tests-jenkins] commands = {[testenv:integration-tests]commands} deps = {[testenv:integration-tests]deps} passenv = *_proxy CLOUD_INIT_* SSH_AUTH_SOCK OS_* GOOGLE_* GCP_* setenv = PYTEST_ADDOPTS="-m not adhoc" [flake8] # E203: whitespace before ':', doesn't adhere to pep8 or black formatting # W503: line break before binary operator ignore=E203,W503 exclude = .venv,.tox,dist,doc,*egg,.git,build,tools per-file-ignores = cloudinit/cmd/main.py:E402 [pytest] # TODO: s/--strict/--strict-markers/ once pytest version is high enough testpaths = tests/unittests addopts = --strict log_format = %(asctime)s %(levelname)-9s %(name)s:%(filename)s:%(lineno)d %(message)s log_date_format = %Y-%m-%d %H:%M:%S markers = allow_subp_for: allow subp usage for the given commands (disable_subp_usage) allow_all_subp: allow all subp usage (disable_subp_usage) ci: run this integration test as part of CI test runs ds_sys_cfg: a sys_cfg dict to be used by datasource fixtures ec2: test will only run on EC2 platform gce: test will only run on GCE platform azure: test will only run on Azure platform oci: test will only run on OCI platform openstack: test will only run on openstack platform lxd_config_dict: set the config_dict passed on LXD instance creation lxd_container: test will only run in LXD container lxd_setup: specify callable to be called between init and start lxd_use_exec: `execute` will use `lxc exec` instead of SSH lxd_vm: test will only run in LXD VM not_bionic: test cannot run on the bionic release no_container: test cannot run in a container user_data: the user data to be passed to the test instance instance_name: the name to be used for the test instance sru_2020_11: test is part of the 2020/11 SRU verification sru_2021_01: test is part of the 2021/01 SRU verification sru_next: test is part of the next SRU verification ubuntu: this test should run on Ubuntu unstable: skip this test because it is flakey adhoc: only run on adhoc basis, not in any CI environment (travis or jenkins)