[generic] Add a test case for direct links with broken HEAD (#4032)
authorPhilipp Hagemeister <phihag@phihag.de>
Sun, 26 Oct 2014 19:49:51 +0000 (20:49 +0100)
committerPhilipp Hagemeister <phihag@phihag.de>
Sun, 26 Oct 2014 19:49:51 +0000 (20:49 +0100)
test/helper.py
test/test_download.py
youtube_dl/extractor/generic.py

index 2fa45631adba0144bf0260117c33f944e53f66eb..fb8618120dcbbcdcfe6d576442e5bea189cb2521 100644 (file)
@@ -171,3 +171,13 @@ def assertGreaterEqual(self, got, expected, msg=None):
         if msg is None:
             msg = '%r not greater than or equal to %r' % (got, expected)
         self.assertTrue(got >= expected, msg)
+
+
+def expect_warnings(ydl, warnings_re):
+    real_warning = ydl.report_warning
+
+    def _report_warning(w):
+        if not any(re.search(w_re, w) for w_re in warnings_re):
+            real_warning(w)
+
+    ydl.report_warning = _report_warning
index 8178015eacb5600f99c983a77bfa43abd9d37b6a..608e4528ed55b1bbdc60f922e3d6d50af877ad98 100644 (file)
@@ -8,6 +8,7 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 
 from test.helper import (
     assertGreaterEqual,
+    expect_warnings,
     get_params,
     gettestcases,
     expect_info_dict,
@@ -100,6 +101,7 @@ def generator(test_case):
             if status['status'] == 'finished':
                 finished_hook_called.add(status['filename'])
         ydl.add_progress_hook(_hook)
+        expect_warnings(ydl, test_case.get('expected_warnings', []))
 
         def get_tc_filename(tc):
             return tc.get('file') or ydl.prepare_filename(tc.get('info_dict', {}))
index 51dbbc8db13fb680822eac81b526e7397d18b6d2..52f286ac6efd35f33524bef31084ea181e55002d 100644 (file)
@@ -389,8 +389,23 @@ class GenericIE(InfoExtractor):
                 'title': 'Conversation about Hexagonal Rails Part 1 - ThoughtWorks',
                 'duration': 1715.0,
                 'uploader': 'thoughtworks.wistia.com',
-            },   
+            },
         },
+        # Direct download with broken HEAD
+        {
+            'url': 'http://ai-radio.org:8000/radio.opus',
+            'info_dict': {
+                'id': 'radio',
+                'ext': 'opus',
+                'title': 'radio',
+            },
+            'params': {
+                'skip_download': True,  # infinite live stream
+            },
+            'expected_warnings': [
+                r'501.*Not Implemented'
+            ],
+        }
     ]
 
     def report_following_redirect(self, new_url):