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
6import os
7import unittest
8
9from telemetry.util import path_set
10
11
12class PathSetTest(unittest.TestCase):
13  def testCreate(self):
14    ps = path_set.PathSet()
15    self.assertEqual(len(ps), 0)  # Check __len__.
16    self.assertFalse(__file__ in ps)
17    for _ in ps:  # Check __iter__.
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
39if __name__ == '__main__':
40  unittest.main()
41