/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/commands/test_cat.py

  • Committer: Vincent Ladeuil
  • Date: 2010-01-25 15:55:48 UTC
  • mto: (4985.1.4 add-attr-cleanup)
  • mto: This revision was merged to the branch mainline in revision 4988.
  • Revision ID: v.ladeuil+lp@free.fr-20100125155548-0l352pujvt5bzl5e
Deploy addAttrCleanup on the whole test suite.

Several use case worth mentioning:

- setting a module or any other object attribute is the majority
by far. In some cases the setting itself is deferred but most of
the time we want to set at the same time we add the cleanup.

- there multiple occurrences of protecting hooks or ui factory
which are now useless (the test framework takes care of that now),

- there was some lambda uses that can now be avoided.

That first cleanup already simplifies things a lot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
27
27
        super(TestCat, self).setUp()
28
28
        # Redirect sys.stdout as this is what cat uses
29
29
        self.outf = StringIOWrapper()
30
 
        self.overrideAttr(sys, 'stdout', self.outf)
 
30
        self.addAttrCleanup(sys, 'stdout')
 
31
        sys.stdout = self.outf
31
32
 
32
33
    def test_cat(self):
33
34
        # FIXME: sftp raises ReadError instead of NoSuchFile when probing for
44
45
        self.start_logging_connections()
45
46
 
46
47
        cmd = cmd_cat()
47
 
        cmd.run(self.get_url('branch/foo'))
 
48
        cmd.run_direct(self.get_url('branch/foo'))
48
49
        self.assertEquals(1, len(self.connections))
49
50
        self.assertEquals('foo', self.outf.getvalue())
50
51