Neels Janosch Hofmeyr wrote:
> This is how I implemented the same test cmpilato wrote in about two minutes
> sharp:
>
> [[[
> def mine(sbox):
> "lock a file using a comment with xml special chars"
> svntest.factory.make(sbox, """
> echo "This represents a binary file\\n" >> iota
> svn ci
> svn lock -m 'lock & load' iota
> """)
> ]]]
> (Note that I had to double-escape the '\n' to '\\n' because of python
> parsing it before factory can.)
>
Good start. Now add some syntactic sugar so you can write the tests like
this:
[[[
@svntest.factory("lock a file using a comment with xml special chars")
def mine(sbox):
"""
echo "This represents a binary file\\n" >> iota
svn ci
svn lock -m 'lock & load' iota
"""
]]]
I leave the implementation as an exercise for the reader. :)
However this approach has some serious flaws:
* it introduces another scripting language for defining test cases;
we already have Python, so this appears to be serious overkill.
* Testcase syntax is only verified at runtime.
* New features for testcases must be implemented twice -- once in
the factory parser, and once in the svntest infrastructure
This testcase could written like this:
[[[
from svntest import testcase
@testcase
def mine(sbox):
"lock a file using a comment with xml special chars"
iota = sbox.wc_file('iota')
iota.append("This represents a binary file\n")
svn.commit(iota)
svn.lock(iota, m='lock & load', EXPECT=(".*locked by user", []))
]]]
In general, with a bit of objective Pythonic magic, we could make our
testcase writing a lot less verbose.
-- Brane
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2363935
Received on 2009-06-21 14:04:32 CEST