Example #1
0
    def test_set_error(self):

        self.assertEqual(pygame.get_error(), "")
        pygame.set_error("hi")
        self.assertEqual(pygame.get_error(), "hi")
        pygame.set_error("")
        self.assertEqual(pygame.get_error(), "")
Example #2
0
    def test_set_error(self):

        self.assertEqual(pygame.get_error(), "")
        pygame.set_error("hi")
        self.assertEqual(pygame.get_error(), "hi")
        pygame.set_error("")
        self.assertEqual(pygame.get_error(), "")
Example #3
0
    def test_get_error(self):

        # __doc__ (as of 2008-08-02) for pygame.base.get_error:

        # pygame.get_error(): return errorstr
        # get the current error message
        #
        # SDL maintains an internal error message. This message will usually
        # be given to you when pygame.error is raised. You will rarely need to
        # call this function.
        #

        e = pygame.get_error()
        self.assertTrue(
            e == "" or
            # This may be returned by SDL_mixer built with
            # FluidSynth support. Setting environment variable
            # SDL_SOUNDFONTS to the path of a valid sound font
            # file removes the error message.
            e == "No SoundFonts have been requested",
            e)
        pygame.set_error("hi")
        self.assertEqual(pygame.get_error(), "hi")
        pygame.set_error("")
        self.assertEqual(pygame.get_error(), "")
Example #4
0
def main():
    numpass, numfail = pg.init()
    print(f'pass:{numpass}, fail:{numfail}')

    inited = pg.get_init()
    print(f'Inited: {inited}')

    try:
        raise pg.error('Custom Error')
    except RuntimeError as re:
        print(f'Exception: {re}')

    pg.set_error('Set Error')
    err = pg.get_error()
    print(f'Error: {err}')

    major, minor, path = pg.get_sdl_version()
    print(f'SDL: {major}.{minor}.{path}')

    pg.register_quit(quit)

    unencoded = '你好'
    encoded = pg.encode_string(unencoded, encoding='utf-8')
    print(f'Encoded: {encoded}, Original: {unencoded}')

    encoded_path = pg.encode_file_path(os.path.join(__file__))
    print(f'Encoded Path: {encoded_path}')

    print(f'{pg.version.PygameVersion(1, 2, 3)}, {pg.vernum}')
Example #5
0
    def test_get_error(self):

        # __doc__ (as of 2008-08-02) for pygame.base.get_error:

          # pygame.get_error(): return errorstr
          # get the current error message
          #
          # SDL maintains an internal error message. This message will usually
          # be given to you when pygame.error is raised. You will rarely need to
          # call this function.
          #

        e = pygame.get_error()
        self.assertTrue(e == "" or
                        # This may be returned by SDL_mixer built with
                        # FluidSynth support. Setting environment variable
                        # SDL_SOUNDFONTS to the path of a valid sound font
                        # file removes the error message.
                        e == "No SoundFonts have been requested" or
                        e.startswith("Failed to access the SoundFont"),
                        e)
        pygame.set_error("hi")
        self.assertEqual(pygame.get_error(), "hi")
        pygame.set_error("")
        self.assertEqual(pygame.get_error(), "")
Example #6
0
    def test_set_error(self):

        # The first error could be all sorts of nonsense or empty.
        e = pygame.get_error()
        pygame.set_error("hi")
        self.assertEqual(pygame.get_error(), "hi")
        pygame.set_error("")
        self.assertEqual(pygame.get_error(), "")
Example #7
0
    def test_set_error(self):

        # The first error could be all sorts of nonsense or empty.
        e = pygame.get_error()
        pygame.set_error("hi")
        self.assertEqual(pygame.get_error(), "hi")
        pygame.set_error("")
        self.assertEqual(pygame.get_error(), "")
Example #8
0
 def test_unicode_error(self):
     if sys.version_info.major > 2:
         pygame.set_error(u"你好")
         self.assertEqual(u"你好", pygame.get_error())
     else:
         # no unicode objects for now
         pygame.set_error(u"你好")
         encstr = u"你好".encode("utf8")
         self.assertEqual(encstr, pygame.get_error())
Example #9
0
 def test_unicode_error(self):
     if sys.version_info.major > 2:
         pygame.set_error(u'你好')
         self.assertEqual(u'你好', pygame.get_error())
     else:
         # no unicode objects for now
         pygame.set_error(u'你好')
         encstr = u'你好'.encode('utf8')
         self.assertEqual(encstr, pygame.get_error())
Example #10
0
    def test_set_error(self):

        e = pygame.get_error()
        self.assertTrue(e == "" or
                        # This may be returned by SDL_mixer built with
                        # FluidSynth support. Setting environment variable
                        # SDL_SOUNDFONTS to the path of a valid sf2 file
                        # removes the error message.
                        e == "No SoundFonts have been requested",
                        e)
        pygame.set_error("hi")
        self.assertEqual(pygame.get_error(), "hi")
        pygame.set_error("")
        self.assertEqual(pygame.get_error(), "")
Example #11
0
    def test_set_error(self):

        e = pygame.get_error()
        self.assertTrue(e == "" or
                        # This may be returned by SDL_mixer built with
                        # FluidSynth support. Setting environment variable
                        # SDL_SOUNDFONTS to the path of a valid sf2 file
                        # removes the error message.
                        e == "No SoundFonts have been requested",
                        e)
        pygame.set_error("hi")
        self.assertEqual(pygame.get_error(), "hi")
        pygame.set_error("")
        self.assertEqual(pygame.get_error(), "")
Example #12
0
    def test_get_error(self):

        # __doc__ (as of 2008-08-02) for pygame.base.get_error:

          # pygame.get_error(): return errorstr
          # get the current error message
          # 
          # SDL maintains an internal error message. This message will usually
          # be given to you when pygame.error is raised. You will rarely need to
          # call this function.
          # 

        self.assertEqual(pygame.get_error(), "")
        pygame.set_error("hi")
        self.assertEqual(pygame.get_error(), "hi")
        pygame.set_error("")
        self.assertEqual(pygame.get_error(), "")
Example #13
0
    def test_get_error(self):

        # __doc__ (as of 2008-08-02) for pygame.base.get_error:

        # pygame.get_error(): return errorstr
        # get the current error message
        #
        # SDL maintains an internal error message. This message will usually
        # be given to you when pygame.error is raised. You will rarely need to
        # call this function.
        #

        self.assertEqual(pygame.get_error(), "")
        pygame.set_error("hi")
        self.assertEqual(pygame.get_error(), "hi")
        pygame.set_error("")
        self.assertEqual(pygame.get_error(), "")
Example #14
0
 def test_unicode_error(self):
     pygame.set_error("你好")
     self.assertEqual("你好", pygame.get_error())