Beispiel #1
0
 def test_vertical_ru_upper_left(self) -> None:
     self.assertEqual(
         make_ship_from_str("А1А4", Locale.RU),
         Ship([Coord((0, 0)),
               Coord((1, 0)),
               Coord((2, 0)),
               Coord((3, 0))]))
Beispiel #2
0
 def test_10(self) -> None:
     self.assertEqual(
         make_ship_from_str("А10Г10", Locale.RU),
         Ship([Coord((9, 0)),
               Coord((9, 1)),
               Coord((9, 2)),
               Coord((9, 3))]))
Beispiel #3
0
 def test_vertical_ru(self) -> None:
     self.assertEqual(
         make_ship_from_str("Г1Г4", Locale.RU),
         Ship([Coord((0, 3)),
               Coord((1, 3)),
               Coord((2, 3)),
               Coord((3, 3))]))
Beispiel #4
0
 def request_move(self, opponent_view: FieldView) -> Coord:
     print(
         micro_draw(opponent_view,
                    self.field.get_view(opponent=False),
                    locale=self.locale,
                    theme=self.theme,
                    border=self.border))
     print('{}, ваш ход!'.format(self.field.player_name))
     while True:
         try:
             move = make_ship_from_str(input('>'), self.locale)
             assert len(move) == 1
             return move.cells[0]
         except AssertionError:
             pass
Beispiel #5
0
 def test_out_of_bounds_2(self) -> None:
     with self.assertRaises(Exception):
         make_ship_from_str("А9А11", Locale.RU)
Beispiel #6
0
    def test_incorrect_locale(self) -> None:
        with self.assertRaises(AssertionError) as ctx:
            make_ship_from_str("Г1Г2", Locale.EN)

        self.assertEqual(ctx.exception.args[0], 'Incorrect input')
Beispiel #7
0
 def test_horizontal_en(self) -> None:
     self.assertEqual(make_ship_from_str("D1F1", Locale.EN),
                      Ship([Coord((0, 3)),
                            Coord((0, 4)),
                            Coord((0, 5))]))
Beispiel #8
0
 def test_single_ru(self) -> None:
     self.assertEqual(make_ship_from_str("Г1", Locale.RU),
                      Ship([Coord((0, 3))]))
Beispiel #9
0
    def test_diagonal_ru(self) -> None:
        with self.assertRaises(Exception) as ctx:
            make_ship_from_str("Г1Д2", Locale.RU)

        self.assertEqual(ctx.exception.args[0],
                         'Ship should be a straight line')
Beispiel #10
0
 def test_horizontal_ru_2deck(self) -> None:
     self.assertEqual(make_ship_from_str("Г1Д1", Locale.RU),
                      Ship([Coord((0, 3)), Coord((0, 4))]))