summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorJason DeTiberus <detiber@gmail.com>2017-02-20 12:36:23 -0500
committerGitHub <noreply@github.com>2017-02-20 12:36:23 -0500
commit3d80a37685da4948aad62419e49335cb5a140826 (patch)
tree2dabc7c9bee247b9e85a10ed4178765a54f7fe6c /utils
parentbc26f6b0fc90d4501161e16dcf68130d03ca06a7 (diff)
parentdf1fd5b8f97c69eef10c02f317b62755c4519d92 (diff)
downloadopenshift-3d80a37685da4948aad62419e49335cb5a140826.tar.gz
openshift-3d80a37685da4948aad62419e49335cb5a140826.tar.bz2
openshift-3d80a37685da4948aad62419e49335cb5a140826.tar.xz
openshift-3d80a37685da4948aad62419e49335cb5a140826.zip
Merge pull request #3419 from rhcarvalho/pytest
Migrate from nose to pytest
Diffstat (limited to 'utils')
-rw-r--r--utils/.coveragerc15
-rw-r--r--utils/README.md41
-rw-r--r--utils/setup.cfg27
-rw-r--r--utils/setup.py7
-rw-r--r--utils/src/ooinstall/oo_config.py2
-rw-r--r--utils/test-requirements.txt3
-rw-r--r--utils/tox.ini5
7 files changed, 58 insertions, 42 deletions
diff --git a/utils/.coveragerc b/utils/.coveragerc
index e1d918755..551e13192 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 = 73
+
+[html]
+directory = cover
diff --git a/utils/README.md b/utils/README.md
index c37ab41e6..7aa045ae4 100644
--- a/utils/README.md
+++ b/utils/README.md
@@ -1,56 +1,61 @@
-# Running Tests (NEW)
+# Running Tests
Run the command:
make ci
-to run an array of unittests locally.
+to run tests and linting tools.
Underneath the covers, we use [tox](http://readthedocs.org/docs/tox/) to manage virtualenvs and run
tests. Alternatively, tests can be run using [detox](https://pypi.python.org/pypi/detox/) which allows
-for running tests in parallel
-
+for running tests in parallel.
```
pip install tox detox
```
List the test environments available:
+
```
tox -l
```
Run all of the tests with:
+
```
tox
```
Run all of the tests in parallel with detox:
+
```
detox
```
-Running a particular test environment (python 2.7 flake8 tests in this case):
+Run a particular test environment:
+
```
-tox -e py27-ansible22-flake8
+tox -e py27-flake8
```
-Running a particular test environment in a clean virtualenv (python 3.5 pylint
-tests in this case):
+Run a particular test environment in a clean virtualenv:
+
```
-tox -r -e py35-ansible22-pylint
+tox -r -e py35-pylint
```
If you want to enter the virtualenv created by tox to do additional
-testing/debugging (py27-flake8 env in this case):
+testing/debugging:
+
```
-source .tox/py27-ansible22-flake8/bin/activate
+source .tox/py27-flake8/bin/activate
```
You will get errors if the log files already exist and can not be
written to by the current user (`/tmp/ansible.log` and
`/tmp/installer.txt`). *We're working on it.*
+
# Running From Source
You will need to setup a **virtualenv** to run from source:
@@ -66,17 +71,3 @@ The virtualenv `bin` directory should now be at the start of your
You can exit the virtualenv with:
$ deactivate
-
-# Testing (OLD)
-
-*This section is deprecated, but still works*
-
-First, run the **virtualenv setup steps** described above.
-
-Install some testing libraries: (we cannot do this via setuptools due to the version virtualenv bundles)
-
-$ pip install mock nose
-
-Then run the tests with:
-
-$ oo-install/bin/nosetests
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..2524923cb 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 {posargs}
flake8: python setup.py flake8
- unit: python setup.py nosetests
pylint: python setup.py lint