<s> import unittest <EOL> import sys <EOL> if sys . path [ <NUM_LIT:0> ] . endswith ( "<STR_LIT>" ) : <EOL> sys . path = sys . path [ <NUM_LIT:1> : ] <EOL> import vlogging <EOL> class BasicTestCase ( unittest . TestCase ) : <EOL> def test_nothing ( self ) : <EOL> s = str ( vlogging . VisualRecord ( ) ) <EOL> self . assertTrue ( "<STR_LIT>" in s ) <EOL> def test_text_only ( self ) : <EOL> s = str ( vlogging . VisualRecord ( title = "<STR_LIT:title>" , footnotes = "<STR_LIT>" ) ) <EOL> self . assertTrue ( "<STR_LIT:title>" in s ) <EOL> self . assertTrue ( "<STR_LIT>" in s ) <EOL> self . assertTrue ( "<STR_LIT>" in s ) <EOL> def test_all_renderers ( self ) : <EOL> self . assertEqual ( len ( vlogging . renderers ) , <NUM_LIT:3> ) <EOL> def test_invalid_images ( self ) : <EOL> s = str ( vlogging . VisualRecord ( <EOL> title = "<STR_LIT:title>" , <EOL> imgs = "<STR_LIT>" , <EOL> footnotes = "<STR_LIT>" ) ) <EOL> self . assertTrue ( "<STR_LIT:title>" in s ) <EOL> self . assertTrue ( "<STR_LIT>" in s ) <EOL> self . assertTrue ( "<STR_LIT>" in s ) <EOL> self . assertEqual ( s . count ( "<STR_LIT>" ) , <NUM_LIT:0> ) <EOL> s = str ( vlogging . VisualRecord ( <EOL> title = "<STR_LIT:title>" , <EOL> imgs = [ "<STR_LIT>" , <NUM_LIT:1> , <NUM_LIT:2> , dict ( ) ] , <EOL> footnotes = "<STR_LIT>" ) ) <EOL> self . assertTrue ( "<STR_LIT:title>" in s ) <EOL> self . assertTrue ( "<STR_LIT>" in s ) <EOL> self . assertTrue ( "<STR_LIT>" in s ) <EOL> self . assertEqual ( s . count ( "<STR_LIT>" ) , <NUM_LIT:0> ) <EOL> def test_pil ( self ) : <EOL> from PIL import Image <EOL> pil_image = Image . open ( '<STR_LIT>' ) <EOL> s = str ( vlogging . VisualRecord ( <EOL> title = "<STR_LIT:title>" , <EOL> imgs = pil_image , <EOL> footnotes = "<STR_LIT>" ) ) <EOL> self . assertTrue ( "<STR_LIT:title>" in s ) <EOL> self . assertTrue ( "<STR_LIT>" in s ) <EOL> self . assertTrue ( "<STR_LIT>" in s ) <EOL> self . assertTrue ( "<STR_LIT>" in s ) <EOL> self . assertEqual ( s . count ( "<STR_LIT>" ) , <NUM_LIT:1> ) <EOL> s = str ( vlogging . VisualRecord ( <EOL> title = "<STR_LIT:title>" , <EOL> imgs = [ pil_image ] , <EOL> footnotes = "<STR_LIT>" ) ) <EOL> self . assertEqual ( s . count ( "<STR_LIT>" ) , <NUM_LIT:1> ) <EOL> s = str ( vlogging . VisualRecord ( <EOL> title = "<STR_LIT:title>" , <EOL> imgs = [ pil_image , pil_image ] , <EOL> footnotes = "<STR_LIT>" , <EOL> fmt = "<STR_LIT>" ) ) <EOL> self . assertTrue ( "<STR_LIT>" in s ) <EOL> self . assertEqual ( s . count ( "<STR_LIT>" ) , <NUM_LIT:2> ) <EOL> def test_opencv ( self ) : <EOL> import cv2 <EOL> cv_image = cv2 . imread ( '<STR_LIT>' ) <EOL> s = str ( vlogging . VisualRecord ( <EOL> title = "<STR_LIT:title>" , <EOL> imgs = cv_image , <EOL> footnotes = "<STR_LIT>" ) ) <EOL> self . assertTrue ( "<STR_LIT:title>" in s ) <EOL> self . assertTrue ( "<STR_LIT>" in s ) <EOL> self . assertTrue ( "<STR_LIT>" in s ) <EOL> self . assertEqual ( s . count ( "<STR_LIT>" ) , <NUM_LIT:1> ) <EOL> s = str ( vlogging . VisualRecord ( <EOL> title = "<STR_LIT:title>" , <EOL> imgs = [ cv_image ] , <EOL> footnotes = "<STR_LIT>" ) ) <EOL> self . assertEqual ( s . count ( "<STR_LIT>" ) , <NUM_LIT:1> ) <EOL> s = str ( vlogging . VisualRecord ( <EOL> title = "<STR_LIT:title>" , <EOL> imgs = [ cv_image , cv_image ] , <EOL> footnotes = "<STR_LIT>" ) ) <EOL> self . assertEqual ( s . count ( "<STR_LIT>" ) , <NUM_LIT:2> ) <EOL> def test_pylab_basic ( self ) : <EOL> import matplotlib . pyplot as plt <EOL> import numpy as np <EOL> t = np . arange ( <NUM_LIT:0.> , <NUM_LIT> , <NUM_LIT> ) <EOL> plt . plot ( t , t , '<STR_LIT>' , t , t ** <NUM_LIT:2> , '<STR_LIT>' , t , t ** <NUM_LIT:3> , '<STR_LIT>' ) <EOL> s = str ( vlogging . VisualRecord ( <EOL> title = "<STR_LIT:title>" , <EOL> imgs = plt , <EOL> footnotes = "<STR_LIT>" ) ) <EOL> self . assertTrue ( "<STR_LIT:title>" in s ) <EOL> self . assertTrue ( "<STR_LIT>" in s ) <EOL> self . assertTrue ( "<STR_LIT>" in s ) <EOL> self . assertEqual ( s . count ( "<STR_LIT>" ) , <NUM_LIT:1> ) <EOL> def test_pylab_figure ( self ) : <EOL> import matplotlib . pyplot as plt <EOL> import numpy as np <EOL> t = np . arange ( <NUM_LIT:0.> , <NUM_LIT> , <NUM_LIT> ) <EOL> fig = plt . figure ( ) <EOL> plt . plot ( t , t , '<STR_LIT>' , t , t ** <NUM_LIT:2> , '<STR_LIT>' , t , t ** <NUM_LIT:3> , '<STR_LIT>' ) <EOL> s = str ( vlogging . VisualRecord ( <EOL> title = "<STR_LIT:title>" , <EOL> imgs = fig , <EOL> footnotes = "<STR_LIT>" ) ) <EOL> self . assertTrue ( "<STR_LIT:title>" in s ) <EOL> self . assertTrue ( "<STR_LIT>" in s ) <EOL> self . assertTrue ( "<STR_LIT>" in s ) <EOL> self . assertEqual ( s . count ( "<STR_LIT>" ) , <NUM_LIT:1> ) </s>
