@@ -79,25 +79,12 @@ def getUndrawables(self, console=None):
7979 if console is None :
8080 console = self .console
8181 w , h = console .getSize ()
82- RANGE = ERROR_RANGE # distance from bounds to test, just needs to be some moderate number
83- results = []
84- for _ in range (8 ):
85- for x , y in [(- 1 , 0 ), (1 , 0 ), (0 , - 1 ), (0 , 1 ), # every side
86- (- 1 , - 1 ), (- 1 , 1 ), (1 , 1 ), (1 , - 1 )]: # every corner
87- if x == - 1 :
88- x = random .randint (- RANGE , - 1 ) # over left bound
89- elif x == 1 :
90- x = random .randint (w + 1 , w + RANGE ) # over right bound
91- else :
92- x = random .randint (0 , w ) # within bounds
93- if y == - 1 :
94- y = random .randint (- RANGE , - 1 )
95- elif y == 1 :
96- y = random .randint (h + 1 , h + RANGE )
97- else :
98- y = random .randint (0 , h )
99- results .append ((x , y ))
100- return results
82+ for y in range (- 1 , h + 1 ):
83+ yield - w - 1 , y
84+ yield w , y
85+ for x in range (0 , w ):
86+ yield x , h
87+ yield x , - h - 1
10188
10289 def compareConsoles (self , consoleA , consoleB , errorMsg = 'colors should be the same' ):
10390 "Compare two console assuming they match and failing if they don't"
@@ -182,12 +169,12 @@ def test_drawCharWebcolor(self):
182169 for (x ,y ), data in record .items ():
183170 self .assertEqual (data , self .console .getChar (x , y ), 'drawChar should not overwrite any other tiles' )
184171
185- # @unittest.skipIf(not __debug__, 'python run with optimized flag, skipping an AssertionError test')
186- # def test_drawCharErrors(self):
187- # "test out of bounds assertion errors"
188- # for x,y in self.getUndrawables():
189- # with self.assertRaisesRegexp(AssertionError, r"\(%i, %i\)" % (x, y)):
190- # self.console.drawChar(x, y, *(self.getRandomCharacter()))
172+ @unittest .skipIf (not __debug__ , 'python run with optimized flag, skipping an AssertionError test' )
173+ def test_drawCharErrors (self ):
174+ "test out of bounds assertion errors"
175+ for x ,y in self .getUndrawables ():
176+ with self .assertRaisesRegexp (AssertionError , r"\(%i, %i\)" % (x , y )):
177+ self .console .drawChar (x , y , * (self .getRandomCharacter ()))
191178
192179 def test_drawStrArray (self ):
193180 """strings will raise errors if they pass over the end of the console.
0 commit comments