| OLD | NEW |
| (Empty) |
| 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 | |
| 5 import os | |
| 6 import unittest | |
| 7 | |
| 8 from telemetry.core import util | |
| 9 | |
| 10 from core import find_dependencies | |
| 11 | |
| 12 | |
| 13 class FindDependenciesTest(unittest.TestCase): | |
| 14 | |
| 15 def testFindPythonDependencies(self): | |
| 16 try: | |
| 17 dog_object_path = os.path.join( | |
| 18 util.GetUnittestDataDir(), | |
| 19 'dependency_test_dir', 'dog', 'dog', 'dog_object.py') | |
| 20 cat_module_path = os.path.join( | |
| 21 util.GetUnittestDataDir(), | |
| 22 'dependency_test_dir', 'other_animals', 'cat', 'cat') | |
| 23 cat_module_init_path = os.path.join(cat_module_path, '__init__.py') | |
| 24 cat_object_path = os.path.join(cat_module_path, 'cat_object.py') | |
| 25 self.assertEquals( | |
| 26 set(p for p in | |
| 27 find_dependencies.FindPythonDependencies(dog_object_path)), | |
| 28 {dog_object_path, cat_module_path, cat_module_init_path, | |
| 29 cat_object_path}) | |
| 30 except ImportError: # crbug.com/559527 | |
| 31 pass | |
| 32 | |
| 33 def testFindPythonDependenciesWithNestedImport(self): | |
| 34 try: | |
| 35 moose_module_path = os.path.join( | |
| 36 util.GetUnittestDataDir(), | |
| 37 'dependency_test_dir', 'other_animals', 'moose', 'moose') | |
| 38 moose_object_path = os.path.join(moose_module_path, 'moose_object.py') | |
| 39 horn_module_path = os.path.join(moose_module_path, 'horn') | |
| 40 horn_module_init_path = os.path.join(horn_module_path, '__init__.py') | |
| 41 horn_object_path = os.path.join(horn_module_path, 'horn_object.py') | |
| 42 self.assertEquals( | |
| 43 set(p for p in | |
| 44 find_dependencies.FindPythonDependencies(moose_object_path)), | |
| 45 {moose_object_path, | |
| 46 horn_module_path, horn_module_init_path, horn_object_path}) | |
| 47 except ImportError: # crbug.com/559527 | |
| 48 pass | |
| OLD | NEW |