It seems to me once the failure is reliably repeatable it should be fairly straightforward to debug, right?
...but I'm a bit confused, looking at the test that is failing, I'm not sure how that could be considered a repeatable test... with 8 bpp, don't you have to set a palette? the SDL docs SDL_CreateRGBSurface say: "If depth is 8 bits an empty palette is allocated for the surface" - and set_at is calling SDL_MapRGBA which will map the (255, 255, 255) tuple to the closest index in the palette. Also, the "in" operator on PixelArray objects always works on palette indices for 8 bit (if given a color tuple it will call SDL_MapRGBA to map it to a palette index as well). So isn't the exact behavior dependent on the values of an "empty palette"? So given that the palette is undefined, why shouldn't (255,255,255) map to index 255 (0x000000ff)? And why shouldn't 0x000000ff exist as a member of the array in that case? likewise why shouldn't (0,0,0) map to index 255? So Lenard, when the test fails what does sf.map_rgb((255,255,255)) return? does it return 255? how about sf.map_rgb((0,0,0))? check out this script designed to demonstrate a pathologically bad case for this test (and why wouldn't the palette be as I set it up in the script given that it's undefined?) ---------------- import pygame pygame.display.init() sf = pygame.Surface ((10, 20), 0, 8) palette = [] for i in xrange(255): palette.append((0,0,0)) palette.append((255,255,255)) sf.set_palette(palette) print "white maps to:",sf.map_rgb((255,255,255)) print "yellow maps to:",sf.map_rgb((255,255,0)) print "black maps to:",sf.map_rgb((0,0,0)) sf.fill ((0, 0, 0)) sf.set_at ((8, 8), (255, 255, 255)) ar = pygame.PixelArray (sf) print (0, 0, 0) in ar print (255, 255, 255) in ar print (255, 255, 0) in ar print 0x0000ff in ar On Tue, Feb 26, 2008 at 12:14 AM, Lenard Lindstrom <[EMAIL PROTECTED]> wrote: > def test_contains (self): > print 'x', > for bpp in (8, 16, 24, 32): > sf = pygame.Surface ((10, 20), 0, bpp) > sf.fill ((0, 0, 0)) > sf.set_at ((8, 8), (255, 255, 255)) > > ar = pygame.PixelArray (sf) > self.assertTrue ((0, 0, 0) in ar) > self.assertTrue ((255, 255, 255) in ar) > self.assertFalse ((255, 255, 0) in ar) > self.assertFalse (0x0000ff in ar) > > # Test sliced array > self.assertTrue ((0, 0, 0) in ar[8]) > self.assertTrue ((255, 255, 255) in ar[8]) > self.assertFalse ((255, 255, 0) in ar[8]) > self.assertFalse (0x0000ff in ar[8]) >