Merged revisions 73814-73815 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r73814 | tarek.ziade | 2009-07-03 21:01:12 +0200 (Fri, 03 Jul 2009) | 1 line

  basic tests to raise distutils.file_util coverage
........
  r73815 | tarek.ziade | 2009-07-03 21:14:49 +0200 (Fri, 03 Jul 2009) | 1 line

  cleaned distutils.file_util
........
This commit is contained in:
Tarek Ziadé 2009-07-03 19:22:23 +00:00
parent 89b8917022
commit c2b7188995
2 changed files with 41 additions and 25 deletions

View file

@ -3,7 +3,7 @@ import unittest
import os
import shutil
from distutils.file_util import move_file
from distutils.file_util import move_file, write_file, copy_file
from distutils import log
from distutils.tests import support
@ -55,6 +55,21 @@ class FileUtilTestCase(support.TempdirManager, unittest.TestCase):
wanted = ['moving %s -> %s' % (self.source, self.target_dir)]
self.assertEquals(self._logs, wanted)
def test_write_file(self):
lines = ['a', 'b', 'c']
dir = self.mkdtemp()
foo = os.path.join(dir, 'foo')
write_file(foo, lines)
content = [line.strip() for line in open(foo).readlines()]
self.assertEquals(content, lines)
def test_copy_file(self):
src_dir = self.mkdtemp()
foo = os.path.join(src_dir, 'foo')
write_file(foo, 'content')
dst_dir = self.mkdtemp()
copy_file(foo, dst_dir)
self.assertTrue(os.path.exists(os.path.join(dst_dir, 'foo')))
def test_suite():
return unittest.makeSuite(FileUtilTestCase)