def setUp(self): Settings.DEFAULT_EXTENSION_TYPES.clear() Settings.DEFAULT_EXTENSION_TYPES.append( 'yuuno.vs.extension.VapourSynth') Yuuno.instance(environment=TestEnvironment()).start() self.vs = import_item("vapoursynth") # We will work with a dedicated VapourSynth-core. self.core = self.vs.core.core self.black_clip_grey = self.core.std.BlankClip(width=10, height=10, format=self.vs.GRAY8) self.black_clip_yuv444 = self.core.std.BlankClip( width=10, height=10, format=self.vs.YUV444P8) self.black_clip_yuv422 = self.core.std.BlankClip( width=10, height=10, format=self.vs.YUV422P8) self.black_clip_yuv420 = self.core.std.BlankClip( width=10, height=10, format=self.vs.YUV420P8) self.black_clip = self.core.std.BlankClip(width=10, height=10, format=self.vs.RGB24) self.black_compat = self.black_clip.resize.Spline36( format=self.vs.COMPATBGR32)
def test_002_ipython_disable(self): load_ipython_extension(self.shell) yuuno = Yuuno.instance() ext = yuuno.extensions[0] unload_ipython_extension(self.shell) self.assertIsNot(yuuno, Yuuno.instance()) self.assertNotIn(yuuno, self.shell.configurables) self.assertNotIn(yuuno.environment, self.shell.configurables) self.assertNotIn(ext, self.shell.configurables)
def with_name(cls, name): mgr = Yuuno.instance().get_extension('MultiScript') environment = Yuuno.instance().environment if mgr is None or not environment.use_vsscript: # VSScript is not enabled. Don't do anything. return manager: ScriptManager = mgr.get_manager('VSScript') if manager is None: # VSScript is not enabled. Don't do anything. return return cls(manager.create(name, initialize=True))
def test_003_feature_initialization(self): load_ipython_extension(self.shell) yuuno = Yuuno.instance() self.assertInstanceIn(yuuno.environment.features, TestFeature) self.assertTrue(yuuno.environment.features[0].init_called) self.assertFalse(yuuno.environment.features[0].deinit_called)
def test_004_feature_deinitialization(self): load_ipython_extension(self.shell) yuuno = Yuuno.instance() unload_ipython_extension(self.shell) self.assertTrue(yuuno.environment.features[0].init_called) self.assertTrue(yuuno.environment.features[0].deinit_called)
def test_001_ipython_enable(self): load_ipython_extension(self.shell) yuuno = Yuuno.instance() self.assertIsInstance(yuuno.environment, YuunoIPythonEnvironment) self.assertIn(yuuno.environment, self.shell.configurables) self.assertInstanceIn(self.shell.configurables, SupportedTestExtension) self.assertIn(yuuno, self.shell.configurables)
def test_001_formatter_correct_image(self): tc = TestClip(None) inline = InlineFormat(environment=Yuuno.instance().environment, clip=tc) self.assertEqual(inline.ipy_image.data, TestPNGOutput.EXPECTED_RESULT_SIMPLE)
def _wrap_for(self, target): if target is None: return None elif not isinstance(target, Clip): target = Yuuno.instance().wrap(target) return target
def setUp(self): # To be test-friendly, disable all extensions Settings.DEFAULT_EXTENSION_TYPES.clear() Settings.DEFAULT_EXTENSION_TYPES.extend([ "tests.test_yuuno.SupportedTestExtension", "tests.test_yuuno.UnsupportedTestExtension" ]) self.environment = TestEnvironment() self.yuuno = Yuuno.instance(environment=self.environment)
def setUp(self): Settings.DEFAULT_EXTENSION_TYPES.clear() Settings.DEFAULT_EXTENSION_TYPES.append( "tests.test_ipython_formatter.TestClipExtension") YuunoIPythonEnvironment.feature_classes = [ "yuuno_ipython.ipython.formatter.Formatter" ] self.shell = globalipapp.get_ipython() load_ipython_extension(self.shell) Yuuno.instance().output.icc_profile = None self.loaded = True
def setUp(self): Settings.DEFAULT_EXTENSION_TYPES.clear() Settings.DEFAULT_EXTENSION_TYPES.append( 'tests.test_ipython_namespace.TestExtension') YuunoIPythonEnvironment.feature_classes = [ "yuuno_ipython.ipython.namespace.Namespace" ] self.shell = globalipapp.get_ipython() load_ipython_extension(self.shell) self.loaded = True self.yuuno = Yuuno.instance()
def _handle_request_frame(self, _, content, buffers): wrapped = self._target_for(content) if wrapped is None: return {"size": [0, 0], "props": {}}, [EMPTY_IMAGE] frameno = content.get('payload', {}).get('frame', self.frame) if frameno >= len(wrapped): frameno = len(wrapped) - 1 frame = yield wrapped[frameno] data = Yuuno.instance().output.bytes_of(frame.to_pil()) return { "size": frame.size(), "props": frame.properties() }, [data]
def execute(cls, read: Connection, write: Connection, framebuffer: Array): cls._preload() Thread(target=cls._check_parent, daemon=True).start() from yuuno import Yuuno yuuno = Yuuno.instance(parent=None) env = cls(parent=yuuno, read=read, write=write) env._framebuffer = framebuffer yuuno.environment = env # Wait for the ProviderMeta to be set. print(os.getpid(), ">", "Ready to deploy!") env._provider_meta = read.recv() yuuno.start() print(os.getpid(), ">", "Deployed", env._provider_meta) # Run the environment env.run() # Stop Yuuno. yuuno.stop()
def test_002_test_magic_unregister(self): Yuuno.instance().environment.features[0].unregister_magics(TestMagicFeature.TestMagics) self.assertIsNone(self._run_magic("line", "test_line_magic", "testificate")) self.assertIsNone(self._run_magic("cell", "test_cell_magic", "testificate", "1 2 3"))
def yuuno(self): return Yuuno.instance()
def instance() -> 'VapourSynth': from yuuno import Yuuno return Yuuno.instance().get_extension(VapourSynth)
def tearDown(self): Yuuno.instance().stop()
def extension(self) -> VapourSynth: return Yuuno.instance().get_extension(VapourSynth)
def create(cls): return TestEnvironment(parent=Yuuno.instance())
def _default_environment(self): return Yuuno.instance().environment
def tearDown(self): Yuuno.clear_instance()
def test_007_vapoursynth_variable_push(self): ns = Yuuno.instance().namespace.as_dict() import vapoursynth self.assertEqual(ns['vs'], vapoursynth) self.assertIn('core', ns)
def deinitialize(self): extension: VapourSynth = Yuuno.instance().get_extension('VapourSynth') if extension is None: return extension.log_handlers.remove(self._push_log_msg)
def environment(self): return Yuuno.instance().environment