diff options
| author | Philipp Hagemeister <phihag@phihag.de> | 2014-04-30 02:02:41 +0200 | 
|---|---|---|
| committer | Philipp Hagemeister <phihag@phihag.de> | 2014-04-30 02:02:41 +0200 | 
| commit | c57f7757101690681af2eb8c40c8bf81bbe6e64f (patch) | |
| tree | 5b400e9f49991a5143cc7e464a885bb97757d936 /test | |
| parent | e75cafe9fbd5bbca134264ad7dcb27df35d07bb5 (diff) | |
[YoutubeDL] Add simple tests for format_note (Closes #2825)
Diffstat (limited to 'test')
| -rw-r--r-- | test/helper.py | 14 | ||||
| -rw-r--r-- | test/test_YoutubeDL.py | 8 | 
2 files changed, 21 insertions, 1 deletions
| diff --git a/test/helper.py b/test/helper.py index da714078d..d5e0a603e 100644 --- a/test/helper.py +++ b/test/helper.py @@ -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) diff --git a/test/test_YoutubeDL.py b/test/test_YoutubeDL.py index 2902dbec7..8735013f7 100644 --- a/test/test_YoutubeDL.py +++ b/test/test_YoutubeDL.py @@ -8,7 +8,7 @@ import sys  import unittest  sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from test.helper import FakeYDL +from test.helper import FakeYDL, assertRegexpMatches  from youtube_dl import YoutubeDL  from youtube_dl.extractor import YoutubeIE @@ -274,6 +274,12 @@ class TestFormatSelection(unittest.TestCase):          # Replace missing fields with 'NA'          self.assertEqual(fname('%(uploader_date)s-%(id)s.%(ext)s'), 'NA-1234.mp4') +    def test_format_note(self): +        ydl = YoutubeDL() +        self.assertEqual(ydl._format_note({}), '') +        assertRegexpMatches(self, ydl._format_note({ +            'vbr': 10, +        }), '^x\s*10k$')  if __name__ == '__main__':      unittest.main() | 
