~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_pack.py

  • Committer: Vincent Ladeuil
  • Date: 2012-01-05 13:02:31 UTC
  • mto: This revision was merged to the branch mainline in revision 6434.
  • Revision ID: v.ladeuil+lp@free.fr-20120105130231-grtl31ovy72doqp9
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2007, 2009-2012 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
32
32
        for i in range(total_lines):
33
33
            text += line_prefix + str(i+1) + "\n"
34
34
 
35
 
        open(path, 'w').write(text)
 
35
        with open(path, 'w') as f:
 
36
            f.write(text)
36
37
        if versioned:
37
38
            self.run_bzr(['add', path])
38
39
            self.run_bzr(['ci', '-m', '"' + path + '"'])
69
70
    def test_pack_clean_obsolete_packs(self):
70
71
        """Ensure --clean-obsolete-packs removes obsolete pack files
71
72
        """
72
 
        wd = 'foobar0'
73
 
        wt = self.make_branch_and_tree(wd)
74
 
        transport = wt.branch.repository.bzrdir.transport
75
 
        os.chdir(wd)
 
73
        wt = self.make_branch_and_tree('.')
 
74
        t = wt.branch.repository.bzrdir.transport
76
75
 
77
76
        # do multiple commits to ensure that obsolete packs are created
78
77
        # by 'bzr pack'
82
81
 
83
82
        out, err = self.run_bzr(['pack', '--clean-obsolete-packs'])
84
83
 
85
 
        pack_names = transport.list_dir('repository/obsolete_packs')
 
84
        pack_names = t.list_dir('repository/obsolete_packs')
86
85
        self.assertTrue(len(pack_names) == 0)
87
86
 
88
87