-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathunit_tests.py
More file actions
37 lines (29 loc) · 1.38 KB
/
unit_tests.py
File metadata and controls
37 lines (29 loc) · 1.38 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
import unittest
from rlbot.training.training import Pass, Fail
from rlbottraining.exercise_runner import run_playlist
from hello_world_training import StrikerPatience
class PatienceTest(unittest.TestCase):
"""
These units check that this bot behaves as we expect,
with regards to the StrikerPatience exercise.
By default, the bot isn't very smart so it'll fail in the cases where
patience is required but passes in cases where no patience is required.
Tutorial:
https://youtu.be/hCw250aGN8c?list=PL6LKXu1RlPdxh9vxmG1y2sghQwK47_gCH&t=187
"""
def test_patience_required(self):
result_iter = run_playlist([StrikerPatience(name='patience required')])
results = list(result_iter)
self.assertEqual(len(results), 1)
result = results[0]
self.assertEqual(result.exercise.name, 'patience required')
self.assertIsInstance(result.grade, Fail) # If you make the bot is smarter, update this assert that we pass.
def test_no_patience_required(self):
result_iter = run_playlist([StrikerPatience(name='no patience required', car_start_x=-1000)])
results = list(result_iter)
self.assertEqual(len(results), 1)
result = results[0]
self.assertEqual(result.exercise.name, 'no patience required')
self.assertIsInstance(result.grade, Pass)
if __name__ == '__main__':
unittest.main()