/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/test_bzrdir.py

MergeĀ upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Tests for the BzrDir facility and any format specific tests.
18
18
 
1306
1306
        parent = grandparent_tree.bzrdir.sprout('parent').open_branch()
1307
1307
        branch_tree = parent.bzrdir.sprout('branch').open_branch()
1308
1308
        self.assertContainsRe(branch_tree.get_parent(), '/parent/$')
 
1309
 
 
1310
 
 
1311
class TestBzrDirHooks(TestCaseWithMemoryTransport):
 
1312
 
 
1313
    def test_pre_open_called(self):
 
1314
        calls = []
 
1315
        bzrdir.BzrDir.hooks.install_named_hook('pre_open', calls.append, None)
 
1316
        transport = self.get_transport('foo')
 
1317
        url = transport.base
 
1318
        self.assertRaises(errors.NotBranchError, bzrdir.BzrDir.open, url)
 
1319
        self.assertEqual([transport.base], [t.base for t in calls])
 
1320
 
 
1321
    def test_pre_open_actual_exceptions_raised(self):
 
1322
        count = [0]
 
1323
        def fail_once(transport):
 
1324
            count[0] += 1
 
1325
            if count[0] == 1:
 
1326
                raise errors.BzrError("fail")
 
1327
        bzrdir.BzrDir.hooks.install_named_hook('pre_open', fail_once, None)
 
1328
        transport = self.get_transport('foo')
 
1329
        url = transport.base
 
1330
        err = self.assertRaises(errors.BzrError, bzrdir.BzrDir.open, url)
 
1331
        self.assertEqual('fail', err._preformatted_string)