From c58f954864b6cc7aaade4cbca8c36b4ea6305e89 Mon Sep 17 00:00:00 2001 From: Akshay Date: Fri, 24 Feb 2017 09:57:09 +0530 Subject: [PATCH 1/5] Added support for knowmfailure to work without parentheses --- testsuite/MDAnalysisTests/plugins/knownfailure.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/testsuite/MDAnalysisTests/plugins/knownfailure.py b/testsuite/MDAnalysisTests/plugins/knownfailure.py index 2c5b4d43284..93de4f1194e 100644 --- a/testsuite/MDAnalysisTests/plugins/knownfailure.py +++ b/testsuite/MDAnalysisTests/plugins/knownfailure.py @@ -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): @@ -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 From a01b19a1eb0a3c41230b72b294dea28e52d2a0cc Mon Sep 17 00:00:00 2001 From: Akshay Date: Fri, 24 Feb 2017 17:47:02 +0530 Subject: [PATCH 2/5] Removed parentheses from existing @knownfailure() usage --- testsuite/MDAnalysisTests/coordinates/test_dcd.py | 2 +- testsuite/MDAnalysisTests/test_streamio.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/testsuite/MDAnalysisTests/coordinates/test_dcd.py b/testsuite/MDAnalysisTests/coordinates/test_dcd.py index 104d6f08164..4dc39bec4c8 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_dcd.py +++ b/testsuite/MDAnalysisTests/coordinates/test_dcd.py @@ -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) diff --git a/testsuite/MDAnalysisTests/test_streamio.py b/testsuite/MDAnalysisTests/test_streamio.py index 7388f928b74..57373ecb16c 100644 --- a/testsuite/MDAnalysisTests/test_streamio.py +++ b/testsuite/MDAnalysisTests/test_streamio.py @@ -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) From 165f5aedef35c18d3f7df82329f8d405b1ecf417 Mon Sep 17 00:00:00 2001 From: Akshay Date: Fri, 24 Feb 2017 18:29:26 +0530 Subject: [PATCH 3/5] Updated docs --- testsuite/MDAnalysisTests/__init__.py | 4 ++-- testsuite/MDAnalysisTests/plugins/knownfailure.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/testsuite/MDAnalysisTests/__init__.py b/testsuite/MDAnalysisTests/__init__.py index 6d830740c2d..e087d108a87 100644 --- a/testsuite/MDAnalysisTests/__init__.py +++ b/testsuite/MDAnalysisTests/__init__.py @@ -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: diff --git a/testsuite/MDAnalysisTests/plugins/knownfailure.py b/testsuite/MDAnalysisTests/plugins/knownfailure.py index 93de4f1194e..4689663f5e1 100644 --- a/testsuite/MDAnalysisTests/plugins/knownfailure.py +++ b/testsuite/MDAnalysisTests/plugins/knownfailure.py @@ -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 From d3db3149d41f4b38440ecf4015f442bc1564ab27 Mon Sep 17 00:00:00 2001 From: Akshay Date: Fri, 24 Feb 2017 18:31:28 +0530 Subject: [PATCH 4/5] Added Entry in CHANGELOG --- testsuite/CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/testsuite/CHANGELOG b/testsuite/CHANGELOG index a5f18e496e3..27fb6fc94b7 100644 --- a/testsuite/CHANGELOG +++ b/testsuite/CHANGELOG @@ -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() From c2b8579944dabaaa559939094fe9b7d058162011 Mon Sep 17 00:00:00 2001 From: Akshay Date: Sat, 25 Feb 2017 13:30:47 +0530 Subject: [PATCH 5/5] Added name in Authors --- package/AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/package/AUTHORS b/package/AUTHORS index 281c053e17f..abb69d77ecd 100644 --- a/package/AUTHORS +++ b/package/AUTHORS @@ -84,6 +84,7 @@ Chronological list of authors - Shobhit Agarwal - Vedant Rathore - Xiki Tempula + - Akshay Gupta External code -------------