aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-07-22 11:42:31 -0700
committerGravatar MarkKoz <[email protected]>2020-07-22 11:42:31 -0700
commit63c7827d9d9025c7505747904237b37eb46464df (patch)
tree3eb002bc138b19373996e0f23da60ad9935fced2
parentJam Tests: Fix `test_duplicate_member_provided` assertions (diff)
Jam Tests: fix utils patch
stop needs to be called on the patcher, not the mock. Furthermore, using addCleanup is safer than tearDown because the latter may not be called if an exception is raised in setUp.
-rw-r--r--tests/bot/cogs/test_jams.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/bot/cogs/test_jams.py b/tests/bot/cogs/test_jams.py
index 2f2cb4695..28eb1ab53 100644
--- a/tests/bot/cogs/test_jams.py
+++ b/tests/bot/cogs/test_jams.py
@@ -16,11 +16,12 @@ class JamCreateTeamTests(unittest.IsolatedAsyncioTestCase):
self.guild = MockGuild([self.admin_role])
self.ctx = MockContext(bot=self.bot, author=self.command_user, guild=self.guild)
self.cog = CodeJams(self.bot)
- self.utils_mock = patch("bot.cogs.jams.utils").start()
- self.default_args = [self.cog, self.ctx, "foo"]
- def tearDown(self):
- self.utils_mock.stop()
+ utils_patcher = patch("bot.cogs.jams.utils")
+ self.utils_mock = utils_patcher.start()
+ self.addCleanup(utils_patcher.stop)
+
+ self.default_args = [self.cog, self.ctx, "foo"]
async def test_too_small_amount_of_team_members_passed(self):
"""Should `ctx.send` and exit early when too small amount of members."""