Skip to content

Commit 6192593

Browse files
committed
Renamed python files to prevent
expection after installation from package control related to import order
1 parent c2545bc commit 6192593

File tree

7 files changed

+49
-49
lines changed

7 files changed

+49
-49
lines changed
File renamed without changes.

gist_request.py renamed to gist_40_request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import urllib.request as urllib
1010

11-
from exceptions import MissingCredentialsException, SimpleHTTPError
11+
from gist_20_exceptions import MissingCredentialsException, SimpleHTTPError
1212

1313

1414
def token_auth_string():
File renamed without changes.

gist.py renamed to gist_80.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717

1818
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
1919

20-
from exceptions import MissingCredentialsException
21-
from gist_helpers import (
20+
from gist_20_exceptions import MissingCredentialsException
21+
from gist_60_helpers import (
2222
gistify_view,
2323
gists_filter,
2424
set_syntax,
2525
ungistify_view,
2626
)
27-
from gist_request import api_request
27+
from gist_40_request import api_request
2828

2929
settings = None
3030

test/test_commands.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from unittest import TestCase
33
from unittest.mock import Mock, patch
44

5-
import gist
5+
import gist_80 as gist
66
from test.stubs import github_api, sublime
77

88
DEFAULT_GISTS_URL = 'https://api.github.com/gists?per_page=100'
@@ -22,21 +22,21 @@ def test_gist_copy_url(self,):
2222
gist_copy_url.run(edit=None)
2323
sublime.set_clipboard.assert_called_with(None)
2424

25-
@patch('gist.webbrowser')
25+
@patch('gist_80.webbrowser')
2626
def test_gist_open_browser(self, patch_gist_webbrowser):
2727
gist_open_browser = gist.GistOpenBrowser()
2828
gist_open_browser.run(edit=None)
2929
patch_gist_webbrowser.open.assert_called_with(None)
3030

31-
@patch('gist.api_request')
31+
@patch('gist_80.api_request')
3232
def test_gist_list_command_base(self, mocked_api_request):
3333
gist.plugin_loaded()
3434
mocked_api_request.side_effect = [github_api.GIST_STARRED_LIST, github_api.GIST_LIST]
3535
gist.settings.set('include_users', ['some user'])
3636
gist.settings.set('include_orgs', ['some org'])
3737
gist_list_base = gist.GistListCommandBase()
3838

39-
with patch('gist.GistListCommandBase.get_window') as mocked_get_window:
39+
with patch('gist_80.GistListCommandBase.get_window') as mocked_get_window:
4040
mocked_window = Mock()
4141
mocked_get_window.return_value = mocked_window
4242
gist_list_base.run()
@@ -71,7 +71,7 @@ def test_gist_list_command_base(self, mocked_api_request):
7171
# pass flow
7272
mocked_window.reset_mock()
7373
mocked_api_request.reset_mock()
74-
with patch('gist.GistListCommandBase.handle_gist') as mocked_handle_gist:
74+
with patch('gist_80.GistListCommandBase.handle_gist') as mocked_handle_gist:
7575
on_gist_num(-1)
7676

7777
self.assertEqual(mocked_api_request.call_count, 0)
@@ -81,7 +81,7 @@ def test_gist_list_command_base(self, mocked_api_request):
8181
# personal gists flow
8282
mocked_window.reset_mock()
8383
mocked_api_request.reset_mock()
84-
with patch('gist.GistListCommandBase.handle_gist') as mocked_handle_gist:
84+
with patch('gist_80.GistListCommandBase.handle_gist') as mocked_handle_gist:
8585
on_gist_num(0)
8686

8787
self.assertEqual(mocked_api_request.call_count, 0)
@@ -116,32 +116,32 @@ def test_gist_list_command_base(self, mocked_api_request):
116116
self.assertRaises(NotImplementedError, gist_list_base.handle_gist, None)
117117
self.assertRaises(NotImplementedError, gist_list_base.get_window)
118118

119-
@patch('gist.open_gist')
119+
@patch('gist_80.open_gist')
120120
def test_gist_list_command(self, mocked_open_gist):
121121
mocked_window = Mock()
122122
gist_list = gist.GistListCommand(mocked_window)
123123
gist_list.handle_gist({'url': TEST_GIST_URL})
124124
mocked_open_gist.assert_called_with(TEST_GIST_URL)
125125
self.assertEqual(gist_list.get_window(), mocked_window)
126126

127-
@patch('gist.insert_gist')
127+
@patch('gist_80.insert_gist')
128128
def test_insert_gist_list_command(self, mocked_insert_gist):
129129
mocked_window = Mock()
130130
insert_gist_list = gist.InsertGistListCommand(mocked_window)
131131
insert_gist_list.handle_gist({'url': TEST_GIST_URL})
132132
mocked_insert_gist.assert_called_with(TEST_GIST_URL)
133133
self.assertEqual(insert_gist_list.get_window(), mocked_window)
134134

135-
@patch('gist.insert_gist_embed')
135+
@patch('gist_80.insert_gist_embed')
136136
def test_insert_gist_embed_list_command(self, mocked_insert_gist_embed):
137137
mocked_window = Mock()
138138
insert_gist_embed_list = gist.InsertGistEmbedListCommand(mocked_window)
139139
insert_gist_embed_list.handle_gist({'url': TEST_GIST_URL})
140140
mocked_insert_gist_embed.assert_called_with(TEST_GIST_URL)
141141
self.assertEqual(insert_gist_embed_list.get_window(), mocked_window)
142142

143-
@patch('gist.gistify_view')
144-
@patch('gist.update_gist')
143+
@patch('gist_80.gistify_view')
144+
@patch('gist_80.update_gist')
145145
def test_gist_add_file_command(self, mocked_update_gist, mocked_gistify_view):
146146
add_file = gist.GistAddFileCommand()
147147
add_file.handle_gist({'url': TEST_GIST_URL})
@@ -179,9 +179,9 @@ def test_gist_view_command(self):
179179
self.assertEqual(gist_view_command.gist_filename(), 'some gist filename')
180180
self.assertEqual(gist_view_command.gist_description(), 'some gist description')
181181

182-
@patch('gist.gistify_view')
182+
@patch('gist_80.gistify_view')
183183
@patch('test.stubs.sublime.Region')
184-
@patch('gist.create_gist')
184+
@patch('gist_80.create_gist')
185185
def test_gist_command(self, mocked_create_gist, mocked_region, mocked_gistify_view):
186186
gist_command = gist.GistCommand()
187187
gist_command.view = sublime.View()
@@ -234,8 +234,8 @@ def test_gist_private_command(self):
234234
gist_private_command = gist.GistPrivateCommand()
235235
self.assertEqual(gist_private_command.mode(), 'Private')
236236

237-
@patch('gist.gistify_view')
238-
@patch('gist.update_gist')
237+
@patch('gist_80.gistify_view')
238+
@patch('gist_80.update_gist')
239239
def test_gist_rename_file_command(self, mocked_update_gist, mocked_gistify_view):
240240
gist_rename_file = gist.GistRenameFileCommand()
241241
mocked_update_gist.return_value = 'some updated gist'
@@ -254,8 +254,8 @@ def test_gist_rename_file_command(self, mocked_update_gist, mocked_gistify_view)
254254
mocked_gistify_view.assert_called_with(gist_rename_file.view, 'some updated gist', 'some new filename')
255255
sublime.status_message.assert_called_with('Gist file renamed')
256256

257-
@patch('gist.gistify_view')
258-
@patch('gist.update_gist')
257+
@patch('gist_80.gistify_view')
258+
@patch('gist_80.update_gist')
259259
def test_change_description_command(self, mocked_update_gist, mocked_gistify_view):
260260
sublime._windows[0] = sublime.Window(0)
261261
mocked_update_gist.return_value = 'some updated gist'
@@ -274,7 +274,7 @@ def test_change_description_command(self, mocked_update_gist, mocked_gistify_vie
274274
mocked_gistify_view.assert_called_with(sublime._windows[0]._view, 'some updated gist', None)
275275
sublime.status_message.assert_called_with('Gist description changed')
276276

277-
@patch('gist.update_gist')
277+
@patch('gist_80.update_gist')
278278
def test_gist_update_file_command(self, mocked_update_gist):
279279
gist_update_file = gist.GistUpdateFileCommand()
280280
gist_update_file.run(edit=False)
@@ -283,8 +283,8 @@ def test_gist_update_file_command(self, mocked_update_gist):
283283

284284
sublime.status_message.assert_called_with('Gist updated')
285285

286-
@patch('gist.ungistify_view')
287-
@patch('gist.update_gist')
286+
@patch('gist_80.ungistify_view')
287+
@patch('gist_80.update_gist')
288288
def test_gist_delete_file_command(self, mocked_update_gist, mocked_ungistify_view):
289289
gist_delete_file = gist.GistDeleteFileCommand()
290290
gist_delete_file.run(edit=False)
@@ -294,8 +294,8 @@ def test_gist_delete_file_command(self, mocked_update_gist, mocked_ungistify_vie
294294

295295
sublime.status_message.assert_called_with('Gist file deleted')
296296

297-
@patch('gist.ungistify_view')
298-
@patch('gist.api_request')
297+
@patch('gist_80.ungistify_view')
298+
@patch('gist_80.api_request')
299299
def test_gist_delete_command(self, mocked_api_request, mocked_ungistify_view):
300300
gist_delete = gist.GistDeleteCommand()
301301
gist_delete.run(edit=False)
@@ -305,7 +305,7 @@ def test_gist_delete_command(self, mocked_api_request, mocked_ungistify_view):
305305

306306
sublime.status_message.assert_called_with('Gist deleted')
307307

308-
@patch('gist.update_gist')
308+
@patch('gist_80.update_gist')
309309
def test_gist_listener(self, mocked_update_gist):
310310
gist_listener = gist.GistListener()
311311
gist.plugin_loaded()

test/test_gist.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
from unittest.mock import Mock, patch
55
from urllib.error import HTTPError
66

7-
import gist_helpers
8-
import gist
9-
import gist_request
10-
from exceptions import MissingCredentialsException, SimpleHTTPError
7+
import gist_40_request as gist_request
8+
import gist_60_helpers as gist_helpers
9+
import gist_80 as gist
10+
from gist_20_exceptions import MissingCredentialsException, SimpleHTTPError
1111
from test.stubs import sublime
1212
from test.stubs import github_api
1313

1414

1515
class TestGist(TestCase):
16-
@patch('gist.api_request')
16+
@patch('gist_80.api_request')
1717
def test_create_gist(self, mocked_api_request):
1818
gist.plugin_loaded()
1919
description = 'some description'
@@ -45,7 +45,7 @@ def test_create_gist_fail(self):
4545
gist.create_gist(public, description, failed_files)
4646
sublime.error_message.assert_called_with('Gist: Unable to create a Gist with empty content')
4747

48-
@patch('gist.api_request')
48+
@patch('gist_80.api_request')
4949
def test_update_gist(self, mocked_api_request):
5050
gist_url = 'some gist url'
5151
file_changes = 'some file changes'
@@ -64,10 +64,10 @@ def test_update_gist(self, mocked_api_request):
6464
method=http_method)
6565
sublime.status_message.assert_called_with('Gist updated')
6666

67-
@patch('gist.set_syntax')
68-
@patch('gist.gistify_view')
67+
@patch('gist_80.set_syntax')
68+
@patch('gist_80.gistify_view')
6969
@patch('test.stubs.sublime.Window.new_file')
70-
@patch('gist.api_request')
70+
@patch('gist_80.api_request')
7171
def test_open_gist(self, mocked_api_request, mocked_new_file, mocked_gistify_view, mocked_set_syntax):
7272
gist_url = 'some gist url'
7373
mocked_api_request.return_value = github_api.GIST_WITH_FILE_CONTENT_AND_TYPE
@@ -105,7 +105,7 @@ def test_open_gist(self, mocked_api_request, mocked_new_file, mocked_gistify_vie
105105
github_api.GIST_WITH_FILE_CONTENT_AND_TYPE['files']['some_file1.txt'])
106106

107107
@patch('test.stubs.sublime.Window.active_view')
108-
@patch('gist.api_request')
108+
@patch('gist_80.api_request')
109109
def test_insert_gist(self, mocked_api_request, mocked_active_view):
110110
gist_url = 'some gist url'
111111
mocked_api_request.return_value = github_api.GIST_WITH_FILE_CONTENT_AND_TYPE
@@ -127,7 +127,7 @@ def test_insert_gist(self, mocked_api_request, mocked_active_view):
127127
self.assertEqual(view.settings.return_value.set.call_count, 6)
128128

129129
@patch('test.stubs.sublime.Window.active_view')
130-
@patch('gist.api_request')
130+
@patch('gist_80.api_request')
131131
def test_insert_gist_embed(self, mocked_api_request, mocked_active_view):
132132
gist_url = 'some gist url'
133133
mocked_api_request.return_value = github_api.GIST_WITH_RAW_URL
@@ -144,8 +144,8 @@ def test_insert_gist_embed(self, mocked_api_request, mocked_active_view):
144144
{'characters': '<script src="some another raw url"></script>'})
145145

146146
@patch('test.stubs.sublime.Window.open_file')
147-
@patch('gist.shutil.copy')
148-
@patch('gist.traceback.print_exc')
147+
@patch('gist_80.shutil.copy')
148+
@patch('gist_80.traceback.print_exc')
149149
def test_catch_errors(self, mocked_print_exc, mocked_copy, mocked_open_file):
150150
gist.catch_errors(lambda: exec('raise(Exception())'))()
151151
self.assertEqual(mocked_print_exc.call_count, 1)
@@ -158,7 +158,7 @@ def test_catch_errors(self, mocked_print_exc, mocked_copy, mocked_open_file):
158158
mocked_copy.assert_called_with('Gist/Gist.sublime-settings', 'User/Gist.sublime-settings')
159159
mocked_open_file.assert_called_with('User/Gist.sublime-settings')
160160

161-
@patch('gist_helpers.gist_title')
161+
@patch('gist_60_helpers.gist_title')
162162
def test_gistify_view(self, mocked_gist_title):
163163
mocked_gist_title.return_value = ['some gist title']
164164
view = sublime.View()
@@ -219,7 +219,7 @@ def test_gists_filter(self):
219219
self.assertEqual(gists, [{'files': {'some_test2.sh': {}}, 'description': 'some_prefix:some gist 3 #some_tag'}])
220220
self.assertEqual(gists_names, [['some gist 3']])
221221

222-
@patch('gist.os.name', 'nt')
222+
@patch('gist_80.os.name', 'nt')
223223
def test_set_syntax(self):
224224
view = Mock()
225225

@@ -243,7 +243,7 @@ def test_token_auth_string(self):
243243

244244
self.assertEqual(gist_request.token_auth_string(), 'some token')
245245

246-
@patch('gist_request.urllib')
246+
@patch('gist_40_request.urllib')
247247
def test_api_request(self, mocked_urllib):
248248
url = 'https://url.test'
249249
data = 'some data'

test/test_settings.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from unittest import TestCase
2-
from unittest.mock import Mock, patch
2+
from unittest.mock import patch
33

4-
import gist
5-
import gist_helpers
4+
import gist_60_helpers as gist_helpers
5+
import gist_80 as gist
66
from test.stubs import github_api, sublime
77

88
DEFAULT_GISTS_URL = 'https://api.github.com/gists?per_page=100'
@@ -41,7 +41,7 @@ def test_custom_url_setting(self):
4141
self.assertEqual(gist.settings.get('STARRED_GISTS_URL'), CUSTOM_STARRED_GISTS_URL)
4242
self.assertEqual(gist.settings.get('ORGS_URL'), CUSTOM_ORGS_URL)
4343

44-
@patch('gist.sublime.status_message')
44+
@patch('gist_80.sublime.status_message')
4545
def test_max_gists(self, patched_status_message):
4646
gist.settings.set('max_gists', 101)
4747
gist.set_settings()
@@ -88,8 +88,8 @@ def test_show_authors(self):
8888
result = gist_helpers.gist_title(github_api.GIST_WITH_DESCRIPTION)
8989
self.assertEqual(result, ['some description', 'some_user'])
9090

91-
@patch('gist.GistListCommandBase.get_window')
92-
@patch('gist.api_request')
91+
@patch('gist_80.GistListCommandBase.get_window')
92+
@patch('gist_80.api_request')
9393
def test_use_starred(self, mocked_api_request, mocked_get_window):
9494
gist.plugin_loaded()
9595
mocked_api_request.side_effect = [github_api.GIST_STARRED_LIST, github_api.GIST_LIST]

0 commit comments

Comments
 (0)