From c541603af123b81937edb163870aa18f960fd3cf Mon Sep 17 00:00:00 2001 From: Bryan Deeney Date: Tue, 15 Apr 2014 09:29:52 -0400 Subject: Test expected warning from wait_for_occupied_port() --- cherrypy/test/test_states.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cherrypy/test/test_states.py b/cherrypy/test/test_states.py index 63635e52..d62f0085 100644 --- a/cherrypy/test/test_states.py +++ b/cherrypy/test/test_states.py @@ -1,13 +1,14 @@ -from cherrypy._cpcompat import BadStatusLine, ntob import os +import signal +import socket import sys import time -import signal import unittest -import socket +import warnings import cherrypy import cherrypy.process.servers +from cherrypy._cpcompat import BadStatusLine, ntob from cherrypy.test import helper engine = cherrypy.engine @@ -477,7 +478,13 @@ class WaitTests(unittest.TestCase): def do_waiting(): # Wait on the free port that's unbound - servers.wait_for_occupied_port('0.0.0.0', free_port) + with warnings.catch_warnings(record=True) as w: + servers.wait_for_occupied_port('0.0.0.0', free_port) + self.assertEqual(len(w), 1) + self.assertIsInstance(w[0], warnings.WarningMessage) + self.assertIn('Unable to verify that the server is bound on ', + str(w[0])) + # The wait should still raise an IO error if INADDR_ANY was # not supplied. self.assertRaises(IOError, servers.wait_for_occupied_port, -- cgit v1.2.1