Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 95950b3

Browse files
committed
Allow user_setup to be called multiple times.
1 parent 364aeb8 commit 95950b3

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

IPython/iplib.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,11 @@ def wait():
11251125
print >> Term.cout
11261126
print '*'*70
11271127

1128+
# Install mode should be re-entrant: if the install dir already exists,
1129+
# bail out cleanly
1130+
if mode == 'install' and os.path.isdir(ipythondir):
1131+
return
1132+
11281133
cwd = os.getcwd() # remember where we started
11291134
glb = glob.glob
11301135
print '*'*70

IPython/tests/test_iplib.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,25 @@
33

44
import nose.tools as nt
55

6+
# Useful global ipapi object and main IPython one
7+
ip = _ip
8+
IP = ip.IP
9+
610

711
def test_reset():
812
"""reset must clear most namespaces."""
9-
ip = _ip.IP
10-
ip.reset() # first, it should run without error
13+
IP.reset() # first, it should run without error
1114
# Then, check that most namespaces end up empty
12-
for ns in ip.ns_refs_table:
13-
if ns is ip.user_ns:
15+
for ns in IP.ns_refs_table:
16+
if ns is IP.user_ns:
1417
# The user namespace is reset with some data, so we can't check for
1518
# it being empty
1619
continue
1720
nt.assert_equals(len(ns),0)
21+
22+
23+
def test_user_setup():
24+
"""make sure that user_setup can be run re-entrantly in 'install' mode.
25+
"""
26+
# This should basically run without errors or output.
27+
IP.user_setup(ip.options.ipythondir,'','install')

0 commit comments

Comments
 (0)