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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # 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
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 shutil
6 import sys
7 import tempfile
8
9 import testing_support
10
11 from infra.libs import git2
12
13
14 class TestBasis(testing_support.git.unittest_helpers.GitRepoReadWriteTestBase):
15 # TODO(iannucci): Make this covered by the other tests in this folder
16
17 REPO_SCHEMA = """
18 A B C D E F
19 D L M N O
20 O P Q R S
21 B G H I J K
22 H Z
23 O Z
24 """
25
26 @staticmethod
27 def capture_stdio(fn, *args, **kwargs): # pragma: no cover
28 stdout = sys.stdout
29 stderr = sys.stderr
30 try:
31 # "multiple statements on a line" pylint: disable=C0321
32 with tempfile.TemporaryFile() as out, tempfile.TemporaryFile() as err:
33 sys.stdout = out
34 sys.stderr = err
35 fn(*args, **kwargs)
36 out.seek(0)
37 err.seek(0)
38 return out.read(), err.read()
39 finally:
40 sys.stdout = stdout
41 sys.stderr = stderr
42
43 def setUp(self): # pragma: no cover
44 # "super on old-style class" pylint: disable=E1002
45 self.repos_dir = tempfile.mkdtemp(suffix='.git_test')
46 super(TestBasis, self).setUp()
47 self.repo.git('branch', 'branch_O', self.repo['O'])
48
49 def tearDown(self): # pragma: no cover
50 # "super on old-style class" pylint: disable=E1002
51 shutil.rmtree(self.repos_dir)
52 super(TestBasis, self).tearDown()
53
54 def mkRepo(self): # pragma: no cover
55 r = git2.Repo(self.repo.repo_path)
56 r.repos_dir = self.repos_dir
57 self.capture_stdio(r.reify)
58 return r
OLDNEW
« 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