Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ max-line-length = 120
# D103 Missing docstring in public function
# D104 Missing docstring in public package
# D107 Missing docstring in __init__
# W503 line break before binary operator
# W606 'async' and 'await' are reserved keywords starting with Python 3.7
ignore = D100, D101, D102, D103, D104, D107, W606
ignore = D100, D101, D102, D103, D104, D107, W503, W606
7 changes: 0 additions & 7 deletions unittesting/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,6 @@ def current_package_name(self):

return None

@property
def current_test_file(self):
current_file = sublime.active_window().active_view().file_name()
if current_file and current_file.endswith(".py"):
current_file = os.path.basename(current_file)
return current_file

def input_parser(self, package):
m = re.match(r'([^:]+):(.+)', package)
if m:
Expand Down
22 changes: 19 additions & 3 deletions unittesting/test_current.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from fnmatch import fnmatch
import os
import sublime
import sys
from .test_package import UnitTestingCommand
Expand Down Expand Up @@ -43,9 +45,23 @@ def run(self, **kwargs):
sublime.message_dialog("Cannot determine package name.")
return

test_file = self.current_test_file
if not test_file:
test_file = ""
window = sublime.active_window()
if not window:
return

view = window.active_view()

settings = self.load_unittesting_settings(project_name, kwargs)
current_file = (view and view.file_name()) or ''
file_name = os.path.basename(current_file)
if file_name and fnmatch(file_name, settings['pattern']):
test_file = file_name
window.settings().set('UnitTesting.last_test_file', test_file)
else:
test_file = (
window.settings().get('UnitTesting.last_test_file')
or current_file
)

sublime.set_timeout_async(
lambda: super(UnitTestingCurrentFileCommand, self).run(
Expand Down