1. Python User Group Austria
  2. Untitled project
  3. PythonDojo

Source

PythonDojo / Reversi / test_reversi.py

from nose.tools import *

import reversi

dummy_input_1 = """........
........
........
...BW...
...WB...
........
........
........
B"""

player_fields_1 = [
    (3, 3),
    (4, 4),
]

enemy_fields_1 = [
    (3, 4),
    (4, 3),
]

dummy_input_2 = """........
........
....B...
...BB...
...WB...
........
........
........
W"""

def test_input_return_object():
    assert_is_not_none(reversi.parse(dummy_input_1))

def test_find_current_player():
    assert_equal(reversi.current_player(dummy_input_1), 'B')

def test_find_other_current_player():
    assert_equal(reversi.current_player(dummy_input_2), 'W')
    
def test_input_parses_into_list():
    assert_equal(len(reversi.parse(dummy_input_1)), 8)

def test_input_parses_into_list_of_lists():
    result = reversi.parse(dummy_input_1)
    for line in result:
        assert_equal(len(line), 8)
    
def test_element_is_char():
    assert_equal(reversi.parse(dummy_input_1)[0][0],'.' )
    
def test_determine_player_positions():
    assert_equal(reversi.determine_player_positions(dummy_input_1),
        player_fields_1)
        
def test_determine_attackable_enemy_positions():
    assert_equal(reversi.determine_attackable_enemy_positions(dummy_input_1, (3,3)),
        enemy_fields_1)