Skip to content

Instantly share code, notes, and snippets.

@devforfu devforfu/sample_test.py
Last active Mar 19, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.