Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / third_party / tvcm / tvcm / fake_fs_unittest.py
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4 import unittest
5 import os
6
7 from tvcm import fake_fs
8
9 class FakeFSUnittest(unittest.TestCase):
10   def testBasic(self):
11     fs = fake_fs.FakeFS()
12     fs.AddFile('/blah/x', 'foobar')
13     with fs:
14       assert os.path.exists('/blah/x')
15       self.assertEquals(
16           'foobar',
17           open('/blah/x', 'r').read())
18
19
20   def testWithableOpen(self):
21     fs = fake_fs.FakeFS()
22     fs.AddFile('/blah/x', 'foobar')
23     with fs:
24       with open('/blah/x', 'r') as f:
25         self.assertEquals('foobar', f.read())