Skip to content

Commit

Permalink
print slowest tests (#1486)
Browse files Browse the repository at this point in the history
* print slowest tests

* remove explicit pytest dependencies

it should be installed automatically by ci-helpers

* remove pytest-cov and pytest-xdist requirement

These packages are only giving new runtime options for pytest. The testsuite
can be run without them.

* remove pytest-raises dependency

* use SETUP_CMD for ci-helpers to recognize options
  • Loading branch information
kain88-de authored and richardjgowers committed Jul 15, 2017
1 parent e71888e commit c3e9cc5
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 27 deletions.
17 changes: 9 additions & 8 deletions .travis.yml
Expand Up @@ -24,17 +24,17 @@ env:
- COVERALLS=false
- NOSE_FLAGS="--processes=2 --process-timeout=400 --no-open-files --with-timer --timer-top-n 50"
- NOSE_TEST_LIST=""
- PYTEST_FLAGS="--disable-pytest-warnings -n 2"
- PYTEST_FLAGS="--disable-pytest-warnings --numprocesses 2 --durations=50"
- PYTEST_LIST="testsuite/MDAnalysisTests/lib testsuite/MDAnalysisTests/formats testsuite/MDAnalysisTests/coordinates testsuite/MDAnalysisTests/utils testsuite/MDAnalysisTests/topology testsuite/MDAnalysisTests/auxiliary testsuite/MDAnalysisTests/core testsuite/MDAnalysisTests/analysis"
- NOSE_COVERAGE_FILE="nose_coverage"
- PYTEST_COVERAGE_FILE="pytest_coverage"
- MAIN_CMD="pytest ${PYTEST_LIST} ${PYTEST_FLAGS}"
- SETUP_CMD=""
- MAIN_CMD="pytest ${PYTEST_LIST}"
- SETUP_CMD="${PYTEST_FLAGS}"
- BUILD_CMD="pip install -v package/ && pip install testsuite/"
- CONDA_DEPENDENCIES="mmtf-python nose=1.3.7 mock six biopython networkx cython joblib nose-timer matplotlib scipy griddataformats pytest-cov pytest-xdist hypothesis"
- CONDA_ALL_DEPENDENCIES="mmtf-python nose=1.3.7 mock six biopython networkx cython joblib nose-timer matplotlib netcdf4 scikit-learn scipy griddataformats seaborn coveralls clustalw=2.1 pytest-cov pytest-xdist hypothesis"
- CONDA_DEPENDENCIES="mmtf-python nose=1.3.7 mock six biopython networkx cython joblib nose-timer matplotlib scipy griddataformats hypothesis"
- CONDA_ALL_DEPENDENCIES="mmtf-python nose=1.3.7 mock six biopython networkx cython joblib nose-timer matplotlib netcdf4 scikit-learn scipy griddataformats seaborn coveralls clustalw=2.1 hypothesis"
# Install griddataformats from PIP so that scipy is only installed in the full build (#1147)
- PIP_DEPENDENCIES='pytest-raises'
- PIP_DEPENDENCIES=''
- CONDA_CHANNELS='biobuilds conda-forge'
- CONDA_CHANNEL_PRIORITY=True
- NUMPY_VERSION=stable
Expand All @@ -60,6 +60,7 @@ matrix:
- os: linux
env: NAME="Lint"
MAIN_CMD="pylint --rcfile=package/.pylintrc package/MDAnalysis && pylint --rcfile=package/.pylintrc testsuite/MDAnalysisTests"
SETUP_CMD=''
BUILD_CMD=""
CONDA_DEPENDENCIES="pylint backports.functools_lru_cache"
PIP_DEPENDENCIES=""
Expand All @@ -68,7 +69,7 @@ matrix:
env: NAME='full'
NOSE_COVERAGE='--with-coverage --cover-package MDAnalysis'
PYTEST_COVERAGE='--cov=MDAnalysis'
MAIN_CMD='pytest ${PYTEST_LIST} ${PYTEST_FLAGS} ${PYTEST_COVERAGE}'
SETUP_CMD="${PYTEST_FLAGS} ${PYTEST_COVERAGE}"
CONDA_DEPENDENCIES=${CONDA_ALL_DEPENDENCIES}
COVERALLS='true'

Expand Down Expand Up @@ -124,4 +125,4 @@ after_success:
# can't use test here since this leads to travis fails even though the build passes
- if [[ ${TRAVIS_PULL_REQUEST} == "false" ]] && [[ ${BUILD_DOCS} == "true" ]] && [[ ${TRAVIS_BRANCH} == ${GH_DOC_BRANCH} ]]; then
bash ${TRAVIS_BUILD_DIR}/maintainer/deploy_docs.sh;
fi
fi
9 changes: 7 additions & 2 deletions testsuite/MDAnalysisTests/utils/test_distances.py
Expand Up @@ -701,7 +701,6 @@ def backend_selection_pos():
@pytest.mark.parametrize('backend', [
"serial", "Serial", "SeRiAL", "SERIAL",
"openmp", "OpenMP", "oPENmP", "OPENMP",
pytest.mark.raises('not_implemented_stuff', exception=ValueError),
])
def test_case_insensitivity(self, backend, backend_selection_pos):
positions, result = backend_selection_pos
Expand All @@ -710,8 +709,14 @@ def test_case_insensitivity(self, backend, backend_selection_pos):
args=(positions, result),
backend=backend)
except RuntimeError:
raise AssertionError("Failed to understand backend {0}".format(backend))
pytest.fail("Failed to understand backend {0}".format(backend))

