Repository navigation
Expand file tree
/
Copy pathtests.py
More file actions
56 lines (45 loc) · 1.53 KB
/
Copy pathtests.py
File metadata and controls
56 lines (45 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import sys
import unittest
import unreal_engine as ue
import tests
class UnrealEngineOutput:
def __init__(self, logger):
self.logger = logger
def write(self, buf):
self.logger(buf)
def flush(self):
return
sys.stdout = UnrealEngineOutput(ue.log)
sys.stderr = UnrealEngineOutput(ue.log_error)
tester_actor = None
class TestTransform(unittest.TestCase):
def setUp(self):
self.actor = tests.tester_actor
def test_location(self):
self.actor.set_actor_location(1, 1, 1)
location = self.actor.get_actor_location()
self.assertEqual(location, (1, 1, 1))
def test_rotation(self):
self.actor.set_actor_rotation(17, 22, 30)
roll, pitch, yaw = self.actor.get_actor_rotation()
self.assertTrue(17 - roll < 0.01)
self.assertTrue(22 - pitch < 0.01)
self.assertTrue(30 - yaw < 0.01)
def test_scale(self):
self.actor.set_actor_scale(3, 5, 7)
scale = self.actor.get_actor_scale()
self.assertEqual(scale, (3, 5, 7))
class TestPlayer(unittest.TestCase):
def setUp(self):
self.actor = tests.tester_actor
def test_create_player(self):
self.assertEqual(self.actor.get_num_players(), 1)
self.actor.create_player(-1)
self.assertEqual(self.actor.get_num_players(), 2)
class TesterActor:
def begin_play(self):
tests.tester_actor = self.uobject
unittest.main(module='tests', exit=False)
self.uobject.quit_game()
def tick(self, delta_time):
pass