You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Daniel Rall <dl...@collab.net> on 2006/04/13 20:58:06 UTC
Re: svn commit: r19269 - trunk/subversion/tests/cmdline/svntest
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)
Re: svn commit: r19269 - trunk/subversion/tests/cmdline/svntest
Posted by Michael Haggerty <mh...@alum.mit.edu>.
Daniel Rall wrote:
> Though TestCase does seem like a really appropriate name here, it also
> seems easily confusable with the standard unittest.TestCase class.
Yes, I considered this point when naming the class.
BTW, before I started mucking about in svntest, there was a class called
TestCase in testcase.py, even less related to unittest.TestCase. I
renamed that class to TestRunner and moved it to main.py because that
seemed like a better description of its role. But of course that is no
excuse for re-using a confusing name.
I'd be fine with renaming the TestCase class. But since its role is
similar to that of unittest.TestCase, I would like its name to be
similar too (so that experience in one framework carries over more
easily to the other). What name would you like? Maybe SvnTestCase?
CmdLineTestCase?
To me, a more interesting question is whether svntest should build on
Python's unittest infrastructure instead of implementing everything from
scratch. I have been postponing the investigation of this issue pending
the more obvious cleanups that I wanted to work on.
Michael
> 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.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org