File tree 1 file changed +6
-9
lines changed
1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change 1
1
import socket
2
- from unittest import mock
3
2
3
+ import pytest
4
4
from jupyter_client .localinterfaces import localhost , public_ips
5
5
6
6
from ipyparallel import util
7
7
8
8
9
- @mock .patch ('warnings.warn' )
10
- def test_disambiguate_ip (warn_mock ):
9
+ def test_disambiguate_ip ():
11
10
# garbage in, garbage out
12
11
public_ip = public_ips ()[0 ]
13
12
assert util .disambiguate_ip_address ('garbage' ) == 'garbage'
14
13
assert util .disambiguate_ip_address ('0.0.0.0' , socket .gethostname ()) == localhost ()
15
14
wontresolve = 'this.wontresolve.dns'
16
- assert util .disambiguate_ip_address ('0.0.0.0' , wontresolve ) == wontresolve
17
- assert warn_mock .called_once_with (
18
- 'IPython could not determine IPs for {}: '
19
- '[Errno -2] Name or service not known' .format (wontresolve ),
20
- RuntimeWarning ,
21
- )
15
+ with pytest .warns (
16
+ RuntimeWarning , match = f"IPython could not determine IPs for { wontresolve } "
17
+ ):
18
+ assert util .disambiguate_ip_address ('0.0.0.0' , wontresolve ) == wontresolve
22
19
assert util .disambiguate_ip_address ('0.0.0.0' , public_ip ) == localhost ()
You can’t perform that action at this time.
0 commit comments