11import sublime
22import sublime_api
3- import sublime_plugin
43from unittesting .helpers import TempDirectoryTestCase , OverridePreferencesTestCase
54from ProjectManager .project_manager import Manager
65
76
87import os
9- import imp
10- from unittest import skipIf
118from unittest .mock import patch
129
1310
@@ -19,27 +16,16 @@ class TestBasicFeatures(TempDirectoryTestCase, OverridePreferencesTestCase):
1916 "project_manager.sublime-settings" : {}
2017 }
2118 project_name = None
22- last_view = [None ]
2319
2420 @classmethod
2521 def setUpClass (cls ):
26- capture_event_listener = type (
27- "capture_event_listener" ,
28- (sublime_plugin .EventListener ,),
29- {"on_activated" : lambda self , view : cls .last_view .__setitem__ (0 , view )})
30- capture_module = imp .new_module ("capture" )
31- capture_module .capture_event_listener = capture_event_listener
32- sublime_plugin .load_module (capture_module )
33- cls .capture_module = capture_module
34- yield 100
3522 yield from TempDirectoryTestCase .setUpClass .__func__ (cls )
3623 yield from OverridePreferencesTestCase .setUpClass .__func__ (cls )
3724 cls .project_name = os .path .basename (cls ._temp_dir )
3825 cls .manager = Manager (cls .window )
3926
4027 @classmethod
4128 def tearDownClass (cls ):
42- sublime_plugin .unload_module (cls .capture_module )
4329 TempDirectoryTestCase .tearDownClass .__func__ (cls )
4430 OverridePreferencesTestCase .tearDownClass .__func__ (cls )
4531
@@ -49,13 +35,8 @@ def tearDownClass(cls):
4935 yield mocked .called
5036
5137 def setUp (self ):
52- self .last_view [0 ] = None
5338 yield from self .__class__ .setWindowFolder ()
5439
55- def active_widget_view (self ):
56- yield lambda : self .last_view [0 ] and self .last_view [0 ].settings ().get ("is_widget" )
57- return self .last_view [0 ]
58-
5940 def test_add_and_open_with_mock (self ):
6041 def _window_show_input_panel (wid , caption , initial_text , on_done , on_change , on_cancel ):
6142 sublime .set_timeout (lambda : on_done (initial_text ), 100 )
@@ -98,39 +79,3 @@ def _window_show_quick_panel(wid, items, items_per_row, on_done, *args, **kwargs
9879 with patch ("sublime.ok_cancel_dialog" , return_value = True ):
9980 self .window .run_command ("project_manager" , {"action" : "remove_project" })
10081 yield lambda : self .window .project_file_name () is None
101-
102- @skipIf (sublime .version () < "4000" , SELECT_NOT_AVAILABLE )
103- def test_add_and_open_with_select (self ):
104- if sublime .platform () == "linux" and os .environ .get ("CI" ):
105- # it gives enough time for the window manager to response to changes in focus
106- yield 5000
107- self .window .run_command ("project_manager" , {"action" : "add_project" })
108- yield from self .active_widget_view ()
109- self .window .run_command ("select" )
110-
111- yield lambda : self .window .project_file_name () is not None
112-
113- projects_info = self .manager .projects_info .info ()
114-
115- self .assertTrue (self .project_name in projects_info )
116-
117- # clear sidebar
118- self .window .run_command ('close_workspace' )
119-
120- self .assertTrue (self .window .project_file_name () is None )
121-
122- self .window .run_command ("project_manager" , {"action" : "open_project" })
123- view = yield from self .active_widget_view ()
124- view .run_command ("insert" , {"characters" : self .project_name })
125- self .window .run_command ("select" )
126-
127- yield lambda : self .window .project_file_name () is not None
128-
129- self .assertEqual (os .path .basename (self .window .folders ()[0 ]), self .project_name )
130-
131- with patch ("sublime.ok_cancel_dialog" , return_value = True ):
132- self .window .run_command ("project_manager" , {"action" : "remove_project" })
133- view = yield from self .active_widget_view ()
134- view .run_command ("insert" , {"characters" : self .project_name })
135- self .window .run_command ("select" )
136- yield lambda : self .window .project_file_name () is None
0 commit comments