OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 import os | 4 import os |
5 import unittest | 5 import unittest |
6 | 6 |
7 from telemetry.core import discover | 7 from py_utils import discover |
8 from telemetry.core import util | |
9 | 8 |
10 | 9 |
11 class DiscoverTest(unittest.TestCase): | 10 class DiscoverTest(unittest.TestCase): |
12 | 11 |
13 def setUp(self): | 12 def setUp(self): |
14 self._base_dir = util.GetUnittestDataDir() | 13 self._base_dir = os.path.join(os.path.dirname(__file__), 'test_data') |
15 self._start_dir = os.path.join(self._base_dir, 'discoverable_classes') | 14 self._start_dir = os.path.join(self._base_dir, 'discoverable_classes') |
16 self._base_class = Exception | 15 self._base_class = Exception |
17 | 16 |
18 def testDiscoverClassesWithIndexByModuleName(self): | 17 def testDiscoverClassesWithIndexByModuleName(self): |
19 classes = discover.DiscoverClasses(self._start_dir, | 18 classes = discover.DiscoverClasses(self._start_dir, |
20 self._base_dir, | 19 self._base_dir, |
21 self._base_class, | 20 self._base_class, |
22 index_by_class_name=False) | 21 index_by_class_name=False) |
23 | 22 |
24 actual_classes = dict((name, cls.__name__) | 23 actual_classes = dict((name, cls.__name__) |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 self.assertTrue(discover.IsDirectlyConstructable(ClassWithoutInitDefOne)) | 137 self.assertTrue(discover.IsDirectlyConstructable(ClassWithoutInitDefOne)) |
139 self.assertTrue(discover.IsDirectlyConstructable(ClassWithoutInitDefTwo)) | 138 self.assertTrue(discover.IsDirectlyConstructable(ClassWithoutInitDefTwo)) |
140 self.assertTrue(discover.IsDirectlyConstructable(ClassWhoseInitOnlyHasSelf)) | 139 self.assertTrue(discover.IsDirectlyConstructable(ClassWhoseInitOnlyHasSelf)) |
141 self.assertTrue( | 140 self.assertTrue( |
142 discover.IsDirectlyConstructable(ClassWhoseInitWithDefaultArguments)) | 141 discover.IsDirectlyConstructable(ClassWhoseInitWithDefaultArguments)) |
143 | 142 |
144 def testIsDirectlyConstructableReturnsFalse(self): | 143 def testIsDirectlyConstructableReturnsFalse(self): |
145 self.assertFalse( | 144 self.assertFalse( |
146 discover.IsDirectlyConstructable( | 145 discover.IsDirectlyConstructable( |
147 ClassWhoseInitWithDefaultArgumentsAndNonDefaultArguments)) | 146 ClassWhoseInitWithDefaultArgumentsAndNonDefaultArguments)) |
OLD | NEW |