Skip to content

Instantly share code, notes, and snippets.

@devforfu
Last active March 19, 2019 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devforfu/effa1e83d39a0cc772397d396be5dfa8 to your computer and use it in GitHub Desktop.
Save devforfu/effa1e83d39a0cc772397d396be5dfa8 to your computer and use it in GitHub Desktop.
An illustrative snippet for the blog post
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