import os import unittest import pygame from pathlib import Path from enemies.enemies import EnemyBall, Enemies from display import Scaling from text import Fonts class TestEnemyBall(unittest.TestCase): def setUp(self): Fonts.load_fonts(os.path.join( Path(__file__).parent.parent.resolve(), "src", "sliceitoff")) def test_can_create(self): enemy = EnemyBall() self.assertNotEqual(None, enemy) class TestEnemies(unittest.TestCase): def setUp(self): Scaling.update_scaling((640,400)) Fonts.load_fonts(os.path.join( Path(__file__).parent.parent.resolve(), "src", "sliceitoff")) def test_can_create(self): enemies = Enemies() self.assertNotEqual(None, enemies) def test_right_amount_of_enemies(self): enemies = Enemies(count = 6) self.assertEqual(6, len(enemies.sprites())) def test_update_notcrashing(self): enemies = Enemies(count = 6) for _ in range(10000): enemies.update( dt=100, field_rects=[ Scaling.active, pygame.Rect(800,0,200,200) ])