Skip to content

Commit bafa20b

Browse files
committed
(station/tests) Refactor some test cases to use whole-image comparison
1 parent 81fb6e4 commit bafa20b

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

agrf/lib/building/layout_test.py

+17-14
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
11
import grf
2+
import numpy as np
3+
from PIL import Image
24
from agrf.lib.building.layout import AGroundSprite, ADefaultGroundSprite, ALayout
35
from agrf.lib.building.symmetry import BuildingSymmetrical
46
from agrf.lib.building.image_sprite import image_sprite
57
from agrf.graphics.misc import SCALE_TO_ZOOM
68

9+
temperate_1011 = np.array(Image.open("agrf/third_party/opengfx2/temperate/1011.png"))
10+
temperate_1012 = np.array(Image.open("agrf/third_party/opengfx2/temperate/1012.png"))
11+
12+
13+
gs1012 = ADefaultGroundSprite(1012)
14+
715

816
def test_default_groundsprite():
9-
gs1012 = ADefaultGroundSprite(1012)
17+
assert (temperate_1012 == gs1012.graphics(4, 32).to_image()).all()
1018

11-
graphics = gs1012.graphics(4, 32).to_image()
12-
assert graphics.shape == (127, 256, 4)
13-
assert graphics[64, 128, 1] == 67
1419

15-
m_graphics = gs1012.M.graphics(4, 32).to_image()
16-
assert m_graphics.shape == (127, 256, 4)
17-
assert m_graphics[64, 128, 1] == 72
20+
def test_default_groundsprite_M():
21+
assert (temperate_1011 == gs1012.M.graphics(4, 32).to_image()).all()
1822

19-
r_graphics = gs1012.R.graphics(4, 32).to_image()
20-
assert r_graphics.shape == (127, 256, 4)
21-
assert r_graphics[64, 128, 1] == 67
2223

23-
t_graphics = gs1012.T.graphics(4, 32).to_image()
24-
assert t_graphics.shape == (127, 256, 4)
25-
assert t_graphics[64, 128, 1] == 67
24+
def test_default_groundsprite_R():
25+
assert (temperate_1012 == gs1012.R.graphics(4, 32).to_image()).all()
26+
27+
28+
def test_default_groundsprite_T():
29+
assert (temperate_1012 == gs1012.T.graphics(4, 32).to_image()).all()
2630

2731

2832
def test_groundsprite():
@@ -33,7 +37,6 @@ def test_groundsprite():
3337

3438

3539
def test_layout():
36-
gs1012 = ADefaultGroundSprite(1012)
3740
l = ALayout(gs1012, [], True)
3841

3942
graphics = l.graphics(4, 32).to_image()

0 commit comments

Comments
 (0)