Skip to content

Commit fc2ba4f

Browse files
committed
Handle warnings better in deprecated tests.
Remove outdated doctest which was fully deprecated.
1 parent 21c93c1 commit fc2ba4f

File tree

5 files changed

+15
-23
lines changed

5 files changed

+15
-23
lines changed

tcod/console.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,11 @@ def rgba(self) -> NDArray[Any]:
304304
305305
Example:
306306
>>> con = tcod.console.Console(10, 2)
307+
>>> WHITE, BLACK = (255, 255, 255), (0, 0, 0)
307308
>>> con.rgba[0, 0] = (
308309
... ord("X"),
309-
... (*tcod.white, 255),
310-
... (*tcod.black, 255),
310+
... (*WHITE, 255),
311+
... (*BLACK, 255),
311312
... )
312313
>>> con.rgba[0, 0]
313314
(88, [255, 255, 255, 255], [ 0, 0, 0, 255])
@@ -328,10 +329,11 @@ def rgb(self) -> NDArray[Any]:
328329
329330
Example:
330331
>>> con = tcod.console.Console(10, 2)
331-
>>> con.rgb[0, 0] = ord("@"), tcod.yellow, tcod.black
332+
>>> BLUE, YELLOW, BLACK = (0, 0, 255), (255, 255, 0), (0, 0, 0)
333+
>>> con.rgb[0, 0] = ord("@"), YELLOW, BLACK
332334
>>> con.rgb[0, 0]
333335
(64, [255, 255, 0], [0, 0, 0])
334-
>>> con.rgb["bg"] = tcod.blue
336+
>>> con.rgb["bg"] = BLUE
335337
>>> con.rgb[0, 0]
336338
(64, [255, 255, 0], [ 0, 0, 255])
337339
@@ -916,7 +918,7 @@ def __repr__(self) -> str:
916918
self.width,
917919
self.height,
918920
self._order,
919-
self.tiles,
921+
self.rgba,
920922
)
921923

922924
def __str__(self) -> str:

tcod/libtcodpy.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3260,19 +3260,6 @@ def line_where(x1: int, y1: int, x2: int, y2: int, inclusive: bool = True) -> tu
32603260
32613261
If `inclusive` is true then the start point is included in the result.
32623262
3263-
Example:
3264-
>>> where = tcod.line_where(1, 0, 3, 4)
3265-
>>> where
3266-
(array([1, 1, 2, 2, 3]...), array([0, 1, 2, 3, 4]...))
3267-
>>> array = np.zeros((5, 5), dtype=np.int32)
3268-
>>> array[where] = np.arange(len(where[0])) + 1
3269-
>>> array
3270-
array([[0, 0, 0, 0, 0],
3271-
[1, 2, 0, 0, 0],
3272-
[0, 0, 3, 4, 0],
3273-
[0, 0, 0, 0, 5],
3274-
[0, 0, 0, 0, 0]]...)
3275-
32763263
.. versionadded:: 4.6
32773264
32783265
.. deprecated:: 11.14

tests/test_console.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ def test_console_repr() -> None:
106106
eval(repr(tcod.console.Console(10, 2)))
107107

108108

109-
@pytest.mark.filterwarnings("ignore")
110109
def test_console_str() -> None:
111110
console = tcod.console.Console(10, 2)
112111
console.ch[:] = ord(".")
113-
console.print_(0, 0, "Test")
112+
with pytest.warns():
113+
console.print_(0, 0, "Test")
114114
assert str(console) == ("<Test......\n" " ..........>")
115115

116116

@@ -161,4 +161,5 @@ def test_draw_frame() -> None:
161161

162162
console.draw_frame(0, 0, 3, 3, decoration=(49, 50, 51, 52, 53, 54, 55, 56, 57))
163163
assert console.ch.tolist() == [[49, 50, 51], [52, 53, 54], [55, 56, 57]]
164-
console.draw_frame(0, 0, 3, 3, title="T")
164+
with pytest.warns():
165+
console.draw_frame(0, 0, 3, 3, title="T")

tests/test_deprecated.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33

44
import pytest
55

6-
import libtcodpy
76
import tcod
87
import tcod.event
98
import tcod.libtcodpy
109

10+
with pytest.warns():
11+
import libtcodpy
12+
1113
# ruff: noqa: D103
1214

1315

tests/test_tcod.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def raise_Exception(*args: object) -> NoReturn:
1919

2020
def test_line_error() -> None:
2121
"""Test exception propagation."""
22-
with pytest.raises(RuntimeError):
22+
with pytest.raises(RuntimeError), pytest.warns():
2323
tcod.line(0, 0, 10, 10, py_callback=raise_Exception)
2424

2525

0 commit comments

Comments
 (0)