예제 #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"