Rev 4489: (vila) Cleanup imports in some test files in http://bazaar.launchpad.net/%7Evila/bzr/integration

Vincent Ladeuil v.ladeuil+lp at free.fr
Mon Jun 29 13:12:28 BST 2009


At http://bazaar.launchpad.net/%7Evila/bzr/integration

------------------------------------------------------------
revno: 4489 [merge]
revision-id: v.ladeuil+lp at free.fr-20090629121215-nyjaxps6hffe02ym
parent: pqm at pqm.ubuntu.com-20090627002953-q4333x7hfvw1q3wz
parent: v.ladeuil+lp at free.fr-20090629120604-s1mhzj8llocamvzr
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: integration
timestamp: Mon 2009-06-29 14:12:15 +0200
message:
  (vila) Cleanup imports in some test files
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/help_topics/en/configuration.txt configuration.txt-20060314161707-868350809502af01
  bzrlib/send.py                 send.py-20090521192735-j7cdb33ykmtmzx4w-1
  bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
  bzrlib/tests/blackbox/test_send.py test_bundle.py-20060616222707-c21c8b7ea5ef57b1
  bzrlib/tests/test_config.py    testconfig.py-20051011041908-742d0c15d8d8c8eb
  bzrlib/tests/test_ui.py        test_ui.py-20051130162854-458e667a7414af09
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2009-06-26 23:28:46 +0000
+++ b/NEWS	2009-06-29 11:07:16 +0000
@@ -21,9 +21,16 @@
 New Features
 ************
 
-* ``bzr push`` now checks if uncommitted changes are present in the working
-  tree if the ``--strict`` option is used.
-  (Vincent Ladeuil, #284038)
+* ``bzr push`` now aborts if uncommitted changes (including pending merges)
+  are present in the working tree (if one is present) and no revision is
+  speficied. The ``push_strict`` option can be declared in a configuration
+  file.  option is used.  (Vincent Ladeuil, #284038, #322808, #65286)
+
+* ``bzr send`` now aborts if uncommitted changes (including pending merges)
+  are present in the working tree and no revision is speficied. The
+  ``--no-strict`` option can be used to force the sending. The
+  ``send_strict`` option can be declared in a configuration file.
+  (Vincent Ladeuil, #206577)
 
 
 Bug Fixes

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2009-06-26 03:44:30 +0000
+++ b/bzrlib/builtins.py	2009-06-29 11:07:16 +0000
@@ -1057,16 +1057,17 @@
                     strict = bools[strict.lower()]
                 except KeyError:
                     strict = None
-        if strict:
-            changes = tree.changes_from(tree.basis_tree())
-            if changes.has_changed():
-                raise errors.UncommittedChanges(tree)
         # Get the tip's revision_id
         revision = _get_one_revision('push', revision)
         if revision is not None:
             revision_id = revision.in_history(br_from).rev_id
         else:
             revision_id = None
+        if (tree is not None and revision_id is None
+            and (strict is None or strict)): # Default to True:
+            changes = tree.changes_from(tree.basis_tree())
+            if changes.has_changed() or len(tree.get_parent_ids()) > 1:
+                raise errors.UncommittedChanges(tree)
 
         # Get the stacked_on branch, if any
         if stacked_on is not None:
@@ -4899,24 +4900,29 @@
                help='Write merge directive to this file; '
                     'use - for stdout.',
                type=unicode),
+        Option('strict',
+               help='Refuse to send if there are uncommitted changes in'
+               ' the working tree.'),
         Option('mail-to', help='Mail the request to this address.',
                type=unicode),
         'revision',
         'message',
         Option('body', help='Body for the email.', type=unicode),
         RegistryOption('format',
-                       help='Use the specified output format.', 
-                       lazy_registry=('bzrlib.send', 'format_registry'))
+                       help='Use the specified output format.',
+                       lazy_registry=('bzrlib.send', 'format_registry')),
         ]
 
     def run(self, submit_branch=None, public_branch=None, no_bundle=False,
             no_patch=False, revision=None, remember=False, output=None,
-            format=None, mail_to=None, message=None, body=None, **kwargs):
+            format=None, mail_to=None, message=None, body=None,
+            strict=None, **kwargs):
         from bzrlib.send import send
         return send(submit_branch, revision, public_branch, remember,
-                         format, no_bundle, no_patch, output,
-                         kwargs.get('from', '.'), mail_to, message, body,
-                         self.outf)
+                    format, no_bundle, no_patch, output,
+                    kwargs.get('from', '.'), mail_to, message, body,
+                    self.outf,
+                    strict=strict)
 
 
 class cmd_bundle_revisions(cmd_send):
