[Pkg-bazaar-commits] ./bzr/unstable r751: - new TestBase.build_tree helper method
Martin Pool
mbp at sourcefrog.net
Fri Apr 10 08:20:55 UTC 2009
------------------------------------------------------------
revno: 751
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Wed 2005-06-22 18:07:30 +1000
message:
- new TestBase.build_tree helper method
modified:
bzrlib/selftest/__init__.py
-------------- next part --------------
=== modified file 'bzrlib/selftest/__init__.py'
--- a/bzrlib/selftest/__init__.py 2005-06-22 07:56:41 +0000
+++ b/bzrlib/selftest/__init__.py 2005-06-22 08:07:30 +0000
@@ -77,6 +77,7 @@
def backtick(self, cmd, retcode=0):
+ """Run a command and return its output"""
cmd = self.formcmd(cmd)
child = Popen(cmd, stdout=PIPE, stderr=self.TEST_LOG)
outd, errd = child.communicate()
@@ -93,6 +94,24 @@
+ def build_tree(self, shape):
+ """Build a test tree according to a pattern.
+
+ shape is a sequence of file specifications. If the final
+ character is '/', a directory is created.
+
+ This doesn't add anything to a branch.
+ """
+ # XXX: It's OK to just create them using forward slashes on windows?
+ for name in shape:
+ assert isinstance(name, basestring)
+ if name[-1] == '/':
+ os.mkdir(name[:-1])
+ else:
+ f = file(name, 'wt')
+ print >>f, "contents of", name
+ f.close()
+
def log(self, msg):
"""Log a message to a progress file"""
More information about the Pkg-bazaar-commits
mailing list