diff options
| author | Philipp Hagemeister <phihag@phihag.de> | 2014-09-29 22:19:11 +0200 | 
|---|---|---|
| committer | Philipp Hagemeister <phihag@phihag.de> | 2014-09-29 22:19:11 +0200 | 
| commit | c0f64ac689627bfaaea677c6edfc7ec153ccd9be (patch) | |
| tree | 56ecbee6e42502b4b36e9067ed647153ff18462d | |
| parent | 7a08ad7d592a91ed12eead2cdc80ef509cf5c1cf (diff) | |
[test/helper] Improve output of missing test definition dictionaries
| -rw-r--r-- | test/helper.py | 11 | 
1 files changed, 10 insertions, 1 deletions
| diff --git a/test/helper.py b/test/helper.py index 53494196e..62cb3ce02 100644 --- a/test/helper.py +++ b/test/helper.py @@ -14,6 +14,7 @@ from youtube_dl import YoutubeDL  from youtube_dl.utils import (      compat_str,      preferredencoding, +    write_string,  ) @@ -136,7 +137,15 @@ def expect_info_dict(self, expected_dict, got_dict):          if value and key in ('title', 'description', 'uploader', 'upload_date', 'timestamp', 'uploader_id', 'location'))      missing_keys = set(test_info_dict.keys()) - set(expected_dict.keys())      if missing_keys: -        sys.stderr.write('\n"info_dict": ' + json.dumps(test_info_dict, ensure_ascii=False, indent=4) + '\n') +        def _repr(v): +            if isinstance(v, compat_str): +                return "'%s'" % v.replace('\\', '\\\\').replace("'", "\\'") +            else: +                return repr(v) +        info_dict_str = ''.join( +            '    %s: %s,\n' % (_repr(k), _repr(v)) +            for k, v in test_info_dict.items()) +        write_string('\n"info_dict": {' + info_dict_str + '}\n', out=sys.stderr)          self.assertFalse(              missing_keys,              'Missing keys in test definition: %s' % ( | 
