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)
        
    
    
    
    
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.