From 266021313a1501c86c11c803851c2b4bb50a8c00 Mon Sep 17 00:00:00 2001 From: Jeremy Thurgood Date: Fri, 16 May 2014 16:03:46 +0200 Subject: [PATCH] flake8 all the things. --- naja/player.py | 7 +++++-- naja/scenes/menu.py | 3 ++- naja/tests/test_actions.py | 14 +++++++++----- naja/tests/test_gameboard.py | 5 ++--- naja/tests/test_player.py | 12 +++++++----- naja/widgets/tile.py | 10 ++++++---- 6 files changed, 31 insertions(+), 20 deletions(-) diff --git a/naja/player.py b/naja/player.py index 2f6fdcf..2aad55b 100644 --- a/naja/player.py +++ b/naja/player.py @@ -1,4 +1,4 @@ -from naja.constants import BITS, MOVES, CHESS_PIECES +from naja.constants import BITS, MOVES class PlayerBits(object): @@ -62,7 +62,10 @@ class Player(object): @classmethod def import_player(cls, definition): - return cls(definition['bits'], tuple(definition['position']), definition['movement_mode']) + return cls( + definition['bits'], + tuple(definition['position']), + definition['movement_mode']) def export(self): return { diff --git a/naja/scenes/menu.py b/naja/scenes/menu.py index 91f858b..3a78969 100644 --- a/naja/scenes/menu.py +++ b/naja/scenes/menu.py @@ -23,7 +23,8 @@ class MenuScene(Scene): run_game.add_callback('click', lambda event: SceneChangeEvent.post(GameScene)) selector.add(run_game) - credits = TextWidget((100, 200), 'Credits', fontsize=32, colour='white') + credits = TextWidget( + (100, 200), 'Credits', fontsize=32, colour='white') credits.add_callback('click', lambda event: SceneChangeEvent.post(CreditsScene)) selector.add(credits) diff --git a/naja/tests/test_actions.py b/naja/tests/test_actions.py index 14d5f0e..8919367 100644 --- a/naja/tests/test_actions.py +++ b/naja/tests/test_actions.py @@ -190,17 +190,21 @@ class TestActions(TestCase): def test_AllowKnightMove(self): board = self.make_board(player_bits=[BITS.RED, BITS.BLUE]) - actions.AllowChessMove(set([BITS.RED, BITS.BLUE]), chesspiece="KNIGHT").perform_action(board, None) + actions.AllowChessMove( + set([BITS.RED, BITS.BLUE]), chesspiece="KNIGHT" + ).perform_action(board, None) self.assertEqual(board.player.movement_mode, MOVES.KNIGHT) - def test_AllowBishopMove(self): board = self.make_board(player_bits=[BITS.RED, BITS.BLUE]) - actions.AllowChessMove(set([BITS.RED, BITS.BLUE]), chesspiece="BISHOP").perform_action(board, None) + actions.AllowChessMove( + set([BITS.RED, BITS.BLUE]), chesspiece="BISHOP" + ).perform_action(board, None) self.assertEqual(board.player.movement_mode, MOVES.BISHOP) - def test_AllowCastleMove(self): board = self.make_board(player_bits=[BITS.RED, BITS.BLUE]) - actions.AllowChessMove(set([BITS.RED, BITS.BLUE]), chesspiece="CASTLE").perform_action(board, None) + actions.AllowChessMove( + set([BITS.RED, BITS.BLUE]), chesspiece="CASTLE" + ).perform_action(board, None) self.assertEqual(board.player.movement_mode, MOVES.CASTLE) diff --git a/naja/tests/test_gameboard.py b/naja/tests/test_gameboard.py index 3bbf59b..6231ac7 100644 --- a/naja/tests/test_gameboard.py +++ b/naja/tests/test_gameboard.py @@ -22,8 +22,8 @@ class TestGameBoard(TestCase): def test_export_new_board(self): board = GameBoard.new_game([{'actions': [{ - 'action_class': 'LoseHealthOrMSB', - 'required_bits': [], + 'action_class': 'LoseHealthOrMSB', + 'required_bits': [], }]}]) exported_state = board.export() board_locations = exported_state.pop('board_locations') @@ -143,7 +143,6 @@ class TestGameBoard(TestCase): self.assertEqual(board.player.movement_mode, MOVES.CASTLE) - class TestLocationCard(TestCase): def test_generate_bitwise_operand(self): # This is testing a random process, so it may fail occasionally. diff --git a/naja/tests/test_player.py b/naja/tests/test_player.py index a7173cb..2e17379 100644 --- a/naja/tests/test_player.py +++ b/naja/tests/test_player.py @@ -130,17 +130,19 @@ class TestPlayer(TestCase): def test_legal_moves_castle(self): player = Player(0x0f, (1, 3), MOVES.CASTLE) - self.assertEqual(player.legal_moves(), [(0, 3), (1, 0), (1, 1), (1, 2), - (1, 3), (1, 4), (2, 3), (3, 3), (4, 3)]) + self.assertEqual(player.legal_moves(), [ + (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, 3), (3, 3), + (4, 3)]) def test_legal_moves_bishop(self): player = Player(0x0f, (1, 3), MOVES.BISHOP) - self.assertEqual(player.legal_moves(), [(0, 2), (0, 4), (1, 3), (2, 2), - (2, 4), (3, 1), (4, 0)]) + self.assertEqual(player.legal_moves(), [ + (0, 2), (0, 4), (1, 3), (2, 2), (2, 4), (3, 1), (4, 0)]) def test_legal_moves_knight(self): player = Player(0x0f, (1, 3), MOVES.KNIGHT) - self.assertEqual(player.legal_moves(), [(0, 1), (1, 3), (2, 1), (3, 2), (3, 4)]) + self.assertEqual(player.legal_moves(), [ + (0, 1), (1, 3), (2, 1), (3, 2), (3, 4)]) def test_set_position(self): player = Player(0x0f, (3, 3), MOVES.BISHOP) diff --git a/naja/widgets/tile.py b/naja/widgets/tile.py index 808798f..b199418 100644 --- a/naja/widgets/tile.py +++ b/naja/widgets/tile.py @@ -2,7 +2,8 @@ import pygame from naja.constants import ( - TILE_SIZE, BITS, LOCK_HEIGHT, SMALL_LOCK_HEIGHT, EXAMINE, ACTION_GLYPHS, PALETTE) + TILE_SIZE, BITS, LOCK_HEIGHT, SMALL_LOCK_HEIGHT, EXAMINE, ACTION_GLYPHS, + PALETTE) from naja.resources import resources from naja.resources.mutators import EIGHT_BIT, blender from naja.widgets.base import Widget @@ -58,10 +59,10 @@ class TileWidget(Widget): if self.state.gameboard.player_mode == EXAMINE and legal_move: overlays.append(resources.get_image('board/tile_available.png', - transforms=(EIGHT_BIT,))) + transforms=(EIGHT_BIT,))) if self.highlighted: overlays.append(resources.get_image('board/tile_selected.png', - transforms=(EIGHT_BIT,))) + transforms=(EIGHT_BIT,))) self.surface = pygame.surface.Surface(TILE_SIZE) self.surface.blit(bg, (0, 0)) @@ -87,7 +88,8 @@ class TileWidget(Widget): if y_offset == LOCK_HEIGHT: y_offset = 0 # middle -> top elif y_offset == 2 * LOCK_HEIGHT: - y_offset += LOCK_HEIGHT - SMALL_LOCK_HEIGHT - 2 # bottom -> further down + # bottom -> further down + y_offset += LOCK_HEIGHT - SMALL_LOCK_HEIGHT - 2 img = resources.get_image(img_name, transforms=(EIGHT_BIT,)) self.surface.blit(img, (x_offset, y_offset)) -- 2.34.1