Anonymous avatar Anonymous committed 42a506e

Added sdl and sdlgfx tags. Added tag listing option for test execution.

Comments (0)

Files changed (24)

test/base_bufferproxy_test.py

 import pygame2.sdl.video as video
 
 class BufferProxyTest (unittest.TestCase):
+    __tags__ = [ "sdl" ]
 
     def setUp (self):
         video.init ()

test/freetype_base_test.py

 import pygame2.freetype.base as base
 
 class FreeTypeTest(unittest.TestCase):
+    __tags__ = [ "freetype" ]
 
     def test_pygame2_freetype_base_get_version(self):
 

test/freetype_font_test.py

 FONTDIR = os.path.dirname (os.path.abspath (__file__))
 
 class FreeTypeFontTest(unittest.TestCase):
+    __tags__ = [ "sdl", "freetype" ]
 
     def get_fixed_font (self):
         return ft.Font(os.path.join (FONTDIR, 'test_fixed.otf'))

test/mask_test.py

         self.assertEqual (m.width, 322)
 
     def test_pygame2_mask_from_surface(self):
+        __tags__ = [ "sdl" ]
 
         # __doc__ (as of 2008-11-03) for pygame2.mask.from_surface:
 
         video.quit ()
 
     def test_pygame2_mask_from_threshold(self):
+        __tags__ = [ "sdl" ]
 
         # __doc__ (as of 2008-11-03) for pygame2.mask.from_threshold:
 

test/sdl_audio_test.py

 import pygame2.sdl.constants as constants
 
 class SDLAudioTest (unittest.TestCase):
+    __tags__ = [ "sdl" ]
+
     def test_pygame2_sdl_audio_init(self):
 
         # __doc__ (as of 2009-05-13) for pygame2.sdl.audio.init:

test/sdl_base_test.py

 import pygame2.sdl.constants as constants
 
 class SDLTest (unittest.TestCase):
+    __tags__ = [ "sdl" ]
 
     def test_pygame2_sdl_base_get_compiled_version(self):
 

test/sdl_cdrom_test.py

     from util.testutils import interactive, doprint
 
 class SDLCDRomTest (unittest.TestCase):
+    __tags__ = [ "sdl" ]
 
     def todo_test_pygame2_sdl_cdrom_CD_close(self):
 

test/sdl_cursors_test.py

 import pygame2.sdl.constants as constants
 
 class SDLCursorsTest (unittest.TestCase):
+    __tags__ = [ "sdl" ]
 
     def todo_test_pygame2_sdl_cursors_compile(self):
 

test/sdl_event_test.py

 import pygame2.sdl.constants as constants
 
 class SDLEventTest (unittest.TestCase):
+    __tags__ = [ "sdl" ]
 
     def test_pygame2_sdl_event_Event (self):
         # check argument handling

test/sdl_gl_test.py

 import pygame2.sdl.constants as constants
 
 class SDLGLTest (unittest.TestCase):
+    __tags__ = [ "sdl" ]
 
     def _get_gllib (self):
         gllib = ""

test/sdl_image_test.py

 import pygame2.sdl.constants as constants
 
 class SDLImageTest (unittest.TestCase):
+    __tags__ = [ "sdl" ]
 
     def setUp (self):
         video.init ()

test/sdl_joystick_test.py

 import pygame2.sdl.constants as constants
 
 class SDLJoystickTest (unittest.TestCase):
+    __tags__ = [ "sdl" ]
 
     def todo_test_pygame2_sdl_joystick_Joystick_close(self):
 

test/sdl_keyboard_test.py

 import pygame2.sdl.constants as constants
 
 class SDLKeyboardTest (unittest.TestCase):
+    __tags__ = [ "sdl" ]
 
     def setUp (self):
         video.init ()

test/sdl_mouse_test.py

 import pygame2.sdl.constants as constants
 
 class SDLMouseTest (unittest.TestCase):
+    __tags__ = [ "sdl" ]
 
     def todo_test_pygame2_sdl_mouse_get_position(self):
 

test/sdl_time_test.py

 import pygame2.sdl.constants as constants
 
 class SDLTimeTest (unittest.TestCase):
+    __tags__ = [ "sdl" ]
 
     def test_pygame2_sdl_time_add_timer(self):
 

test/sdl_video_overlay_test.py

 import pygame2.sdl.constants as constants
 
 class SDLVideoOverlayTest (unittest.TestCase):
+    __tags__ = [ "sdl" ]
 
     def todo_test_pygame2_sdl_video_Overlay_display(self):
 

test/sdl_video_pixelformat_test.py

 import pygame2.sdl.constants as constants
 
 class SDLVideoPixelFormatTest (unittest.TestCase):
+    __tags__ = [ "sdl" ]
 
     def test_pygame2_sdl_video_PixelFormat_alpha(self):
 

test/sdl_video_surface_blit_test.py

 import pygame2.sdl.constants as constants
 
 class SDLVideoSurfaceBlitTest (unittest.TestCase):
