def test_global_attr_not_recognized_in_class(self): global SOURCE_COMPLETION source_code = SOURCE_COMPLETION + '\n cat.' self.cc.analyze_file('', source_code) offset = len(source_code) results = self.cc.get_completion(source_code, offset) expected = get_source_data(SOURCE_COMPLETION, 'cat') self.assertEqual(expected, results)
def test_invalid_var(self): global SOURCE_COMPLETION new_lines = '\n\ninvalid.' source_code = SOURCE_COMPLETION + new_lines self.cc.analyze_file('', source_code) offset = len(source_code) results = self.cc.get_completion(source_code, offset) expected = get_source_data(source_code, 'invalid') self.assertEqual(expected, results)
def test_simple_import_late_resolution_not_outside_func(self): new_code = ['def func():', ' q = os.path', 'q.'] source_code = SOURCE_LATE_RESOLUTION + '\n'.join(new_code) self.cc.analyze_file('', source_code) offset = len(source_code) time.sleep(1) results = self.cc.get_completion(source_code, offset) expected = get_source_data(source_code, 'q') self.assertEqual(results, expected)
def test_simple_import_late_resolution_chained_func_7(self): new_code = ['import threading', 'import sys', 'def func():', ' q = threading.Lock()', ' def gfunc():', ' a = sys', 'q.'] source_code = SOURCE_LATE_RESOLUTION + '\n'.join(new_code) self.cc.analyze_file('', source_code) offset = len(source_code) time.sleep(1) results = self.cc.get_completion(source_code, offset) expected = get_source_data(source_code, 'q') self.assertEqual(expected, results)