Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / tools / telemetry_tools / path_set_unittest.py
1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import os
7 import unittest
8
9 import path_set
10
11
12 class PathSetTest(unittest.TestCase):
13   def testCreate(self):
14     ps = path_set.PathSet()
15     self.assertEqual(len(ps), 0)
16     self.assertFalse(__file__ in ps)
17     for path in ps:
18       self.fail('New set is not empty.')
19
20     ps = path_set.PathSet([__file__])
21     self.assertEqual(len(ps), 1)
22     self.assertTrue(__file__ in ps)
23     self.assertEqual(ps.pop(), os.path.realpath(__file__))
24
25   def testAdd(self):
26     ps = path_set.PathSet()
27     ps.add(__file__)
28     self.assertEqual(len(ps), 1)
29     self.assertTrue(__file__ in ps)
30     self.assertEqual(ps.pop(), os.path.realpath(__file__))
31
32   def testDiscard(self):
33     ps = path_set.PathSet([__file__])
34     ps.discard(__file__)
35     self.assertEqual(len(ps), 0)
36     self.assertFalse(__file__ in ps)
37
38
39 if __name__ == '__main__':
40   unittest.main()