def test_construct_too_small_car(): with assert_raises_regexp(InvalidCarError, ".*more than 1 block.*"): _car_from_positions('r', {}) with assert_raises_regexp(InvalidCarError, ".*more than 1 block.*"): _car_from_positions('r', {(0, 0)})
def test_car_from_vertical_positions1(): position, car = _car_from_positions('r', {(0, 0), (0, 1), (0, 2)}) eq_(car.color, 'r') eq_(car.orientation, Direction.vertical) eq_(car.length, 3) eq_(position, (0, 0))
def test_car_from_horizontal_positions2(): position, car = _car_from_positions('r', {(2, 5), (3, 5), (4, 5)}) eq_(car.color, 'r') eq_(car.orientation, Direction.horizontal) eq_(car.length, 3) eq_(position, (2, 5))
def test_car_from_horizontal_positions1(): position, car = _car_from_positions('r', {(0, 0), (1, 0)}) eq_(car.color, 'r') eq_(car.orientation, Direction.horizontal) eq_(car.length, 2) eq_(position, (0, 0))
def test_construct_car_with_gaps(): with assert_raises_regexp(InvalidCarError, ".*gaps.*"): _car_from_positions('r', {(0, 0), (0, 2)})
def test_construct_car_that_extends_beyond_one_line(): with assert_raises_regexp(InvalidCarError, ".*1 row.*1 column.*"): _car_from_positions('r', {(0, 0), (1, 0), (0, 1)})