1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-27 21:54:17 +01:00

Fix unittest failures for progessbar

This solution is not super nice, but solves the current errors. A proper mock
based solution would probably be preferable.

Reference: #ep14boat
This commit is contained in:
Olof Johansson 2014-07-24 18:39:15 +02:00
parent b494a61d41
commit 17500539a5

View File

@ -38,49 +38,49 @@ class progressTest(unittest.TestCase):
class progressbarTest(unittest.TestCase): class progressbarTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.old_termsiz = svtplay_dl.output.get_terminal_size
svtplay_dl.output.get_terminal_size = lambda: (50, 25)
self.mockfile = mockfile() self.mockfile = mockfile()
svtplay_dl.output.progress_stream = self.mockfile svtplay_dl.output.progress_stream = self.mockfile
def tearDown(self):
svtplay_dl.output.get_terminal_size = self.old_termsiz
def test_0_100(self): def test_0_100(self):
svtplay_dl.output.progressbar(100, 0) svtplay_dl.output.progressbar(100, 0)
self.assertEqual( self.assertEqual(
self.mockfile.read(), self.mockfile.read(), "\r[000/100][.........................] "
"\r[000/100][..................................................] "
) )
def test_progress_1_100(self): def test_progress_1_100(self):
svtplay_dl.output.progressbar(100, 1) svtplay_dl.output.progressbar(100, 1)
self.assertEqual( self.assertEqual(
self.mockfile.read(), self.mockfile.read(), "\r[001/100][.........................] "
"\r[001/100][..................................................] "
) )
def test_progress_2_100(self): def test_progress_2_100(self):
svtplay_dl.output.progressbar(100, 2) svtplay_dl.output.progressbar(100, 2)
self.assertEqual( self.assertEqual(
self.mockfile.read(), self.mockfile.read(), "\r[002/100][.........................] "
"\r[002/100][=.................................................] "
) )
def test_progress_50_100(self): def test_progress_50_100(self):
svtplay_dl.output.progressbar(100, 50) svtplay_dl.output.progressbar(100, 50)
self.assertEqual( self.assertEqual(
self.mockfile.read(), self.mockfile.read(), "\r[050/100][============.............] "
"\r[050/100][=========================.........................] "
) )
def test_progress_100_100(self): def test_progress_100_100(self):
svtplay_dl.output.progressbar(100, 100) svtplay_dl.output.progressbar(100, 100)
self.assertEqual( self.assertEqual(
self.mockfile.read(), self.mockfile.read(), "\r[100/100][=========================] "
"\r[100/100][==================================================] "
) )
def test_progress_20_100_msg(self): def test_progress_20_100_msg(self):
svtplay_dl.output.progressbar(100, 20, "msg") svtplay_dl.output.progressbar(100, 20, "msg")
self.assertEqual( self.assertEqual(
self.mockfile.read(), self.mockfile.read(), "\r[020/100][=====....................] msg"
"\r[020/100][==========........................................] msg"
) )
class EtaTest(unittest.TestCase): class EtaTest(unittest.TestCase):