Rev 4671: Implement 'bzr' command. in file:///home/vila/src/bzr/experimental/shell-like-tests/

Vincent Ladeuil v.ladeuil+lp at free.fr
Tue Sep 1 13:46:10 BST 2009


At file:///home/vila/src/bzr/experimental/shell-like-tests/

------------------------------------------------------------
revno: 4671
revision-id: v.ladeuil+lp at free.fr-20090901124610-22vnmwr647x8f3jz
parent: v.ladeuil+lp at free.fr-20090901122728-o33dw2k63tz1k0my
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: shell-like-tests
timestamp: Tue 2009-09-01 14:46:10 +0200
message:
  Implement 'bzr' command.
  
  * bzrlib/tests/test_script.py:
  (TestScriptExecution.test_unexpected_output): Test output semantic
  change.
  (TestBzr): Simple test for bzr command. 
  
  * bzrlib/tests/script.py:
  (TestCaseWithScript.do_bzr): Implement the bzr command.
  (TestCaseWithScript._check_output): Change output/error semantic:
  if none is specified, no checking is done.
-------------- next part --------------
=== modified file 'bzrlib/tests/script.py'
--- a/bzrlib/tests/script.py	2009-09-01 12:27:28 +0000
+++ b/bzrlib/tests/script.py	2009-09-01 12:46:10 +0000
@@ -118,12 +118,10 @@
 
     def _check_output(self, expected, actual):
         if expected is None:
-            str_expected = ''
-        else:
-            str_expected = ''.join(expected)
-        if actual is None:
-            actual = ''
-        self.assertEqualDiff(str_expected, actual)
+            # Specifying None means: any output is accepted
+            return
+        str_expected = ''.join(expected)
+        self.assertEquals(str_expected, actual)
 
     def run_command(self, cmd, input, output, error):
         mname = 'do_' + cmd[0]
@@ -141,6 +139,11 @@
         self._check_output(error, actual_error)
         return actual_output, actual_error
 
+    def do_bzr(self, input, args):
+        out, err = self._run_bzr_core(args, retcode=None, encoding=None,
+                                      stdin=input, working_dir=None)
+        return out, err
+
     def do_cat(self, input, args):
         in_name = None
         out_name = None
@@ -201,3 +204,4 @@
         self._ensure_in_jail(d)
         os.mkdir(d)
         return None, None
+

=== modified file 'bzrlib/tests/test_script.py'
--- a/bzrlib/tests/test_script.py	2009-09-01 12:27:28 +0000
+++ b/bzrlib/tests/test_script.py	2009-09-01 12:46:10 +0000
@@ -86,6 +86,14 @@
     def test_unknown_command(self):
         self.assertRaises(SyntaxError, self.run_script, 'foo')
 
+    def test_unexpected_output(self):
+        story = """
+mkdir dir
+cd dir
+>Hello, I have just cd into dir !
+"""
+        self.assertRaises(AssertionError, self.run_script, story)
+
 
 class TestCat(script.TestCaseWithScript):
 
@@ -150,3 +158,10 @@
 
         self.run_script('cd')
         self.assertEquals(self.test_dir, osutils.getcwd())
+
+
+class TestBzr(script.TestCaseWithScript):
+
+    def test_bzr_smoke(self):
+        self.run_script('bzr init branch')
+        self.failUnlessExists('branch')



More information about the bazaar-commits mailing list