Skip to content

Commit cb0d510

Browse files
authored
Merge pull request #458 from ellert/local-ip-deprecated-warn
Only check for RuntimeWarnings in test_local_ip_true_doesnt_trigger_warning
2 parents 804a8f1 + 92ccc65 commit cb0d510

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

ipyparallel/tests/test_client.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -615,26 +615,29 @@ def test_become_dask(self):
615615
def test_warning_on_hostname_match(self):
616616
location = socket.gethostname()
617617
with mock.patch('ipyparallel.client.client.is_local_ip', lambda x: False):
618-
with mock.patch('socket.gethostname', lambda: location[0:-1]), pytest.warns(
619-
RuntimeWarning
620-
): # should trigger warning
621-
c = self.connect_client()
618+
with mock.patch('socket.gethostname', lambda: location[0:-1]):
619+
with pytest.warns(RuntimeWarning): # should trigger warning
620+
c = self.connect_client()
621+
c.close()
622+
with mock.patch('socket.gethostname', lambda: location):
623+
with pytest.warns(None) as record: # should not trigger warning
624+
c = self.connect_client()
625+
# only capture runtime warnings
626+
runtime_warnings = [
627+
w for w in record if isinstance(w.message, RuntimeWarning)
628+
]
629+
assert len(runtime_warnings) == 0, str(
630+
[str(w) for w in runtime_warnings]
631+
)
622632
c.close()
623-
with mock.patch('socket.gethostname', lambda: location), pytest.warns(
624-
None
625-
) as record: # should not trigger warning
633+
634+
def test_local_ip_true_doesnt_trigger_warning(self):
635+
with mock.patch('ipyparallel.client.client.is_local_ip', lambda x: True):
636+
with pytest.warns(None) as record:
626637
c = self.connect_client()
627638
# only capture runtime warnings
628639
runtime_warnings = [
629640
w for w in record if isinstance(w.message, RuntimeWarning)
630641
]
631642
assert len(runtime_warnings) == 0, str([str(w) for w in runtime_warnings])
632643
c.close()
633-
634-
def test_local_ip_true_doesnt_trigger_warning(self):
635-
with mock.patch(
636-
'ipyparallel.client.client.is_local_ip', lambda x: True
637-
), pytest.warns(None) as record:
638-
c = self.connect_client()
639-
assert len(record) == 0, str([str(w) for w in record])
640-
c.close()

0 commit comments

Comments
 (0)