@@ -4966,6 +4972,9 @@
                type=unicode),
         Option('output', short_name='o', help='Write directive to this file.',
                type=unicode),
+        Option('strict',
+               help='Refuse to bundle revisions if there are'
+               ' uncommitted changes in the working tree.'),
         'revision',
         RegistryOption('format',
                        help='Use the specified output format.',
@@ -4979,14 +4988,14 @@
 
     def run(self, submit_branch=None, public_branch=None, no_bundle=False,
             no_patch=False, revision=None, remember=False, output=None,
-            format=None, **kwargs):
+            format=None, strict=None, **kwargs):
         if output is None:
             output = '-'
         from bzrlib.send import send
         return send(submit_branch, revision, public_branch, remember,
                          format, no_bundle, no_patch, output,
                          kwargs.get('from', '.'), None, None, None,
-                         self.outf)
+                         self.outf, strict=strict)
 
 
 class cmd_tag(Command):

=== modified file 'bzrlib/help_topics/en/configuration.txt'
--- a/bzrlib/help_topics/en/configuration.txt	2009-06-10 13:18:48 +0000
+++ b/bzrlib/help_topics/en/configuration.txt	2009-06-26 18:13:41 +0000
@@ -421,3 +421,10 @@
 
 If set to "True", the branch should act as a checkout, and push each commit to
 the bound_location.  This option is normally set by ``bind``/``unbind``.
+
+send_strict
+~~~~~~~~~~~
+
+If present, defines the ``--strict`` option default value for checking
+uncommitted changes before sending a merge directive.
+

=== modified file 'bzrlib/send.py'
--- a/bzrlib/send.py	2009-05-28 16:14:16 +0000
+++ b/bzrlib/send.py	2009-06-26 18:13:41 +0000
@@ -37,8 +37,8 @@
 
 
 def send(submit_branch, revision, public_branch, remember, format,
-         no_bundle, no_patch, output, from_, mail_to, message, body, 
-         to_file):
+         no_bundle, no_patch, output, from_, mail_to, message, body,
+         to_file, strict=None):
     tree, branch = bzrdir.BzrDir.open_containing_tree_or_branch(from_)[:2]
     # we may need to write data into branch's repository to calculate
     # the data to send.
@@ -107,6 +107,21 @@
             if len(revision) == 2:
                 base_revision_id = revision[0].as_revision_id(branch)
         if revision_id is None:
+            if strict is None:
+                strict = branch.get_config().get_user_option('send_strict')
+                if strict is not None:
+                    # FIXME: This should be better supported by config
+                    # -- vila 20090626
+                    bools = dict(yes=True, no=False, on=True, off=False,
+                                 true=True, false=False)
+                    try:
+                        strict = bools[strict.lower()]
+                    except KeyError:
+                        strict = None
+            if strict is None or strict: # Default to True
+                changes = tree.changes_from(tree.basis_tree())
+                if changes.has_changed() or len(tree.get_parent_ids()) > 1:
+                    raise errors.UncommittedChanges(tree)
             revision_id = branch.last_revision()
         if revision_id == NULL_REVISION:
             raise errors.BzrCommandError('No revisions to submit.')

=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- a/bzrlib/tests/blackbox/test_push.py	2009-06-22 08:14:24 +0000
+++ b/bzrlib/tests/blackbox/test_push.py	2009-06-29 09:02:28 +0000
@@ -35,6 +35,28 @@
 from bzrlib.transport import memory
 
 
