From 7fb570d334fe8df40492c452e9bd7f251f284ed9 Mon Sep 17 00:00:00 2001 From: "A. Jesse Jiryu Davis" Date: Tue, 7 Oct 2014 14:20:07 -0400 Subject: [PATCH] test_atexit_hook wasn't testing what it meant to. --- test/test_monitor.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/test_monitor.py b/test/test_monitor.py index caa85c9b3..eaa38b418 100644 --- a/test/test_monitor.py +++ b/test/test_monitor.py @@ -22,7 +22,7 @@ sys.path[0:0] = [""] from pymongo.monitor import MONITORS from test import unittest, port, host, IntegrationTest -from test.utils import single_client, wait_until +from test.utils import single_client, wait_until, one class TestMonitor(IntegrationTest): @@ -33,12 +33,16 @@ class TestMonitor(IntegrationTest): wait_until(lambda: MONITORS - prior_monitors, 'register new monitor') + # Just one new monitor should have been registered. + new_monitor_refs = MONITORS - prior_monitors + self.assertEqual(1, len(new_monitor_refs)) + monitor_ref = one(new_monitor_refs) del client start = time.time() while time.time() - start < 30: gc.collect() - if MONITORS - prior_monitors: + if monitor_ref not in MONITORS: # New monitor was unregistered. break