# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1372855930 -7200
# Node ID eef0388e8feac2ff9f5c58b0f71771f9a420bd26
# Parent  d42540bacff49324b5ff6b2bca60e39c9e3f963e
[devtool] randomise available ports search in http test

This lowers the chance of parallel tests to race for the same port.

diff -r d42540bacff4 -r eef0388e8fea devtools/httptest.py
--- a/devtools/httptest.py	Wed Jul 03 14:48:34 2013 +0200
+++ b/devtools/httptest.py	Wed Jul 03 14:52:10 2013 +0200
@@ -20,6 +20,7 @@
 """
 __docformat__ = "restructuredtext en"
 
+import random
 import threading
 import socket
 import httplib
@@ -46,6 +47,8 @@
 
     .. see:: :func:`test.test_support.bind_port`
     """
+    ports_scan = list(ports_scan)
+    random.shuffle(ports_scan)  # lower the chance of race condition
     for port in ports_scan:
         try:
             s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)