##// END OF EJS Templates
Add test for IPython.utils.localinterfaces
Thomas Kluyver -
Show More
@@ -0,0 +1,15 b''
1 #-----------------------------------------------------------------------------
2 # Copyright (C) 2013 The IPython Development Team
3 #
4 # Distributed under the terms of the BSD License. The full license is in
5 # the file COPYING, distributed as part of this software.
6 #-----------------------------------------------------------------------------
7
8 from .. import localinterfaces
9
10 def test_load_ips():
11 # Override the machinery that skips it if it was called before
12 localinterfaces._load_ips.called = False
13
14 # Just check this doesn't error
15 localinterfaces._load_ips(suppress_exceptions=False) No newline at end of file
@@ -42,10 +42,10 b" LOCALHOST = ''"
42 42 def _only_once(f):
43 43 """decorator to only run a function once"""
44 44 f.called = False
45 def wrapped():
45 def wrapped(**kwargs):
46 46 if f.called:
47 47 return
48 ret = f()
48 ret = f(**kwargs)
49 49 f.called = True
50 50 return ret
51 51 return wrapped
@@ -203,7 +203,7 b' def _load_ips_dumb():'
203 203 PUBLIC_IPS[:] = []
204 204
205 205 @_only_once
206 def _load_ips():
206 def _load_ips(suppress_exceptions=True):
207 207 """load the IPs that point to this machine
208 208
209 209 This function will only ever be called once.
@@ -241,6 +241,8 b' def _load_ips():'
241 241
242 242 return _load_ips_gethostbyname()
243 243 except Exception as e:
244 if not suppress_exceptions:
245 raise
244 246 # unexpected error shouldn't crash, load dumb default values instead.
245 247 warn("Unexpected error discovering local network interfaces: %s" % e)
246 248 _load_ips_dumb()
General Comments 0
You need to be logged in to leave comments. Login now