def test_find_hard_dependencies(self): path_finder = partial(find_module_path, '/tmp/my_package') path = os.path.join(self.dir, 'chinatown/india.py') result = list(ir.find_dependencies(path, path_finder)) self.assertEquals(['/tmp/my_package/israel.py', '/tmp/my_package/istanbul/__init__.py'], result)
def test_find_from_init(self): path_finder = partial(find_module_path, '/tmp/my_package') path = os.path.join(self.dir, 'istanbul/__init__.py') result = list(ir.find_dependencies(path, path_finder)) self.assertEquals(['/tmp/my_package/africa.py'], result)
def test_find_dependencies(self): path_finder = partial(find_module_path, '/tmp/my_package') result = list(ir.find_dependencies(os.path.join(self.dir, 'africa.py'), path_finder)) self.assertIn('/tmp/my_package/israel.py', result)
def get_all_dependencies_in_project(directory): path_finder = partial(find_module_path, directory) for dirname, _, filenames in os.walk(os.path.abspath(directory)): for full_path in imap(os.path.join, repeat(dirname), filenames): if full_path.endswith('.py'): yield full_path, find_dependencies(full_path, path_finder)