]> git.bitcoin.ninja Git - youtube-dl/commitdiff
the test didn't load our Gzip opener
authorFilippo Valsorda <filippo.valsorda@gmail.com>
Tue, 11 Dec 2012 10:33:15 +0000 (11:33 +0100)
committerFilippo Valsorda <filippo.valsorda@gmail.com>
Tue, 11 Dec 2012 10:33:15 +0000 (11:33 +0100)
this was blocking the Vimeo test

+ some more gentest fixes

.travis.yml
test/gentests.py
youtube_dl/InfoExtractors.py

index 696fa9a0830861037b91ecb4aa4ffb7ea829049c..0c62e4729681c7a7a865bcedad24f8b6b2d76e5a 100644 (file)
@@ -8,4 +8,4 @@ notifications:
 #command to install the setup
 install:
 # command to run tests
-script: nosetests test --nocapture
+script: nosetests test --verbose
index 9352d6d94931812f1cfb79519801d52bd1a5456d..a20b139f5dce282353698aff3d70f996a1fbf5f6 100755 (executable)
@@ -23,13 +23,28 @@ import os
 import json
 import unittest
 import sys
+import socket
 
 # Allow direct execution
 import os
 sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 
-from youtube_dl.FileDownloader import FileDownloader
+import youtube_dl.FileDownloader
 import youtube_dl.InfoExtractors
+from youtube_dl.utils import *
+
+# General configuration (from __init__, not very elegant...)
+jar = compat_cookiejar.CookieJar()
+cookie_processor = compat_urllib_request.HTTPCookieProcessor(jar)
+proxy_handler = compat_urllib_request.ProxyHandler()
+opener = compat_urllib_request.build_opener(proxy_handler, cookie_processor, YoutubeDLHandler())
+compat_urllib_request.install_opener(opener)
+socket.setdefaulttimeout(300) # 5 minutes should be enough (famous last words)
+
+class FileDownloader(youtube_dl.FileDownloader):
+    def __init__(self, *args, **kwargs):
+        youtube_dl.FileDownloader.__init__(self, *args, **kwargs)
+        self.to_stderr = self.to_screen
 
 def _file_md5(fn):
     with open(fn, 'rb') as f:
@@ -76,12 +91,12 @@ def gentests():
     with io.open(TEST_FILE, 'w', encoding='utf-8') as testf:
         testf.write(HEADER)
         spaces = ' ' * 4
-        write = lambda l: testf.write(spaces + l + '\n')
+        write = lambda l: testf.write(spaces + l + u'\n')
 
         for d in defs:
             name = d['name']
             ie = getattr(youtube_dl.InfoExtractors, name + 'IE')
-            testf.write('\n')
+            testf.write(u'\n')
             write('@_skip_unless(youtube_dl.InfoExtractors.' + name + 'IE._WORKING, "IE marked as not _WORKING")')
             if not d['file']:
                 write('@_skip("No output file specified")')
@@ -101,7 +116,7 @@ def gentests():
                 write('    md5_for_file = _file_md5(filename)')
                 write('    self.assertEqual(md5_for_file, ' + repr(d['md5']) + ')')
 
-        testf.write('\n\n')
+        testf.write(u'\n\n')
         write('def tearDown(self):')
         for d in defs:
             if d['file']:
@@ -109,7 +124,7 @@ def gentests():
                 write('        os.remove(' + repr(d['file']) + ')')
             else:
                 write('    # No file specified for ' + d['name'])
-        testf.write('\n')
+        testf.write(u'\n')
         testf.write(FOOTER)
 
 if __name__ == '__main__':
index 49976c25b2d8a5da6867d5dbc3dbaf292fd2a0e1..9cfff153b12fce1c4db4c1420b6f0caab323a8c2 100644 (file)
@@ -1072,8 +1072,8 @@ class VimeoIE(InfoExtractor):
         self.report_extraction(video_id)
 
         # Extract the config JSON
-        config = webpage.split(' = {config:')[1].split(',assets:')[0]
         try:
+            config = webpage.split(' = {config:')[1].split(',assets:')[0]
             config = json.loads(config)
         except:
             self._downloader.trouble(u'ERROR: unable to extract info section')