Переглянути джерело

Get rid of unused imports.

79-col-ify.

Fix _make_http_servers fixture ('socketfile' didn't exist).
Chris McDonough 17 роки тому
батько
коміт
d431228e8d

+ 1 - 3
src/supervisor/tests/test_datatypes.py

@@ -6,8 +6,6 @@ import unittest
 import socket
 import tempfile
 
-from supervisor.tests.base import DummySocket
-from supervisor.tests.base import DummySocketConfig
 from supervisor.datatypes import UnixStreamSocketConfig
 from supervisor.datatypes import InetStreamSocketConfig
 
@@ -81,4 +79,4 @@ def test_suite():
     return unittest.findTestCases(sys.modules[__name__])
 
 if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')
+    unittest.main(defaultTest='test_suite')

+ 7 - 11
src/supervisor/tests/test_http.py

@@ -304,21 +304,17 @@ class TopLevelFunctionTests(unittest.TestCase):
         options.rpcinterface_factories = [('dummy',DummyRPCInterfaceFactory,{})]
         supervisord = DummySupervisor()
         from supervisor.http import make_http_servers
+        servers = make_http_servers(options, supervisord)
         try:
-            servers = make_http_servers(options, supervisord)
-            for s in servers:
-                try:
-                    s.close()
-                except:
-                    pass
-            return servers
+            for config, s in servers:
+                s.close()
+                socketfile = config.get('file')
+                if socketfile is not None:
+                    os.unlink(socketfile)
         finally:
             from asyncore import socket_map
             socket_map.clear()
-            try:
-                os.unlink(socketfile)
-            except:
-                pass
+        return servers
         
     def test_make_http_servers_noauth(self):
         socketfile = tempfile.mktemp()

+ 8 - 6
src/supervisor/tests/test_options.py

@@ -427,7 +427,6 @@ class ServerOptionsTests(unittest.TestCase):
         pconfigs = instance.processes_from_section(config, 'program:foo', 'bar')
         self.assertEqual(len(pconfigs), 2)
         pconfig = pconfigs[0]
-        from supervisor import datatypes
         self.assertEqual(pconfig.name, 'bar_foo_00')
         self.assertEqual(pconfig.command, '/bin/cat')
         self.assertEqual(pconfig.autostart, False)
@@ -639,7 +638,6 @@ class ServerOptionsTests(unittest.TestCase):
         numprocs = 3
         """)
         from supervisor.options import UnhosedConfigParser
-        from supervisor.dispatchers import default_handler
         config = UnhosedConfigParser()
         config.read_string(text)
         instance = self._makeOne()
@@ -650,15 +648,19 @@ class ServerOptionsTests(unittest.TestCase):
         self.assertEqual(gconfig0.__class__, FastCGIGroupConfig)
         self.assertEqual(gconfig0.name, 'foo')
         self.assertEqual(gconfig0.priority, 1)
-        self.assertEqual(gconfig0.socket_manager.config().url, 'unix:///tmp/foo.sock')
+        self.assertEqual(gconfig0.socket_manager.config().url,
+                         'unix:///tmp/foo.sock')
         self.assertEqual(len(gconfig0.process_configs), 2)
-        self.assertEqual(gconfig0.process_configs[0].__class__, FastCGIProcessConfig)
-        self.assertEqual(gconfig0.process_configs[1].__class__, FastCGIProcessConfig)
+        self.assertEqual(gconfig0.process_configs[0].__class__,
+                         FastCGIProcessConfig)
+        self.assertEqual(gconfig0.process_configs[1].__class__,
+                         FastCGIProcessConfig)
         
         gconfig1 = gconfigs[1]
         self.assertEqual(gconfig1.name, 'bar')
         self.assertEqual(gconfig1.priority, 999)
-        self.assertEqual(gconfig1.socket_manager.config().url, 'tcp://localhost:6000')
+        self.assertEqual(gconfig1.socket_manager.config().url,
+                         'tcp://localhost:6000')
         self.assertEqual(len(gconfig1.process_configs), 3)
 
     def test_fcgi_program_no_socket(self):

+ 0 - 4
src/supervisor/tests/test_rpcinterfaces.py

@@ -376,7 +376,6 @@ class SupervisorNamespaceXMLRPCInterfaceTests(TestBase):
         self._assertRPCError(xmlrpc.Faults.ABNORMAL_TERMINATION, callback)
 
     def test_startProcess_splat_calls_startProcessGroup(self):
-        from supervisor import http
         options = DummyOptions()
         pconfig1 = DummyPConfig(options, 'process1', __file__, autostart=False,
                                startsecs=.01)
@@ -681,7 +680,6 @@ class SupervisorNamespaceXMLRPCInterfaceTests(TestBase):
                              interface.stopProcessGroup, 'foo')
 
     def test_stopProcess_splat_calls_stopProcessGroup(self):
-        from supervisor import http
         options = DummyOptions()
         pconfig1 = DummyPConfig(options, 'process1', __file__, autostart=False,
                                startsecs=.01)
@@ -850,8 +848,6 @@ class SupervisorNamespaceXMLRPCInterfaceTests(TestBase):
         self.failUnless(data['description'].startswith('pid 111'))
 
     def test_getProcessInfo_logfile_NONE(self):
-        from supervisor.process import ProcessStates
-
         options = DummyOptions()
         config = DummyPConfig(options, 'foo', '/bin/foo',
                               stdout_logfile=None)

+ 1 - 2
src/supervisor/tests/test_socket_manager.py

@@ -6,7 +6,6 @@ import unittest
 import socket
 import tempfile
 
-from supervisor.tests.base import DummySocket
 from supervisor.tests.base import DummySocketConfig
 from supervisor.datatypes import UnixStreamSocketConfig
 from supervisor.datatypes import InetStreamSocketConfig
@@ -99,4 +98,4 @@ def test_suite():
     return unittest.findTestCases(sys.modules[__name__])
 
 if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')
+    unittest.main(defaultTest='test_suite')

+ 0 - 4
src/supervisor/tests/test_xmlrpc.py

@@ -4,7 +4,6 @@ import unittest
 from supervisor.tests.base import DummySupervisor
 from supervisor.tests.base import DummyRequest
 from supervisor.tests.base import DummySupervisorRPCNamespace
-from supervisor.tests.base import _NOW
 
 class XMLRPCMarshallingTests(unittest.TestCase):
     def test_xmlrpc_marshal(self):
@@ -156,7 +155,6 @@ class TesstSupervisorTransport(unittest.TestCase):
         self.assertEqual(conn.socketfile, '/foo/bar')
 
     def test__get_connection_http_9001(self):
-        from supervisor import xmlrpc
         import httplib
         transport = self._makeOne('user', 'pass', 'http://127.0.0.1:9001/')
         conn = transport._get_connection()
@@ -165,7 +163,6 @@ class TesstSupervisorTransport(unittest.TestCase):
         self.assertEqual(conn.port, 9001)
 
     def test__get_connection_http_80(self):
-        from supervisor import xmlrpc
         import httplib
         transport = self._makeOne('user', 'pass', 'http://127.0.0.1/')
         conn = transport._get_connection()
@@ -206,7 +203,6 @@ class TesstSupervisorTransport(unittest.TestCase):
         self.assertEqual(dummy_conn.requestargs[3]['Accept'], 'text/xml')
 
     def test_request_200_response(self):
-        import xmlrpclib
         transport = self._makeOne('user', 'pass', 'http://127.0.0.1/')
         response = """<?xml version="1.0"?>
         <methodResponse>