Example #1
0
def test_FunctionChain():
    
    f1 = Function("void f1(){}")
    f2 = Function("void f2(){}")
    f3 = Function("float f3(vec3 x){}")
    f4 = Function("vec3 f4(vec3 y){}")
    f5 = Function("vec3 f5(vec4 z){}")
    
    ch = FunctionChain('chain', [f1, f2])
    assert ch.name == 'chain'
    assert ch.args == []
    assert ch.rtype == 'void'
    
    assert_in('f1', ch.compile())
    assert_in('f2', ch.compile())
    
    ch.remove(f2)
    assert_not_in('f2', ch.compile())

    ch.append(f2)
    assert_in('f2', ch.compile())

    ch = FunctionChain(funcs=[f5, f4, f3])
    assert_equal('float', ch.rtype)
    assert_equal([('vec4', 'z')], ch.args)
    assert_in('f3', ch.compile())
    assert_in('f4', ch.compile())
    assert_in('f5', ch.compile())
    assert_in(f3, ch.dependencies())
    assert_in(f4, ch.dependencies())
    assert_in(f5, ch.dependencies())
Example #2
0
def test_FunctionChain():

    f1 = Function("void f1(){}")
    f2 = Function("void f2(){}")
    f3 = Function("float f3(vec3 x){}")
    f4 = Function("vec3 f4(vec3 y){}")
    f5 = Function("vec3 f5(vec4 z){}")

    ch = FunctionChain('chain', [f1, f2])
    assert ch.name == 'chain'
    assert ch.args == []
    assert ch.rtype == 'void'

    assert_in('f1', ch.compile())
    assert_in('f2', ch.compile())

    ch.remove(f2)
    assert_not_in('f2', ch.compile())

    ch.append(f2)
    assert_in('f2', ch.compile())

    ch = FunctionChain(funcs=[f5, f4, f3])
    assert_equal('float', ch.rtype)
    assert_equal([('vec4', 'z')], ch.args)
    assert_in('f3', ch.compile())
    assert_in('f4', ch.compile())
    assert_in('f5', ch.compile())
    assert_in(f3, ch.dependencies())
    assert_in(f4, ch.dependencies())
    assert_in(f5, ch.dependencies())
Example #3
0
def test_import_vispy_app2():
    """ Importing vispy.app should not pull in any backend toolkit. """
    allmodnames = loaded_vispy_modules('vispy.app', 2, True)
    assert_not_in('PySide', allmodnames)
    assert_not_in('PySide2', allmodnames)
    assert_not_in('PyQt4', allmodnames)
    assert_not_in('PyQt5', allmodnames)
    assert_not_in('pyglet', allmodnames)
Example #4
0
def test_import_vispy_app2():
    """ Importing vispy.app should not pull in any backend toolkit. """
    allmodnames = loaded_vispy_modules('vispy.app', 2, True)
    assert_not_in('PySide', allmodnames)
    assert_not_in('PySide2', allmodnames)
    assert_not_in('PyQt4', allmodnames)
    assert_not_in('PyQt5', allmodnames)
    assert_not_in('pyglet', allmodnames)
Example #5
0
def test_testing():
    """Test testing ports"""
    assert_raises(AssertionError, assert_in, 'foo', 'bar')
    assert_in('foo', 'foobar')
    assert_raises(AssertionError, assert_not_in, 'foo', 'foobar')
    assert_not_in('foo', 'bar')
    assert_raises(AssertionError, assert_is, None, 0)
    assert_is(None, None)
Example #6
0
def test_testing():
    """Test testing ports"""
    assert_raises(AssertionError, assert_in, 'foo', 'bar')
    assert_in('foo', 'foobar')
    assert_raises(AssertionError, assert_not_in, 'foo', 'foobar')
    assert_not_in('foo', 'bar')
    assert_raises(AssertionError, assert_is, None, 0)
    assert_is(None, None)
Example #7
0
def test_testing():
    """Test testing ports"""
    assert_raises(AssertionError, assert_in, "foo", "bar")
    assert_in("foo", "foobar")
    assert_raises(AssertionError, assert_not_in, "foo", "foobar")
    assert_not_in("foo", "bar")
    assert_raises(AssertionError, assert_is, None, 0)
    assert_is(None, None)
