def test_report_on_robot_not_placed():
    with pytest.raises(MissingPlaceCommandException) as e:
        robot = Robot()
        robot.report()
    assert str(e.value) == 'Robot not placed.'
    assert robot.x_coordinate is None
    assert robot.y_coordinate is None
    assert robot.facing is None
def test_report_on_robot_placed(capsys):
    robot = Robot()
    robot.place([0, 0, 'NORTH'])
    robot.report()
    assert robot.x_coordinate == 0
    assert robot.y_coordinate == 0
    assert robot.facing == 'NORTH'
    captured = capsys.readouterr()
    assert captured.out.replace('\n', '') == 'Output: 0, 0, NORTH'
示例#3
0
 def test_robot_report(self):
     subject = Robot()
     with OutputBuffer() as bf:
         self.assertIsNone(subject.report())
     self.assertEqual(bf.out, '0, 0, NORTH\n')