예제 #1
0
    def test_back_distance_bounds_and_type(self):
        self.begin_for_testing()

        with self.assertRaisesRegexp(
                AssertionError,
                "Oops, back\(0\) won't work. Distance must be a whole number between 1 and 1000."
        ):
            back(0)

        with self.assertRaisesRegexp(
                AssertionError,
                "Oops, back\(-1\) won't work. Distance must be a whole number between 1 and 1000."
        ):
            back(-1)

        with self.assertRaisesRegexp(
                AssertionError,
                "Oops, back\(1001\) won't work. Distance must be a whole number between 1 and 1000."
        ):
            back(1001)

        with self.assertRaisesRegexp(
                AssertionError,
                "Oops, back\(1.1\) won't work. Distance must be a whole number between 1 and 1000."
        ):
            back(1.1)

        with self.assertRaisesRegexp(
                AssertionError,
                "Oops, back\(abc\) won't work. Distance must be a whole number between 1 and 1000."
        ):
            back('abc')
예제 #2
0
    def test_back(self):
        self.begin_for_testing()
        back(2)

        self.assertEqual(
            {
                (100, 200, 300): "gold_block",
                (100, 200, 299): "gold_block",
                (100, 200, 298): ("piston", {
                    "facing": "north"
                })
            }, self.game.tiles)
예제 #3
0
    def test_forward_and_back_return_block_info_of_where_turtle_ended_up(self):

        # the fake is hard-coded to always return a piston.

        self.begin_for_testing()
        self.assertEqual(back(1), block.PISTON)
        self.assertEqual(forward(2), block.PISTON)