OLD | NEW |
(Empty) | |
| 1 # Copyright 2015 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 import os |
| 6 import unittest |
| 7 |
| 8 from testing_support import trial_dir |
| 9 |
| 10 |
| 11 class TestTrialDir(unittest.TestCase): |
| 12 def test_simple_workflow(self): |
| 13 self.assertEqual(trial_dir.TrialDir.TRIAL_ROOT, None) |
| 14 |
| 15 trial_dir1 = trial_dir.TrialDir('subdir1') |
| 16 trial_dir1.set_up() |
| 17 self.assertIsInstance(trial_dir1.TRIAL_ROOT, basestring) |
| 18 orig_trial_root = trial_dir1.TRIAL_ROOT |
| 19 self.assertTrue( |
| 20 os.path.isdir(os.path.join(trial_dir1.TRIAL_ROOT, 'subdir1'))) |
| 21 |
| 22 trial_dir2 = trial_dir.TrialDir('subdir2') |
| 23 trial_dir2.set_up() |
| 24 self.assertEqual(trial_dir2.TRIAL_ROOT, orig_trial_root) |
| 25 self.assertTrue(os.path.isdir(trial_dir2.root_dir)) |
| 26 |
| 27 trial_dir2.tear_down() |
| 28 self.assertTrue(os.path.isdir(trial_dir1.root_dir)) |
| 29 self.assertFalse( |
| 30 os.path.isdir(os.path.join(trial_dir2.TRIAL_ROOT, 'subdir2'))) |
| 31 |
| 32 trial_dir1.tear_down() |
| 33 self.assertFalse( |
| 34 os.path.isdir(os.path.join(trial_dir1.TRIAL_ROOT, 'subdir1'))) |
| 35 |
| 36 # Not supposed to be called directly, but we're testing. |
| 37 trial_dir1._clean() |
| 38 self.assertFalse(os.path.isdir(orig_trial_root)) |
| 39 |
| 40 |
| 41 class TestTrialDirMixIn(unittest.TestCase, trial_dir.TrialDirMixIn): |
| 42 def setUp(self): |
| 43 trial_dir.TrialDirMixIn.setUp(self) |
| 44 self.mixin_root_dir = self.root_dir |
| 45 |
| 46 def test_mixin(self): |
| 47 self.assertTrue(os.path.isdir(self.root_dir)) |
| 48 |
| 49 def tearDown(self): |
| 50 trial_dir.TrialDirMixIn.tearDown(self) |
| 51 self.assertIsNone(self.root_dir) |
| 52 self.assertFalse(os.path.isdir(self.mixin_root_dir)) |
| 53 |
| 54 |
| 55 class TestTrialDirTestCase(trial_dir.TestCase): |
| 56 def setUp(self): |
| 57 trial_dir.TestCase.setUp(self) |
| 58 self.mixin_root_dir = self.root_dir |
| 59 |
| 60 def test_root_dir(self): |
| 61 self.assertTrue(os.path.isdir(self.root_dir)) |
| 62 # Only testing TrialDir here, auto_stub is tested elsewhere. |
| 63 |
| 64 def tearDown(self): |
| 65 trial_dir.TestCase.tearDown(self) |
| 66 self.assertIsNone(self.root_dir) |
| 67 self.assertFalse(os.path.isdir(self.mixin_root_dir)) |
OLD | NEW |