From 9ba33ac11cfaa5cbbdc8dca9f1959387a5d156da Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Wed, 16 Oct 2019 13:14:36 +0200 Subject: [PATCH] python-common: Add mypy testing Signed-off-by: Sebastian Wagner --- src/python-common/setup.cfg | 5 +++++ src/python-common/setup.py | 15 +++++++++++++-- src/python-common/tox.ini | 10 +++++++--- 3 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 src/python-common/setup.cfg diff --git a/src/python-common/setup.cfg b/src/python-common/setup.cfg new file mode 100644 index 0000000000000..e518626339c6b --- /dev/null +++ b/src/python-common/setup.cfg @@ -0,0 +1,5 @@ +[tool:pytest] +addopts = -vv + +[aliases] +test=pytest diff --git a/src/python-common/setup.py b/src/python-common/setup.py index cf1f661cfd465..6692ddab4dda6 100644 --- a/src/python-common/setup.py +++ b/src/python-common/setup.py @@ -1,6 +1,16 @@ +import sys + from setuptools import setup, find_packages +if sys.version_info >= (3,0): + mypy = ['mypy', 'pytest-mypy'] + pytest = 'pytest >=2.1.3' +else: + mypy = [] + pytest = 'pytest >=2.1.3,<5' + + with open("README.rst", "r") as fh: long_description = fh.read() @@ -20,10 +30,11 @@ setup( install_requires=( 'six', ), + setup_requires=['pytest-runner'], tests_require=[ - 'pytest >=2.1.3', + pytest, 'tox', - ], + ] + mypy, classifiers = [ 'Intended Audience :: Developer', 'Operating System :: POSIX :: Linux', diff --git a/src/python-common/tox.ini b/src/python-common/tox.ini index 5af1cc086b3f2..268cd56a71f42 100644 --- a/src/python-common/tox.ini +++ b/src/python-common/tox.ini @@ -3,9 +3,13 @@ envlist = py27, py3, lint skip_missing_interpreters = true [testenv] -deps= - pytest -commands=py.test -v {posargs:ceph/tests} +deps=-rrequirements.txt + +[testenv:py3] +commands=python setup.py test --addopts="--mypy --mypy-ignore-missing-imports" {posargs} + +[testenv:py27] +commands=python setup.py test {posargs} [tool:pytest] norecursedirs = .* _* virtualenv -- 2.39.5