Index: Lib/test/test_gl.py =================================================================== --- Lib/test/test_gl.py (revisione 60620) +++ Lib/test/test_gl.py (copia locale) @@ -1,10 +1,13 @@ -#! /usr/bin/env python """Very simple test script for the SGI gl library extension module - taken mostly from the documentation. - Roger E. Masse +taken mostly from the documentation. + +Roger E. Masse """ -from test.test_support import verbose, TestSkipped + + +from test.test_support import verbose, TestSkipped, run_unittest import gl, GL, time +import unittest glattrs = ['RGBcolor', 'RGBcursor', 'RGBmode', 'RGBrange', 'RGBwritemask', '__doc__', '__name__', 'addtopup', 'altgetmatrix', 'arc', 'arcf', @@ -81,70 +84,79 @@ 'xfpt4s', 'xfpti', 'xfpts', 'zbuffer', 'zclear', 'zdraw', 'zfunction', 'zsource', 'zwritemask'] -def main(): - # insure that we at least have an X display before continuing. - import os - try: - display = os.environ['DISPLAY'] - except: - raise TestSkipped, "No $DISPLAY -- skipping gl test" - # touch all the attributes of gl without doing anything - if verbose: - print 'Touching gl module attributes...' - for attr in glattrs: +class TestGl(unittest.TestCase): + + def test_touch_attributes(self): + # touch all the attributes of gl without doing anything if verbose: - print 'touching: ', attr - getattr(gl, attr) + print 'Touching gl module attributes...' + for attr in glattrs: + if verbose: + print 'touching: ', attr + getattr(gl, attr) + + def test_create_window(self): + # insure that we at least have an X display before continuing. + import os + try: + display = os.environ['DISPLAY'] + except: + raise TestSkipped, "No $DISPLAY -- skipping gl test" + # create a small 'Crisscross' window + if verbose: + print 'Creating a small "CrissCross" window...' + print 'foreground' + gl.foreground() + if verbose: + print 'prefposition' + gl.prefposition(500, 900, 500, 900) + if verbose: + print 'winopen "CrissCross"' + w = gl.winopen('CrissCross') + if verbose: + print 'clear' + gl.clear() + if verbose: + print 'ortho2' + gl.ortho2(0.0, 400.0, 0.0, 400.0) + if verbose: + print 'color WHITE' + gl.color(GL.WHITE) + if verbose: + print 'color RED' + gl.color(GL.RED) + if verbose: + print 'bgnline' + gl.bgnline() + if verbose: + print 'v2f' + gl.v2f(0.0, 0.0) + gl.v2f(400.0, 400.0) + if verbose: + print 'endline' + gl.endline() + if verbose: + print 'bgnline' + gl.bgnline() + if verbose: + print 'v2i' + gl.v2i(400, 0) + gl.v2i(0, 400) + if verbose: + print 'endline' + gl.endline() + if verbose: + print 'Displaying window for 2 seconds...' + time.sleep(2) + if verbose: + print 'winclose' + gl.winclose(w) - # create a small 'Crisscross' window - if verbose: - print 'Creating a small "CrissCross" window...' - print 'foreground' - gl.foreground() - if verbose: - print 'prefposition' - gl.prefposition(500, 900, 500, 900) - if verbose: - print 'winopen "CrissCross"' - w = gl.winopen('CrissCross') - if verbose: - print 'clear' - gl.clear() - if verbose: - print 'ortho2' - gl.ortho2(0.0, 400.0, 0.0, 400.0) - if verbose: - print 'color WHITE' - gl.color(GL.WHITE) - if verbose: - print 'color RED' - gl.color(GL.RED) - if verbose: - print 'bgnline' - gl.bgnline() - if verbose: - print 'v2f' - gl.v2f(0.0, 0.0) - gl.v2f(400.0, 400.0) - if verbose: - print 'endline' - gl.endline() - if verbose: - print 'bgnline' - gl.bgnline() - if verbose: - print 'v2i' - gl.v2i(400, 0) - gl.v2i(0, 400) - if verbose: - print 'endline' - gl.endline() - if verbose: - print 'Displaying window for 2 seconds...' - time.sleep(2) - if verbose: - print 'winclose' - gl.winclose(w) -main() +def test_main(): + run_unittest(TestGl) + +if __name__ == '__main__': + test_main() +