File tree Expand file tree Collapse file tree 4 files changed +37
-4
lines changed Expand file tree Collapse file tree 4 files changed +37
-4
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ fun! pymode#virtualenv#init() "{{{
11
11
12
12
endfunction " }}}
13
13
14
- fun ! pymode#virtualenv#activate (relpath ) " {{{
15
- let g: pymode_virtualenv_path = getcwd () . ' / ' . a: relpath
14
+ fun ! pymode#virtualenv#activate (path ) " {{{
15
+ let g: pymode_virtualenv_path = a: path
16
16
call pymode#virtualenv#init ()
17
17
endfunction " }}}
Original file line number Diff line number Diff line change @@ -212,8 +212,8 @@ Bind keys to show documentation for current word (selection)
212
212
*pymode-virtualenv*
213
213
214
214
Commands:
215
- *:PymodeVirtualenv* <path> -- Activate virtualenv (path is related to
216
- current working directory)
215
+ *:PymodeVirtualenv* <path> -- Activate virtualenv (path can be absolute or
216
+ relative to current working directory)
217
217
218
218
Enable automatic virtualenv detection *'g:pymode_virtualenv'*
219
219
>
Original file line number Diff line number Diff line change @@ -15,6 +15,11 @@ def enable_virtualenv():
15
15
16
16
"""
17
17
path = env .var ('g:pymode_virtualenv_path' )
18
+ # Normalize path to be an absolute path
19
+ # If an absolute path is provided, that path will be returned, otherwise
20
+ # the returned path will be an absolute path but computed relative
21
+ # to the current working directory
22
+ path = os .path .abspath (path )
18
23
enabled = env .var ('g:pymode_virtualenv_enabled' )
19
24
if path == enabled :
20
25
env .message ('Virtualenv %s already enabled.' % path )
Original file line number Diff line number Diff line change
1
+ describe ' pymode-virtualenv'
2
+
3
+ before
4
+ source plugin /pymode.vim
5
+ set filetype = python
6
+ end
7
+
8
+ after
9
+ bd !
10
+ end
11
+
12
+ " TODO: How can we mock the virtualenv activation to check that the
13
+ " proper path is set to pymode_virtualenv_enabled? Right now, the
14
+ " python function enable_virtualenv gets called but fails when trying
15
+ " to actually activate so the env.let never gets called
16
+
17
+ it ' accepts relative paths'
18
+ call pymode#virtualenv#activate (" sample/relative/path" )
19
+ " Our path variable is the path argument
20
+ Expect g: pymode_virtualenv_path == " sample/relative/path"
21
+ end
22
+
23
+ it ' accepts absolute paths'
24
+ call pymode#virtualenv#activate (" /sample/absolute/path" )
25
+ " Our path variable is the path argument
26
+ Expect g: pymode_virtualenv_path == " /sample/absolute/path"
27
+ end
28
+ end
You can’t perform that action at this time.
0 commit comments