-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathtest_cd_alias.sh
More file actions
executable file
·52 lines (44 loc) · 1.03 KB
/
test_cd_alias.sh
File metadata and controls
executable file
·52 lines (44 loc) · 1.03 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
# -*- mode: shell-script -*-
test_dir=$(cd $(dirname $0) && pwd)
source "$test_dir/setup.sh"
oneTimeSetUp() {
rm -rf "$WORKON_HOME"
mkdir -p "$WORKON_HOME"
load_wrappers
unset VIRTUAL_ENV
mkvirtualenv cd-test >/dev/null 2>&1
deactivate
}
oneTimeTearDown() {
rm -rf "$WORKON_HOME"
}
setUp () {
echo
workon cd-test
}
tearDown () {
deactivate >/dev/null 2>&1
}
test_cd() {
alias cd='fail "Should not be using override cd function"'
start_dir="$(pwd)"
virtualenvwrapper_cd "$VIRTUAL_ENV"
assertSame "$VIRTUAL_ENV" "$(pwd)"
virtualenvwrapper_cd "$start_dir"
unalias cd
}
# Define hook function to make cd break
chpwd () {
return 1
}
# Run a test that uses cd to ensure the hook is not called
test_cd_zsh_chpwd_not_called () {
if [ -n "$ZSH_VERSION" ]; then
start_dir="$(pwd)"
virtualenvwrapper_cd "$VIRTUAL_ENV"
assertSame "$VIRTUAL_ENV" "$(pwd)"
virtualenvwrapper_cd "$start_dir"
fi
unset -f chpwd >/dev/null 2>&1
}
. "$test_dir/shunit2"