Skip to content
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
1 change: 1 addition & 0 deletions package/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Chronological list of authors
- Shobhit Agarwal
- Vedant Rathore
- Xiki Tempula
- Akshay Gupta

External code
-------------
Expand Down
1 change: 1 addition & 0 deletions testsuite/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and https://github.com/MDAnalysis/mdanalysis/wiki/UnitTests
tyler.je.reddy, utkbansal, vedantrathore

* 0.16
- Make knownfailure work even without parentheses.
- added two unit tests for MDAnalysis.analysis.polymer
- added test for LeafletFinder handling a selection string
- Added unit test for MDAnalysis.analysis.distances.between()
Expand Down
4 changes: 2 additions & 2 deletions testsuite/MDAnalysisTests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@

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. Beware that even if used with default arguments the
parentheses must be included.
that are expected to fail. If used with default arguments the parentheses can be
excluded.

.. _NumPy: http://www.numpy.org/
.. _nose:
Expand Down
2 changes: 1 addition & 1 deletion testsuite/MDAnalysisTests/coordinates/test_dcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def _slice_generation_test(self, start, stop, step):
ts_skip = self.u.trajectory.timeseries(self.u.atoms, start, stop, step)
assert_array_almost_equal(ts[:, start:stop:step,:], ts_skip, 5)

@knownfailure()
@knownfailure
def _failed_slices_test(self, start, stop, step):
self.u = mda.Universe(PSF, DCD)
ts = self.u.trajectory.timeseries(self.u.atoms)
Expand Down
11 changes: 7 additions & 4 deletions testsuite/MDAnalysisTests/plugins/knownfailure.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
isn't loaded (typically, when using nose's command-line `nosetests` script, which
does not allow for runtime loading of external plugins).

Beware that the decorator must be used as a function call: `@knownfailure()`, with parentheses
and, optionally, arguments.
The decorator can be used without parentheses in case of default arguments as well as
a function call: `@knownfailure()`, with parentheses in case of optional arguments.
"""

from MDAnalysisTests.plugins import loaded_plugins, _check_plugins_loaded
Expand All @@ -44,7 +44,7 @@
plugin_class = KnownFailurePlugin
plugin_class.name = "knownfailure"

def knownfailure(msg="Test skipped due to expected failure", exc_type=AssertionError, mightpass=False):
def knownfailure(args=None, msg="Test skipped due to expected failure", exc_type=AssertionError, mightpass=False):
"""If decorated function raises exception *exc_type* skip test, else raise AssertionError."""
def knownfailure_decorator(f):
def inner(*args, **kwargs):
Expand All @@ -61,6 +61,9 @@ def inner(*args, **kwargs):
if not mightpass:
raise AssertionError('Failure expected')
return nose.tools.make_decorator(f)(inner)
return knownfailure_decorator
if callable(args):
return knownfailure_decorator(args)
else:
return knownfailure_decorator


2 changes: 1 addition & 1 deletion testsuite/MDAnalysisTests/test_streamio.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def test_expanduser_noexpansion_returns_NamedStream(self):
# Segmentation fault when run as a test on Mac OS X 10.6, Py 2.7.11 [orbeckst]
@dec.skipif(True)
@dec.skipif("HOME" not in os.environ)
@knownfailure()
@knownfailure
def test_expandvars(self):
name = "${HOME}/stories/jabberwock.txt"
ns = self.create_NamedStream(name)
Expand Down