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

Unified Diff: infra/libs/git2/test/test_util.py

Issue 413983003: Refactor infra git libs and testing. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Address comments Created 6 years, 5 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 | « infra/libs/git2/test/repo_test.py ('k') | infra/libs/git2/test/util_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: infra/libs/git2/test/test_util.py
diff --git a/infra/libs/git2/test/test_util.py b/infra/libs/git2/test/test_util.py
new file mode 100644
index 0000000000000000000000000000000000000000..eb3a58422f9374c004d550fe3aa9bb4fd9851d74
--- /dev/null
+++ b/infra/libs/git2/test/test_util.py
@@ -0,0 +1,58 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
agable 2014/07/26 00:47:52 Having both util_test and test_util is pretty lulz
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import shutil
+import sys
+import tempfile
+
+import testing_support
+
+from infra.libs import git2
+
+
+class TestBasis(testing_support.git.unittest_helpers.GitRepoReadWriteTestBase):
+ # TODO(iannucci): Make this covered by the other tests in this folder
+
+ REPO_SCHEMA = """
+ A B C D E F
+ D L M N O
+ O P Q R S
+ B G H I J K
+ H Z
+ O Z
+ """
+
+ @staticmethod
+ def capture_stdio(fn, *args, **kwargs): # pragma: no cover
+ stdout = sys.stdout
+ stderr = sys.stderr
+ try:
+ # "multiple statements on a line" pylint: disable=C0321
+ with tempfile.TemporaryFile() as out, tempfile.TemporaryFile() as err:
+ sys.stdout = out
+ sys.stderr = err
+ fn(*args, **kwargs)
+ out.seek(0)
+ err.seek(0)
+ return out.read(), err.read()
+ finally:
+ sys.stdout = stdout
+ sys.stderr = stderr
+
+ def setUp(self): # pragma: no cover
+ # "super on old-style class" pylint: disable=E1002
+ self.repos_dir = tempfile.mkdtemp(suffix='.git_test')
+ super(TestBasis, self).setUp()
+ self.repo.git('branch', 'branch_O', self.repo['O'])
+
+ def tearDown(self): # pragma: no cover
+ # "super on old-style class" pylint: disable=E1002
+ shutil.rmtree(self.repos_dir)
+ super(TestBasis, self).tearDown()
+
+ def mkRepo(self): # pragma: no cover
+ r = git2.Repo(self.repo.repo_path)
+ r.repos_dir = self.repos_dir
+ self.capture_stdio(r.reify)
+ return r
« no previous file with comments | « infra/libs/git2/test/repo_test.py ('k') | infra/libs/git2/test/util_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698