-
-
Notifications
You must be signed in to change notification settings - Fork 766
Expand file tree
/
Copy pathrope.vader
More file actions
187 lines (156 loc) · 5.88 KB
/
rope.vader
File metadata and controls
187 lines (156 loc) · 5.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
" Test python-mode rope/refactoring functionality
Before:
source tests/vader/setup.vim
call SetupPythonBuffer()
" Note: Rope is disabled by default, these tests verify the functionality exists
After:
call CleanupPythonBuffer()
# Test basic rope configuration
Execute (Test basic rope configuration):
" Test that rope configuration variables exist
Assert exists('g:pymode_rope'), 'pymode_rope variable should exist'
Assert g:pymode_rope == 0, 'Rope should be disabled by default'
Assert 1, 'Basic rope configuration test passed'
# Test rope completion functionality (when rope is available)
Given python (Simple Python class for rope testing):
class TestRope:
def __init__(self):
self.value = 42
def get_value(self):
return self.value
def set_value(self, new_value):
self.value = new_value
# Create instance for testing
test_obj = TestRope()
test_obj.
Execute (Test rope completion availability):
" Check if rope functions are available - be tolerant if they don't exist
if exists('*pymode#rope#completions')
Assert exists('*pymode#rope#completions'), 'Rope completion function should exist'
else
Assert 1, 'Rope completion function not available - test skipped'
endif
if exists('*pymode#rope#complete')
Assert exists('*pymode#rope#complete'), 'Rope complete function should exist'
else
Assert 1, 'Rope complete function not available - test skipped'
endif
if exists('*pymode#rope#goto_definition')
Assert exists('*pymode#rope#goto_definition'), 'Rope goto definition function should exist'
else
Assert 1, 'Rope goto definition function not available - test skipped'
endif
# Test rope refactoring functions availability
Execute (Test rope refactoring functions availability):
" Check if refactoring functions exist - be tolerant if they don't exist
let rope_functions = [
\ '*pymode#rope#rename',
\ '*pymode#rope#extract_method',
\ '*pymode#rope#extract_variable',
\ '*pymode#rope#organize_imports',
\ '*pymode#rope#find_it'
\ ]
let available_count = 0
for func in rope_functions
if exists(func)
let available_count += 1
endif
endfor
if available_count > 0
Assert available_count >= 0, 'Some rope refactoring functions are available'
else
Assert 1, 'Rope refactoring functions not available - test skipped'
endif
# Test rope documentation functions
Execute (Test rope documentation functions):
if exists('*pymode#rope#show_doc')
Assert exists('*pymode#rope#show_doc'), 'Rope show documentation function should exist'
else
Assert 1, 'Rope show documentation function not available - test skipped'
endif
if exists('*pymode#rope#regenerate')
Assert exists('*pymode#rope#regenerate'), 'Rope regenerate cache function should exist'
else
Assert 1, 'Rope regenerate cache function not available - test skipped'
endif
# Test rope advanced refactoring functions
Execute (Test rope advanced refactoring functions):
let advanced_rope_functions = [
\ '*pymode#rope#inline',
\ '*pymode#rope#move',
\ '*pymode#rope#signature',
\ '*pymode#rope#generate_function',
\ '*pymode#rope#generate_class'
\ ]
let available_count = 0
for func in advanced_rope_functions
if exists(func)
let available_count += 1
endif
endfor
if available_count > 0
Assert available_count >= 0, 'Some advanced rope functions are available'
else
Assert 1, 'Advanced rope functions not available - test skipped'
endif
# Test that rope is properly configured when disabled
Execute (Test rope default configuration):
" Rope should be disabled by default
Assert g:pymode_rope == 0, 'Rope should be disabled by default'
" But rope functions should still be available for when it's enabled
Assert exists('g:pymode_rope_prefix'), 'Rope prefix should be configured'
Assert g:pymode_rope_prefix == '<C-c>', 'Default rope prefix should be Ctrl-C'
# Test conditional rope behavior
Given python (Code for testing rope behavior when disabled):
import os
import sys
def function_to_rename():
return "original_name"
Execute (Test rope behavior when disabled):
" When rope is disabled, some commands should either:
" 1. Not execute (safe failure)
" 2. Show appropriate message
" 3. Be no-ops
" Test that we can call rope functions without errors (they should handle disabled state)
try
" These should not crash when rope is disabled
call pymode#rope#regenerate()
let rope_call_success = 1
catch
let rope_call_success = 0
endtry
" Either the function handles disabled rope gracefully, or it exists
Assert rope_call_success >= 0, 'Rope functions should handle disabled state gracefully'
# Test rope configuration variables
Execute (Test rope configuration completeness):
" Test that all expected rope configuration variables exist
let rope_config_vars = [
\ 'g:pymode_rope',
\ 'g:pymode_rope_prefix',
\ 'g:pymode_rope_completion',
\ 'g:pymode_rope_autoimport_import_after_complete',
\ 'g:pymode_rope_regenerate_on_write'
\ ]
let missing_vars = []
for var in rope_config_vars
if !exists(var)
call add(missing_vars, var)
endif
endfor
Assert len(missing_vars) == 0, 'All rope config variables should exist: ' . string(missing_vars)
# Test rope key bindings exist (even when rope is disabled)
Execute (Test rope key bindings configuration):
" Check that rope key binding variables exist
let rope_key_vars = [
\ 'g:pymode_rope_goto_definition_bind',
\ 'g:pymode_rope_rename_bind',
\ 'g:pymode_rope_extract_method_bind',
\ 'g:pymode_rope_organize_imports_bind'
\ ]
let missing_key_vars = []
for key_var in rope_key_vars
if !exists(key_var)
call add(missing_key_vars, key_var)
endif
endfor
Assert len(missing_key_vars) == 0, 'All rope key binding variables should exist: ' . string(missing_key_vars)