Skip to content

Commit fee2805

Browse files
committed
Dynamically allocate port numbers so that test don't conflict with
eachother.
1 parent 14e8025 commit fee2805

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

tests/mock_server.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
1+
import random
22
from threading import Thread
33
import urllib2
44

55
from wsgiref.simple_server import make_server
66

7+
import RTC
8+
79
class MockServer(Thread):
810
"""
911
Simple mock server which might be useful so don't have to depend
@@ -17,9 +19,12 @@ def handle(self, app):
1719
"""
1820
Most common testing case for handling a single request.
1921
"""
22+
MockServer.port += random.randint(100, 1000)
23+
RTC.RTC_Client.base_url = 'http://%s:%s/' % (MockServer.host, MockServer.port)
2024
s = MockServer()
2125
s.__create(app)
2226
s.start()
27+
2328

2429
def __init__(self):
2530
Thread.__init__(self)

tests/test_videos.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ def bill_app(env, resp): # should be helper function
6969
return [html]
7070

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

0 commit comments

Comments
 (0)