Exemplo n.º 1
0
    def test_getUnusedPort_pickRange(self):
        # Initialize the testConfig with our test data.
        util._test_config = util._GetSharedTestConfig()
        # Note that the could failed if these port are already in use...
        START_PORT = 12345
        util._test_config.min_port = START_PORT
        util._test_config.max_port = START_PORT + 5

        self.assertEqual(util.getUnusedPort(), START_PORT)
        self.assertEqual(util.getUnusedPort(), START_PORT + 1)
        self.assertEqual(util.getUnusedPort(), START_PORT + 2)
        self.assertEqual(util.getUnusedPort(), START_PORT + 3)
        self.assertEqual(util.getUnusedPort(), START_PORT + 4)
        with self.assertRaises(AssertionError):
            util.getUnusedPort()

        util.releasePort(START_PORT + 2)
        self.assertEqual(util.getUnusedPort(), START_PORT + 2)
        with self.assertRaises(AssertionError):
            util.getUnusedPort()
 def __del__(self):
   self.cleanDumpFiles()
   releasePort(self.port)
Exemplo n.º 3
0
 def __del__(self):
     releasePort(self.port)