From 8e97c3332d66c85786f42f3189e3022a518ed20b Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Sun, 4 Aug 2019 10:07:18 -0400 Subject: [PATCH] test_try_again_many_times(): use three times `None`'s ref count 100,000 iterations was arbitrary anyway, so let's just depend on the initial reference count of `None` and iterate three times that since this is the object we want to avoid destroy. Signed-off-by: Philippe Proulx Change-Id: I3d587c730b4587d5381d07541d0d86ccff344858 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1822 Tested-by: jenkins Reviewed-by: Simon Marchi --- tests/bindings/python/bt2/test_message_iterator.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/bindings/python/bt2/test_message_iterator.py b/tests/bindings/python/bt2/test_message_iterator.py index 3cd27e5b..31f41921 100644 --- a/tests/bindings/python/bt2/test_message_iterator.py +++ b/tests/bindings/python/bt2/test_message_iterator.py @@ -21,6 +21,7 @@ import collections import unittest import copy import bt2 +import sys from utils import TestOutputPortMessageIterator @@ -405,10 +406,12 @@ class UserMessageIteratorTestCase(unittest.TestCase): src = graph.add_component(MySource, 'src') it = TestOutputPortMessageIterator(graph, src.output_ports['out']) - # The initial refcount of Py_None was in the 7000, so 100000 iterations - # should be enough to catch the bug even if there are small differences + # Three times the initial ref count of `None` iterations should + # be enough to catch the bug even if there are small differences # between configurations. - for i in range(100000): + none_ref_count = sys.getrefcount(None) * 3 + + for i in range(none_ref_count): with self.assertRaises(bt2.TryAgain): next(it) -- 2.34.1