Example #8
0
 def test_ignore_comments(self):
     shader = VertexShader("""
         attribute vec4 color; attribute float x;
         // attribute float y;
         attribute float z; //attribute float w;
     """)
     names = [attr[0] for attr in shader.attributes]
     assert_in("color", names)
     assert_in("x", names)
     assert_in("z", names)
     assert_not_in("y", names)
     assert_not_in("w", names)
Example #9
0
 def test_ignore_comments(self):
     shader = VertexShader("""
         attribute vec4 color; attribute float x;
         // attribute float y;
         attribute float z; //attribute float w;
     """)
     names = [attr[0] for attr in shader.attributes]
     assert_in("color", names)
     assert_in("x", names)
     assert_in("z", names)
     assert_not_in("y", names)
     assert_not_in("w", names)
Example #10
0
def test_debug_logging():
    """Test advanced debugging logging"""
    with use_log_level('debug', 'Selected', True, False) as l:
        logger.debug('Selected foo')
    assert_equal(len(l), 1)
    assert_in('test_logging', l[0])  # can't really parse this location

    with use_log_level('debug', record=True, print_msg=False) as l:
        logger.debug('foo')
    assert_equal(len(l), 1)
    assert_in('test_logging', l[0])

    with use_log_level('debug', 'foo', True, False) as l:
        logger.debug('bar')
    assert_equal(len(l), 0)

    with use_log_level('info', record=True, print_msg=False) as l:
        logger.debug('foo')
        logger.info('bar')
    assert_equal(len(l), 1)
    assert_not_in('unknown', l[0])
Example #11
0
def test_debug_logging():
    """Test advanced debugging logging"""
    with use_log_level('debug', 'Selected', True, False) as l:
        logger.debug('Selected foo')
    assert_equal(len(l), 1)
    assert_in('test_logging', l[0])  # can't really parse this location

    with use_log_level('debug', record=True, print_msg=False) as l:
        logger.debug('foo')
    assert_equal(len(l), 1)
    assert_in('test_logging', l[0])

    with use_log_level('debug', 'foo', True, False) as l:
        logger.debug('bar')
    assert_equal(len(l), 0)

    with use_log_level('info', record=True, print_msg=False) as l:
        logger.debug('foo')
        logger.info('bar')
    assert_equal(len(l), 1)
    assert_not_in('unknown', l[0])
Example #12
0
def test_import_vispy_no_pyopengl():
    """ Importing vispy.gloo.gl.gl2 should not import PyOpenGL. """
    # vispy.gloo desktop backend
    allmodnames = loaded_vispy_modules('vispy.gloo.gl.gl2', 2, True)
    assert_not_in('OpenGL', allmodnames)
    # vispy.app
    allmodnames = loaded_vispy_modules('vispy.app', 2, True)
    assert_not_in('OpenGL', allmodnames)
    # vispy.scene
    allmodnames = loaded_vispy_modules('vispy.scene', 2, True)
    assert_not_in('OpenGL', allmodnames)
Example #13
0
def test_import_vispy_no_pyopengl():
    """ Importing vispy.gloo.gl.desktop should not import PyOpenGL. """
    # vispy.gloo desktop backend
    allmodnames = loaded_vispy_modules('vispy.gloo.gl.desktop', 2, True)
    assert_not_in('OpenGL', allmodnames)
    # vispy.app 
    allmodnames = loaded_vispy_modules('vispy.app', 2, True)
    assert_not_in('OpenGL', allmodnames)
    # vispy.scene
    allmodnames = loaded_vispy_modules('vispy.scene', 2, True)
    assert_not_in('OpenGL', allmodnames)
Example #14
0
def test_import_vispy_no_pyopengl():
    """ Importing vispy.gloo.gl.gl2 should not import PyOpenGL. """
    # vispy.gloo desktop backend
    allmodnames = loaded_vispy_modules("vispy.gloo.gl.gl2", 2, True)
    assert_not_in("OpenGL", allmodnames)
    # vispy.app
    allmodnames = loaded_vispy_modules("vispy.app", 2, True)
    assert_not_in("OpenGL", allmodnames)
    # vispy.scene
    allmodnames = loaded_vispy_modules("vispy.scene", 2, True)
    assert_not_in("OpenGL", allmodnames)
Example #15
0
def test_import_vispy_app2():
    """ Importing vispy.app should not pull in any backend toolkit. """
    allmodnames = loaded_vispy_modules("vispy.app", 2, True)
    assert_not_in("PySide", allmodnames)
    assert_not_in("PyQt4", allmodnames)
    assert_not_in("pyglet", allmodnames)