summaryrefslogtreecommitdiff
path: root/systrace/catapult/common/py_utils/py_utils/file_util_unittest.py
diff options
context:
space:
mode:
Diffstat (limited to 'systrace/catapult/common/py_utils/py_utils/file_util_unittest.py')
-rw-r--r--systrace/catapult/common/py_utils/py_utils/file_util_unittest.py66
1 files changed, 0 insertions, 66 deletions
diff --git a/systrace/catapult/common/py_utils/py_utils/file_util_unittest.py b/systrace/catapult/common/py_utils/py_utils/file_util_unittest.py
deleted file mode 100644
index 4bb19a1..0000000
--- a/systrace/catapult/common/py_utils/py_utils/file_util_unittest.py
+++ /dev/null
@@ -1,66 +0,0 @@
-# Copyright 2018 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import errno
-import os
-import shutil
-import tempfile
-import unittest
-
-from py_utils import file_util
-
-
-class FileUtilTest(unittest.TestCase):
-
- def setUp(self):
- self._tempdir = tempfile.mkdtemp()
-
- def tearDown(self):
- shutil.rmtree(self._tempdir)
-
- def testCopySimple(self):
- source_path = os.path.join(self._tempdir, 'source')
- with open(source_path, 'w') as f:
- f.write('data')
-
- dest_path = os.path.join(self._tempdir, 'dest')
-
- self.assertFalse(os.path.exists(dest_path))
- file_util.CopyFileWithIntermediateDirectories(source_path, dest_path)
- self.assertTrue(os.path.exists(dest_path))
- self.assertEqual('data', open(dest_path, 'r').read())
-
- def testCopyMakeDirectories(self):
- source_path = os.path.join(self._tempdir, 'source')
- with open(source_path, 'w') as f:
- f.write('data')
-
- dest_path = os.path.join(self._tempdir, 'path', 'to', 'dest')
-
- self.assertFalse(os.path.exists(dest_path))
- file_util.CopyFileWithIntermediateDirectories(source_path, dest_path)
- self.assertTrue(os.path.exists(dest_path))
- self.assertEqual('data', open(dest_path, 'r').read())
-
- def testCopyOverwrites(self):
- source_path = os.path.join(self._tempdir, 'source')
- with open(source_path, 'w') as f:
- f.write('source_data')
-
- dest_path = os.path.join(self._tempdir, 'dest')
- with open(dest_path, 'w') as f:
- f.write('existing_data')
-
- file_util.CopyFileWithIntermediateDirectories(source_path, dest_path)
- self.assertEqual('source_data', open(dest_path, 'r').read())
-
- def testRaisesError(self):
- source_path = os.path.join(self._tempdir, 'source')
- with open(source_path, 'w') as f:
- f.write('data')
-
- dest_path = ""
- with self.assertRaises(OSError) as cm:
- file_util.CopyFileWithIntermediateDirectories(source_path, dest_path)
- self.assertEqual(errno.ENOENT, cm.exception.error_code)