Last active
March 19, 2019 10:35
-
-
Save devforfu/effa1e83d39a0cc772397d396be5dfa8 to your computer and use it in GitHub Desktop.
An illustrative snippet for the blog post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytest | |
@pytest.mark.parametrize('state', [ | |
'ooo|x.x|..x', | |
'xo.|xo.|x..', | |
'x..|.xo|o.x' | |
]) | |
def test_game_has_winner(state): | |
game = Game(state) | |
assert game.has_winner() | |
class Game: | |
def __init__(self, state): | |
self.state = state_from_string(state) | |
def has_winner(self): | |
pass # check rows, columns, and diagonals | |
def state_from_string(line): | |
return [list(row) for row in line.split('|')] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment