Commit 2261d4c4 by Ned Batchelder

Merge pull request #1521 from edx/ned/quiet-mock-youtube-test-server

Mock servers shouldn't pollute test output.
parents 336d648e c8e0fb25
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
import urlparse import json
import mock import mock
import sys
import threading import threading
import json import time
import urlparse
from logging import getLogger from logging import getLogger
logger = getLogger(__name__) logger = getLogger(__name__)
import time
class MockYoutubeRequestHandler(BaseHTTPRequestHandler): class MockYoutubeRequestHandler(BaseHTTPRequestHandler):
''' '''
...@@ -14,6 +17,15 @@ class MockYoutubeRequestHandler(BaseHTTPRequestHandler): ...@@ -14,6 +17,15 @@ class MockYoutubeRequestHandler(BaseHTTPRequestHandler):
protocol = "HTTP/1.0" protocol = "HTTP/1.0"
def log_message(self, format, *args):
"""Log an arbitrary message."""
# Code copied from BaseHTTPServer.py. Changed to write to sys.stdout
# so that messages won't pollute test output.
sys.stdout.write("%s - - [%s] %s\n" %
(self.client_address[0],
self.log_date_time_string(),
format % args))
def do_HEAD(self): def do_HEAD(self):
code = 200 code = 200
if 'test_transcripts_youtube' in self.path: if 'test_transcripts_youtube' in self.path:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment