From 1ac142fa1e785aade8272759d32561fc716e8740 Mon Sep 17 00:00:00 2001 From: Rodolfo Carvalho Date: Sun, 19 Feb 2017 14:42:33 +0100 Subject: Replace nose with pytest (utils) --- utils/.coveragerc | 15 ++++++++++++++- utils/setup.cfg | 27 ++++++++++++++++++--------- utils/setup.py | 7 +++---- utils/src/ooinstall/oo_config.py | 2 +- utils/test-requirements.txt | 3 ++- utils/tox.ini | 5 ++++- 6 files changed, 42 insertions(+), 17 deletions(-) diff --git a/utils/.coveragerc b/utils/.coveragerc index e1d918755..7a2554caf 100644 --- a/utils/.coveragerc +++ b/utils/.coveragerc @@ -1,5 +1,18 @@ [run] -omit= +branch = True +omit = */lib/python*/site-packages/* */lib/python*/* /usr/* + setup.py + # TODO(rhcarvalho): this is used to ignore test files from coverage report. + # We can make this less generic when we stick with a single test pattern in + # the repo. + test_*.py + *_tests.py + +[report] +fail_under = 70 + +[html] +directory = cover diff --git a/utils/setup.cfg b/utils/setup.cfg index 862dffd7b..d730cd3b4 100644 --- a/utils/setup.cfg +++ b/utils/setup.cfg @@ -4,15 +4,8 @@ # will need to generate wheels for each Python version that you support. universal=1 -[nosetests] -verbosity=2 -with-coverage=1 -cover-html=1 -cover-inclusive=1 -cover-min-percentage=70 -cover-erase=1 -detailed-errors=1 -cover-branches=1 +[aliases] +test=pytest [flake8] max-line-length=120 @@ -21,3 +14,19 @@ ignore=E501 [lint] lint_disable=fixme,locally-disabled,file-ignored,duplicate-code + +[tool:pytest] +testpaths = test +norecursedirs = + .* + __pycache__ +python_files = + # TODO(rhcarvalho): rename test files to follow a single pattern. "test*.py" + # is Python unittest's default, while pytest discovers both "test_*.py" and + # "*_test.py" by default. + test_*.py + *_tests.py +addopts = + --cov=. + --cov-report=term + --cov-report=html diff --git a/utils/setup.py b/utils/setup.py index 3518581e7..20e3d81dc 100644 --- a/utils/setup.py +++ b/utils/setup.py @@ -40,7 +40,7 @@ setup( # simple. Or you can use find_packages(). #packages=find_packages(exclude=['contrib', 'docs', 'tests*']), packages=['ooinstall'], - package_dir={'ooinstall': 'src/ooinstall'}, + package_dir={'': 'src'}, # List run-time dependencies here. These will be installed by pip when @@ -65,9 +65,8 @@ setup( 'ooinstall': ['ansible.cfg', 'ansible-quiet.cfg', 'ansible_plugins/*'], }, - tests_require=['nose'], - - test_suite='nose.collector', + setup_requires=['pytest-runner'], + tests_require=['pytest'], # To provide executable scripts, use entry points in preference to the # "scripts" keyword. Entry points provide cross-platform support and allow diff --git a/utils/src/ooinstall/oo_config.py b/utils/src/ooinstall/oo_config.py index 9670c03bb..c3501c018 100644 --- a/utils/src/ooinstall/oo_config.py +++ b/utils/src/ooinstall/oo_config.py @@ -176,7 +176,7 @@ class Deployment(object): class OOConfig(object): default_dir = os.path.normpath( os.environ.get('XDG_CONFIG_HOME', - os.environ['HOME'] + '/.config/') + '/openshift/') + os.environ.get('HOME', '') + '/.config/') + '/openshift/') default_file = '/installer.cfg.yml' def __init__(self, config_path): diff --git a/utils/test-requirements.txt b/utils/test-requirements.txt index 699afc26a..b26e22a7e 100644 --- a/utils/test-requirements.txt +++ b/utils/test-requirements.txt @@ -2,7 +2,6 @@ ansible # flake8 moved to before setuptools-lint to satisfy mccabe dependency issue flake8 setuptools-lint -nose coverage mock PyYAML @@ -12,3 +11,5 @@ pyOpenSSL yamllint tox detox +pytest +pytest-cov diff --git a/utils/tox.ini b/utils/tox.ini index 1308f7505..2a29d1525 100644 --- a/utils/tox.ini +++ b/utils/tox.ini @@ -11,6 +11,9 @@ deps = -rtest-requirements.txt py35-flake8: flake8-bugbear commands = + # Needed to make detox work, since it ignores usedevelop + # https://github.com/tox-dev/tox/issues/180 + unit: pip install -e . + unit: pytest flake8: python setup.py flake8 - unit: python setup.py nosetests pylint: python setup.py lint -- cgit v1.2.3