Did I find the right examples for you? yes no

All Samples(7)  |  Call(6)  |  Derive(0)  |  Import(1)
Allows the user to select number of human players.
Validates input and returns a matching tuple of players.

        def get_participating_players(raw_input=raw_input):
    """
   Allows the user to select number of human players.
   Validates input and returns a matching tuple of players.
   """
    no_players = 0
    while no_players != 1 and no_players != 2:
        inp = raw_input("Single player or multiplayer? (1/2): ")
        try:
            no_players = int(inp)
        except ValueError:
            print "Invalid input - please try again"
            pass

    if no_players is 1:
        return (HumanPlayer('X'), ComputerPlayer('O'))
    else:
        return (HumanPlayer('X'), HumanPlayer('O'))
        


src/t/i/tictascii-0.0.3/tictascii/tests.py   tictascii(Download)
from ticlib.players import HumanPlayer, ComputerPlayer
from ticlib.base import Tournament, Board
from ticli import get_participating_players
 
import unittest
    def test_getting_1_players(self):
        player_collection = get_participating_players(one_raw_input)
        self.assertNotEqual(player_collection, None)
 
    def test_getting_2_players(self):
        player_collection = get_participating_players(two_raw_input)
        self.assertNotEqual(player_collection, None)
 
    def test_if_1_player_have_correct_marks(self):
        player_collection = get_participating_players(one_raw_input)
    def test_if_2_player_have_correct_marks(self):
        player_collection = get_participating_players(two_raw_input)
        player_1 = player_collection[0]
        player_2 = player_collection[1]
        self.assertEquals('X', player_1.marker)