def test_loader_ram_cache(test_filename): """Tests that the Python loader plug-ins write to the RAM cache.""" # Ensure a clean slate. from panda3d.core import ModelPool ModelPool.release_all_models() with registered_type(DummyLoader): model1 = Loader.get_global_ptr().load_sync( test_filename, LoaderOptions(LoaderOptions.LF_no_disk_cache | LoaderOptions.LF_allow_instance)) assert model1 is not None assert model1.name == "loaded" assert ModelPool.has_model(test_filename) assert ModelPool.get_model(test_filename, True) == model1 model2 = Loader.get_global_ptr().load_sync( test_filename, LoaderOptions(LoaderOptions.LF_cache_only | LoaderOptions.LF_allow_instance)) assert model2 is not None assert model1 == model2 ModelPool.release_model(model2)
def temp_model(): from panda3d.core import ModelPool, ModelRoot root = ModelRoot('model') root.fullpath = '/test-model.bam' ModelPool.add_model(root.fullpath, root) yield root.fullpath ModelPool.release_model(root.fullpath)