+def load_tests(standard_tests, module, loader):
+    """Multiply tests for the push command."""
+    result = loader.suiteClass()
+
+    # one for each king of change
+    changes_tests, remaining_tests = tests.split_suite_by_condition(
+        standard_tests, tests.condition_isinstance((
+                TestPushStrictWithChanges,
+                )))
+    changes_scenarios = [
+        ('uncommitted',
+         dict(_changes_type= '_uncommitted_changes')),
+        ('pending_merges',
+         dict(_changes_type= '_pending_merges')),
+        ]
+    tests.multiply_tests(changes_tests, changes_scenarios, result)
+    # No parametrization for the remaining tests
+    result.addTests(remaining_tests)
+
+    return result
+
+
 class TestPush(tests.TestCaseWithTransport):
 
     def test_push_error_on_vfs_http(self):
@@ -569,72 +591,112 @@
 class TestPushStrict(tests.TestCaseWithTransport):
 
     def make_local_branch_and_tree(self):
-        tree = self.make_branch_and_tree('local')
+        self.tree = self.make_branch_and_tree('local')
         self.build_tree_contents([('local/file', 'initial')])
-        tree.add('file')
-        tree.commit('adding file', rev_id='from-1')
-        return tree
-
-    def make_local_branch_and_tree_with_changes(self):
-        tree = self.make_local_branch_and_tree()
-        # Make some changes
+        self.tree.add('file')
+        self.tree.commit('adding file', rev_id='added')
         self.build_tree_contents([('local/file', 'modified')])
-        return tree
+        self.tree.commit('modify file', rev_id='modified')
 
-    def set_config_push_strict(self, tree, value):
+    def set_config_push_strict(self, value):
         # set config var (any of bazaar.conf, locations.conf, branch.conf
         # should do)
-        conf = tree.branch.get_config()
+        conf = self.tree.branch.get_config()
         conf.set_user_option('push_strict', value)
 
-    def assertPushFails(self, location, *args):
+    def assertPushFails(self, args):
         self.run_bzr_error(['Working tree ".*/local/"'
                             ' has uncommitted changes.$',],
-                           ['push', '../' + location] + list(args),
+                           ['push', '../to'] + args,
                            working_dir='local', retcode=3)
 
