[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Proposal: Use decorators in test suite for XFail, Skip, etc

From: Hyrum K Wright <hyrum_at_hyrumwright.org>
Date: Fri, 4 Feb 2011 17:15:11 +0000

We currently mark tests XFail (or Skip, or something else) by wrapping
them in the test_list in the test suite. Rather than doing it there,
I think it makes more sense to use Python's decorator syntax to mark
tests as XFail right at their definition, rather than down in the test
list. Keeping all attributes of a test in close proximity is a Good
Thing, imo. Attached is a patch which demonstrates this.

Decorators were added to Python in 2.4, which is the minimal version
required for our test suite. In addition to the functional
decorators, we should be able to add ones which record other
information, such as the issues which the tests were added for. (In
some future world, we could also divide up the test suite into
"levels", and decorators could be added to indicate that.)



Index: subversion/tests/cmdline/svntest/testcase.py
--- subversion/tests/cmdline/svntest/testcase.py (revision 1067180)
+++ subversion/tests/cmdline/svntest/testcase.py (working copy)
@@ -207,6 +207,14 @@
     return self._delegate.list_mode() or 'XFAIL'

+def xfail_deco(f):
+ def _inner(sbox):
+ return f(sbox)
+ _inner.__doc__ = f.__doc__
+ return XFail(_inner)
 class Wimp(XFail):
   """Like XFail, but indicates a work-in-progress: an unexpected pass
   is not considered a test failure."""
Index: subversion/tests/cmdline/basic_tests.py
--- subversion/tests/cmdline/basic_tests.py (revision 1067180)
+++ subversion/tests/cmdline/basic_tests.py (working copy)
@@ -1961,6 +1961,7 @@

 # Test for issue #1199
 def basic_rm_urls_multi_repos(sbox):
   "remotely remove directories from two repositories"

@@ -2721,7 +2722,7 @@
- XFail(basic_rm_urls_multi_repos),
+ basic_rm_urls_multi_repos,
Received on 2011-02-04 18:15:56 CET

This is an archived mail posted to the Subversion Dev mailing list.