forked from pbs/pycaption
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated CaptionList to handle list operations.
- Loading branch information
1 parent
5c38167
commit 1e1ad53
Showing
4 changed files
with
76 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import unittest | ||
|
||
from pycaption.base import CaptionList | ||
|
||
|
||
class CaptionListTestCase(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.layout_info = "My Layout" | ||
self.caps = CaptionList([1, 2, 3], layout_info=self.layout_info) | ||
|
||
def test_splice(self): | ||
newcaps = self.caps[1:] | ||
self.assertTrue(isinstance(newcaps, CaptionList)) | ||
self.assertTrue(newcaps.layout_info == self.layout_info) | ||
|
||
def test_mul(self): | ||
newcaps = self.caps * 2 | ||
self.assertTrue(isinstance(newcaps, CaptionList)) | ||
self.assertTrue(newcaps.layout_info == self.layout_info) | ||
|
||
def test_rmul(self): | ||
newcaps = 2 * self.caps | ||
self.assertTrue(isinstance(newcaps, CaptionList)) | ||
self.assertTrue(newcaps.layout_info == self.layout_info) | ||
|
||
def test_add_list_to_caption_list(self): | ||
newcaps = self.caps + [9, 8, 7] | ||
self.assertTrue(isinstance(newcaps, CaptionList)) | ||
self.assertTrue(newcaps.layout_info == self.layout_info) | ||
|
||
def test_add_two_caption_lists(self): | ||
newcaps = self.caps + CaptionList([4], layout_info=None) | ||
self.assertTrue(isinstance(newcaps, CaptionList)) | ||
self.assertTrue(newcaps.layout_info == self.layout_info) | ||
|
||
newcaps = self.caps + CaptionList([4], layout_info=self.layout_info) | ||
self.assertTrue(isinstance(newcaps, CaptionList)) | ||
self.assertTrue(newcaps.layout_info == self.layout_info) | ||
|
||
with self.assertRaises(ValueError): | ||
newcaps = self.caps + CaptionList([4], layout_info="Other Layout") |