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

Side by Side Diff: reviewbot/patching_test.py

Issue 20517002: Python class for accessing Rietveld reviews. (Closed) Base URL: https://src.chromium.org/chrome/trunk/tools/
Patch Set: Created 7 years, 4 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 | « reviewbot/patching.py ('k') | reviewbot/review.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:executable
+ *
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import unittest
7
8 import patching
9
10
11 class TestParsePatchToLines(unittest.TestCase):
12 def test_empty(self):
13 self.assertEquals([], patching.ParsePatchToLines([]))
14
15 def test_prelude(self):
16 self.assertEquals([], patching.ParsePatchToLines("""
17 Here goes some prelude.
18 And it continues on for some while.
19
20 --- file
21 +++ file
22 """.splitlines()))
23
24 def test_bad_hunk_header(self):
25 with self.assertRaises(patching.PatchParseError):
26 patching.ParsePatchToLines("""
27 --- file
28 +++ file
29 @@ bad
30 """.splitlines())
31
32 def test_multiple_files(self):
33 with self.assertRaises(patching.PatchParseError):
34 patching.ParsePatchToLines("""
35 diff -urN test1/bar test2/bar
36 --- test1/bar 2013-08-08 14:15:46.604119530 +0200
37 +++ test2/bar 2013-08-08 14:15:49.814145535 +0200
38 @@ -1 +1 @@
39 -foo
40 +bar
41 diff -urN test1/foo test2/foo
42 --- test1/foo 2013-08-08 14:15:36.044033982 +0200
43 +++ test2/foo 2013-08-08 14:15:42.204083886 +0200
44 @@ -1 +1 @@
45 -foo
46 +bar
47 """.splitlines())
48
49 def test_simple(self):
50 self.assertEquals([
51 (1, 1, 'common line'),
52 (2, None, 'old line'),
53 (None, 2, 'new line'),
54 (3, 3, 'common line'),
55 ], patching.ParsePatchToLines("""
56 --- old 2013-08-08 14:05:18.539090366 +0200
57 +++ new 2013-08-08 14:05:18.539090366 +0200
58 @@ -1,3 +1,3 @@
59 common line
60 -old line
61 +new line
62 common line
63 """.splitlines()))
64
65 def test_multiple_hunks(self):
66 self.assertEquals([
67 (None, 1, 'prepended line'),
68 (1, 2, ''),
69 (2, 3, ''),
70 (3, 4, ''),
71 (8, 9, ''),
72 (9, 10, ''),
73 (10, 11, ''),
74 (None, 12, 'appended line'),
75 ], patching.ParsePatchToLines("""
76 --- old 2013-08-08 14:10:10.391408985 +0200
77 +++ new 2013-08-08 14:10:15.511449623 +0200
78 @@ -1,3 +1,4 @@
79 +prepended line
80
81
82
83 @@ -8,3 +9,4 @@
84
85
86
87 +appended line
88 """.splitlines()))
89
90 if __name__ == '__main__':
91 unittest.main()
OLDNEW
« no previous file with comments | « reviewbot/patching.py ('k') | reviewbot/review.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698