Skip to content

Commit d11f17d

Browse files
committed
Add pickle test for v13 Random.
The internal C type will have a slight change, so the old format needs to stay supported.
1 parent 0fa7240 commit d11f17d

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ include *.py *.cfg *.txt *.rst *.toml
33
recursive-include tcod *.py *.c *.h
44

55
recursive-include libtcod/src *.glsl* *.c *.h
6-
include libtcod/*.txt libtcod/*.md
6+
include libtcod/*.txt libtcod/*.md tests/data/*.pkl
77

88
exclude tcod/*/SDL2.dll

tests/data/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Data files for tests, such as old pickle streams.
2+
3+
Remember to add new file types to `MANIFEST.in`.

tests/data/random_v13.pkl

11.8 KB
Binary file not shown.

tests/test_random.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import copy
2+
import pathlib
23
import pickle
34

45
import tcod
@@ -26,3 +27,10 @@ def test_tcod_random_pickle() -> None:
2627
assert rand.uniform(0, 1) == rand2.uniform(0, 1)
2728
assert rand.uniform(0, 1) == rand2.uniform(0, 1)
2829
assert rand.uniform(0, 1) == rand2.uniform(0, 1)
30+
31+
32+
def test_load_rng_v13() -> None:
33+
with open(pathlib.Path(__file__).parent / "data/random_v13.pkl", "rb") as f:
34+
rand: tcod.random.Random = pickle.load(f)
35+
assert rand.randint(0, 0xFFFF) == 56422
36+
assert rand.randint(0, 0xFFFF) == 15795

0 commit comments

Comments
 (0)