Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_srt_to_dfxp_conversion(self):
caption_set = SRTReader().read(SAMPLE_SRT)
results = DFXPWriter().write(caption_set)
self.assertTrue(isinstance(results, six.text_type))
self.assertDFXPEquals(
SAMPLE_DFXP, results,
ignore_styling=True, ignore_spans=True
)
def test_sami_to_dfxp_with_bad_span_align(self):
caption_set = SAMIReader().read(SAMPLE_SAMI_WITH_BAD_SPAN_ALIGN)
results = DFXPWriter(
relativize=False, fit_to_screen=False).write(caption_set)
self.assertDFXPEquals(
SAMPLE_DFXP_FROM_SAMI_WITH_BAD_SPAN_ALIGN,
results
)
def test_dont_create_style_tags_with_no_id(self):
# The
def test_fit_to_screen(self):
# Check if caption width and height are is explicitly set and
# recalculate it if necessary. This prevents long captions from being
# cut out of the screen.
caption_set = DFXPReader().read(SAMPLE_DFXP_LONG_CUE)
result = DFXPWriter().write(caption_set)
self.assertEqual(result, SAMPLE_DFXP_LONG_CUE_FIT_TO_SCREEN)
def test_scc_to_dfxp(self):
caption_set = SCCReader().read(SAMPLE_SCC_MULTIPLE_POSITIONING)
dfxp = DFXPWriter(
relativize=False, fit_to_screen=False).write(caption_set)
self.assertEqual(SAMPLE_DFXP_FROM_SCC_OUTPUT, dfxp)
def test_sami_to_dfxp_with_margin_for_language(self):
caption_set = SAMIReader().read(SAMPLE_SAMI_LANG_MARGIN)
results = DFXPWriter(
relativize=False, fit_to_screen=False).write(caption_set)
self.assertDFXPEquals(
SAMPLE_DFXP_FROM_SAMI_WITH_LANG_MARGINS,
results
)
def test_default_styling_p_tags(self):
caption_set = DFXPReader().read(SAMPLE_DFXP)
result = DFXPWriter().write(caption_set)
soup = BeautifulSoup(result, 'lxml')
for p in soup.find_all('p'):
self.assertEqual(p.attrs.get('style'), 'p')
def test_correct_region_attributes_are_recreated(self):
caption_set = DFXPReader().read(SAMPLE_DFXP_MULTIPLE_REGIONS_INPUT)
result = DFXPWriter(
relativize=False, fit_to_screen=False).write(caption_set)
self.assertDFXPEquals(result, SAMPLE_DFXP_MULTIPLE_REGIONS_OUTPUT)
def test_dfxp_to_dfxp_conversion(self):
caption_set = DFXPReader().read(SAMPLE_DFXP)
results = DFXPWriter().write(caption_set)
self.assertTrue(isinstance(results, text_type))
self.assertDFXPEquals(SAMPLE_DFXP_OUTPUT, results)
def test_sami_to_dfxp_conversion(self):
caption_set = SAMIReader().read(SAMPLE_SAMI)
results = DFXPWriter(relativize=False,
fit_to_screen=False).write(caption_set)
self.assertTrue(isinstance(results, six.text_type))
self.assertDFXPEquals(
DFXP_FROM_SAMI_WITH_POSITIONING,
results
)