def test_repr_zwraca_dobry_opis(self):
        p = Prostokat(3, 5)

        oczekiwana = 'Prostokąt o bokach: a=3, b=5'  # Wypełnij tę wartość aby test przechodził
        aktualna = p.__repr__()

        self.assertEqual(oczekiwana, aktualna)
示例#2
0
 def test_prostokat(self):
     
     Pros1 = Prostokat(2,2)
     #Pros1.szerokosc = 2
     #Pros1.wysokosc = 2
     self.assertAlmostEqual(Pros1.pobierz_obwod(),8)
     self.assertAlmostEqual(Pros1.pobierz_pole(),4)
示例#3
0
    def test_repr_zwraca_dobry_opis(self):
        p = Prostokat(3, 5)

        oczekiwana = 'Prostokąt o bokach: a=3, b=5'
        aktualna = p.__repr__()

        self.assertEqual(oczekiwana, aktualna)
示例#4
0
 def test_prostokat_z_zerowymi_bokami_rzuca_wyjatek(self):
     with self.assertRaises(ValueError):
         Prostokat(0, 0)
     with self.assertRaises(ValueError):
         Prostokat(3, 0)
     with self.assertRaises(ValueError):
         Prostokat(0, 4)
示例#5
0
 def test_prostokat_z_ujemnymi_bokami_rzuca_wyjatek(self):
     with self.assertRaises(ValueError):
         Prostokat(-3, 5)
     with self.assertRaises(ValueError):
         Prostokat(3, -5)
     with self.assertRaises(ValueError):
         Prostokat(-3, -5)
示例#6
0
 def __init__(self):
     pygame.init()
     self.settings = Settings()
     self.screen = pygame.display.set_mode(
         (self.settings.screen_width, self.settings.screen_height))
     pygame.display.set_caption("Gra Prostokat")
     self.ship = Ship(self)
     self.prostokat = Prostokat(self)
 def test_cz_ujemne(self):
     with self.assertRaises(ValueError):
         Prostokat(3, -5)
     with self.assertRaises(ValueError):
         Prostokat(-3, 5)
     with self.assertRaises(ValueError):
         Prostokat(-3, -5)
     with self.assertRaises(ValueError):
         Prostokat(0, 0)
    def test_udaje_sie_utworzyc_prostokat(self):
        p = Prostokat(3, 5)

        oczekiwana = 3
        aktualna = p.bok_a
        self.assertEqual(oczekiwana, aktualna)

        self.assertEqual(5, p.bok_b)
示例#9
0
class Gra_Prostokat:
    def __init__(self):
        pygame.init()
        self.settings = Settings()
        self.screen = pygame.display.set_mode(
            (self.settings.screen_width, self.settings.screen_height))
        pygame.display.set_caption("Gra Prostokat")
        self.ship = Ship(self)
        self.prostokat = Prostokat(self)

    def run_game(self):
        while True:
            self._check_events()
            self._update_screen()
            self._update_prostokat()

    def _update_prostokat(self):

        self._check_flet_edges()
        self.prostokat.update()

    def _check_flet_edges(self):

        if self.prostokat.rect1.top < 0 or self.prostokat.rect1.bottom > 800:
            self._changes_fleet_direction()

    def _changes_fleet_direction(self):

        self.settings.flet_direction *= -1

    def _check_events(self):
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()

    def _update_screen(self):

        self.screen.fill(self.settings.bg_color)
        self.ship.blitme()
        self.prostokat.wys_pros()
        pygame.display.flip()
    def test_czy_kwadrat(self):
        p1 = Prostokat(3, 5)
        oczekiwana = p1.czy_kwadrat()
        self.assertFalse(oczekiwana)

        p2 = Prostokat(3, 3)
        self.assertTrue(p2.czy_kwadrat())
 def test_pole_jest_obliczone_prawidlowo(self):
     p = Prostokat(3, 5)
     oczekiwana = p.pole()
     self.assertEqual(
         oczekiwana, 15
     )  # napisz test, który sprawdzi, czy metoda pole() zwraca prawidłowy wynik
示例#12
0
    def test_czy_kwadrat(self):
        p1 = Prostokat(3, 5)
        self.assertFalse(p1.czy_kwadrat())

        p2 = Prostokat(4, 4)
        self.assertTrue(p2.czy_kwadrat())
示例#13
0
 def test_pole_jest_obliczone_prawidlowo(self):
     p = Prostokat(3, 5)
     self.assertEqual(p.pole(), 15)