def test_context_taking():
 def get_canvas(c):
  return c.shared.ref
 cb = DummyCanvasBackend()
 c = GLContext()
 assert (c.shared.name is None)
 assert_raises(RuntimeError, get_canvas, c)
 assert_in('None backend', repr(c.shared))
 c.shared.add_ref('test-foo', cb)
 assert (c.shared.ref is cb)
 assert_in('test-foo backend', repr(c.shared))
 c.shared.add_ref('test-foo', cb)
 assert (len(c.shared._refs) == 2)
 cb = DummyCanvasBackend()
 gc.collect()
 assert_raises(RuntimeError, get_canvas, c)

def test_context_taking ( ) : def get_canvas ( c ) : return c . shared . ref cb = DummyCanvasBackend ( ) c = GLContext ( ) assert ( c . shared . name is None ) assert_raises ( RuntimeError , get_canvas , c ) assert_in ( 'None backend' , repr ( c . shared ) ) c . shared . add_ref ( 'test-foo' , cb ) assert ( c . shared . ref is cb ) assert_in ( 'test-foo backend' , repr ( c . shared ) ) c . shared . add_ref ( 'test-foo' , cb ) assert ( len ( c . shared . _refs ) == 2 ) cb = DummyCanvasBackend ( ) gc . collect ( ) assert_raises ( RuntimeError , get_canvas , c )
test glcontext ownership and taking .