示例#1
0
文件: tests.py 项目: dirksen/toyrobot
def test_invalid_instruction(capsys):
    instructions = """
        PLACE
        REPORT
    """
    robot = Robot()
    with pytest.raises(InvalidInstruction):
        robot.simulate(instructions)
示例#2
0
文件: tests.py 项目: dirksen/toyrobot
def test_incorect_placement(capsys):
    instructions = """
        PLACE 6,6,EAST
        REPORT
    """
    robot = Robot()
    with pytest.raises(InvalidInstruction):
        robot.simulate(instructions)
示例#3
0
文件: tests.py 项目: dirksen/toyrobot
def test1(capsys):
    instructions = """
        PLACE 0,0,NORTH
        MOVE
        REPORT
    """
    robot = Robot()
    robot.simulate(instructions)
    captured = capsys.readouterr()
    assert captured.out.strip() == "0,1,NORTH", "Example 1 failed"
示例#4
0
文件: tests.py 项目: dirksen/toyrobot
def test2(capsys):
    instructions = """
        PLACE 0,0,NORTH
        LEFT
        REPORT
    """
    robot = Robot()
    robot.simulate(instructions)
    captured = capsys.readouterr()
    assert captured.out.strip() == "0,0,WEST", "Example 2 failed"
示例#5
0
文件: tests.py 项目: dirksen/toyrobot
def test_proper_start(capsys):
    instructions = """
        MOVE
        RIGHT
        PLACE 5,5,EAST
        REPORT
    """
    robot = Robot()
    robot.simulate(instructions)
    captured = capsys.readouterr()
    assert captured.out.strip(
    ) == "5,5,EAST", "Failed finding the starting instruction"
示例#6
0
文件: tests.py 项目: dirksen/toyrobot
def test3(capsys):
    instructions = """
        PLACE 1,2,EAST
        MOVE
        MOVE
        LEFT
        MOVE
        REPORT
    """
    robot = Robot()
    robot.simulate(instructions)
    captured = capsys.readouterr()
    assert captured.out.strip() == "3,3,NORTH", "Example 3 failed"
示例#7
0
文件: tests.py 项目: dirksen/toyrobot
def test_overboundary2(capsys):
    instructions = """
        PLACE 5,5,EAST
        MOVE
        LEFT
        MOVE
        LEFT
        MOVE
        REPORT
    """
    robot = Robot()
    robot.simulate(instructions)
    captured = capsys.readouterr()
    assert captured.out.strip() == "4,5,WEST", "Failed boundary test 2"