

def check(self, img, colors):
    glClear(GL_COLOR_BUFFER_BIT)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
    img.blit(img.anchor_x, img.anchor_y)
    buffer = image.get_buffer_manager().get_color_buffer().get_image_data()
    bytes = buffer.get_data('RGBA', (buffer.width * 4))

    def sample(x, y):
        i = ((y * buffer.pitch) + (x * len(buffer.format)))
        (r, g, b, _) = bytes[i:(i + len(buffer.format))]
        if (type(r) is str):
            (r, g, b) = map(ord, (r, g, b))
        return {
            (255, 0, 0): 'r',
            (0, 255, 0): 'g',
            (0, 0, 255): 'b',
            (255, 0, 255): 'm',
        }.get((r, g, b), 'x')
    samples = ''.join([sample(3, 3), sample(3, 0), sample(0, 0), sample(0, 3)])
    self.assertTrue((samples == colors), samples)

dataset/ETHPy150Open ardekantur/pyglet/tests/resource/RES_LOAD_IMAGE.py TestCase.check/original