Skip to content

Commit c18a3fd

Browse files
committed
Hide known warnings from tests.
1 parent 22e2a1a commit c18a3fd

5 files changed

Lines changed: 30 additions & 16 deletions

File tree

tcod/console.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ def blit(self, dest, dest_x=0, dest_y=0,
376376
warnings.warn(
377377
"Parameter names have been moved around, see documentation.",
378378
DeprecationWarning,
379+
stacklevel=2,
379380
)
380381

381382
if key_color or self._key_color:

tests/test_libtcodpy.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,29 @@ def assert_char(console, x, y, ch=None, fg=None, bg=None):
2626
ch = ord(ch)
2727
except TypeError:
2828
pass
29-
assert libtcodpy.console_get_char(console, x, y) == ch
29+
assert console.ch[y, x] == ch
3030
if fg is not None:
31-
assert libtcodpy.console_get_char_foreground(console, x, y) == fg
31+
assert (console.fg[y, x] == fg).all()
3232
if bg is not None:
33-
assert libtcodpy.console_get_char_background(console, x, y) == bg
33+
assert (console.bg[y, x] == bg).all()
3434

3535
def test_console_defaults(console, fg, bg):
3636
libtcodpy.console_set_default_foreground(console, fg)
3737
libtcodpy.console_set_default_background(console, bg)
3838
libtcodpy.console_clear(console)
3939
assert_char(console, 0, 0, None, fg, bg)
4040

41+
@pytest.mark.filterwarnings("ignore:Directly access a consoles")
4142
def test_console_set_char_background(console, bg):
4243
libtcodpy.console_set_char_background(console, 0, 0, bg, libtcodpy.BKGND_SET)
4344
assert_char(console, 0, 0, bg=bg)
4445

46+
@pytest.mark.filterwarnings("ignore:Directly access a consoles")
4547
def test_console_set_char_foreground(console, fg):
4648
libtcodpy.console_set_char_foreground(console, 0, 0, fg)
4749
assert_char(console, 0, 0, fg=fg)
4850

51+
@pytest.mark.filterwarnings("ignore:Directly access a consoles")
4952
def test_console_set_char(console, ch):
5053
libtcodpy.console_set_char(console, 0, 0, ch)
5154
assert_char(console, 0, 0, ch=ch)
@@ -100,15 +103,12 @@ def test_console_fade(console):
100103
libtcodpy.console_get_fade()
101104
libtcodpy.console_get_fading_color()
102105

106+
103107
def assertConsolesEqual(a, b):
104-
for y in range(libtcodpy.console_get_height(a)):
105-
for x in range(libtcodpy.console_get_width(a)):
106-
assert libtcodpy.console_get_char(a, x, y) == \
107-
libtcodpy.console_get_char(b, x, y)
108-
assert libtcodpy.console_get_char_foreground(a, x, y) == \
109-
libtcodpy.console_get_char_foreground(b, x, y)
110-
assert libtcodpy.console_get_char_background(a, x, y) == \
111-
libtcodpy.console_get_char_background(b, x, y)
108+
return ((a.fg[:] == b.fg[:]).all() and
109+
(a.bg[:] == b.bg[:]).all() and
110+
(a.ch[:] == b.ch[:]).all())
111+
112112

113113
def test_console_blit(console, offscreen):
114114
libtcodpy.console_print(offscreen, 0, 0, 'test')
@@ -132,6 +132,7 @@ def test_console_apf_read_write(console, offscreen, tmpdir):
132132
assert libtcodpy.console_load_apf(offscreen, apf_file)
133133
assertConsolesEqual(console, offscreen)
134134

135+
@pytest.mark.filterwarnings("ignore:Directly access a consoles")
135136
def test_console_rexpaint_load_test_file(console):
136137
xp_console = libtcodpy.console_from_xp('libtcod/data/rexpaint/test.xp')
137138
assert xp_console
@@ -180,6 +181,7 @@ def test_console_fill_errors(console):
180181
with pytest.raises(TypeError):
181182
libtcodpy.console_fill_foreground(console, [0], [], [])
182183

184+
@pytest.mark.filterwarnings("ignore:Directly access a consoles")
183185
def test_console_fill(console):
184186
width = libtcodpy.console_get_width(console)
185187
height = libtcodpy.console_get_height(console)
@@ -200,6 +202,7 @@ def test_console_fill(console):
200202
assert fill == ch
201203

202204
@pytest.mark.skipif(not numpy, reason='requires numpy module')
205+
@pytest.mark.filterwarnings("ignore:Directly access a consoles")
203206
def test_console_fill_numpy(console):
204207
width = libtcodpy.console_get_width(console)
205208
height = libtcodpy.console_get_height(console)
@@ -225,6 +228,7 @@ def test_console_fill_numpy(console):
225228
assert fill == fg.tolist()
226229
assert fill == ch.tolist()
227230

231+
@pytest.mark.filterwarnings("ignore:Console array attributes perform better")
228232
def test_console_buffer(console):
229233
buffer = libtcodpy.ConsoleBuffer(
230234
libtcodpy.console_get_width(console),
@@ -236,6 +240,7 @@ def test_console_buffer(console):
236240
buffer.set(0, 0, 0, 0, 0, 0, 0, 0, '@')
237241
buffer.blit(console)
238242

243+
@pytest.mark.filterwarnings("ignore:Console array attributes perform better")
239244
def test_console_buffer_error(console):
240245
buffer = libtcodpy.ConsoleBuffer(0, 0)
241246
with pytest.raises(ValueError):
@@ -253,6 +258,7 @@ def test_mouse(console):
253258
repr(mouse)
254259
libtcodpy.mouse_move(0, 0)
255260

261+
@pytest.mark.filterwarnings("ignore:Use Python's standard 'time' module")
256262
def test_sys_time(console):
257263
libtcodpy.sys_set_fps(0)
258264
libtcodpy.sys_get_fps()
@@ -307,6 +313,7 @@ def test_image(console, tmpdir):
307313

308314
@pytest.mark.parametrize('sample', ['@', u'\u2603']) # Unicode snowman
309315
@pytest.mark.xfail(reason='Unreliable')
316+
@pytest.mark.filterwarnings("ignore:This function does not provide reliable")
310317
def test_clipboard(console, sample):
311318
saved = libtcodpy.sys_clipboard_get()
312319
try:

tests/test_parser.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
import os
44

5+
import pytest
6+
57
import tcod as libtcod
68

9+
@pytest.mark.filterwarnings("ignore:Using this class is not recommended.")
710
def test_parser():
811
print ('***** File Parser test *****')
912
parser=libtcod.parser_new()

tests/test_tcod.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def test_tcod_bsp():
5151
str(bsp)
5252

5353

54+
@pytest.mark.filterwarnings("ignore:Directly access a consoles")
5455
def test_array_read_write(console):
5556
FG = (255, 254, 253)
5657
BG = (1, 2, 3)
@@ -93,7 +94,7 @@ def test_console_defaults(console):
9394
console.default_alignment = tcod.RIGHT
9495
assert console.default_alignment == tcod.RIGHT
9596

96-
97+
@pytest.mark.filterwarnings("ignore:Parameter names have been moved around,")
9798
def test_console_methods(console):
9899
console.put_char(0, 0, ord('@'))
99100
console.print_(0, 0, 'Test')

tests/test_tdl_map.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import unittest
44
import itertools
5+
import pytest
56

67
import tdl
78

@@ -47,14 +48,14 @@ def setUp(self):
4748
for x, ch in enumerate(line):
4849
trans = ch == ' '
4950
self.map.transparent[x,y] = self.map.walkable[x,y] = trans
50-
self.assertEquals(self.map.transparent[x,y], trans)
51-
self.assertEquals(self.map.walkable[x,y], trans)
51+
assert self.map.transparent[x,y] == trans
52+
assert self.map.walkable[x,y] == trans
5253

5354
def test_map_compute_fov(self):
5455
fov = self.map.compute_fov(*self.POINT_A)
55-
self.assertTrue(list(fov), 'should be non-empty')
56+
assert list(fov), 'should be non-empty'
5657
fov = self.map.compute_fov(*self.POINT_A, fov='PERMISSIVE8')
57-
self.assertTrue(list(fov), 'should be non-empty')
58+
assert list(fov), 'should be non-empty'
5859
with self.assertRaises(tdl.TDLError):
5960
self.map.compute_fov(*self.POINT_A, fov='invalid option')
6061

@@ -69,6 +70,7 @@ def test_map_specials(self):
6970
self.assertTrue((x, y) in self.map)
7071
self.assertFalse((-1, -1) in self.map)
7172

73+
@pytest.mark.filterwarnings("ignore:This function is very slow.")
7274
def test_quick_fov(self):
7375
fov = tdl.map.quick_fov(self.POINT_B[0], self.POINT_B[1],
7476
self.map_is_transparant, radius=2.5)

0 commit comments

Comments
 (0)