7
7
8
8
import os
9
9
import pytest
10
+ from pathlib import Path
10
11
11
12
from pecs_framework import Engine
12
13
from pecs_framework .base_system import BaseSystem , Loop
25
26
import json
26
27
27
28
28
- TEST_DIR = os . path . dirname ( __file__ )
29
- PREFABS = os . path . join (TEST_DIR , 'prefabs' )
29
+ TEST_DIR = Path ( __file__ ). parent . resolve ( )
30
+ PREFABS = Path (TEST_DIR , 'prefabs' )
30
31
31
32
32
33
class MovementSystem (BaseSystem ):
@@ -64,9 +65,6 @@ def post_update(self) -> None:
64
65
pass
65
66
66
67
67
- #! TESTS ======================================================================
68
- #! ----------------------------------------------------------------------------
69
-
70
68
@pytest .fixture (scope = "function" )
71
69
def ecs () -> Engine :
72
70
ecs = Engine (loader = loader )
@@ -132,7 +130,6 @@ def prefab() -> str:
132
130
return definition
133
131
134
132
135
- #* PASSING
136
133
def test_entity_creation (ecs : Engine , caplog ) -> None :
137
134
"""
138
135
Test that the Entity instances we created exist and are accessible via the
@@ -148,7 +145,7 @@ def test_entity_creation(ecs: Engine, caplog) -> None:
148
145
assert all ([e1 , e2 , e3 , e4 , e5 ])
149
146
150
147
151
- # #* PASSING
148
+ pytest . mark . skipif ( os . environ . get ( "ENVIRONMENT" ) == "Github" )
152
149
def test_component_registration (ecs : Engine ) -> None :
153
150
"""
154
151
Test that specific Component types exist in the ECS Engine and that their
@@ -176,7 +173,6 @@ def test_component_registration(ecs: Engine) -> None:
176
173
assert velocity .cbit == 6
177
174
178
175
179
- #* PASSING
180
176
def test_component_attachment (ecs : Engine ) -> None :
181
177
"""
182
178
Test that our Component attachments were successful by checking that the
@@ -199,7 +195,6 @@ def test_component_attachment(ecs: Engine) -> None:
199
195
assert utils .owns_component (e1 , e1_position )
200
196
201
197
202
- #* PASSING
203
198
def test_component_instantiation (ecs : Engine ) -> None :
204
199
"""
205
200
Test that a Component that is attached to an Entity was instantiated with
@@ -213,7 +208,6 @@ def test_component_instantiation(ecs: Engine) -> None:
213
208
assert e1_position .y == 10
214
209
215
210
216
- #* PASSING
217
211
def test_component_removal (ecs : Engine ) -> None :
218
212
"""
219
213
Test that a Component that is attached to an Entity was removed when a
@@ -226,7 +220,6 @@ def test_component_removal(ecs: Engine) -> None:
226
220
assert not ecs .components .has (e3 , Position )
227
221
228
222
229
- #* PASSING
230
223
def test_entity_destruction (ecs : Engine ) -> None :
231
224
"""
232
225
Test that an Entity that currently exists in the Domain is destroyed when
@@ -251,7 +244,6 @@ def test_entity_destruction(ecs: Engine) -> None:
251
244
assert entity3 .eid not in domain .entities .keys ()
252
245
253
246
254
- #* PASSING
255
247
def test_component_destruction_with_entity (ecs : Engine ) -> None :
256
248
"""
257
249
Test that when an Entity is destroyed, all of its attached Components are
@@ -276,17 +268,16 @@ def test_component_destruction_with_entity(ecs: Engine) -> None:
276
268
assert frozen .entity_id == ''
277
269
278
270
279
- # TODO
271
+ pytest . mark . skip ( reason = "todo" )
280
272
def test_on_component_added (ecs : Engine ) -> None :
281
273
pass
282
274
283
275
284
- # TODO
276
+ pytest . mark . skip ( reason = "todo" )
285
277
def test_on_component_removed (ecs : Engine ) -> None :
286
278
pass
287
279
288
280
289
- #* PASSING
290
281
def test_multidomain (ecs : Engine ) -> None :
291
282
"""
292
283
Test the Domain switching feature.
@@ -301,7 +292,6 @@ def test_multidomain(ecs: Engine) -> None:
301
292
assert ecs .domain == ecs ._domains ['World' ]
302
293
303
294
304
- #* PASSING
305
295
def test_component_query (ecs : Engine ) -> None :
306
296
"""
307
297
Test Component querying. This is crucial to system creation and the heart
@@ -321,7 +311,6 @@ def test_component_query(ecs: Engine) -> None:
321
311
assert len (movable .result ) == 1
322
312
323
313
324
- #* PASSING
325
314
def test_system_behavior (ecs : Engine ) -> None :
326
315
"""
327
316
Test that a system using a Query can modify the state of Component
@@ -371,18 +360,15 @@ def test_entity_events(ecs: Engine) -> None:
371
360
assert e2 [Health ].current == e2 [Health ].maximum - 15
372
361
373
362
374
- #* PASSING
375
363
def test_component_loader (ecs : Engine ) -> None :
376
364
assert len (ecs .components ._map ) == 7
377
365
378
366
379
- # TODO
367
+ pytest . mark . skip ( reason = "todo" )
380
368
def test_serialization (ecs : Engine ) -> None :
381
- # ecs.serialize()
382
369
pass
383
370
384
371
385
- #* PASSING
386
372
def test_deserialization (ecs : Engine , prefab : str ) -> None :
387
373
"""Test prefab definition unpacking into the correct objects."""
388
374
template : EntityTemplate = ecs .prefabs .deserialize (prefab )
@@ -392,7 +378,6 @@ def test_deserialization(ecs: Engine, prefab: str) -> None:
392
378
assert len (template .components ) == 3
393
379
394
380
395
- #* PASSING
396
381
def test_prefab (ecs : Engine , prefab : str ) -> None :
397
382
template : EntityTemplate = ecs .prefabs .deserialize (prefab )
398
383
components : list [ComponentTemplate ] = template .components
@@ -401,7 +386,6 @@ def test_prefab(ecs: Engine, prefab: str) -> None:
401
386
assert components [1 ].properties ['ch' ] == '?'
402
387
403
388
404
- #* PASSING
405
389
def test_entity_from_prefab (ecs : Engine ) -> None :
406
390
test_entity = ecs .domain .entities .create_from_prefab (
407
391
template = 'Character' ,
0 commit comments