class TestVideo(TestCase): def setUp(self): from pycdstar.media import Video with NamedTemporaryFile(delete=False, suffix='.avi') as fp: fp.write(b"""test""") self.file = Video(fp.name) def test_create_object(self): class subprocess(object): def check_call(self, args): with open(args[-1], 'w') as fp: fp.write(b'test' if PY2 else 'test') return def check_output(self, args): return '{"streams":[{"duration":5.5}]}' with patch('pycdstar.media.subprocess', subprocess()): obj, md, bs = self.file.create_object(Mock()) self.assertAlmostEqual(md['duration'], 5.5) def tearDown(self): if os.path.exists(self.file.path): os.remove(self.file.path)
def setUp(self): from pycdstar.media import Video with NamedTemporaryFile(delete=False, suffix='.avi') as fp: fp.write(b"""test""") self.file = Video(fp.name)