~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__dirstate_helpers.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2008 Canonical Ltd
 
1
# Copyright (C) 2007, 2008, 2009 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
1295
1295
            tree.unlock()
1296
1296
        self.assertEqual(sorted(expected), sorted(file_ids))
1297
1297
 
 
1298
    def test_exceptions_raised(self):
 
1299
        # This is a direct test of bug #495023, it relies on osutils.is_inside
 
1300
        # getting called in an inner function. Which makes it a bit brittle,
 
1301
        # but at least it does reproduce the bug.
 
1302
        def is_inside_raises(*args, **kwargs):
 
1303
            raise RuntimeError('stop this')
 
1304
        tree = self.make_branch_and_tree('tree')
 
1305
        self.build_tree(['tree/file', 'tree/dir/', 'tree/dir/sub',
 
1306
                         'tree/dir2/', 'tree/dir2/sub2'])
 
1307
        tree.add(['file', 'dir', 'dir/sub', 'dir2', 'dir2/sub2'])
 
1308
        tree.commit('first commit')
 
1309
        tree.lock_read()
 
1310
        self.addCleanup(tree.unlock)
 
1311
        basis_tree = tree.basis_tree()
 
1312
        orig = osutils.is_inside
 
1313
        self.addCleanup(setattr, osutils, 'is_inside', orig)
 
1314
        osutils.is_inside = is_inside_raises
 
1315
        self.assertListRaises(RuntimeError, tree.iter_changes, basis_tree)
 
1316
 
1298
1317
    def test_simple_changes(self):
1299
1318
        tree = self.make_branch_and_tree('tree')
1300
1319
        self.build_tree(['tree/file'])