File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ [build-system ]
2+ requires = [" setuptools>=68" ]
3+ build-backend = " setuptools.backends.legacy:build"
4+
15[project ]
26name = " python-tetris-game-pygame"
37version = " 1.0.0"
Original file line number Diff line number Diff line change @@ -83,3 +83,40 @@ def test_get_random_block_all_7_types():
8383 block = game .get_random_block ()
8484 drawn_types .add (type (block ))
8585 assert drawn_types == ALL_BLOCK_TYPES
86+
87+
88+ def test_lock_block_writes_cells_to_grid ():
89+ game = Game ()
90+ block = game .current_block
91+ block_id = block .id
92+ positions = block .get_cell_positions ()
93+ game .lock_block ()
94+ for pos in positions :
95+ assert game .grid .grid [pos .row ][pos .column ] == block_id
96+
97+
98+ def test_lock_block_advances_current_block ():
99+ game = Game ()
100+ old_next = game .next_block
101+ game .lock_block ()
102+ assert game .current_block is old_next
103+
104+
105+ def test_lock_block_clears_full_row_and_updates_score ():
106+ game = Game ()
107+ # Fill row 19 (bottom) — all blocks start in rows 0-3 so no overlap
108+ for col in range (game .grid .num_cols ):
109+ game .grid .grid [19 ][col ] = 1
110+ old_score = game .score
111+ game .lock_block ()
112+ assert game .score > old_score
113+
114+
115+ def test_lock_block_sets_game_over_when_grid_full ():
116+ game = Game ()
117+ # Fill top rows so that whatever block becomes current can't fit
118+ for row in range (4 ):
119+ for col in range (game .grid .num_cols ):
120+ game .grid .grid [row ][col ] = 1
121+ game .lock_block ()
122+ assert game .game_over is True
You can’t perform that action at this time.
0 commit comments