def test_wront_backend(self, backend_selection_pos):
positions, result = backend_selection_pos
with pytest.raises(ValueError):
MDAnalysis.lib.distances._run("calc_self_distance_array",
args=(positions, result),
backend="not implemented stuff")

def test_used_openmpflag():
assert_(isinstance(MDAnalysis.lib.distances.USED_OPENMP, bool))
11 changes: 8 additions & 3 deletions testsuite/MDAnalysisTests/utils/test_log.py
Expand Up @@ -156,12 +156,17 @@ class TestSetVerbose(object):
(None, False, False, True), # Verbose is not provided
(None, None, True, True), # Nothing is provided
(None, None, False, False), # Nothing is provided
pytest.mark.raises((True, True, None, None), exception=ValueError), # quiet and verbose contradict each other
pytest.mark.raises((False, False, None, None), exception=ValueError), # quiet and verbose contradict each other
])
def test__set_verbose(self, verbose, quiet, default, result):
assert _set_verbose(verbose=verbose, quiet=quiet, default=default) == result


@pytest.mark.parametrize('verbose', (True, False))
def test__set_verbose_invalid_args(self, verbose):
with pytest.raises(ValueError):
# setting quiet==verbose is a contradiction
_set_verbose(verbose=verbose, quiet=verbose, default=None)


@pytest.mark.parametrize('verbose, quiet', [
(None, True),
(False, True)
Expand Down
17 changes: 7 additions & 10 deletions testsuite/MDAnalysisTests/utils/test_units.py
Expand Up @@ -117,17 +117,14 @@ def test_energy(self, quantity, unit1, unit2, ref):
def test_force(self, quantity, unit1, unit2, ref):
self._assert_almost_equal_convert(quantity, unit1, unit2, ref)

@pytest.mark.parametrize('quantity, unit1, unit2, ref', (
pytest.mark.raises((nm, 'Stone', 'nm', None), exception=ValueError),
pytest.mark.raises((nm, 'nm', 'Stone', None), exception=ValueError),
))
def test_unit_unknown(self, quantity, unit1, unit2, ref):
val = units.convert(quantity, unit1, unit2)
assert_almost_equal(val, ref,
err_msg="Conversion {0} --> {1} failed".format(unit1, unit2))
@pytest.mark.parametrize('quantity, unit1, unit2', ((nm, 'Stone', 'nm'),
(nm, 'nm', 'Stone')))
def test_unit_unknown(self, quantity, unit1, unit2):
with pytest.raises(ValueError):
units.convert(quantity, unit1, unit2)

def test_unit_unconvertable(self):
nm = 12.34567
A = nm * 10.
assert_raises(ValueError, units.convert, A, 'A', 'ps')

with pytest.raises(ValueError):
units.convert(A, 'A', 'ps')
4 changes: 0 additions & 4 deletions testsuite/setup.py
Expand Up @@ -213,12 +213,8 @@ def dynamic_author_list():
long_description=LONG_DESCRIPTION,
install_requires=[
'MDAnalysis=={0!s}'.format(RELEASE), # same as this release!
'numpy>=1.10.4',
'nose>=1.3.7',
'pytest>=3.1.2',
'pytest-cov',
'pytest-xdist',
'pytest-raises',
'hypothesis',
'psutil>=4.0.2',
'mock>=2.0.0',
Expand Down

0 comments on commit c3e9cc5

Please sign in to comment.