/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 breezy/tests/treeshape.py

  • Committer: Breezy landing bot
  • Author(s): Martin
  • Date: 2017-06-10 02:49:30 UTC
  • mfrom: (6677.1.4 py3_bootstrap)
  • Revision ID: breezy.the.bot@gmail.com-20170610024930-enw8wdbjy9s4dtnm
Progress on Python 3 to get TestCaseWithTransport working

Merged from https://code.launchpad.net/~gz/brz/py3_bootstrap/+merge/325439

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
        elif name[-1] == '@':
54
54
            os.symlink(tt[1], tt[0][:-1])
55
55
        else:
56
 
            f = file(name, 'wb')
57
 
            try:
 
56
            with open(name, 'wb') as f:
58
57
                f.write(tt[1])
59
 
            finally:
60
 
                f.close()
61
58
 
62
59
 
63
60
def capture_tree_contents(top):
75
72
            if stat.S_ISLNK(info.st_mode):
76
73
                yield (fullpath + '@', os.readlink(fullpath))
77
74
            elif stat.S_ISREG(info.st_mode):
78
 
                yield (fullpath, file(fullpath, 'rb').read())
 
75
                with open(fullpath, 'rb') as f:
 
76
                    file_bytes = f.read()
 
77
                yield (fullpath, file_bytes)
79
78
            else:
80
79
                warning("can't capture file %s with mode %#o",
81
80
                        fullpath, info.st_mode)