summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViljami Ilola <+@hix.fi>2024-03-29 00:55:14 +0200
committerViljami Ilola <+@hix.fi>2024-03-29 00:55:14 +0200
commit9e60c8dd2a3c8d27d02d1e7a019c55f23c6831c6 (patch)
tree43981f1be48b56a60d5640ab553ae26e9cbb3073
parent5c5df6e068b2957987cb51b34d6930769424f8ca (diff)
textpage tests
-rw-r--r--tests/test_enemies.py22
-rw-r--r--tests/test_text.py29
2 files changed, 50 insertions, 1 deletions
diff --git a/tests/test_enemies.py b/tests/test_enemies.py
index 24c608c..aaf2b0c 100644
--- a/tests/test_enemies.py
+++ b/tests/test_enemies.py
@@ -1,8 +1,28 @@
+import os
import unittest
-from enemies.enemies import EnemySprite
+from pathlib import Path
+
+
+from enemies.enemies import EnemySprite, Enemies
+from text import Fonts
class TestEnemySprite(unittest.TestCase):
def test_can_create(self):
enemy = EnemySprite()
self.assertNotEqual(None, enemy)
+
+class TestEnemies(unittest.TestCase):
+ def setUp(self):
+ 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())) \ No newline at end of file
diff --git a/tests/test_text.py b/tests/test_text.py
new file mode 100644
index 0000000..c4f51fd
--- /dev/null
+++ b/tests/test_text.py
@@ -0,0 +1,29 @@
+import os
+import unittest
+
+from pathlib import Path
+
+from text import Fonts, TextPage
+
+class TestText(unittest.TestCase):
+ def setUp(self):
+ Fonts.load_fonts(os.path.join(
+ Path(__file__).parent.parent.resolve(),
+ "src",
+ "sliceitoff"))
+
+ def test_can_create(self):
+ textpage = TextPage("")
+ self.assertNotEqual(None, textpage)
+
+ def test_right_amount_of_letters(self):
+ textpage = TextPage("MOII")
+ textpage.update()
+ self.assertEqual(4, len(textpage.sprites()))
+
+ def test_exploding_not_chashing(self):
+ textpage = TextPage("MOII\n\thei\xeeOK", grid = (1_000, 1_000))
+ for _ in range(1000):
+ textpage.update(dt = 333, explode = True)
+
+ \ No newline at end of file