Skip to content

Commit

Permalink
Flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
almarklein committed Feb 27, 2014
1 parent a32e571 commit e529c5e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 31 deletions.
2 changes: 1 addition & 1 deletion vispy/gloo/gl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def use(target='desktop'):
"""
target = target or 'desktop'

# Get options
target, _, options = target.partition(' ')
debug = config['gl_debug'] or ('debug' in options)
Expand Down
29 changes: 14 additions & 15 deletions vispy/gloo/gl/tests/test_functionality.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,34 @@


def test_functionality_desktop():
""" Test that desktop GL backend functions appropriately. """
""" Test that desktop GL backend functions appropriately. """
_test_functonality('desktop')


def test_functionality_angle():
""" Test that angle GL backend functions appropriately. """
""" Test that angle GL backend functions appropriately. """
if True:
raise SkipTest('Skip Angle functionality test for now.')
if sys.platform.startswith('win'):
raise SkipTest('Can only test angle functionality on Windows.')

_test_functonality('angle')


def _test_functonality(backend):
""" Create app and canvas so we have a context. Then run tests.
"""

# use the backend
gl.use(backend)

# Create app and canvas to get an OpenGL context
app.create()
c = app.Canvas()
c.show()
app.process_events()
app.process_events()

try:
_test_setting_parameters()
_test_enabling_disabling()
Expand Down Expand Up @@ -90,51 +90,50 @@ def _test_setting_stuff():


def _test_object_creation_and_deletion():

# Stuff that is originally glGenX

# Create/delete texture
assert_equal(gl.glIsTexture(1), False)
handle = gl.glCreateTexture()
gl.glBindTexture(gl.GL_TEXTURE_2D, handle)
assert_equal(gl.glIsTexture(handle), True)
gl.glDeleteTexture(handle)
assert_equal(gl.glIsTexture(handle), False)

# Create/delete buffer
assert_equal(gl.glIsBuffer(1), False)
handle = gl.glCreateBuffer()
gl.glBindBuffer(gl.GL_ARRAY_BUFFER, handle)
assert_equal(gl.glIsBuffer(handle), True)
gl.glDeleteBuffer(handle)
assert_equal(gl.glIsBuffer(handle), False)

# Create/delete framebuffer
assert_equal(gl.glIsFramebuffer(1), False)
handle = gl.glCreateFramebuffer()
gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, handle)
assert_equal(gl.glIsFramebuffer(handle), True)
gl.glDeleteFramebuffer(handle)
assert_equal(gl.glIsFramebuffer(handle), False)

# Create/delete renderbuffer
assert_equal(gl.glIsRenderbuffer(1), False)
handle = gl.glCreateRenderbuffer()
gl.glBindRenderbuffer(gl.GL_RENDERBUFFER, handle)
assert_equal(gl.glIsRenderbuffer(handle), True)
gl.glDeleteRenderbuffer(handle)
assert_equal(gl.glIsRenderbuffer(handle), False)



# Stuff that is originally called glCreate

# Create/delete program
assert_equal(gl.glIsProgram(1), False)
handle = gl.glCreateProgram()
assert_equal(gl.glIsProgram(handle), True)
gl.glDeleteProgram(handle)
assert_equal(gl.glIsProgram(handle), False)

# Create/delete shader
assert_equal(gl.glIsShader(1), False)
handle = gl.glCreateShader(gl.GL_VERTEX_SHADER)
Expand Down
29 changes: 17 additions & 12 deletions vispy/gloo/gl/tests/test_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
from vispy.gloo import gl


class _DummyObject:
""" To be able to import angle even in Linux, so that we can test the
names defined inside.
"""
def LoadLibrary(self, fname):
return _DummyObject()

def __getattr__(self, name):
setattr(self, name, self.__class__())
return getattr(self, name)


def _test_function_names(mod):
fnames = set([name for name in dir(mod) if name.startswith('gl')])
assert_equal(function_names.difference(fnames), set())
Expand All @@ -26,18 +38,12 @@ def test_angle():
""" Angle backend should have all ES 2.0 names. No more, no less. """
# Import. Install a dummy lib so that at least we can import angle.
try:
from vispy.gloo.gl import angle
from vispy.gloo.gl import angle # noqa
except Exception:
import ctypes
class _DummyObject:
def LoadLibrary(self, fname):
return _DummyObject()
def __getattr__(self, name):
setattr(self, name, self.__class__())
return getattr(self, name)
ctypes.windll = _DummyObject()
from vispy.gloo.gl import angle
from vispy.gloo.gl import angle # noqa

# Test
_test_function_names(angle)
_test_contant_names(angle)
Expand All @@ -64,7 +70,7 @@ def _main():
test_destop()
test_angle()
test_pyopengl()


# Note: I took these names below from _main and _constants, which is a
# possible cause for error.
Expand Down Expand Up @@ -202,7 +208,6 @@ def _main():
constant_names = [n.strip() for n in constant_names.split(' ')]
constant_names = set([n for n in constant_names if n])


if __name__ == '__main__':
_main()

7 changes: 4 additions & 3 deletions vispy/gloo/gl/tests/test_use.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

from vispy.gloo import gl


def test_use_desktop():
""" Using that gl.use injects all names in gl namespace """

# Use desktop
gl.use('desktop')
#
Expand All @@ -13,7 +14,7 @@ def test_use_desktop():
val1 = getattr(gl, name)
val2 = getattr(gl.desktop, name)
assert_is(val1, val2)

# Use pyopengl
gl.use('pyopengl')
#
Expand All @@ -22,7 +23,7 @@ def test_use_desktop():
val1 = getattr(gl, name)
val2 = getattr(gl.pyopengl, name)
assert_is(val1, val2)

# Use desktop again
gl.use('desktop')
#
Expand Down

0 comments on commit e529c5e

Please sign in to comment.