]> git.bitcoin.ninja Git - youtube-dl/blobdiff - test/helper.py
[YoutubeDL] Add simple tests for format_note (Closes #2825)
[youtube-dl] / test / helper.py
index 09873aea33c3815dcd56e8acf992156dbbb5974e..d5e0a603e38285109f4892587ccfb9edffcb901d 100644 (file)
@@ -85,7 +85,7 @@ def gettestcases(include_onlymatching=False):
         else:
             tests = getattr(ie, '_TESTS', [])
         for t in tests:
-            if not include_onlymatching and getattr(t, 'only_matching', False):
+            if not include_onlymatching and t.get('only_matching', False):
                 continue
             t['name'] = type(ie).__name__[:-len('IE')]
             yield t
@@ -134,3 +134,17 @@ def expect_info_dict(self, expected_dict, got_dict):
             missing_keys,
             'Missing keys in test definition: %s' % (
                 ', '.join(sorted(missing_keys))))
+
+
+def assertRegexpMatches(self, text, regexp, msg=None):
+    if hasattr(self, 'assertRegexpMatches'):
+        return self.assertRegexpMatches(text, regexp, msg)
+    else:
+        m = re.match(regexp, text)
+        if not m:
+            note = 'Regexp didn\'t match: %r not found in %r' % (regexp, text)
+            if msg is None:
+                msg = note
+            else:
+                msg = note + ', ' + msg
+            self.assertTrue(m, msg)