Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
use random ports for api and callback services
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-burnett committed Mar 28, 2014
1 parent 81c02fb commit fff47a6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tests/api/v1/generator/func.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .base_case import TestCaseMixin
import os
import socket
import unittest


Expand All @@ -24,8 +25,8 @@ def _create_and_attach_test_case(target_module, test_case_directory,

def _create_test_case(test_case_directory, test_case_name):
class_dict = {
'api_port': 8822,
'callback_port': 2288,
'api_port': _get_available_port(),
'callback_port': _get_available_port(),
'directory': os.path.join(test_case_directory, test_case_name),
'test_name': test_case_name,
}
Expand All @@ -35,3 +36,12 @@ def _create_test_case(test_case_directory, test_case_name):

def _attach_test_case(target_module, test_case):
setattr(target_module, test_case.__name__, test_case)


def _get_available_port():
s = socket.socket()
s.bind(('127.0.0.1', 0))
port = s.getsockname()[1]
s.close()

return port

0 comments on commit fff47a6

Please sign in to comment.