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

Side by Side Diff: tools/telemetry/telemetry/core/util_unittest.py

Issue 625123002: Make credential_path a page attribute instead of page_set attribute. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 2 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
OLDNEW
1 # Copyright 2012 The Chromium Authors. All rights reserved. 1 # Copyright 2012 The Chromium Authors. All rights reserved.
2 # 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
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 import os 4 import os
5 import shutil 5 import shutil
6 import tempfile 6 import tempfile
7 import unittest 7 import unittest
8 8
9 from telemetry.core import util 9 from telemetry.core import util
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 with open( 55 with open(
56 os.path.join(self.test_directory, 'test_%03d.json' % i), 'w') as _: 56 os.path.join(self.test_directory, 'test_%03d.json' % i), 'w') as _:
57 pass 57 pass
58 next_json_test_file_path = util.GetSequentialFileName( 58 next_json_test_file_path = util.GetSequentialFileName(
59 os.path.join(self.test_directory, 'test')) 59 os.path.join(self.test_directory, 'test'))
60 self.assertEquals(os.path.join(self.test_directory, 'test_003'), 60 self.assertEquals(os.path.join(self.test_directory, 'test_003'),
61 next_json_test_file_path) 61 next_json_test_file_path)
62 62
63 def tearDown(self): 63 def tearDown(self):
64 shutil.rmtree(self.test_directory) 64 shutil.rmtree(self.test_directory)
65
66
67 class TestGetAbsPathIfExists(unittest.TestCase):
68 def setUp(self):
69 self.test_directory = tempfile.mkdtemp()
70 self.test_abs_path = tempfile.mkstemp(dir=self.test_directory)[1]
71
72 def testTestGetAbsPathIfExistsWithExistedAbsPathInput(self):
73 self.assertEquals(
74 self.test_abs_path, util.GetAbsPathIfExist(
75 self.test_abs_path, self.test_directory))
76
77 def testTestGetAbsPathIfExistsWithExistedRelativePathInput(self):
78 # Case path = foo and relative path = /tmp/xyz/
79 # (The actual naming maybe different)
80 path = os.path.basename(self.test_abs_path)
81 relative_path = self.test_directory
82 self.assertEquals(
83 self.test_abs_path, util.GetAbsPathIfExist(path, relative_path))
84 # Case path = xyz/foo and relative path = /tmp/
85 # (The actual naming maybe different)
86 path = os.path.join(os.path.basename(self.test_directory),
87 os.path.basename(self.test_abs_path))
88 relative_path = os.path.join(self.test_directory, os.pardir)
89 self.assertEquals(
90 self.test_abs_path, util.GetAbsPathIfExist(path, relative_path))
91
92 def testTestGetAbsPathIfExistsWithNonExistedPathInput(self):
93 self.assertIsNone(util.GetAbsPathIfExist('foo', self.test_directory))
94 self.assertIsNone(util.GetAbsPathIfExist('foo/bar', self.test_directory))
95
96 def tearDown(self):
97 shutil.rmtree(self.test_directory)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698