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

Re: svn commit: r19269 - trunk/subversion/tests/cmdline/svntest

From: Daniel Rall <dlr_at_collab.net>
Date: 2006-04-13 22:58:06 CEST

Though TestCase does seem like a really appropriate name here, it also
seems easily confusable with the standard unittest.TestCase class.

On Sat, 08 Apr 2006, mhagger@tigris.org wrote:

> Author: mhagger
> Date: Sat Apr 8 15:25:14 2006
> New Revision: 19269
>
> Modified:
> trunk/subversion/tests/cmdline/svntest/main.py
> trunk/subversion/tests/cmdline/svntest/testcase.py
>
> Log:
> Create an abstract base class TestCase, from which _Predicate inherits.
>
> [in subversion/tests/cmdline/svntest]
>
> * testcase.py (TestCase): New class. Some method bodies for
> check_description() and convert_result() taken from _Predicate.
>
> (_Predicate): Inherit from TestCase. Use inherited definitions of
> check_description() and convert_result().
>
> (create_test_case): New function (renamed from create_predicate()).
>
> * main.py (TestRunner.__init__): Call testcase.create_test_case() by
> its new name.
>
>
> Modified: trunk/subversion/tests/cmdline/svntest/main.py
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/tests/cmdline/svntest/main.py?pathrev=19269&r1=19268&r2=19269
> ==============================================================================
> --- trunk/subversion/tests/cmdline/svntest/main.py (original)
> +++ trunk/subversion/tests/cmdline/svntest/main.py Sat Apr 8 15:25:14 2006
> @@ -639,7 +639,7 @@
> runing the test and test list output."""
>
> def __init__(self, func, index):
> - self.pred = testcase.create_predicate(func)
> + self.pred = testcase.create_test_case(func)
> self.index = index
>
> def list(self):
>
> Modified: trunk/subversion/tests/cmdline/svntest/testcase.py
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/tests/cmdline/svntest/testcase.py?pathrev=19269&r1=19268&r2=19269
> ==============================================================================
> --- trunk/subversion/tests/cmdline/svntest/testcase.py (original)
> +++ trunk/subversion/tests/cmdline/svntest/testcase.py Sat Apr 8 15:25:14 2006
> @@ -23,7 +23,46 @@
> __all__ = ['XFail', 'Skip']
>
>
> -class _Predicate:
> +class TestCase:
> + """A thing that can be tested. This is an abstract class with
> + several methods that need to be overridden."""
> +
> + def get_description(self):
> + raise NotImplementedError()
> +
> + def check_description(self):
> + description = self.get_description()
> +
> + if len(description) > 50:
> + print 'WARNING: Test doc string exceeds 50 characters'
> + if description[-1] == '.':
> + print 'WARNING: Test doc string ends in a period (.)'
> + if not string.lower(description[0]) == description[0]:
> + print 'WARNING: Test doc string is capitalized'
> +
> + def need_sandbox(self):
> + return 0
> +
> + def get_sandbox_name(self):
> + return 'sandbox'
> +
> + def run(self, args):
> + raise NotImplementedError()
> +
> + def list_mode(self):
> + raise NotImplementedError()
> +
> + def skip_text(self):
> + raise NotImplementedError()
> +
> + def run_text(self, result=0):
> + raise NotImplementedError()
> +
> + def convert_result(self, result):
> + return result
> +
> +
> +class _Predicate(TestCase):
> """A general-purpose predicate that encapsulates a test case (function),
> a condition for its execution and a set of display properties for test
> lists and test log output."""
> @@ -46,16 +85,6 @@
> raise Exception(self.func.__name__ + ' lacks required doc string')
> return description
>
> - def check_description(self):
> - description = self.get_description()
> -
> - if len(description) > 50:
> - print 'WARNING: Test doc string exceeds 50 characters'
> - if description[-1] == '.':
> - print 'WARNING: Test doc string ends in a period (.)'
> - if not string.lower(description[0]) == description[0]:
> - print 'WARNING: Test doc string is capitalized'
> -
> def need_sandbox(self):
> return self.func.func_code.co_argcount != 0
>
> @@ -75,9 +104,6 @@
> def run_text(self, result=0):
> return self.text[result]
>
> - def convert_result(self, result):
> - return result
> -
>
> class XFail(_Predicate):
> "A test that is expected to fail."
> @@ -110,7 +136,7 @@
> return _Predicate.run(self, args)
>
>
> -def create_predicate(func):
> +def create_test_case(func):
> return _Predicate(func)

  • application/pgp-signature attachment: stored
Received on Thu Apr 13 23:00:06 2006

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.