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

Side by Side Diff: infra/libs/git2/test/util_test.py

Issue 355153002: Refactor infra git libs and testing. (Closed) Base URL: https://chromium.googlesource.com/infra/infra@fake_testing_support
Patch Set: Change config ref to have a sandard naming scheme 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
OLDNEW
(Empty)
1 # Copyright 2014 The Chromium Authors. All rights reserved.
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 unittest
6 import textwrap
7
8 from infra.libs.git2 import util
9
10
11 class TestInvalid(unittest.TestCase):
12 def testBasic(self):
13 self.assertIs(util.INVALID, util.INVALID)
14 self.assertIs(util.INVALID.bob, util.INVALID)
15 self.assertIs(util.INVALID('cat', dog='food'), util.INVALID)
16 self.assertTrue(not (util.INVALID == util.INVALID))
17 self.assertNotEqual(util.INVALID, util.INVALID)
18
19
20 class TestCalledProcessError(unittest.TestCase):
21 def testBasic(self):
22 cpe = util.CalledProcessError(100, ('cat', 'dog'), None, None)
23 self.assertEqual(
24 str(cpe), "Command ('cat', 'dog') returned non-zero exit status 100.\n")
25
26 def testErr(self):
27 cpe = util.CalledProcessError(
28 100, ('cat', 'dog'), None,
29 'Cat says the dog smells funny.\nCat is not amused.')
30
31 self.assertEqual(str(cpe), textwrap.dedent('''\
32 Command ('cat', 'dog') returned non-zero exit status 100:
33 STDERR ========================================
34 Cat says the dog smells funny.
35 Cat is not amused.
36 '''))
37
38 def testOut(self):
39 cpe = util.CalledProcessError(
40 100, ('cat', 'dog'),
41 'This totally worked! Squirrels are awesome!',
42 '')
43
44 self.assertEqual(str(cpe), textwrap.dedent('''\
45 Command ('cat', 'dog') returned non-zero exit status 100:
46 STDOUT ========================================
47 This totally worked! Squirrels are awesome!
48 '''))
49
50 def testBoth(self):
51 cpe = util.CalledProcessError(
52 100, ('cat', 'dog'),
53 'This totally worked! Squirrels are awesome!',
54 'Cat says the dog smells funny.\nCat is not amused.')
55
56 self.assertEqual(str(cpe), textwrap.dedent('''\
57 Command ('cat', 'dog') returned non-zero exit status 100:
58 STDOUT ========================================
59 This totally worked! Squirrels are awesome!
60 STDERR ========================================
61 Cat says the dog smells funny.
62 Cat is not amused.
63 '''))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698