| OLD | NEW |
| 1 #!/usr/bin/env python | |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 5 | 4 |
| 6 | 5 |
| 7 import atexit | 6 import atexit |
| 8 import logging | 7 import logging |
| 9 import os | 8 import os |
| 10 import sys | 9 import sys |
| 11 import tempfile | 10 import tempfile |
| 12 import unittest | 11 |
| 12 from testing_support import auto_stub |
| 13 | 13 |
| 14 import gclient_utils | 14 import gclient_utils |
| 15 | 15 |
| 16 | 16 |
| 17 class TrialDir(object): | 17 class TrialDir(object): |
| 18 """Manages a temporary directory. | 18 """Manages a temporary directory. |
| 19 | 19 |
| 20 On first object creation, TrialDir.TRIAL_ROOT will be set to a new temporary | 20 On first object creation, TrialDir.TRIAL_ROOT will be set to a new temporary |
| 21 directory created in /tmp or the equivalent. It will be deleted on process | 21 directory created in /tmp or the equivalent. It will be deleted on process |
| 22 exit unless TrialDir.SHOULD_LEAK is set to True. | 22 exit unless TrialDir.SHOULD_LEAK is set to True. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 self.trial.set_up() | 72 self.trial.set_up() |
| 73 | 73 |
| 74 def tearDown(self): | 74 def tearDown(self): |
| 75 self.trial.tear_down() | 75 self.trial.tear_down() |
| 76 | 76 |
| 77 @property | 77 @property |
| 78 def root_dir(self): | 78 def root_dir(self): |
| 79 return self.trial.root_dir | 79 return self.trial.root_dir |
| 80 | 80 |
| 81 | 81 |
| 82 class TestCase(unittest.TestCase, TrialDirMixIn): | 82 class TestCase(auto_stub.TestCase, TrialDirMixIn): |
| 83 """Base unittest class that cleans off a trial directory in tearDown().""" | 83 """Base unittest class that cleans off a trial directory in tearDown().""" |
| 84 def setUp(self): | 84 def setUp(self): |
| 85 unittest.TestCase.setUp(self) | 85 auto_stub.TestCase.setUp(self) |
| 86 TrialDirMixIn.setUp(self) | 86 TrialDirMixIn.setUp(self) |
| 87 | 87 |
| 88 def tearDown(self): | 88 def tearDown(self): |
| 89 TrialDirMixIn.tearDown(self) | 89 TrialDirMixIn.tearDown(self) |
| 90 unittest.TestCase.tearDown(self) | 90 auto_stub.TestCase.tearDown(self) |
| 91 | 91 |
| 92 | 92 |
| 93 if '-l' in sys.argv: | 93 if '-l' in sys.argv: |
| 94 # See SHOULD_LEAK definition in TrialDir for its purpose. | 94 # See SHOULD_LEAK definition in TrialDir for its purpose. |
| 95 TrialDir.SHOULD_LEAK = True | 95 TrialDir.SHOULD_LEAK = True |
| 96 print 'Leaking!' | 96 print 'Leaking!' |
| 97 sys.argv.remove('-l') | 97 sys.argv.remove('-l') |
| OLD | NEW |