Skip to content
This repository was archived by the owner on Jul 8, 2023. It is now read-only.

Commit 74b3df1

Browse files
committed
Issue #33. Fix tests regression
1 parent 090ee83 commit 74b3df1

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

project/mahjong/table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def get_player(self, player_seat):
140140
return self.players[player_seat]
141141

142142
def get_players_sorted_by_scores(self):
143-
return sorted(self.players, key=lambda x: x.scores, reverse=True)
143+
return sorted(self.players, key=lambda x: x.scores or 0, reverse=True)
144144

145145
@property
146146
def round_wind(self):

project/tenhou/tests/tests_client.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88

99
class TenhouClientTestCase(unittest.TestCase):
1010

11+
def setUp(self):
12+
self.client = None
13+
14+
def tearDown(self):
15+
self.client.end_game(False)
16+
1117
def test_fixed_crash_after_called_kan(self):
1218
log = """
1319
Get: <HELO uname="Name" auth="20170415-1111111" />
@@ -63,14 +69,14 @@ def test_fixed_crash_after_called_kan(self):
6369
Get: <N who="0" m="30211" /> <T39/>
6470
"""
6571

66-
client = TenhouClient(SocketMock(None, log))
72+
self.client = TenhouClient(SocketMock(None, log))
6773
with self.assertRaises(KeyboardInterrupt) as context:
68-
client.connect()
69-
client.authenticate()
70-
client.start_game()
74+
self.client.connect()
75+
self.client.authenticate()
76+
self.client.start_game()
7177

7278
# close all threads
73-
client.end_game()
79+
self.client.end_game()
7480

7581
# end of commands is correct way to end log reproducing
7682
self.assertTrue('End of commands' in str(context.exception))

0 commit comments

Comments
 (0)