update tests and test doc

add (partially escaped) italics to test doc
add new test for `preserve_formatting=True`
This commit is contained in:
E. Seiver 2023-03-15 18:21:34 -07:00
parent c1a037c39c
commit c1e5ce4ebb
3 changed files with 16 additions and 4 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<transcript>
<text start="0" dur="1.54">Hey, this is just a test</text>
<text start="1.54" dur="4.16">this is not the original transcript</text>
<text start="1.54" dur="4.16">this is &lt;i>not&lt;/i> the original transcript</text>
<text start="5" dur="0.5"></text>
<text start="5.7" dur="3.239">just something shorter, I made up for testing</text>
</transcript>

View File

@ -61,6 +61,18 @@ class TestYouTubeTranscriptApi(TestCase):
]
)
def test_get_transcript_formatted(self):
transcript = YouTubeTranscriptApi.get_transcript('GJLlxj_dtq8', preserve_formatting=True)
self.assertEqual(
transcript,
[
{'text': 'Hey, this is just a test', 'start': 0.0, 'duration': 1.54},
{'text': 'this is <i>not</i> the original transcript', 'start': 1.54, 'duration': 4.16},
{'text': 'just something shorter, I made up for testing', 'start': 5.7, 'duration': 3.239}
]
)
def test_list_transcripts(self):
transcript_list = YouTubeTranscriptApi.list_transcripts('GJLlxj_dtq8')

View File

@ -12,7 +12,7 @@ class TestYouTubeTranscriptCli(TestCase):
self.transcript_mock = MagicMock()
self.transcript_mock.fetch = MagicMock(return_value=[
{'text': 'Hey, this is just a test', 'start': 0.0, 'duration': 1.54},
{'text': 'this is not the original transcript', 'start': 1.54, 'duration': 4.16},
{'text': 'this is <i>not</i> the original transcript', 'start': 1.54, 'duration': 4.16},
{'text': 'just something shorter, I made up for testing', 'start': 5.7, 'duration': 3.239}
])
self.transcript_mock.translate = MagicMock(return_value=self.transcript_mock)