Coverage for tests/e2e/fuzz/test_fuzz_newbie.py : 91%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# -*- coding: utf-8 -*-
2from __future__ import annotations
4# -- stdlib --
5# -- third party --
6import gevent
8# -- own --
9from ..mock import Environ, EventTap
10from .common import UserInputFuzzingHandler, let_it_go
13# -- code --
14class GameEnded(Exception):
15 pass
18def wait():
19 gevent.idle(-100)
20 gevent.sleep(0.01)
21 gevent.idle(-100)
24class TestFuzzTHBattleFaith(object):
25 def testFuzzTHBattleFaith(self):
26 env = Environ()
27 t = EventTap()
29 me = gevent.getcurrent()
31 def fail_crash(g):
32 e = Exception('GAME CRASH')
33 e.__cause__ = g.runner.exception
34 gevent.kill(me, e)
35 return g
37 s = env.server_core()
38 c = env.client_core()
39 t.tap(s, c)
41 c.auth.login('Reimu')
42 wait()
43 assert c.auth.uid
44 c.room.create('Test1', 'THBattleNewbie', {})
45 wait()
47 s.events.game_crashed += fail_crash
49 g = t[c.events.game_joined]
50 c.events.game_crashed += fail_crash
51 g.event_observer = UserInputFuzzingHandler(g)
53 c.room.get_ready()
54 wait()
56 def game_ended(g):
57 gevent.kill(me, GameEnded())
58 return g
60 s.events.game_ended += game_ended
62 c.game.start_game(t[c.events.game_started])
64 try:
65 let_it_go(c)
66 except GameEnded:
67 pass