diff --git a/plugins/cmds.py b/plugins/cmds.py index 5aaee98..de2fe0b 100644 --- a/plugins/cmds.py +++ b/plugins/cmds.py @@ -6,25 +6,15 @@ import re import string import subprocess -import sys import threading from collections import defaultdict, deque -from functools import reduce from itertools import chain from operator import itemgetter as iget -try: - import sublime - import sublime_plugin - from sublime import status_message, error_message - -except ImportError: # running tests - from .tests.sublime_fake import sublime - from .tests.sublime_fake import sublime_plugin - - sys.modules['sublime'] = sublime - sys.modules['sublime_plugin'] = sublime_plugin +import sublime +import sublime_plugin +from sublime import status_message, error_message from .ctags import (FILENAME, PATH_ORDER, SYMBOL, build_ctags, parse_tag_lines, diff --git a/plugins/ctags.py b/plugins/ctags.py index a758a9f..695cb2c 100644 --- a/plugins/ctags.py +++ b/plugins/ctags.py @@ -8,7 +8,6 @@ import os import re import subprocess -import sys from subprocess import check_output diff --git a/plugins/tests/__init__.py b/plugins/tests/__init__.py index e69de29..d6ddff9 100644 --- a/plugins/tests/__init__.py +++ b/plugins/tests/__init__.py @@ -0,0 +1,7 @@ +import sys + +from . import mock_sublime +from . import mock_sublime_plugin + +sys.modules['sublime'] = mock_sublime +sys.modules['sublime_plugin'] = mock_sublime_plugin diff --git a/plugins/tests/mock_sublime.py b/plugins/tests/mock_sublime.py new file mode 100644 index 0000000..d22c237 --- /dev/null +++ b/plugins/tests/mock_sublime.py @@ -0,0 +1,40 @@ +""" +Mock module for ``sublime`` in Sublime Text. +""" + +import sys + +# find flags +LITERAL = 1 +IGNORECASE = 2 +WHOLEWORD = 4 +REVERSE = 8 +WRAP = 16 + + +def arch(): + return 'x64' + + +def platform(): + if sys.platform == 'darwin': + return 'osx' + if sys.platform == 'win32': + return 'windows' + return 'linux' + + +def version(): + return '4126' + + +def load_settings(self, **kargs): + pass + + +def status_message(msg): + pass + + +def error_message(msg): + pass diff --git a/plugins/tests/mock_sublime_plugin.py b/plugins/tests/mock_sublime_plugin.py new file mode 100644 index 0000000..af16313 --- /dev/null +++ b/plugins/tests/mock_sublime_plugin.py @@ -0,0 +1,19 @@ +""" +Mock module for ``sublime_plugin`` in Sublime Text. +""" + +all_callbacks = { + 'on_load': [] +} + + +class WindowCommand(object): + pass + + +class TextCommand(object): + pass + + +class EventListener(object): + pass diff --git a/plugins/tests/sublime_fake.py b/plugins/tests/sublime_fake.py deleted file mode 100644 index bf2ee89..0000000 --- a/plugins/tests/sublime_fake.py +++ /dev/null @@ -1,30 +0,0 @@ -class sublime(object): - """ - Mock object for ``sublime`` class in Sublime Text. - """ - LITERAL = '' - VERSION = '2.0' - - def load_settings(self, **kargs): - pass - - @staticmethod - def version(): - return sublime.VERSION - -class sublime_plugin(object): - """ - Mock object for ``sublime_plugin`` class in Sublime Text. - """ - all_callbacks = { - 'on_load': [] - } - - class WindowCommand(object): - pass - - class TextCommand(object): - pass - - class EventListener(object): - pass diff --git a/plugins/utils.py b/plugins/utils.py index 9c7928f..4d4ac37 100644 --- a/plugins/utils.py +++ b/plugins/utils.py @@ -1,23 +1,12 @@ """ common utilities used by all ctags modules """ -import os import re -import sys # Helper functions -try: - import sublime - import sublime_plugin - from sublime import status_message, error_message - -except ImportError: # running tests - from .tests.sublime_fake import sublime - from .tests.sublime_fake import sublime_plugin - - sys.modules['sublime'] = sublime - sys.modules['sublime_plugin'] = sublime_plugin +import sublime +import sublime_plugin def get_settings():