Commits

Lenard Lindstrom committed e635eb9

make pygame.tests.__init__.py import __main__.py. This is done consistently with other pygame.tests modules

  • Participants
  • Parent commits 11a3312

Comments (0)

Files changed (1)

     from pygame.tests.test_utils.run_tests import run
 elif __name__ == '__main__':
     import os
-    pkg_dir = os.path.dirname(os.path.abspath(__file__))
-    main = os.path.join(pkg_dir, '__main__.py')
-    execfile(main)
+    import sys
+    pkg_dir = os.path.split(os.path.abspath(__file__))[0]
+    parent_dir, pkg_name = os.path.split(pkg_dir)
+    is_pygame_pkg = (pkg_name == 'tests' and
+                     os.path.split(parent_dir)[1] == 'pygame')
+    if not is_pygame_pkg:
+        sys.path.insert(0, parent_dir)
+
+    if is_pygame_pkg:
+        import pygame.tests.__main__
+    else:
+        import test.__main__
 else:
     from test.test_utils.run_tests import run