From d0406b416d7f8899c064bef1d02e16c188a384b3 Mon Sep 17 00:00:00 2001 From: David Halter Date: Wed, 12 Sep 2012 23:19:53 +0200 Subject: [PATCH] fixed ModuleNotFound error --- functions.py | 5 ++++- test/regression.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/functions.py b/functions.py index 9be27d85..7b36ff73 100644 --- a/functions.py +++ b/functions.py @@ -244,7 +244,10 @@ def get_definition(source, line, column, source_path): for s in scopes.copy(): if isinstance(s, imports.ImportPath): scopes.remove(s) - scopes.update(resolve_import_paths(set(s.follow()))) + try: + scopes.update(resolve_import_paths(set(s.follow()))) + except imports.ModuleNotFound: + pass return scopes pos = (line, column) diff --git a/test/regression.py b/test/regression.py index bf70b379..5da107a5 100755 --- a/test/regression.py +++ b/test/regression.py @@ -84,8 +84,8 @@ class TestRegression(unittest.TestCase): assert len(s) > 0 def test_get_definition_on_import(self): - assert self.get_def("import os_blabla", (1, 8)) == [] - assert len(self.get_def("import os", (1, 8))) == 1 + assert self.get_def("import sys_blabla", (1, 8)) == [] + assert len(self.get_def("import sys", (1, 8))) == 1 def test_new(self): """ This is just to try out things, removing or deleting it is ok. """