mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-25 03:32:05 +00:00
Beautify test code
This commit is contained in:
parent
e6abe3f933
commit
796447b1a5
1 changed files with 7 additions and 3 deletions
|
@ -11,14 +11,17 @@ from test.helper import get_params, try_rm
|
||||||
import youtube_dl.YoutubeDL
|
import youtube_dl.YoutubeDL
|
||||||
from youtube_dl.utils import DownloadError
|
from youtube_dl.utils import DownloadError
|
||||||
|
|
||||||
|
|
||||||
class YoutubeDL(youtube_dl.YoutubeDL):
|
class YoutubeDL(youtube_dl.YoutubeDL):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(YoutubeDL, self).__init__(*args, **kwargs)
|
super(YoutubeDL, self).__init__(*args, **kwargs)
|
||||||
self.to_stderr = self.to_screen
|
self.to_stderr = self.to_screen
|
||||||
|
|
||||||
|
|
||||||
TEST_ID = 'gr51aVj-mLg'
|
TEST_ID = 'gr51aVj-mLg'
|
||||||
EXPECTED_NAME = 'gr51aVj-mLg'
|
EXPECTED_NAME = 'gr51aVj-mLg'
|
||||||
|
|
||||||
|
|
||||||
class TestPostHooks(unittest.TestCase):
|
class TestPostHooks(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.stored_name_1 = None
|
self.stored_name_1 = None
|
||||||
|
@ -44,15 +47,15 @@ class TestPostHooks(unittest.TestCase):
|
||||||
ydl = YoutubeDL(self.params)
|
ydl = YoutubeDL(self.params)
|
||||||
self.assertRaises(DownloadError, ydl.download, [TEST_ID])
|
self.assertRaises(DownloadError, ydl.download, [TEST_ID])
|
||||||
|
|
||||||
def hook_one(self,filename):
|
def hook_one(self, filename):
|
||||||
self.stored_name_1, _ = os.path.splitext(os.path.basename(filename))
|
self.stored_name_1, _ = os.path.splitext(os.path.basename(filename))
|
||||||
self.files.append(filename)
|
self.files.append(filename)
|
||||||
|
|
||||||
def hook_two(self,filename):
|
def hook_two(self, filename):
|
||||||
self.stored_name_2, _ = os.path.splitext(os.path.basename(filename))
|
self.stored_name_2, _ = os.path.splitext(os.path.basename(filename))
|
||||||
self.files.append(filename)
|
self.files.append(filename)
|
||||||
|
|
||||||
def hook_three(self,filename):
|
def hook_three(self, filename):
|
||||||
self.files.append(filename)
|
self.files.append(filename)
|
||||||
raise Exception('Test exception for \'%s\'' % filename)
|
raise Exception('Test exception for \'%s\'' % filename)
|
||||||
|
|
||||||
|
@ -60,5 +63,6 @@ class TestPostHooks(unittest.TestCase):
|
||||||
for f in self.files:
|
for f in self.files:
|
||||||
try_rm(f)
|
try_rm(f)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in a new issue