ya2 · news · projects · code · about

unit test: pyflakes
[pmachines.git] / ya2 / p3d / asserts.py
CommitLineData
1bfdf72a
FC
1import threading
2
1bfdf72a 3def assert_render3d():
067a36db 4 preserve = ['camera']
1bfdf72a 5 for child in render.children:
067a36db
FC
6 if child.name not in preserve:
7 render.ls()
8 msg = 'unexpected render3d node: %s' % child.name
9 raise Exception(msg)
1bfdf72a
FC
10
11def assert_aspect2d():
067a36db
FC
12 preserve = [
13 'a2dBackground', 'a2dTopCenter', 'a2dTopCenterNS',
14 'a2dBottomCenter', 'a2dBottomCenterNS', 'a2dLeftCenter',
15 'a2dLeftCenterNS', 'a2dRightCenter', 'a2dRightCenterNS',
16 'a2dTopLeft', 'a2dTopLeftNS', 'a2dTopRight',
17 'a2dTopRightNS', 'a2dBottomLeft', 'a2dBottomLeftNS',
18 'a2dBottomRight', 'a2dBottomRightNS', 'test_txt']
1bfdf72a 19 for child in aspect2d.children:
1bfdf72a 20 if child.name not in preserve and not child.has_python_tag('preserve'):
067a36db
FC
21 aspect2d.ls()
22 msg = 'unexpected aspect2d node: %s' % child.name
23 raise Exception(msg)
1bfdf72a
FC
24
25def assert_render2d():
26 for child in render2d.children:
27 preserve = ['aspect2d', 'pixel2d', 'camera2d']
28 if child.name not in preserve and not child.has_python_tag('preserve'):
067a36db
FC
29 render2d.ls()
30 msg = 'unexpected render2d node: %s' % child.name
31 raise Exception(msg)
1bfdf72a
FC
32
33def assert_events():
34 preserve = ['window-event', 'window-closed', 'async_loader_0',
35 'render-texture-targets-changed', 'aspectRatioChanged']
36 for evt in messenger.getEvents():
37 if evt not in preserve:
46629372
FC
38 if (acc := messenger.who_accepts(evt)):
39 for key, _acc in acc.items():
40 if _acc[2]:
41 print('the event %s accepted by <%s, %s> is persistent' % (evt, key, _acc[0]))
42 else:
43 msg = 'unexpected event: %s, %s' % (evt, str(acc))
44 raise Exception(msg)
1bfdf72a
FC
45
46def assert_tasks():
47 preserve = [
48 'ivalLoop', 'garbageCollectStates', 'collisionLoop',
49 'igLoop', 'audioLoop', 'resetPrevTransform', 'dataLoop',
067a36db
FC
50 'eventManager', 'simplepbr update', 'on frame music',
51 'assert_fps']
1bfdf72a
FC
52 for task in taskMgr.getTasks() + taskMgr.getDoLaters():
53 if task.name not in preserve and not hasattr(task, 'preserve'):
54 msg = 'unexpected task: %s' % task.name
55 raise Exception(msg)
56
57def assert_buffers():
58 pass
59 #for buffer in RenderToTexture.buffers:
60 # raise Error()
61
1bfdf72a
FC
62def assert_threads():
63 thr_names = [thread.name for thread in threading.enumerate()]
067a36db 64 preserve = ['MainThread', 'rpc_server']
1bfdf72a
FC
65 for thr_name in thr_names:
66 if thr_name not in preserve:
67 msg = 'unexpected thread: %s' % thr_name
68 raise Exception(msg)