import os import unittest import pygame from pathlib import Path from sliceitoff.stats import Stats class TestStats(unittest.TestCase): def setUp(self): self.stats0 = Stats() self.stats = Stats() def test_can_create(self): self.assertNotEqual(None, self.stats) def test_lose_lives(self): self.stats.lose_life() self.assertEqual(self.stats.lives + 1, self.stats0.lives) def test_lose_lives_return_true_when_dead(self): for _ in range(self.stats.lives-1): self.assertFalse(self.stats.lose_life()) self.assertTrue(self.stats.lose_life()) def test_levelup_levels_up(self): self.stats.level_up() self.assertEqual(self.stats.level + 1, self.stats0.lives) def test_add_score_works(self): self.stats.score=500 self.stats.add_score(400) self.assertEqual(self.stats.score, 900) self.stats.add_score(-600) self.assertEqual(self.stats.score, 300) self.stats.add_score(-300) self.assertEqual(self.stats.score, 0) self.stats.add_score(-300) self.assertEqual(self.stats.score, 0)