-    def assertPushSucceeds(self, location, *args):
-        self.run_bzr(['push', '../' + location] + list(args),
+    def assertPushSucceeds(self, args, pushed_revid=None):
+        self.run_bzr(['push', '../to'] + args,
                      working_dir='local')
-        tree_to = workingtree.WorkingTree.open(location)
+        if pushed_revid is None:
+            pushed_revid = 'modified'
+        tree_to = workingtree.WorkingTree.open('to')
         repo_to = tree_to.branch.repository
-        self.assertTrue(repo_to.has_revision('from-1'))
-        self.assertEqual(tree_to.branch.last_revision_info()[1], 'from-1')
-
-    def test_push_default(self):
-        tree = self.make_local_branch_and_tree_with_changes()
-        self.assertPushSucceeds('to')
-
-    def test_push_no_strict_with_changes(self):
-        tree = self.make_local_branch_and_tree_with_changes()
-        self.assertPushSucceeds('to', '--no-strict')
+        self.assertTrue(repo_to.has_revision(pushed_revid))
+        self.assertEqual(tree_to.branch.last_revision_info()[1], pushed_revid)
+
+
+
+class TestPushStrictWithoutChanges(TestPushStrict):
+
+    def setUp(self):
+        super(TestPushStrictWithoutChanges, self).setUp()
+        self.make_local_branch_and_tree()
+
+    def test_push_default(self):
+        self.assertPushSucceeds([])
+
+    def test_push_strict(self):
+        self.assertPushSucceeds(['--strict'])
+
+    def test_push_no_strict(self):
+        self.assertPushSucceeds(['--no-strict'])
+
+    def test_push_config_var_strict(self):
+        self.set_config_push_strict('true')
+        self.assertPushSucceeds([])
+
+    def test_push_config_var_no_strict(self):
+        self.set_config_push_strict('false')
+        self.assertPushSucceeds([])
+
+
+class TestPushStrictWithChanges(TestPushStrict):
+
+    _changes_type = None # Set by load_tests
+
+    def setUp(self):
+        super(TestPushStrictWithChanges, self).setUp()
+        getattr(self, self._changes_type)()
+
+    def _uncommitted_changes(self):
+        self.make_local_branch_and_tree()
+        # Make a change without committing it
+        self.build_tree_contents([('local/file', 'in progress')])
+
+    def _pending_merges(self):
+        self.make_local_branch_and_tree()
+        # Create 'other' branch containing a new file
+        other_bzrdir = self.tree.bzrdir.sprout('other')
+        other_tree = other_bzrdir.open_workingtree()
+        self.build_tree_contents([('other/other-file', 'other')])
+        other_tree.add('other-file')
+        other_tree.commit('other commit', rev_id='other')
+        # Merge and revert, leaving a pending merge
+        self.tree.merge_from_branch(other_tree.branch)
+        self.tree.revert(filenames=['other-file'], backups=False)
+
+    def test_push_default(self):
+        self.assertPushFails([])
+
+    def test_push_with_revision(self):
+        self.assertPushSucceeds(['-r', 'revid:added'], pushed_revid='added')
+
+    def test_push_no_strict(self):
+        self.assertPushSucceeds(['--no-strict'])
 
     def test_push_strict_with_changes(self):
-        tree = self.make_local_branch_and_tree_with_changes()
-        self.assertPushFails('to', '--strict')
-
-    def test_push_strict_without_changes(self):
-        tree = self.make_local_branch_and_tree()
-        self.assertPushSucceeds('to', '--strict')
+        self.assertPushFails(['--strict'])
 
     def test_push_respect_config_var_strict(self):
-        tree = self.make_local_branch_and_tree_with_changes()
-        self.set_config_push_strict(tree, 'true')
-        self.assertPushFails('to')
+        self.set_config_push_strict('true')
+        self.assertPushFails([])
 
     def test_push_bogus_config_var_ignored(self):
-        tree = self.make_local_branch_and_tree_with_changes()
-        self.set_config_push_strict(tree, "I don't want you to be strict")
-        self.assertPushSucceeds('to')
+        self.set_config_push_strict("I don't want you to be strict")
+        self.assertPushFails([])
 
     def test_push_no_strict_command_line_override_config(self):
-        tree = self.make_local_branch_and_tree_with_changes()
-        self.set_config_push_strict(tree, 'yES')
-        self.assertPushFails('to')
-        self.assertPushSucceeds('to', '--no-strict')
+        self.set_config_push_strict('yES')
+        self.assertPushFails([])
+        self.assertPushSucceeds(['--no-strict'])
 
     def test_push_strict_command_line_override_config(self):
-        tree = self.make_local_branch_and_tree_with_changes()
-        self.set_config_push_strict(tree, 'oFF')
-        self.assertPushFails('to', '--strict')
-        self.assertPushSucceeds('to')
+        self.set_config_push_strict('oFF')
+        self.assertPushFails(['--strict'])
+        self.assertPushSucceeds([])

=== modified file 'bzrlib/tests/blackbox/test_send.py'
--- a/bzrlib/tests/blackbox/test_send.py	2009-06-26 08:20:13 +0000
+++ b/bzrlib/tests/blackbox/test_send.py	2009-06-29 09:50:35 +0000
@@ -28,12 +28,52 @@
 from bzrlib.bundle import serializer
 
 
-def read_bundle(fileobj):
-    md = merge_directive.MergeDirective.from_lines(fileobj.readlines())
-    return serializer.read_bundle(StringIO(md.get_raw_bundle()))
-
-
-class TestSend(tests.TestCaseWithTransport):
+def load_tests(standard_tests, module, loader):
+    """Multiply tests for the send command."""
+    result = loader.suiteClass()
+
+    # one for each king of change
+    changes_tests, remaining_tests = tests.split_suite_by_condition(
+        standard_tests, tests.condition_isinstance((
+                TestSendStrictWithChanges,
+                )))
+    changes_scenarios = [
+        ('uncommitted',
+         dict(_changes_type= '_uncommitted_changes')),
+        ('pending_merges',
+         dict(_changes_type= '_pending_merges')),
+        ]
+    tests.multiply_tests(changes_tests, changes_scenarios, result)
+    # No parametrization for the remaining tests
+    result.addTests(remaining_tests)
+
+    return result
+
+
+class TestSendMixin(object):
+
+    _default_command = ['send', '-o-']
+    _default_wd = 'branch'
+
+    def run_send(self, args, cmd=None, rc=0, wd=None, err_re=None):
+        if cmd is None: cmd = self._default_command
+        if wd is None: wd = self._default_wd
+        if err_re is None: err_re = []
+        return self.run_bzr(cmd + args, retcode=rc,
+                            working_dir=wd,
+                            error_regexes=err_re)
+
+    def get_MD(self, args, cmd=None, wd='branch'):
+        out = StringIO(self.run_send(args, cmd=cmd, wd=wd)[0])
+        return merge_directive.MergeDirective.from_lines(out.readlines())
+
+    def assertBundleContains(self, revs, args, cmd=None, wd='branch'):
+        md = self.get_MD(args, cmd=cmd, wd=wd)
+        br = serializer.read_bundle(StringIO(md.get_raw_bundle()))
+        self.assertEqual(set(revs), set(r.revision_id for r in br.revisions))
+
+
+class TestSend(tests.TestCaseWithTransport, TestSendMixin):
 
     def setUp(self):
         super(TestSend, self).setUp()
@@ -51,24 +91,6 @@
         self.build_tree_contents([('branch/file1', 'branch')])
         branch_tree.commit('last commit', rev_id='rev3')
 
-    def run_send(self, args, cmd=None, rc=0, wd='branch'):
-        if cmd is None:
-            cmd = ['send', '-o-']
-        return self.run_bzr(cmd + args, retcode=rc, working_dir=wd)
-
-    def get_MD(self, args, cmd=None, wd='branch'):
-        out = StringIO(self.run_send(args, cmd=cmd, wd=wd)[0])
-        return merge_directive.MergeDirective.from_lines(out.readlines())
-
-    def get_bundle(self, args, cmd=None, wd='branch'):
-        md = self.get_MD(args, cmd=cmd, wd=wd)
-        return serializer.read_bundle(StringIO(md.get_raw_bundle()))
-
-    def assertBundleContains(self, revs, args, cmd=None, wd='branch'):
-        out = self.run_send(args, cmd=cmd, wd=wd)[0]
-        br = read_bundle(StringIO(out))
-        self.assertEqual(set(revs), set(r.revision_id for r in br.revisions))
-
     def assertFormatIs(self, fmt_string, md):
         self.assertEqual(fmt_string, md.get_raw_bundle().splitlines()[0])
 
@@ -263,3 +285,131 @@
         out, err = self.run_bzr(["send", "--from", location], retcode=3)
         self.assertEqual(out, '')
         self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
+
+
+class TestSendStrictMixin(TestSendMixin):
+
+    _default_command = ['send', '-o-', '../parent']
+    _default_wd = 'local'
+
+    def make_parent_and_local_branches(self):
+        # Create a 'parent' branch as the base
+        self.parent_tree = bzrdir.BzrDir.create_standalone_workingtree('parent')
+        self.build_tree_contents([('parent/file', 'parent')])
+        self.parent_tree.add('file')
+        self.parent_tree.commit('first commit', rev_id='parent')
+        # Branch 'local' from parent and do a change
+        local_bzrdir = self.parent_tree.bzrdir.sprout('local')
+        self.local_tree = local_bzrdir.open_workingtree()
+        self.build_tree_contents([('local/file', 'local')])
+        self.local_tree.commit('second commit', rev_id='local')
+
+    def set_config_send_strict(self, value):
+        # set config var (any of bazaar.conf, locations.conf, branch.conf
+        # should do)
+        conf = self.local_tree.branch.get_config()
+        conf.set_user_option('send_strict', value)
+
+    def assertSendFails(self, args):
+        self.run_send(args, rc=3,
+                      err_re=['Working tree ".*/local/"'
+                              ' has uncommitted changes.$',])
+
+    def assertSendSucceeds(self, revs, args):
+        out, err = self.run_send(args)
+        self.assertEquals('Bundling 1 revision(s).\n', err)
+        md = merge_directive.MergeDirective.from_lines(
+                StringIO(out).readlines())
+        self.assertEqual('parent', md.base_revision_id)
+        br = serializer.read_bundle(StringIO(md.get_raw_bundle()))
+        self.assertEqual(set(revs), set(r.revision_id for r in br.revisions))
+
+
+class TestSendStrictWithoutChanges(tests.TestCaseWithTransport,
+                                   TestSendStrictMixin):
+
+    def setUp(self):
+        super(TestSendStrictWithoutChanges, self).setUp()
+        self.make_parent_and_local_branches()
+
+    def test_send_default(self):
+        self.assertSendSucceeds(['local'], [])
+
+    def test_send_strict(self):
+        self.assertSendSucceeds(['local'], ['--strict'])
+
+    def test_send_no_strict(self):
+        self.assertSendSucceeds(['local'], ['--no-strict'])
+
+    def test_send_config_var_strict(self):
+        self.set_config_send_strict('true')
+        self.assertSendSucceeds(['local'], [])
+
+    def test_send_config_var_no_strict(self):
+        self.set_config_send_strict('false')
+        self.assertSendSucceeds(['local'], [])
+
+
+class TestSendStrictWithChanges(tests.TestCaseWithTransport,
+                                   TestSendStrictMixin):
+
+    _changes_type = None # Set by load_tests
+
+    def setUp(self):
+        super(TestSendStrictWithChanges, self).setUp()
+        getattr(self, self._changes_type)()
+
+    def _uncommitted_changes(self):
+        self.make_parent_and_local_branches()
+        # Make a change without committing it
+        self.build_tree_contents([('local/file', 'modified')])
+
+    def _pending_merges(self):
+        self.make_parent_and_local_branches()
+        # Create 'other' branch containing a new file
+        other_bzrdir = self.parent_tree.bzrdir.sprout('other')
+        other_tree = other_bzrdir.open_workingtree()
+        self.build_tree_contents([('other/other-file', 'other')])
+        other_tree.add('other-file')
+        other_tree.commit('other commit', rev_id='other')
+        # Merge and revert, leaving a pending merge
+        self.local_tree.merge_from_branch(other_tree.branch)
+        self.local_tree.revert(filenames=['other-file'], backups=False)
+
+    def test_send_default(self):
+        self.assertSendFails([])
+
+    def test_send_with_revision(self):
+        self.assertSendSucceeds(['local'], ['-r', 'revid:local'])
+
+    def test_send_no_strict(self):
+        self.assertSendSucceeds(['local'], ['--no-strict'])
+
+    def test_send_strict_with_changes(self):
+        self.assertSendFails(['--strict'])
+
+    def test_send_respect_config_var_strict(self):
+        self.set_config_send_strict('true')
+        self.assertSendFails([])
+        self.assertSendSucceeds(['local'], ['--no-strict'])
+
+
+    def test_send_bogus_config_var_ignored(self):
+        self.set_config_send_strict("I'm unsure")
+        self.assertSendFails([])
+
+
+    def test_send_no_strict_command_line_override_config(self):
+        self.set_config_send_strict('true')
+        self.assertSendFails([])
+        self.assertSendSucceeds(['local'], ['--no-strict'])
+
+    def test_push_strict_command_line_override_config(self):
+        self.set_config_send_strict('false')
+        self.assertSendSucceeds(['local'], [])
+        self.assertSendFails(['--strict'])
+
+
+class TestBundleStrictWithoutChanges(TestSendStrictWithoutChanges):
+
+    _default_command = ['bundle-revisions', '../parent']

=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py	2009-06-10 03:56:49 +0000
+++ b/bzrlib/tests/test_config.py	2009-06-29 12:06:04 +0000
@@ -18,7 +18,6 @@
 """Tests for finding and reading the bzr config file[s]."""
 # import system imports here
 from cStringIO import StringIO
-import getpass
 import os
 import sys
 

=== modified file 'bzrlib/tests/test_ui.py'
--- a/bzrlib/tests/test_ui.py	2009-06-17 05:16:48 +0000
+++ b/bzrlib/tests/test_ui.py	2009-06-29 12:06:04 +0000
@@ -23,21 +23,15 @@
 import sys
 import time
 
-import bzrlib
-import bzrlib.errors as errors
+from bzrlib import (
+    errors,
+    tests,
+    ui as _mod_ui,
+    )
 from bzrlib.symbol_versioning import (
     deprecated_in,
     )
-from bzrlib.tests import (
-    TestCase,
-    TestUIFactory,
-    StringIOWrapper,
-    )
 from bzrlib.tests.test_progress import _TTYStringIO
-from bzrlib.ui import (
-    CLIUIFactory,
-    SilentUIFactory,
-    )
 from bzrlib.ui.text import (
     NullProgressView,
     TextProgressView,
@@ -45,10 +39,10 @@
     )
 
 
-class UITests(TestCase):
+class UITests(tests.TestCase):
 
     def test_silent_factory(self):
-        ui = SilentUIFactory()
+        ui = _mod_ui.SilentUIFactory()
         stdout = StringIO()
         self.assertEqual(None,
                          self.apply_redirected(None, stdout, stdout,
@@ -62,8 +56,9 @@
         self.assertEqual('', stdout.getvalue())
 
     def test_text_factory_ascii_password(self):
-        ui = TestUIFactory(stdin='secret\n', stdout=StringIOWrapper(),
-                           stderr=StringIOWrapper())
+        ui = tests.TestUIFactory(stdin='secret\n',
+                                 stdout=tests.StringIOWrapper(),
+                                 stderr=tests.StringIOWrapper())
         pb = ui.nested_progress_bar()
         try:
             self.assertEqual('secret',
@@ -84,9 +79,9 @@
         We can't predict what encoding users will have for stdin, so we force
         it to utf8 to test that we transport the password correctly.
         """
-        ui = TestUIFactory(stdin=u'baz\u1234'.encode('utf8'),
-                           stdout=StringIOWrapper(),
-                           stderr=StringIOWrapper())
+        ui = tests.TestUIFactory(stdin=u'baz\u1234'.encode('utf8'),
+                                 stdout=tests.StringIOWrapper(),
+                                 stderr=tests.StringIOWrapper())
         ui.stderr.encoding = ui.stdout.encoding = ui.stdin.encoding = 'utf8'
         pb = ui.nested_progress_bar()
         try:
@@ -194,11 +189,11 @@
         self.assertEqual('', factory.stdin.readline())
 
     def test_silent_ui_getbool(self):
-        factory = SilentUIFactory()
+        factory = _mod_ui.SilentUIFactory()
         self.assert_get_bool_acceptance_of_user_input(factory)
 
     def test_silent_factory_prompts_silently(self):
-        factory = SilentUIFactory()
+        factory = _mod_ui.SilentUIFactory()
         stdout = StringIO()
         factory.stdin = StringIO("y\n")
         self.assertEqual(True,
@@ -222,7 +217,8 @@
     def test_text_factory_prompts_and_clears(self):
         # a get_boolean call should clear the pb before prompting
         out = _TTYStringIO()
-        factory = TextUIFactory(stdin=StringIO("yada\ny\n"), stdout=out, stderr=out)
+        factory = TextUIFactory(stdin=StringIO("yada\ny\n"),
+                                stdout=out, stderr=out)
         pb = factory.nested_progress_bar()
         pb.show_bar = False
         pb.show_spinner = False
@@ -253,7 +249,7 @@
             pb.finished()
 
     def test_silent_ui_getusername(self):
-        factory = SilentUIFactory()
+        factory = _mod_ui.SilentUIFactory()
         factory.stdin = StringIO("someuser\n\n")
         factory.stdout = StringIO()
         factory.stderr = StringIO()
@@ -279,8 +275,9 @@
         self.assertEqual('', factory.stdin.readline())
 
     def test_text_ui_getusername_utf8(self):
-        ui = TestUIFactory(stdin=u'someuser\u1234'.encode('utf8'),
-                           stdout=StringIOWrapper(), stderr=StringIOWrapper())
+        ui = tests.TestUIFactory(stdin=u'someuser\u1234'.encode('utf8'),
+                                 stdout=tests.StringIOWrapper(),
+                                 stderr=tests.StringIOWrapper())
         ui.stderr.encoding = ui.stdout.encoding = ui.stdin.encoding = "utf8"
         pb = ui.nested_progress_bar()
         try:
@@ -295,7 +292,7 @@
             pb.finished()
 
 
-class TestTextProgressView(TestCase):
+class TestTextProgressView(tests.TestCase):
     """Tests for text display of progress bars.
     """
     # XXX: These might be a bit easier to write if the rendering and



More information about the bazaar-commits mailing list