Show More
@@ -996,7 +996,7 b' def get_ipython_dir():' | |||||
996 | home_dir = get_home_dir() |
|
996 | home_dir = get_home_dir() | |
997 | ipdir = os.path.abspath(os.environ.get('IPYTHONDIR', |
|
997 | ipdir = os.path.abspath(os.environ.get('IPYTHONDIR', | |
998 | os.path.join(home_dir,ipdir_def))) |
|
998 | os.path.join(home_dir, ipdir_def))) | |
999 | return ipdir |
|
999 | return ipdir.decode(sys.getfilesystemencoding()) | |
1000 |
|
1000 | |||
1001 | def get_security_dir(): |
|
1001 | def get_security_dir(): | |
1002 | """Get the IPython security directory. |
|
1002 | """Get the IPython security directory. |
@@ -131,19 +131,14 b" object? -> Details about 'object'. ?object also works, ?? prints more." | |||||
131 |
|
131 | |||
132 | IP.usage = interactive_usage |
|
132 | IP.usage = interactive_usage | |
133 |
|
133 | |||
134 | # Platform-dependent suffix and directory names. We use _ipython instead |
|
134 | # Platform-dependent suffix. | |
135 | # of .ipython under win32 b/c there's software that breaks with .named |
|
|||
136 | # directories on that platform. |
|
|||
137 | if os.name == 'posix': |
|
135 | if os.name == 'posix': | |
138 | rc_suffix = '' |
|
136 | rc_suffix = '' | |
139 | ipdir_def = '.ipython' |
|
|||
140 | else: |
|
137 | else: | |
141 | rc_suffix = '.ini' |
|
138 | rc_suffix = '.ini' | |
142 | ipdir_def = '_ipython' |
|
|||
143 |
|
139 | |||
144 | # default directory for configuration |
|
140 | # default directory for configuration | |
145 | ipythondir_def = os.path.abspath(os.environ.get('IPYTHONDIR', |
|
141 | ipythondir_def = get_ipython_dir() | |
146 | os.path.join(IP.home_dir,ipdir_def))) |
|
|||
147 |
|
142 | |||
148 | sys.path.insert(0, '') # add . to sys.path. Fix from Prabhu Ramachandran |
|
143 | sys.path.insert(0, '') # add . to sys.path. Fix from Prabhu Ramachandran | |
149 |
|
144 |
@@ -147,10 +147,57 b' def test_get_home_dir_9():' | |||||
147 | wreg.OpenKey, wreg.QueryValueEx,) = oldstuff |
|
147 | wreg.OpenKey, wreg.QueryValueEx,) = oldstuff | |
148 |
|
148 | |||
149 |
|
149 | |||
150 | def test_get_ipython_dir(): |
|
150 | def test_get_ipython_dir_1(): | |
151 | """Testcase to see if we can call get_ipython_dir without Exceptions.""" |
|
151 | """Testcase to see if we can call get_ipython_dir without Exceptions.""" | |
152 | ipdir = genutils.get_ipython_dir() |
|
152 | ipdir = genutils.get_ipython_dir() | |
153 |
|
153 | |||
|
154 | def test_get_ipython_dir_2(): | |||
|
155 | """Testcase to see if we can call get_ipython_dir without Exceptions.""" | |||
|
156 | oldstuff = (env['IPYTHONDIR'],) | |||
|
157 | ||||
|
158 | env['IPYTHONDIR']="someplace/.ipython" | |||
|
159 | ipdir = genutils.get_ipython_dir() | |||
|
160 | assert ipdir == os.path.abspath("someplace/.ipython") | |||
|
161 | ||||
|
162 | (env['IPYTHONDIR'],)=oldstuff | |||
|
163 | ||||
|
164 | class test_get_ipython_dir_3: | |||
|
165 | @classmethod | |||
|
166 | def setup_class(cls): | |||
|
167 | cls.oldstuff = (env['IPYTHONDIR'], os.name, genutils.get_home_dir) | |||
|
168 | del env['IPYTHONDIR'] | |||
|
169 | genutils.get_home_dir=lambda : "someplace" | |||
|
170 | ||||
|
171 | @classmethod | |||
|
172 | def teardown_class(cls): | |||
|
173 | (env['IPYTHONDIR'], os.name, genutils.get_home_dir)=cls.oldstuff | |||
|
174 | ||||
|
175 | def test_get_ipython_dir_a(self): | |||
|
176 | """Testcase to see if we can call get_ipython_dir without Exceptions.""" | |||
|
177 | ||||
|
178 | os.name="posix" | |||
|
179 | ipdir = genutils.get_ipython_dir() | |||
|
180 | assert ipdir == os.path.abspath(os.path.join("someplace", ".ipython")) | |||
|
181 | ||||
|
182 | def test_get_ipython_dir_b(self): | |||
|
183 | """Testcase to see if we can call get_ipython_dir without Exceptions.""" | |||
|
184 | ||||
|
185 | os.name="nt" | |||
|
186 | ipdir = genutils.get_ipython_dir() | |||
|
187 | assert ipdir == os.path.abspath(os.path.join("someplace", "_ipython")) | |||
|
188 | ||||
|
189 | class test_get_security_dir: | |||
|
190 | @classmethod | |||
|
191 | def setup_class(cls): | |||
|
192 | cls.oldstuff = (env['IPYTHONDIR'], os.name, genutils.get_home_dir) | |||
|
193 | del env['IPYTHONDIR'] | |||
|
194 | genutils.get_home_dir=lambda : "someplace" | |||
|
195 | ||||
|
196 | @classmethod | |||
|
197 | def teardown_class(cls): | |||
|
198 | (env['IPYTHONDIR'], os.name, genutils.get_home_dir)=cls.oldstuff | |||
|
199 | ||||
|
200 | ||||
154 | def test_get_security_dir(): |
|
201 | def test_get_security_dir(): | |
155 | """Testcase to see if we can call get_security_dir without Exceptions.""" |
|
202 | """Testcase to see if we can call get_security_dir without Exceptions.""" | |
156 | sdir = genutils.get_security_dir() |
|
203 | sdir = genutils.get_security_dir() |
General Comments 0
You need to be logged in to leave comments.
Login now