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

Unified Diff: devil/devil/utils/parallelizer_test.py

Issue 2923443002: [devil] Add system app replacement wrapper script. (Closed)
Patch Set: docstrings for device_temp_file Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « devil/devil/utils/parallelizer.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: devil/devil/utils/parallelizer_test.py
diff --git a/devil/devil/utils/parallelizer_test.py b/devil/devil/utils/parallelizer_test.py
index 32ff7ec5473de07360f297fe8a5401343e7a7d83..acbb986eae3ffc5499e978b51a69bfe33feb7618 100644
--- a/devil/devil/utils/parallelizer_test.py
+++ b/devil/devil/utils/parallelizer_test.py
@@ -1,17 +1,24 @@
+#! /usr/bin/env python
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Unit tests for the contents of parallelizer.py."""
-# pylint: disable=W0212
-# pylint: disable=W0613
+# pylint: disable=protected-access
+# pylint: disable=unused-argument
+import contextlib
import os
import tempfile
import time
+import sys
import unittest
+if __name__ == '__main__':
+ sys.path.append(os.path.abspath(
+ os.path.join(os.path.dirname(__file__), '..', '..')))
+
from devil.utils import parallelizer
@@ -157,6 +164,27 @@ class ParallelizerTest(unittest.TestCase):
self.assertEquals(range(9, 19), results)
+class SyncParallelizerTest(unittest.TestCase):
+
+ def testContextManager(self):
+ in_context = [False for i in xrange(10)]
+
+ @contextlib.contextmanager
+ def enter_into_context(i):
+ in_context[i] = True
+ try:
+ yield
+ finally:
+ in_context[i] = False
+
+ parallelized_context = parallelizer.SyncParallelizer(
+ [enter_into_context(i) for i in xrange(10)])
+
+ with parallelized_context:
+ self.assertTrue(all(in_context))
+ self.assertFalse(any(in_context))
+
+
if __name__ == '__main__':
unittest.main(verbosity=2)
« no previous file with comments | « devil/devil/utils/parallelizer.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698