# Coverage for tests/e2e/fuzz/test_fuzz_newbie.py : 91%

## 43 statements 39 run 4 missing 0 excluded 0 partial

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 -*-

2 from __future__ import annotations

3

4# -- stdlib --

5# -- third party --

6 import gevent

7

8# -- own --

9 from ..mock import Environ, EventTap

10 from .common import UserInputFuzzingHandler, let_it_go

11

12

13# -- code --

14 class GameEnded(Exception):

15 pass

16

17

18 def wait():

19 gevent.idle(-100)

20 gevent.sleep(0.01)

21 gevent.idle(-100)

22

23

24 class TestFuzzTHBattleFaith(object):

25 def testFuzzTHBattleFaith(self):

26 env = Environ()

27 t = EventTap()

28

29 me = gevent.getcurrent()

30

31 def fail_crash(g):

32 e = Exception('GAME CRASH')

33 e.__cause__ = g.runner.exception

34 gevent.kill(me, e)

35 return g

36

37 s = env.server_core()

38 c = env.client_core()

39 t.tap(s, c)

40

41 c.auth.login('Reimu')

42 wait()

43 assert c.auth.uid

44 c.room.create('Test1', 'THBattleNewbie', {})

45 wait()

46

47 s.events.game_crashed += fail_crash

48

49 g = t[c.events.game_joined]

50 c.events.game_crashed += fail_crash

51 g.event_observer = UserInputFuzzingHandler(g)

52

53 c.room.get_ready()

54 wait()

55

56 def game_ended(g):

57 gevent.kill(me, GameEnded())

58 return g

59

60 s.events.game_ended += game_ended

61

62 c.game.start_game(t[c.events.game_started])

63

64 try:

65 let_it_go(c)

66 except GameEnded:

67 pass