def test_ignore(self): """Test ignoring glob patterns.""" self.assertTrue(Tools.is_ignored('/tmp/hello', ['/tmp/*'])) self.assertTrue(Tools.is_ignored('/tmp/hello', ['/tmp*'])) self.assertTrue(Tools.is_ignored('/tmp/hello', ['', '/tmp*'])) self.assertTrue(Tools.is_ignored('/tmp/hello', ['', '/tmp/hell*'])) self.assertFalse(Tools.is_ignored('/tmp/hello', ['/tmp/c*']))
def test_pep257(self): """Test conformance to pep257.""" cmd = PEP257_CMD.format(PLUGIN_SOURCE_FOLDER) output = Tools.run_command(cmd) print(output) if LINUX_MISSING_MSG in output or WINDOWS_MISSING_MSG in output: print('no pep257 found in path!') return self.assertTrue(len(output) == 0)
def test_pep8(self): """Test conformance to pep8.""" cmd = PEP8_CMD.format(PLUGIN_SOURCE_FOLDER) output = Tools.run_command(cmd, shell=True) print(output) if LINUX_MISSING_MSG in output or WINDOWS_MISSING_MSG in output: print('no pep8 found in path!') return self.assertTrue(len(output) == 0)
def __animate_progress(self): """Function that changes the status message, i.e animates progress.""" while True: if self.__show_animation: SublBridge.set_status(Tools.generate_next_progress_message()) time.sleep(ThreadPool.__progress_update_delay) else: SublBridge.set_status(READY_MSG) time.sleep(ThreadPool.__progress_idle_delay)
def test_pep257(self): """Test conformance to pep257.""" cmd = PEP257_CMD.format(PLUGIN_SOURCE_FOLDER, ','.join(PEP_257_IGNORE)) print(cmd) output = Tools.run_command(cmd, shell=True) print(output) if LINUX_MISSING_MSG in output or WINDOWS_MISSING_MSG in output: print('no pep257 found in path!') return self.assertTrue(len(output) == 0)
def test_wrong_triggers(self): """Test that we don't complete on numbers and wrong triggers.""" self.tearDown() self.setUpView(path.join('test_files', 'test_wrong_triggers.cpp')) # Load the completions. manager = SettingsManager() settings = manager.user_settings() # Check the current cursor position is completable. self.assertEqual(self.getRow(2), " a > 2.") # check that '>' does not trigger completions pos = self.view.text_point(2, 5) current_word = self.view.substr(self.view.word(pos)) self.assertEqual(current_word, "> ") status = Tools.get_pos_status(pos, self.view, settings) # Verify that we got the expected completions back. self.assertEqual(status, PosStatus.WRONG_TRIGGER) # check that ' >' does not trigger completions pos = self.view.text_point(2, 4) current_word = self.view.substr(self.view.word(pos)) self.assertEqual(current_word, " >") status = Tools.get_pos_status(pos, self.view, settings) # Verify that we got the expected completions back. self.assertEqual(status, PosStatus.COMPLETION_NOT_NEEDED) # check that '2.' does not trigger completions pos = self.view.text_point(2, 8) current_word = self.view.substr(self.view.word(pos)) self.assertEqual(current_word, ".\n") status = Tools.get_pos_status(pos, self.view, settings) # Verify that we got the expected completions back. self.assertEqual(status, PosStatus.WRONG_TRIGGER)
def test_expand_star(self): """Check that expanding a star at the end of folder works.""" this_folder = path.dirname(__file__) this_folder_with_star = path.join(this_folder, '*') print(this_folder_with_star) expanded = Tools.expand_star_wildcard(this_folder_with_star) folder1 = path.join(this_folder, 'cmake_tests') folder2 = path.join(this_folder, 'compilation_db_files') folder3 = path.join(this_folder, 'test_files') self.assertEqual(len(expanded), 3) self.assertIn(folder1, expanded) self.assertIn(folder2, expanded) self.assertIn(folder3, expanded)
def test_expand_star(self): """Check that expanding a star at the end of folder works.""" this_folder = path.dirname(__file__) this_folder_with_star = path.join(this_folder, '*') print(this_folder_with_star) expanded = Tools.expand_star_wildcard(this_folder_with_star) expected_folders = [ path.join(this_folder, 'c_cpp_properties_files'), path.join(this_folder, 'cmake_tests'), path.join(this_folder, 'compilation_db_files'), path.join(this_folder, 'CppProperties_files'), path.join(this_folder, 'test_files'), ] self.assertEqual(len(expanded), len(expected_folders)) self.assertEqual(sorted(expected_folders), sorted(expanded))
def test_get_clang_version(self): """Test getting clang version.""" version = Tools.get_clang_version_str('clang++') print("version: ", version) self.assertIn('.', version)