correcting test to be compatible with python2.6
authorgcmalloc <gcmalloc@gmail.com>
Mon, 15 Oct 2012 12:34:54 +0000 (14:34 +0200)
committergcmalloc <gcmalloc@gmail.com>
Fri, 19 Oct 2012 10:53:20 +0000 (12:53 +0200)
test/test_download.py
test/test_utils.py

index 84a98908a3e3236403411fac0d431b018fc6347a..7de9f2a4897f6f77dbfd3db527bc91144bfe2e1a 100644 (file)
@@ -74,9 +74,10 @@ class DownloadTest(unittest.TestCase):
                md5_down_file = md5_for_file(DownloadTest.DAILYMOTION_FILE)
                self.assertEqual(md5_down_file, DownloadTest.DAILYMOTION_MD5)
 
-       @unittest.skip("no suitable ie")
        def test_metacafe(self):
-               with open("test/json") as f:
+               #this emulate a skip,to be 2.6 compatible
+               return
+               with open(DownloadTest.PARAMETERS_FILE) as f:
                        fd = FileDownloader(json.load(f))
                        print fd
                fd.add_info_extractor(MetacafeIE())
@@ -85,45 +86,50 @@ class DownloadTest(unittest.TestCase):
                md5_down_file = md5_for_file(DownloadTest.METACAFE_FILE)
                self.assertEqual(md5_down_file, DownloadTest.METACAFE_MD5)
 
-       @unittest.skip("no suitable url")
        def test_photobucket(self):
-               fd = FileDownloader({})
+               return
+               with open(DownloadTest.PARAMETERS_FILE) as f:
+                       fd = FileDownloader(json.load(f))
                fd.add_info_extractor(PhotobucketIE())
                fd.download([DownloadTest.PHOTOBUCKET_URL])
                self.assertTrue(os.path.exists(DownloadTest.PHOTOBUCKET_FILE))
                md5_down_file = md5_for_file(DownloadTest.PHOTOBUCKET_FILE)
                self.assertEqual(md5_down_file, DownloadTest.PHOTOBUCKET_MD5)
 
-       @unittest.skip("no suitable url")
        def test_facebook(self):
-               fd = FileDownloader({})
+               return
+               with open(DownloadTest.PARAMETERS_FILE) as f:
+                       fd = FileDownloader(json.load(f))
                fd.add_info_extractor(FacebookIE())
                fd.download([DownloadTest.FACEBOOK_URL])
                self.assertTrue(os.path.exists(DownloadTest.FACEBOOK_FILE))
                md5_down_file = md5_for_file(DownloadTest.FACEBOOK_FILE)
                self.assertEqual(md5_down_file, DownloadTest.FACEBOOK_MD5)
 
-       @unittest.skip("no suitable url")
        def test_blip(self):
-               fd = FileDownloader({})
+               return
+               with open(DownloadTest.PARAMETERS_FILE) as f:
+                       fd = FileDownloader(json.load(f))
                fd.add_info_extractor(BlipTVIE())
                fd.download([DownloadTest.BLIP_URL])
                self.assertTrue(os.path.exists(DownloadTest.BLIP_FILE))
                md5_down_file = md5_for_file(DownloadTest.BLIP_FILE)
                self.assertEqual(md5_down_file, DownloadTest.BLIP_MD5)
 
-       @unittest.skip("no suitable url")
        def test_vimeo(self):
-               fd = FileDownloader({})
+               return
+               with open(DownloadTest.PARAMETERS_FILE) as f:
+                       fd = FileDownloader(json.load(f))
                fd.add_info_extractor(VimeoIE())
                fd.download([DownloadTest.VIMEO_URL])
                self.assertTrue(os.path.exists(DownloadTest.VIMEO_FILE))
                md5_down_file = md5_for_file(DownloadTest.VIMEO_FILE)
                self.assertEqual(md5_down_file, DownloadTest.VIMEO_MD5)
 
-       @unittest.skip("no suitable url")
        def test_xvideo(self):
-               fd = FileDownloader({})
+               return
+               with open(DownloadTest.PARAMETERS_FILE) as f:
+                       fd = FileDownloader(json.load(f))
                fd.add_info_extractor(XVideosIE())
                fd.download([DownloadTest.XVIDEO_URL])
                self.assertTrue(os.path.exists(DownloadTest.XVIDEO_FILE))
index fd3ac4d46c25dbe159a743172c9e855667b13f83..eb0af703f502b7fa80761164fab2c5423d7f1035 100644 (file)
@@ -13,8 +13,8 @@ from youtube_dl.utils import orderedSet
 
 class TestUtil(unittest.TestCase):
        def test_timeconvert(self):
-               self.assertIsNone(timeconvert(''))
-               self.assertIsNone(timeconvert('bougrg'))
+               self.assertTrue(timeconvert('') is None)
+               self.assertTrue(timeconvert('bougrg') is None)
 
        def test_sanitize_filename(self):
                self.assertEqual(sanitize_filename(u'abc'), u'abc')
@@ -23,12 +23,12 @@ class TestUtil(unittest.TestCase):
                self.assertEqual(sanitize_filename(u'123'), u'123')
 
                self.assertEqual(u'abc_de', sanitize_filename(u'abc/de'))
-               self.assertIn(u'de', sanitize_filename(u'abc/de'))
-               self.assertNotIn(u'/', sanitize_filename(u'abc/de///'))
+               self.assertTrue(u'de' in sanitize_filename(u'abc/de'))
+               self.assertFalse(u'/' in sanitize_filename(u'abc/de///'))
 
                self.assertEqual(u'abc_de', sanitize_filename(u'abc\\de'))
                self.assertEqual(u'abc_de', sanitize_filename(u'abc\\de'))
-               self.assertIn(u'de', sanitize_filename(u'abc\\de'))
+               self.assertTrue(u'de' in  sanitize_filename(u'abc\\de'))
 
                self.assertEqual(sanitize_filename(u'ä'), u'ä')
                self.assertEqual(sanitize_filename(u'кириллица'), u'кириллица')