def test_context_config(): """ Test GLContext handling of config dict """ default_config = get_default_config() # Pass default config unchanged c = GLContext(default_config) assert_equal(c.config, default_config) # Must be deep copy c.config['double_buffer'] = False assert_not_equal(c.config, default_config) # Passing nothing should yield default config c = GLContext() assert_equal(c.config, default_config) # Must be deep copy c.config['double_buffer'] = False assert_not_equal(c.config, default_config) # This should work c = GLContext({'red_size': 4, 'double_buffer': False}) assert_equal(c.config.keys(), default_config.keys()) # Passing crap should raise assert_raises(KeyError, GLContext, {'foo': 3}) assert_raises(TypeError, GLContext, {'double_buffer': 'not_bool'})
def test_use(): # Set default app to None, so we can test the use function vispy.app.use_app() default_app = vispy.app._default_app.default_app vispy.app._default_app.default_app = None app_name = default_app.backend_name.split(' ')[0] try: # With no arguments, should do nothing assert_raises(TypeError, vispy.use) assert_equal(vispy.app._default_app.default_app, None) # With only gl args, should do nothing to app vispy.use(gl='gl2') assert_equal(vispy.app._default_app.default_app, None) # Specify app (one we know works) vispy.use(app_name) assert_not_equal(vispy.app._default_app.default_app, None) # Again, but now wrong app wrong_name = 'glfw' if app_name.lower() != 'glfw' else 'pyqt4' assert_raises(RuntimeError, vispy.use, wrong_name) # And both vispy.use(app_name, 'gl2') finally: # Restore vispy.app._default_app.default_app = default_app
def test_context_config(): """Test GLContext handling of config dict""" default_config = get_default_config() # Pass default config unchanged c = GLContext(default_config) assert_equal(c.config, default_config) # Must be deep copy c.config['double_buffer'] = False assert_not_equal(c.config, default_config) # Passing nothing should yield default config c = GLContext() assert_equal(c.config, default_config) # Must be deep copy c.config['double_buffer'] = False assert_not_equal(c.config, default_config) # This should work c = GLContext({'red_size': 4, 'double_buffer': False}) assert_equal(c.config.keys(), default_config.keys()) # Passing crap should raise assert_raises(KeyError, GLContext, {'foo': 3}) assert_raises(TypeError, GLContext, {'double_buffer': 'not_bool'}) # Capabilites are passed on assert 'gl_version' in c.capabilities