aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2015-01-07 07:30:57 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2015-01-07 07:30:57 +0100
commite4a8eae701f22395dae607ed000d39f7a57e80a0 (patch)
treeff33173e1320f25a6af60140c3cd4ff98346d2c3 /test
parent75e51819d010b38d9a3464f8749688c8d53fc123 (diff)
parent8ee341500dea885c79316fb8f12adde2028c55a5 (diff)
downloadyoutube-dl-e4a8eae701f22395dae607ed000d39f7a57e80a0.tar.xz
Merge commit '8ee3415'
Diffstat (limited to 'test')
-rw-r--r--test/helper.py14
-rw-r--r--test/test_utils.py8
2 files changed, 10 insertions, 12 deletions
diff --git a/test/helper.py b/test/helper.py
index 96d58b7c1..77225e4f7 100644
--- a/test/helper.py
+++ b/test/helper.py
@@ -82,18 +82,8 @@ class FakeYDL(YoutubeDL):
def gettestcases(include_onlymatching=False):
for ie in youtube_dl.extractor.gen_extractors():
- t = getattr(ie, '_TEST', None)
- if t:
- assert not hasattr(ie, '_TESTS'), \
- '%s has _TEST and _TESTS' % type(ie).__name__
- tests = [t]
- else:
- tests = getattr(ie, '_TESTS', [])
- for t in tests:
- if not include_onlymatching and t.get('only_matching', False):
- continue
- t['name'] = type(ie).__name__[:-len('IE')]
- yield t
+ for tc in ie.get_testcases(include_onlymatching):
+ yield tc
md5 = lambda s: hashlib.md5(s.encode('utf-8')).hexdigest()
diff --git a/test/test_utils.py b/test/test_utils.py
index dd49a6d17..16e1a1ddf 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -16,6 +16,7 @@ import json
import xml.etree.ElementTree
from youtube_dl.utils import (
+ age_restricted,
args_to_str,
clean_html,
DateRange,
@@ -402,5 +403,12 @@ Trying to open render node...
Success at /dev/dri/renderD128.
ffmpeg version 2.4.4 Copyright (c) 2000-2014 the FFmpeg ...'''), '2.4.4')
+ def test_age_restricted(self):
+ self.assertFalse(age_restricted(None, 10)) # unrestricted content
+ self.assertFalse(age_restricted(1, None)) # unrestricted policy
+ self.assertFalse(age_restricted(8, 10))
+ self.assertTrue(age_restricted(18, 14))
+ self.assertFalse(age_restricted(18, 18))
+
if __name__ == '__main__':
unittest.main()