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))]))
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))]))
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))]))
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
def test_out_of_bounds_2(self) -> None: with self.assertRaises(Exception): make_ship_from_str("А9А11", Locale.RU)
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')
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))]))
def test_single_ru(self) -> None: self.assertEqual(make_ship_from_str("Г1", Locale.RU), Ship([Coord((0, 3))]))
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')
def test_horizontal_ru_2deck(self) -> None: self.assertEqual(make_ship_from_str("Г1Д1", Locale.RU), Ship([Coord((0, 3)), Coord((0, 4))]))