From c6a6fa75b876b0f42cfcf28d170ba711f30b4962 Mon Sep 17 00:00:00 2001 From: ZhiQiang Fan Date: Mon, 30 Dec 2013 10:30:22 +0800 Subject: [PATCH] Avoid failure of test_basic_report on 32 bit OS report.generators.threading module uses sys._current_frames() to get thread id, but it will get a negative number on 32 bit operating system, which will cause test_guru_meditation_report.test_basic_report fail since it expects a positive number. This patch add an optional character '-' to pattern parameter of re.match to avoid such problem. Change-Id: If844894dc1f1032c78d6ed78d221aac27c42712e Closes-Bug: #1264906 --- tests/unit/reports/test_guru_meditation_report.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/unit/reports/test_guru_meditation_report.py b/tests/unit/reports/test_guru_meditation_report.py index 04cc8013c..bb9a98db8 100644 --- a/tests/unit/reports/test_guru_meditation_report.py +++ b/tests/unit/reports/test_guru_meditation_report.py @@ -82,7 +82,9 @@ class TestGuruMeditationReport(utils.BaseTestCase): report_lines[0:len(target_str_header)]) # followed by at least one thread... - self.assertTrue(re.match(r'------(\s+)Thread #\d+\1\s?------', + # NOTE(zqfan): add an optional '-' because sys._current_frames() + # may return a negative thread id on 32 bit operating system. + self.assertTrue(re.match(r'------(\s+)Thread #-?\d+\1\s?------', report_lines[len(target_str_header)])) self.assertEqual('', report_lines[len(target_str_header) + 1])