~luoyonggang/subvertpy/python2

« back to all changes in this revision

Viewing changes to subvertpy/tests/__init__.py

  • Committer: Jelmer Vernooij
  • Date: 2012-03-01 20:42:06 UTC
  • mfrom: (2427.2.2 closefile)
  • Revision ID: jelmer@samba.org-20120301204206-pk5w56xxz30fxuxx
Merge support for always closing files, with tweaks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
365
365
        :param files: Dictionary with filenames as keys, contents as
366
366
            values. None as value indicates a directory.
367
367
        """
368
 
        for f in files:
369
 
            if files[f] is None:
 
368
        for name, content in files.iteritems():
 
369
            if content is None:
370
370
                try:
371
 
                    os.makedirs(f)
 
371
                    os.makedirs(name)
372
372
                except OSError:
373
373
                    pass
374
374
            else:
375
375
                try:
376
 
                    os.makedirs(os.path.dirname(f))
 
376
                    os.makedirs(os.path.dirname(name))
377
377
                except OSError:
378
378
                    pass
379
 
                open(f, 'w').write(files[f])
 
379
                f = open(name, 'w')
 
380
                try:
 
381
                    f.write(content)
 
382
                finally:
 
383
                    f.close()
380
384
 
381
385
    def make_client(self, repospath, clientpath, allow_revprop_changes=True):
382
386
        """Create a repository and a checkout. Return the checkout.