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

Unified Diff: testing_support/tests/trial_dir_test.py

Issue 939523004: Copied files from depot_tools. (Closed) Base URL: https://chromium.googlesource.com/infra/testing/testing_support.git@master
Patch Set: Added some tests Created 5 years, 10 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 | « testing_support/tests/auto_stub_test.py ('k') | testing_support/trial_dir.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing_support/tests/trial_dir_test.py
diff --git a/testing_support/tests/trial_dir_test.py b/testing_support/tests/trial_dir_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..5b05c3b8b99622418533812514a7791890065b5d
--- /dev/null
+++ b/testing_support/tests/trial_dir_test.py
@@ -0,0 +1,67 @@
+# Copyright 2015 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.
+
+import os
+import unittest
+
+from testing_support import trial_dir
+
+
+class TestTrialDir(unittest.TestCase):
+ def test_simple_workflow(self):
+ self.assertEqual(trial_dir.TrialDir.TRIAL_ROOT, None)
+
+ trial_dir1 = trial_dir.TrialDir('subdir1')
+ trial_dir1.set_up()
+ self.assertIsInstance(trial_dir1.TRIAL_ROOT, basestring)
+ orig_trial_root = trial_dir1.TRIAL_ROOT
+ self.assertTrue(
+ os.path.isdir(os.path.join(trial_dir1.TRIAL_ROOT, 'subdir1')))
+
+ trial_dir2 = trial_dir.TrialDir('subdir2')
+ trial_dir2.set_up()
+ self.assertEqual(trial_dir2.TRIAL_ROOT, orig_trial_root)
+ self.assertTrue(os.path.isdir(trial_dir2.root_dir))
+
+ trial_dir2.tear_down()
+ self.assertTrue(os.path.isdir(trial_dir1.root_dir))
+ self.assertFalse(
+ os.path.isdir(os.path.join(trial_dir2.TRIAL_ROOT, 'subdir2')))
+
+ trial_dir1.tear_down()
+ self.assertFalse(
+ os.path.isdir(os.path.join(trial_dir1.TRIAL_ROOT, 'subdir1')))
+
+ # Not supposed to be called directly, but we're testing.
+ trial_dir1._clean()
+ self.assertFalse(os.path.isdir(orig_trial_root))
+
+
+class TestTrialDirMixIn(unittest.TestCase, trial_dir.TrialDirMixIn):
+ def setUp(self):
+ trial_dir.TrialDirMixIn.setUp(self)
+ self.mixin_root_dir = self.root_dir
+
+ def test_mixin(self):
+ self.assertTrue(os.path.isdir(self.root_dir))
+
+ def tearDown(self):
+ trial_dir.TrialDirMixIn.tearDown(self)
+ self.assertIsNone(self.root_dir)
+ self.assertFalse(os.path.isdir(self.mixin_root_dir))
+
+
+class TestTrialDirTestCase(trial_dir.TestCase):
+ def setUp(self):
+ trial_dir.TestCase.setUp(self)
+ self.mixin_root_dir = self.root_dir
+
+ def test_root_dir(self):
+ self.assertTrue(os.path.isdir(self.root_dir))
+ # Only testing TrialDir here, auto_stub is tested elsewhere.
+
+ def tearDown(self):
+ trial_dir.TestCase.tearDown(self)
+ self.assertIsNone(self.root_dir)
+ self.assertFalse(os.path.isdir(self.mixin_root_dir))
« no previous file with comments | « testing_support/tests/auto_stub_test.py ('k') | testing_support/trial_dir.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698