Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: testing_support/thread_watcher.py

Issue 2067533002: Check for stray threads from tests and fail if found (Closed) Base URL: https://chromium.googlesource.com/infra/testing/testing_support.git@master
Patch Set: Addressed comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « testing_support/tests/thread_watcher_test.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5
6 import threading
7 import unittest
8
9
10 class ThreadWatcherMixIn(object):
11 def setUp(self):
12 self._pre_test_threads = [t.ident for t in threading.enumerate()]
13
14 def tearDown(self):
15 new_threads = [t for t in threading.enumerate()
16 if t.ident not in self._pre_test_threads]
17 if new_threads:
18 self.fail('Found %d running thread(s) after the test: %s' % (
19 len(new_threads), ', '.join(t.name for t in new_threads)))
20
21
22
23 class TestCase(unittest.TestCase, ThreadWatcherMixIn):
24 """Base unittest class that cleans off a trial directory in tearDown()."""
tandrii(chromium) 2016/06/14 10:21:43 update doc
Sergiy Byelozyorov 2016/06/14 19:47:01 Done.
25 def setUp(self):
26 super(TestCase, self).setUp()
27 ThreadWatcherMixIn.setUp(self)
28
29 def tearDown(self):
30 ThreadWatcherMixIn.tearDown(self)
31 super(TestCase, self).tearDown()
OLDNEW
« no previous file with comments | « testing_support/tests/thread_watcher_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698