+    __tags__ = [ "sdl" ]
+
     # __doc__ (as of 2009-05-15) for pygame2.sdl.video.Surface.blit:
 
     # blit (srcsurface[, destrect, srcrect, blendargs]) -> Rect

test/sdl_video_surface_test.py

 import pygame2.sdl.constants as constants
 
 class SDLVideoSurfaceTest (unittest.TestCase):
+    __tags__ = [ "sdl" ]
 
     def _cmppixels (self, sf1, sf2):
         # Simple pixel comparision
                 self.failUnlessEqual (getat (x, y), c,
                     failmsg % (getat (x, y), c, x, y))
 
-
     def setUp (self):
         video.init ()
 

test/sdl_video_test.py

 import pygame2.sdl.constants as constants
 
 class SDLVideoTest (unittest.TestCase):
+    __tags__ = [ "sdl" ]
 
     def test_pygame2_sdl_video_get_drivername(self):
 

test/sdl_wm_test.py

     from util.testutils import interactive
 
 class SDLWMTest (unittest.TestCase):
+    __tags__ = [ "sdl" ]
 
     def setUp (self):
         video.init ()

test/sdlgfx_base_test.py

 import pygame2.sdlgfx.constants as constants
 
 class SDLGfxTest (unittest.TestCase):
+    __tags__ = [ "sdl", "sdlgfx" ]
 
     def test_pygame2_sdlgfx_base_FPSmanager (self):
         manager = base.FPSmanager ()

test/util/runtests.py

 def printerror ():
     print (traceback.format_exc ())
 
+
 def include_tag (option, opt, value, parser, *args, **kwargs):
     try:
         if args:
     if value not in EXCLUDETAGS:
         EXCLUDETAGS.append (value)
 
+def list_tags (option, opt, value, parser, *args, **kwargs):
+    alltags = []
+    testsuites = []
+    testdir, testfiles = gettestfiles ()
+    testloader = unittest.defaultTestLoader
+
+    for test in testfiles:
+        try:
+            testmod = os.path.splitext (test)[0]
+            glob, loc = {}, {}
+            package = __import__ (testmod, glob, loc)
+            try:
+                testsuites.append (loadtests_frompkg (package, testloader))
+            except:
+                printerror()
+        except:
+            pass
+    for suite in testsuites:
+        for test in suite:
+            if hasattr (test, "__tags__"):
+                tags = getattr (test, "__tags__")
+                for tag in tags:
+                    if tag not in alltags:
+                        alltags.append (tag)
+    print (alltags)
+    sys.exit ()
+
 def create_options ():
     """Create the accepatble options for the test runner."""
     optparser = optparse.OptionParser ()
     optparser.add_option ("-e", "--exclude", action="callback",
                           callback=exclude_tag, type="string",
                           help="exclude test containing the tag")
+    optparser.add_option ("-T", "--listtags", action="callback",
+                          callback=list_tags,
+                          help="lists all available tags and exits")
     optkeys = [
         "subprocess",
         "random",
         testfiles.sort ()
     return testdir, testfiles
 
+def loadtests_frompkg (package, loader):
+    for x in dir (package):
+        val = package.__dict__[x]
+        if hasattr (val, "setUp") and hasattr (val, "tearDown"):
+            # might be a test.
+            return loader.loadTestsFromTestCase (val)
+
 def loadtests (test, testdir, writer, loader, options):
     """Loads a test."""
     suites = []
             writer.writeline ("Loading tests from [%s] ..." % testmod)
         else:
             writer.writesame ("Loading tests from [%s] ..." % testmod)
-        for x in dir (package):
-            val = package.__dict__[x]
-            if hasattr (val, "setUp") and hasattr (val, "tearDown"):
-                # might be a test.
-                try:
-                    tests = loader.loadTestsFromTestCase (val)
-                    suites.append (tests)
-                    # TODO: provide a meaningful error information about
-                    # the failure.
-                except:
-                    printerror ()
+        try:
+            suites.append (loadtests_frompkg (package, loader))
+        except:
+            printerror ()
     except:
         printerror ()
     return suites
     for key in optkeys:
         writer.writeline ("                '%s' = '%s'" %
                           (key, getattr (options, key)))
+    writer.writeline ("                'excludetags' = '%s'" % EXCLUDETAGS)
     writer.writeline ("Time taken:     %.3f seconds" % timetaken)
     writer.writeline ("Tests executed: %d " % testcount)
     writer.writeline ("Tests OK:       %d " % ok)

test/util/testrunner.py

                     if t in self.excludetags:
                         return False
             return True
-        
+
+        if hasattr (testCaseClass, "__tags__"):
+            tags = getattr (testCaseClass, "__tags__")
+            for t in tags:
+                if t in self.excludetags:
+                    return []
+
         testFnNames = list (filter(isTestMethod, dir(testCaseClass)))
         cmpkey = None
         if hasattr (unittest, "_CmpToKey"):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.