Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropping nose as a dependency #1480

Merged
merged 3 commits into from
Jul 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ examples/output.txt
.eggs
# ignore Vagrant virtual machines
.vagrant
# ignore nosetest/coverage files
# ignore coverage files
.coverage
.noseids
# ignore trajectory offset caches
Expand Down
1 change: 0 additions & 1 deletion maintainer/conda/MDAnalysis/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ requirements:
run:
- python
- biopython
- nose ==1.3.7
- joblib
- scipy
- griddataformats
Expand Down
90 changes: 0 additions & 90 deletions maintainer/run_tests.sh

This file was deleted.

35 changes: 3 additions & 32 deletions package/MDAnalysis/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,33 +39,6 @@
>>> import MDAnalysis.tests
>>> MDAnalysis.tests.test()

Some tests can take a few seconds; in order to skip the slow tests run

>>> MDAnalysis.tests.test(label='fast')

Additional information is displayed at a higher verbosity level (the default is
1):

>>> MDAnalysis.tests.test(label='fast', argv=['--verbosity=3'])

Note that if no tests are being run then one might have to run the
tests with the ``--exe`` flag

>>> MDAnalysis.tests.test(label='fast', argv=['--exe'])

(This happens when python files are installed with the executable bit set. By
default the nose_ testing framework refuses to use those files and must be
encouraged to do so with the ``--exe`` switch.)

See `nose commandline options`_ for additional options that can be used.

For the particular case of code coverage MDAnalysis mustn't be imported prior
to testing, and testing must be invoked directly from `:meth:MDAnalysisTests.run`:

>>> import MDAnalysisTests
>>> MDAnalysisTests.run(argv=['--exe', '--with-coverage', '--cover-package=MDAnalysis'])


Data
====

Expand All @@ -92,16 +65,14 @@
Writing test cases
==================

The unittests use the :mod:`unittest` module together with nose_. See the
The unittests use the :mod:`pytest_` module. See the
examples provided alongside the ``MDAnalysisTests`` module.

The `SciPy testing guidelines`_ are also a good howto for writing test cases.


.. _nose:
http://somethingaboutorange.com/mrl/projects/nose/0.11.3/index.html
.. _nose commandline options:
http://somethingaboutorange.com/mrl/projects/nose/0.11.3/usage.html#extended-usage
.. _pytest:
https://docs.pytest.org/en/latest/
.. _SciPy testing guidelines:
http://projects.scipy.org/numpy/wiki/TestingGuidelines#id11
.. _Charmm: http://www.charmm.org
Expand Down
3 changes: 2 additions & 1 deletion testsuite/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ and https://github.com/MDAnalysis/mdanalysis/wiki/UnitTests
------------------------------------------------------------------------------
mm/dd/yy

