[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.)

Thoughts?

-Hyrum

[[[
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 @@
                                         expected_status)

 # Test for issue #1199
+@svntest.testcase.xfail_deco
 def basic_rm_urls_multi_repos(sbox):
   "remotely remove directories from two repositories"

@@ -2721,7 +2722,7 @@
               delete_keep_local_twice,
               windows_paths_in_repos,
               basic_rm_urls_one_repo,
- XFail(basic_rm_urls_multi_repos),
+ basic_rm_urls_multi_repos,
               automatic_conflict_resolution,
               info_nonexisting_file,
               basic_relative_url_using_current_dir,
]]]
Received on 2011-02-04 18:15:56 CET

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.