From d022c9c7bcaaae51db38af5f45503e0bcb6c175a Mon Sep 17 00:00:00 2001 From: Griatch Date: Thu, 6 Aug 2020 00:22:48 +0200 Subject: [PATCH] Fix unittest error for dice contrib --- evennia/contrib/tests.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/evennia/contrib/tests.py b/evennia/contrib/tests.py index d394cd5a3b..d0eda87ea2 100644 --- a/evennia/contrib/tests.py +++ b/evennia/contrib/tests.py @@ -874,20 +874,17 @@ class TestCustomGameTime(EvenniaTest): # Test dice module +from evennia.contrib import dice # noqa -@patch("random.randint", return_value=5) + +@patch("evennia.contrib.dice.randint", return_value=5) class TestDice(CommandTest): def test_roll_dice(self, mocked_randint): - # we must import dice here for the mocked randint to apply correctly. - from evennia.contrib import dice - self.assertEqual(dice.roll_dice(6, 6, modifier=("+", 4)), mocked_randint() * 6 + 4) self.assertEqual(dice.roll_dice(6, 6, conditional=("<", 35)), True) self.assertEqual(dice.roll_dice(6, 6, conditional=(">", 33)), False) def test_cmddice(self, mocked_randint): - from evennia.contrib import dice - self.call( dice.CmdDice(), "3d6 + 4", "You roll 3d6 + 4.| Roll(s): 5, 5 and 5. Total result is 19." ) @@ -898,7 +895,7 @@ class TestDice(CommandTest): # Test email-login -from evennia.contrib import email_login +from evennia.contrib import email_login # noqa class TestEmailLogin(CommandTest):