Skip to content

Commit f5f6f4a

Browse files
authored
Merge pull request #818 from hroncok/patch-1
Fix unittest.mock usage on Python 3.12
2 parents 4a0b3be + 87d0d93 commit f5f6f4a

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

ipyparallel/tests/test_util.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
import socket
2-
from unittest import mock
32

3+
import pytest
44
from jupyter_client.localinterfaces import localhost, public_ips
55

66
from ipyparallel import util
77

88

9-
@mock.patch('warnings.warn')
10-
def test_disambiguate_ip(warn_mock):
9+
def test_disambiguate_ip():
1110
# garbage in, garbage out
1211
public_ip = public_ips()[0]
1312
assert util.disambiguate_ip_address('garbage') == 'garbage'
1413
assert util.disambiguate_ip_address('0.0.0.0', socket.gethostname()) == localhost()
1514
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
2219
assert util.disambiguate_ip_address('0.0.0.0', public_ip) == localhost()

0 commit comments

Comments
 (0)