Merge support for always closing files, with tweaks.
authorJelmer Vernooij <jelmer@samba.org>
Thu, 1 Mar 2012 20:42:06 +0000 (21:42 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 1 Mar 2012 20:42:06 +0000 (21:42 +0100)
1  2 
subvertpy/tests/__init__.py

@@@ -365,18 -362,18 +365,22 @@@ class SubversionTestCase(TestCaseInTemp
          :param files: Dictionary with filenames as keys, contents as
              values. None as value indicates a directory.
          """
--        for f in files:
--            if files[f] is None:
++        for name, content in files.iteritems():
++            if content is None:
                  try:
--                    os.makedirs(f)
++                    os.makedirs(name)
                  except OSError:
                      pass
              else:
                  try:
--                    os.makedirs(os.path.dirname(f))
++                    os.makedirs(os.path.dirname(name))
                  except OSError:
                      pass
-                 open(f, 'w').write(files[f])
 -                self.write_file(f, files[f])
++                f = open(name, 'w')
++                try:
++                    f.write(content)
++                finally:
++                    f.close()
  
      def make_client(self, repospath, clientpath, allow_revprop_changes=True):
          """Create a repository and a checkout. Return the checkout.