Skip to content

Commit

Permalink
Dynamically allocate port numbers so that test don't conflict with
Browse files Browse the repository at this point in the history
eachother.
  • Loading branch information
lateefj committed Sep 27, 2011
1 parent 14e8025 commit fee2805
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 6 additions & 1 deletion tests/mock_server.py
@@ -1,9 +1,11 @@

import random
from threading import Thread
import urllib2

from wsgiref.simple_server import make_server

import RTC

class MockServer(Thread):
"""
Simple mock server which might be useful so don't have to depend
Expand All @@ -17,9 +19,12 @@ def handle(self, app):
"""
Most common testing case for handling a single request.
"""
MockServer.port += random.randint(100, 1000)
RTC.RTC_Client.base_url = 'http://%s:%s/' % (MockServer.host, MockServer.port)
s = MockServer()
s.__create(app)
s.start()


def __init__(self):
Thread.__init__(self)
Expand Down
1 change: 0 additions & 1 deletion tests/test_videos.py
Expand Up @@ -69,7 +69,6 @@ def bill_app(env, resp): # should be helper function
return [html]

MockServer.handle(bill_app)
RTC.RTC_Client.base_url = 'http://%s:%s/' % (MockServer.host, MockServer.port)
videos = RTC.HouseVideos.get_by_bill(bill_id)
assert len(videos) != 0, 'We expect at least one video to be returned'
for v in videos:
Expand Down

0 comments on commit fee2805

Please sign in to comment.