* 0.16.2
* 0.16.2 utkbansal
- Port to pytest - removed nose as a dependency (Issue #884)

06/03/17 xiki_tempula

Expand Down
7 changes: 4 additions & 3 deletions testsuite/INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,17 @@ From sources

From the top directory of the checked out sources:

./testsuite/MDAnalysisTests/mda_nosetests --exe -v --processes=4 --process-timeout=120
pytest /testsuite/MDAnalysisTests/ --numprocesses 4

(use --processes=4 if you have 4 cores available to run in parallel or
(use --numprocesses 4 if you have 4 cores available to run in parallel or
adapt to available cores.)

To run tests in parallel you will need pytest-xdist>=1.18.1 installed.

From installed package
----------------------

The test runner can be launched as

python -c 'from MDAnalysis.tests import test; test(argv=["--exe", "-v", "--processes=4", "--process-timeout=120"])'
python -c 'from MDAnalysis.tests import test; test()'

1 change: 0 additions & 1 deletion testsuite/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
graft scripts
include README INSTALL CHANGELOG LICENSE AUTHORS TODO SUMMARY.txt
include setup.py
include MDAnalysisTests/mda_nosetests
include MDAnalysisTests/data/*/*
global-exclude *~
global-exclude *.pkl
68 changes: 8 additions & 60 deletions testsuite/MDAnalysisTests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,8 @@

Run all the tests with

>>> import MDAnalysisTests.tests
>>> MDAnalysisTests.tests.test(label='full')

Some tests can take a few seconds; in order to skip the slow tests run

>>> MDAnalysisTests.tests.test(label='fast')

Additional information is displayed at a higher verbosity level (the default is
1):

>>> MDAnalysisTests.tests.test(label='fast', verbose=3)

Note that if no tests are being run then one might have to run the
tests with the ``--exe`` flag

>>> MDAnalysisTests.tests.test(label='fast', extra_argv=['--exe'])

(This happens when python files are installed with the executable bit set. By
default the nose_ testing framework refuses to use those files and must be
encouraged to do so with the ``--exe`` switch.)

See `nose commandline options`_ for additional options that can be used; for
instance, code coverage can also be checked:

>>> MDAnalysisTests.tests.test(label='full', extra_argv=['--exe', '--with-coverage'])
>>> from MDAnalysisTests import run
>>> run()


Data
Expand Down Expand Up @@ -90,22 +67,13 @@
Writing test cases
==================

The unittests use the :mod:`unittest` module together with nose_. See the
The unittests use the :mod:`pytest <https://docs.pytest.org/en/latest/>`_ module. See the
examples in the ``MDAnalysisTests`` directory.

The `SciPy testing guidelines`_ are a good howto for writing test cases,
especially as we are directly using this framework (imported from numpy).

A number of plugins external to nose are automatically loaded. The `knownfailure`
plugin provides the `@knownfailure()` decorator, which can be used to mark tests
that are expected to fail. If used with default arguments the parentheses can be
excluded.

.. _NumPy: http://www.numpy.org/
.. _nose:
http://nose.readthedocs.org/en/latest/
.. _nose commandline options:
http://nose.readthedocs.org/en/latest/man.html?highlight=command%20line
.. _SciPy testing guidelines:
http://projects.scipy.org/numpy/wiki/TestingGuidelines#id11
.. _Charmm: http://www.charmm.org
Expand All @@ -114,6 +82,9 @@
"""
from __future__ import absolute_import
import logging

import pytest

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are still a lot of nose comments in this file

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kain88-de Do I have to update all the comments involving nose in all the files?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please. There is no sense in having them. Only a few might be useful.

logger = logging.getLogger("MDAnalysisTests.__init__")

__version__ = "0.17.0-dev" # keep in sync with RELEASE in setup.py
Expand All @@ -131,9 +102,6 @@
import os
import sys

# We get our nose from the plugins so that version-checking needs only be done there.
from MDAnalysisTests.plugins import nose, loaded_plugins

# Any tests that plot with matplotlib need to run with the simple agg backend because
# on Travis there is no DISPLAY set
try:
Expand All @@ -152,26 +120,6 @@
)
from MDAnalysisTests.core.util import make_Universe

def run(*args, **kwargs):
"""Test-running function that loads plugins, sets up arguments, and calls `nose.run_exit()`"""
try:
kwargs['argv'] = sys.argv + kwargs['argv'] #sys.argv takes precedence
except KeyError:
kwargs['argv'] = sys.argv
# We emulate numpy's treament of the 'fast' label.
if 'label' in kwargs:
label = kwargs.pop('label')
if label == 'fast':
kwargs['argv'].extend(['-A','not slow'])
# We keep accepting numpy's 'extra_argv'
if 'extra_argv' in kwargs:
kwargs['argv'].extend(kwargs.pop('extra_argv'))
try:
kwargs['addplugins'].extend(loaded_plugins.values())
except KeyError:
kwargs['addplugins'] = loaded_plugins.values()
# By default, test our testsuite
kwargs['defaultTest'] = os.path.dirname(__file__)
return nose.run_exit(*args, **kwargs)


def run(*args, **kwargs):
pytest.main()
4 changes: 0 additions & 4 deletions testsuite/MDAnalysisTests/analysis/test_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
assert_array_equal, assert_array_almost_equal,
assert_)
import numpy as np
from nose.plugins.attrib import attr

from MDAnalysisTests.datafiles import PSF, DCD, FASTA, ALIGN_BOUND, ALIGN_UNBOUND
from MDAnalysisTests import executable_not_found, parser_not_found, tempdir
Expand Down Expand Up @@ -262,7 +261,6 @@ def _assert_rmsd(self, fitted, frame, desired, weights=None):
err_msg="frame {0:d} of fit does not have "
"expected RMSD".format(frame))

@attr('issue')
def test_alignto_checks_selections(self):
"""Testing that alignto() fails if selections do not
match (Issue 143)"""
Expand Down Expand Up @@ -307,7 +305,6 @@ def setUp(self):
def tearDown(self):
del self.tempdir

@attr('issue')
def test_fasta2select_aligned(self):
"""test align.fasta2select() on aligned FASTA (Issue 112)"""
sel = align.fasta2select(self.seq, is_aligned=True)
Expand All @@ -317,7 +314,6 @@ def test_fasta2select_aligned(self):
assert_equal(len(sel['mobile']), 30623,
err_msg="selection string has unexpected length")

@attr('issue')
@dec.skipif(executable_not_found("clustalw2"),
msg="Test skipped because clustalw2 executable not found")
def test_fasta2select_ClustalW(self):
Expand Down
3 changes: 3 additions & 0 deletions testsuite/MDAnalysisTests/analysis/test_gnm.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

from MDAnalysisTests.datafiles import GRO, XTC


class TestGNM(object):
@staticmethod
@pytest.fixture()
Expand Down Expand Up @@ -81,6 +82,7 @@ def test_generate_kirchoff(self, universe):

def test_closeContactGNMAnalysis(self, universe):
gnm = MDAnalysis.analysis.gnm.closeContactGNMAnalysis(universe, weights="size")

gnm.run()

result = gnm.results
Expand Down Expand Up @@ -111,6 +113,7 @@ def test_closeContactGNMAnalysis(self, universe):

def test_closeContactGNMAnalysis_weights_None(self, universe):
gnm = MDAnalysis.analysis.gnm.closeContactGNMAnalysis(universe, weights=None)

gnm.run()

result = gnm.results
Expand Down
Loading