MCPcopy Index your code
hub / github.com/ipython/ipython / test_video_embedding

Function test_video_embedding

tests/test_display_2.py:400–434  ·  view source on GitHub ↗

use a tempfile, with dummy-data, to ensure that video embedding doesn't crash

()

Source from the content-addressed store, hash-verified

398
399
400def test_video_embedding():
401 """use a tempfile, with dummy-data, to ensure that video embedding doesn't crash"""
402 v = display.Video("http://ignored")
403 assert not v.embed
404 html = v._repr_html_()
405 assert 'src="data:' not in html
406 assert 'src="http://ignored"' in html
407
408 with pytest.raises(ValueError):
409 v = display.Video(b"abc")
410
411 with NamedFileInTemporaryDirectory("test.mp4", "wb") as f:
412 f.write(b"abc")
413 f.close()
414
415 v = display.Video(f.name)
416 assert not v.embed
417 html = v._repr_html_()
418 assert 'src="data:' not in html
419
420 v = display.Video(f.name, embed=True)
421 html = v._repr_html_()
422 assert 'src="data:video/mp4;base64,YWJj"' in html
423
424 v = display.Video(f.name, embed=True, mimetype="video/other")
425 html = v._repr_html_()
426 assert 'src="data:video/other;base64,YWJj"' in html
427
428 v = display.Video(b"abc", embed=True, mimetype="video/mp4")
429 html = v._repr_html_()
430 assert 'src="data:video/mp4;base64,YWJj"' in html
431
432 v = display.Video("YWJj", embed=True, mimetype="video/xyz")
433 html = v._repr_html_()
434 assert 'src="data:video/xyz;base64,YWJj"' in html
435
436
437def test_html_metadata():

Callers

nothing calls this directly

Calls 4

_repr_html_Method · 0.95
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…