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

Unified Diff: gslib/tests/testcase/base.py

Issue 698893003: Update checked in version of gsutil to version 4.6 (Closed) Base URL: http://dart.googlecode.com/svn/third_party/gsutil/
Patch Set: Created 6 years, 1 month 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 | « gslib/tests/testcase/__init__.py ('k') | gslib/tests/testcase/integration_testcase.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gslib/tests/testcase/base.py
===================================================================
--- gslib/tests/testcase/base.py (revision 33376)
+++ gslib/tests/testcase/base.py (working copy)
@@ -1,3 +1,22 @@
+# -*- coding: utf-8 -*-
+# Copyright 2013 Google Inc. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+"""Base test case class for unit and integration tests."""
+
+from __future__ import absolute_import
+
+from functools import wraps
import os.path
import random
import shutil
@@ -3,14 +22,31 @@
import tempfile
+import boto
+import gslib.tests.util as util
from gslib.tests.util import unittest
-
MAX_BUCKET_LENGTH = 63
+def NotParallelizable(func):
+ @wraps(func)
+ def ParallelAnnotatedFunc(*args, **kwargs):
+ return func(*args, **kwargs)
+ ParallelAnnotatedFunc.is_parallelizable = False
+ return ParallelAnnotatedFunc
+
+
class GsUtilTestCase(unittest.TestCase):
"""Base test case class for unit and integration tests."""
def setUp(self):
+ if util.RUN_S3_TESTS:
+ self.test_api = 'XML'
+ self.default_provider = 's3'
+ self.provider_custom_meta = 'amz'
+ else:
+ self.test_api = boto.config.get('GSUtil', 'prefer_api', 'JSON').upper()
+ self.default_provider = 'gs'
+ self.provider_custom_meta = 'goog'
self.tempdirs = []
@@ -32,6 +68,7 @@
Args:
kind: A string indicating what kind of test name this is.
+ prefix: Prefix string to be used in the temporary name.
Returns:
The temporary name.
@@ -69,12 +106,12 @@
Args:
tmpdir: The temporary directory to place the file in. If not specified, a
new temporary directory is created.
+ contents: The contents to write to the file. If not specified, a test
+ string is constructed and written to the file.
file_name: The name to use for the file. If not specified, a temporary
test file name is constructed. This can also be a tuple, where
('dir', 'foo') means to create a file named 'foo' inside a
subdirectory named 'dir'.
- contents: The contents to write to the file. If not specified, a test
- string is constructed and written to the file.
Returns:
The path to the new temporary file.
@@ -87,7 +124,8 @@
fpath = os.path.join(tmpdir, *file_name)
if not os.path.isdir(os.path.dirname(fpath)):
os.makedirs(os.path.dirname(fpath))
- with open(fpath, 'w') as f:
+
+ with open(fpath, 'wb') as f:
contents = contents or self.MakeTempName('contents')
f.write(contents)
return fpath
« no previous file with comments | « gslib/tests/testcase/__init__.py ('k') | gslib/tests/testcase/integration_testcase.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698