diff --git a/PythonTestOutput.hidden-tmLanguage b/PythonTestOutput.hidden-tmLanguage index acb5a90..90c5ffa 100644 --- a/PythonTestOutput.hidden-tmLanguage +++ b/PythonTestOutput.hidden-tmLanguage @@ -6,6 +6,24 @@ PythonTestOutput patterns + + begin + Command: + captures + + 1 + + name + test.command + + + comment + command running + end + \n + match + "(.*)" + begin ^[=-]+$ diff --git a/PythonTestOutput.hidden-tmTheme b/PythonTestOutput.hidden-tmTheme index 744b430..ac84b79 100644 --- a/PythonTestOutput.hidden-tmTheme +++ b/PythonTestOutput.hidden-tmTheme @@ -23,6 +23,17 @@ #DDF0FF33 + + name + Command + scope + test.command + settings + + foreground + #004ACA + + name Test diff --git a/plugin.py b/plugin.py index 383259c..2315bb2 100644 --- a/plugin.py +++ b/plugin.py @@ -20,6 +20,10 @@ def run(self, edit): # turn on language/theme for output panel somehow panel = self.view.window().create_output_panel('exec') panel.settings().set('color_scheme', self.color_scheme(settings)) + + command_print_msg = 'python -c "print(\'Command \\"{}\\"\')"'.format(re.sub('"', '\\"', command)) + command = command_print_msg + "; " + command + self.view.window().run_command( "exec", {"cmd": [command], "file_regex": TB_FILE, @@ -57,21 +61,22 @@ def find_test_name(self, tx, point): matches = TEST_FUNC_RE.findall(tx) if not matches: return - print(matches) + indent, funcname = matches[-1] if not indent: return funcname + # find the enclosing class before = self.view.substr(sublime.Region(0, point)) - print(len(before)) classes = TEST_CASE_RE.findall(before) - print(classes) + if not classes: return funcname # this is probably bad + candidates = [c for i, c in classes if len(i) < len(indent)] - print(candidates) if candidates: return "%s.%s" % (candidates[-1], funcname) + return funcname # also probably bad def file_to_module(self, wd, fn):