Rev 4583: (mbp) Cleanup TestUIFactory; prevent pb.tick() failures in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue Aug 4 01:55:09 BST 2009


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4583 [merge]
revision-id: pqm at pqm.ubuntu.com-20090804005507-h1qergam3ijkmvci
parent: pqm at pqm.ubuntu.com-20090803071511-dwb041qzak0vjzdk
parent: mbp at sourcefrog.net-20090803055841-pgkkbb60pxf4zzig
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2009-08-04 01:55:07 +0100
message:
  (mbp) Cleanup TestUIFactory; prevent pb.tick() failures
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
  bzrlib/tests/test_ui.py        test_ui.py-20051130162854-458e667a7414af09
=== modified file 'NEWS'
--- a/NEWS	2009-08-03 06:12:10 +0000
+++ b/NEWS	2009-08-04 00:55:07 +0000
@@ -38,13 +38,6 @@
 * BranchBuilder now accepts timezone to avoid test failures in countries far
   from GMT. (Vincent Ladeuil, #397716)
 
-* The environment variable ``BZR_PROGRESS_BAR`` set to either ``text`` or ``none``
-  always forces progress bars either on or off respectively.  Otherwise,
-  they're turned on if ``TERM`` is not ``dumb`` and stderr is a terminal.
-  bzr always uses the 'text' user interface when run as a command, so
-  ``BZR_USE_TEXT_UI`` is no longer needed.
-  (Martin Pool, #339385, #387717)
-
 * ``bzr commit`` no longer saves the unversioning of missing files until
   the commit has completed on the branch. This means that aborting a
   commit that found a missing file will leave the tree unedited.
@@ -69,6 +62,10 @@
 * Fixed a NameError that occurs when merging or pulling from a URL that
   causes a redirection loop when bzr tries to read a URL as a bundle.
   (Andrew Bennetts, #400847)
+
+* Fix ``AttributeError: 'TestUIFactory' object has no attribute 'tick'``
+  running send and similar commands on 2a formats.
+  (Martin Pool, #408201)
   
 * Fixed export to existing directory: if directory is empty then export 
   will succeed, otherwise it fails with error.
@@ -91,6 +88,13 @@
 * Streaming from bzr servers where there is a chain of stacked branches
   (A stacked on B stacked on C) will now work. (Robert Collins, #406597)
 
+* The environment variable ``BZR_PROGRESS_BAR`` set to either ``text`` or ``none``
+  always forces progress bars either on or off respectively.  Otherwise,
+  they're turned on if ``TERM`` is not ``dumb`` and stderr is a terminal.
+  bzr always uses the 'text' user interface when run as a command, so
+  ``BZR_USE_TEXT_UI`` is no longer needed.
+  (Martin Pool, #339385, #387717)
+
 * The optional ``_knit_load_data_pyx`` C extension was never being
   imported.  This caused significant slowdowns when reading data from
   repositories.  (Andrew Bennetts, #405653)

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2009-08-03 03:44:32 +0000
+++ b/bzrlib/tests/__init__.py	2009-08-04 00:55:07 +0000
@@ -102,6 +102,7 @@
                           TestLoader,
                           )
 from bzrlib.tests.treeshape import build_tree_contents
+from bzrlib.ui import NullProgressView
 from bzrlib.ui.text import TextUIFactory
 import bzrlib.version_info_formats.format_custom
 from bzrlib.workingtree import WorkingTree, WorkingTreeFormat2
@@ -719,7 +720,14 @@
     Hide the progress bar but emit note()s.
     Redirect stdin.
     Allows get_password to be tested without real tty attached.
+
+    See also CannedInputUIFactory which lets you provide programmatic input in
+    a structured way.
     """
+    # XXX: Should probably unify more with CannedInputUIFactory or a
+    # particular configuration of TextUIFactory, or otherwise have a clearer
+    # idea of how they're supposed to be different.
+    # See https://bugs.edge.launchpad.net/bzr/+bug/408213
 
     def __init__(self, stdout=None, stderr=None, stdin=None):
         if stdin is not None:
@@ -730,26 +738,8 @@
             stdin = StringIOWrapper(stdin)
         super(TestUIFactory, self).__init__(stdin, stdout, stderr)
 
-    def clear(self):
-        """See progress.ProgressBar.clear()."""
-
-    def clear_term(self):
-        """See progress.ProgressBar.clear_term()."""
-
-    def finished(self):
-        """See progress.ProgressBar.finished()."""
-
-    def note(self, fmt_string, *args):
-        """See progress.ProgressBar.note()."""
-        if args:
-            fmt_string = fmt_string % args
-        self.stdout.write(fmt_string + "\n")
-
-    def progress_bar(self):
-        return self
-
-    def nested_progress_bar(self):
-        return self
+    def make_progress_view(self):
+        return NullProgressView()
 
     def update(self, message, count=None, total=None):
         """See progress.ProgressBar.update()."""

=== modified file 'bzrlib/tests/test_ui.py'
--- a/bzrlib/tests/test_ui.py	2009-07-22 06:00:45 +0000
+++ b/bzrlib/tests/test_ui.py	2009-08-03 05:54:52 +0000
@@ -334,6 +334,18 @@
             None, stdout, stdout, factory.get_boolean, "foo")
 
 
+class TestUIFactoryTests(TestCase):
+
+    def test_test_ui_factory_progress(self):
+        # there's no output; we just want to make sure this doesn't crash -
+        # see https://bugs.edge.launchpad.net/bzr/+bug/408201
+        ui = TestUIFactory()
+        pb = ui.nested_progress_bar()
+        pb.update('hello')
+        pb.tick()
+        pb.finished()
+
+
 class CannedInputUIFactoryTests(TestCase):
     
     def test_canned_input_get_input(self):




More information about the bazaar-commits mailing list