コード例 #1
0
def is_valid_response(response, min_value, max_value):
    """ (str, number, number) -> bool

    Return True if and only if the str response contains the representation
    of an int value without a +/- sign that is between min_value and max_value,
    inclusive.

    >>> is_valid_response('4', 1, 9)
    True
    >>> is_valid_response('abc', 1, 3.14159)
    False
    """

    return (response.isdigit() and tictactoe_functions.is_between(
        int(response), min_value, max_value))
コード例 #2
0
def is_valid_response(response, min_value, max_value):
    """ (str, number, number) -> bool

    Return True if and only if the str response contains the representation
    of an int value without a +/- sign that is between min_value and max_value,
    inclusive.

    >>> is_valid_response('4', 1, 9)
    True
    >>> is_valid_response('abc', 1, 3.14159)
    False
    """

    return (response.isdigit() and 
            tictactoe_functions.is_between(int(response), 
                                               min_value, max_value))
コード例 #3
0
import tictactoe_functions
import builtins

# Get the initial value of the constant
constant_before = [tictactoe_functions.EMPTY]

# Type check and simple test for tictactoe_functions.is_between
result = tictactoe_functions.is_between(2, 1, 3)
assert isinstance(result, bool), \
       'tictactoe_functions.is_between should return a bool, but returned ' \
       '{0}'.format(type(result))
assert result, \
       'tictactoe_functions.is_between(2, 1, 3) should return True, but ' \
       'returned {0}.'.format(result)

# Type check and simple test for tictactoe_functions.game_board_full
result = tictactoe_functions.game_board_full('----')
assert isinstance(result, bool), \
       'tictactoe_functions.game_board_full should return a bool, but ' \
       'returned {0}.'.format(type(result))
assert not result, \
       "tictactoe_functions.game_board_full('----') should return False, " \
       'but returned {0}.'.format(result)

# Type check and simple test for tictactoe_functions.get_board_size
result = tictactoe_functions.get_board_size('-')
assert isinstance(result, int), \
       'tictactoe_functions.get_board_size should return an int, but ' \
       'returned {0} .'.format(type(result))
assert result == 1, \
       "tictactoe_functions.get_board_size('-') should return 1, but "\
コード例 #4
0
ファイル: a1_simple_check.py プロジェクト: F-Ting/Tic-Tac-Toe
import tictactoe_functions
import builtins

# Get the initial value of the constant
constant_before = [tictactoe_functions.EMPTY]

# Type check and simple test for tictactoe_functions.is_between
result = tictactoe_functions.is_between(2, 1, 3)
assert isinstance(result, bool), \
       'tictactoe_functions.is_between should return a bool, but returned ' \
       '{0}'.format(type(result))
assert result, \
       'tictactoe_functions.is_between(2, 1, 3) should return True, but ' \
       'returned {0}.'.format(result)

# Type check and simple test for tictactoe_functions.game_board_full
result = tictactoe_functions.game_board_full('----')
assert isinstance(result, bool), \
       'tictactoe_functions.game_board_full should return a bool, but ' \
       'returned {0}.'.format(type(result))
assert not result, \
       "tictactoe_functions.game_board_full('----') should return False, " \
       'but returned {0}.'.format(result)

# Type check and simple test for tictactoe_functions.get_board_size
result = tictactoe_functions.get_board_size('-')
assert isinstance(result, int), \
       'tictactoe_functions.get_board_size should return an int, but ' \
       'returned {0} .'.format(type(result))
assert result == 1, \
       "tictactoe_functions.get_board_size('-') should return 1, but "\