dice: more test method granularity

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
This commit is contained in:
2026-07-24 09:26:10 -05:00
parent 6fec81917e
commit 915afbf5ec
+12 -2
View File
@@ -48,29 +48,39 @@ class DiceRollerTestCase(TestCase):
result = self.roller.do_roll('1d20 this is a difficulty check')
self.assertEqual(result, '5 this is a difficulty check (5[5])')
def test_cypher_rolls(self):
"""Roll a variety of cypher rolls."""
def test_cypher_roll_normal(self):
"""Roll a normal Cypher System roll."""
with mock.patch('random.SystemRandom.randint', return_value=5):
result = self.roller.do_roll('difficulty 5 might task to muscle good')
self.assertEqual(result, 'task to muscle good failed. (res. 1 (d20=5) vs. might difficulty 5 (5))')
def test_cypher_roll_normal_with_mods(self):
"""Roll a Cypher System roll with mods."""
with mock.patch('random.SystemRandom.randint', return_value=4):
result = self.roller.do_roll('difficulty 2-2 might attack to hit good')
self.assertEqual(result, 'attack to hit good succeeded! (res. 1 (d20=4) vs. might difficulty 0 (2-2))')
def test_cypher_roll_normal_with_positive_mods(self):
"""Roll a Cypher System roll with mods."""
with mock.patch('random.SystemRandom.randint', return_value=20):
result = self.roller.do_roll('difficulty 2+2 might attack to hit good')
self.assertEqual(result, 'attack to hit good succeeded, with a MAJOR EFFECT! '
'(res. 6 (d20=20) vs. might difficulty 4 (2+2))')
def test_cypher_roll_no_difficulty(self):
"""Roll a Cypher System roll without difficulty, just mods."""
with mock.patch('random.SystemRandom.randint', return_value=5):
result = self.roller.do_roll('-1 might task to muscle good')
self.assertEqual(result, 'task to muscle good beats a difficulty 2 task. (res. 1+1 (d20=5) vs. might)')
def test_cypher_roll_no_difficulty_no_comment(self):
"""Roll a Cypher System roll without difficulty, just mods."""
with mock.patch('random.SystemRandom.randint', return_value=5):
result = self.roller.do_roll('-1 might attack')
self.assertEqual(result, 'attack beats a difficulty 2 task. (res. 1+1 (d20=5) vs. might)')
def test_cypher_roll_no_difficulty_intrusion(self):
"""Roll a Cypher System roll without difficulty, just mods."""
with mock.patch('random.SystemRandom.randint', return_value=1):
result = self.roller.do_roll('-1 might attack')
self.assertEqual(result, 'attack beats nothing, with a GM intrusion! (res. 0+1 (d20=1) vs. might)')